This project provides a C++ client for interacting with the OKX Exchange API, supporting authenticated trading operations and market data retrieval. It includes modular components for order handling and client configuration.
.
├── CMakeLists.txt # CMake build configuration
├── OKXOrderSystem.cpp # High-level order management logic
├── Okx\_client.cpp # OKXClient class implementation (API interaction)
├── okx\_client.h # Header for OKXClient class
├── README.md # Project documentation
- Place spot or futures orders (
limit/market). - Modify open orders (update size or price).
- Cancel open orders using
order_idorclient_order_id. - Fetch:
- Open/pending orders
- Order history
- Market order book
- Current open positions
- Built-in support for simulated trading via
x-simulated-trading: 1header.
- C++17 or higher
- CMake ≥ 3.10
- libcurl and OpenSSL
- nlohmann/json (header-only)
sudo apt update
sudo apt install libssl-dev libcurl4-openssl-devbrew install openssl curlgit clone https://github.com/yourusername/okx-cpp-client.git
cd okx-cpp-client
mkdir build && cd build
cmake ..
make
./okx_client_appMake sure to update
main.cpporOKXOrderSystem.cppto call functions you wish to test.
#include "okx_client.h"
int main() {
OKXClient client("API_KEY", "SECRET_KEY", "PASSPHRASE");
// Place a limit buy order
client.placeOrder("BTC-USDT", "buy", "limit", 0.001, 30000);
// Cancel an order
client.cancelOrder("BTC-USDT", "order_id_here", "");
// Fetch order book
std::string book = client.getOrderBook("BTC-USDT");
std::cout << book << std::endl;
return 0;
}| File | Purpose |
|---|---|
Okx_client.cpp |
Implements HTTP communication with OKX API |
okx_client.h |
Defines the OKXClient class and utilities |
OKXOrderSystem.cpp |
Optional high-level wrapper or strategy logic |
CMakeLists.txt |
CMake config for building the project |
This client is provided for educational and testing purposes. Always test on simulated trading first before using real funds.
MIT License. See LICENSE file (if available).