GitHub - OKX Exchange Connector in C++: REST and WebSocket Support

·

Overview

This repository hosts a C++ application designed to connect with the OKX Crypto Exchange API, supporting both REST and WebSocket protocols. The connector facilitates real-time data retrieval and complex computational tasks, optimized for performance and parallel execution.

Core Features


Requirements

Development Environment

Optional (for CMake/Conan Builds):


Getting Started

1. Clone the Repository

git clone https://github.com/siyovush-hamidov/OKX-Exchange-Connector.git

2. Compile Manually

REST Version:

g++ main.cpp -o main CalculationClass.cpp OKXClass.cpp -lcurl -lssl -lcrypto

WebSocket Version:

g++ main.cpp -o main CalculationClass.cpp WebSocketClass.cpp -lssl -lcrypto

3. Build with CMake/Conan

conan install . --output-folder=build --build=missing
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=./build/Release/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
cmake --build .

4. Run the Executable

./WebSocket/websocket_client  # For WebSocket
./main                        # For REST

Project Structure

├── REST/
│   ├── main.cpp               # Main logic for REST implementation
│   ├── CalculationClass.[h/cpp] # Heavy task handler
│   ├── OKXClass.[h/cpp]        # REST API connector
│   └── Recycle Bin/           # Auxiliary files
│
└── WebSocket/
    ├── main.cpp               # Main logic for WebSocket
    ├── CalculationClass.[h/cpp] # Heavy task handler
    ├── WebSocketClass.[h/cpp]  # WebSocket connector
    └── Recycle Bin/           # Auxiliary files

License

👉 MIT License – Free for modification and commercial use.


FAQ

1. What latency can I expect with this connector?

2. Does this support other trading pairs besides BTC-USDT?

Currently optimized for BTC-USDT, but the codebase can be extended to other pairs.

3. How is the computational task parallelized?

The CalculationClass runs in a separate thread, synchronized with API operations via logging.

4. Are external libraries required for HTTP requests?

No—the REST version uses libcurl (included in standard Unix environments).

5. Can I use this for high-frequency trading (HFT)?