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
OKX API Integration:
- Connects to OKX Exchange via pure HTTP requests (REST) or WebSocket.
- Retrieves Level 1 Limit Order Book (LOB) data for BTC-USDT with minimal latency (<1s for REST, <100ms for WebSocket).
Heavy Computational Task:
- Solves matrix inversion (AX = E) via a dedicated
CalculationClass. - Runs concurrently with API operations for efficient resource utilization.
- Solves matrix inversion (AX = E) via a dedicated
Logging & Parallel Execution:
- Tracks API requests and completed computational tasks in real-time.
Requirements
Development Environment
- C++ Compiler (e.g.,
g++,clang++). - Standard C++ Libraries.
Optional (for CMake/Conan Builds):
- CMake (v3.12+).
- Conan (package manager).
Getting Started
1. Clone the Repository
git clone https://github.com/siyovush-hamidov/OKX-Exchange-Connector.git2. Compile Manually
REST Version:
g++ main.cpp -o main CalculationClass.cpp OKXClass.cpp -lcurl -lssl -lcryptoWebSocket Version:
g++ main.cpp -o main CalculationClass.cpp WebSocketClass.cpp -lssl -lcrypto3. 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 RESTProject 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 filesLicense
👉 MIT License – Free for modification and commercial use.
FAQ
1. What latency can I expect with this connector?
- REST: Under 1 second.
- WebSocket: Under 100 milliseconds.
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).