You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+52-59Lines changed: 52 additions & 59 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,7 +75,7 @@
75
75
* Example CMake: example/CMakeLists.txt.
76
76
* Require C++17 and OpenSSL.
77
77
* Macros in the compiler command line:
78
-
* Define service enablement macro such as `CCAPI_ENABLE_SERVICE_MARKET_DATA`, `CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT`, `CCAPI_ENABLE_SERVICE_FIX`, etc. and exchange enablement macros such as `CCAPI_ENABLE_EXCHANGE_OKX`, etc. These macros can be found at the top of [`include/ccapi_cpp/ccapi_session.h`](include/ccapi_cpp/ccapi_session.h).
78
+
* Define service enablement macro such as `CCAPI_ENABLE_SERVICE_MARKET_DATA`, `CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT`, `CCAPI_ENABLE_SERVICE_FIX`, etc. and exchange enablement macros such as `CCAPI_ENABLE_EXCHANGE_BYBIT`, etc. These macros can be found at the top of [`include/ccapi_cpp/ccapi_session.h`](include/ccapi_cpp/ccapi_session.h).
79
79
* Dependencies:
80
80
* boost https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.gz (notice that its include directory is boost).
81
81
* rapidjson https://github.com/Tencent/rapidjson/archive/refs/tags/v1.1.0.tar.gz (notice that its include directory is rapidjson/include).
@@ -240,7 +240,7 @@ int main(int argc, char** argv) {
Instantiate `Subscription` with option `MARKET_DEPTH_MAX` set to be the desired market depth (e.g. you want to receive market depth snapshot whenever the top 10 bid's or ask's price or size changes).
This is used to match a particular request or subscription with its returned data. Within each `Message` there is a `correlationIdList` to identify the request or subscription that requested the data.
385
385
386
386
#### Multiple exchanges and/or instruments
387
387
388
388
Send a `std::vector<Request>`.
389
389
```
390
-
Request request_1(Request::Operation::GET_RECENT_TRADES, "okx", "BTC-USDT", "cool correlation id for BTC");
390
+
Request request_1(Request::Operation::GET_RECENT_TRADES, "bybit", "BTCUSDT", "cool correlation id for BTC");
391
391
request_1.appendParam(...);
392
392
Request request_2(Request::Operation::GET_RECENT_TRADES, "binance", "ETH-USDT", "cool correlation id for ETH");
#### Receive subscription events at periodic intervals including when the market depth snapshot hasn't changed
413
413
414
414
Instantiate `Subscription` with option `CONFLATE_INTERVAL_MILLISECONDS` set to be the desired interval and `CONFLATE_GRACE_PERIOD_MILLISECONDS` to be the grace period for late events.
#### Receive subscription calculated-candlestick events at periodic intervals
434
434
435
435
Instantiate `Subscription` with field `TRADE` and option `CONFLATE_INTERVAL_MILLISECONDS` set to be the desired interval and `CONFLATE_GRACE_PERIOD_MILLISECONDS` to be your network latency.
Instantiate `Request` with operation `GENERIC_PUBLIC_REQUEST`. Provide request parameters `HTTP_METHOD`, `HTTP_PATH`, and optionally `HTTP_QUERY_STRING` (query string parameter values should be url-encoded), `HTTP_BODY`.
450
450
```
451
-
Request request(Request::Operation::GENERIC_PUBLIC_REQUEST, "okx", "", "Check Server Time");
451
+
Request request(Request::Operation::GENERIC_PUBLIC_REQUEST, "bybit", "", "Check Server Time");
452
452
request.appendParam({
453
453
{"HTTP_METHOD", "GET"},
454
454
{"HTTP_PATH", "/api/v5/public/time"},
@@ -459,14 +459,14 @@ request.appendParam({
459
459
460
460
Instantiate `Subscription` with empty instrument, field `GENERIC_PUBLIC_SUBSCRIPTION` and options set to be the desired websocket payload.
Instantiate `Request` with operation `GENERIC_PRIVATE_REQUEST`. Provide request parameters `HTTP_METHOD`, `HTTP_PATH`, and optionally `HTTP_QUERY_STRING` (query string parameter values should be url-encoded), `HTTP_BODY`.
468
468
```
469
-
Request request(Request::Operation::GENERIC_PRIVATE_REQUEST, "okx", "", "close all positions");
469
+
Request request(Request::Operation::GENERIC_PRIVATE_REQUEST, "bybit", "", "close all positions");
470
470
request.appendParam({
471
471
{"HTTP_METHOD", "POST"},
472
472
{"HTTP_PATH", "/api/v5/trade/close-position"},
@@ -511,24 +511,21 @@ using ::ccapi::toString;
511
511
using ::ccapi::UtilSystem;
512
512
513
513
int main(int argc, char** argv) {
514
-
if (UtilSystem::getEnvAsString("OKX_API_KEY").empty()) {
515
-
std::cerr << "Please set environment variable OKX_API_KEY" << std::endl;
514
+
if (UtilSystem::getEnvAsString("BYBIT_API_KEY").empty()) {
515
+
std::cerr << "Please set environment variable BYBIT_API_KEY" << std::endl;
516
516
return EXIT_FAILURE;
517
517
}
518
-
if (UtilSystem::getEnvAsString("OKX_API_SECRET").empty()) {
519
-
std::cerr << "Please set environment variable OKX_API_SECRET" << std::endl;
520
-
return EXIT_FAILURE;
521
-
}
522
-
if (UtilSystem::getEnvAsString("OKX_API_PASSPHRASE").empty()) {
523
-
std::cerr << "Please set environment variable OKX_API_PASSPHRASE" << std::endl;
518
+
if (UtilSystem::getEnvAsString("BYBIT_API_SECRET").empty()) {
519
+
std::cerr << "Please set environment variable BYBIT_API_SECRET" << std::endl;
This is used to match a particular request or subscription with its returned data. Within each `Message` there is a `correlationIdList` to identify the request or subscription that requested the data.
715
709
716
710
#### Multiple exchanges and/or instruments
717
711
718
712
Send a `std::vector<Request>`.
719
713
```
720
-
Request request_1(Request::Operation::CREATE_ORDER, "okx", "BTC-USDT", "cool correlation id for BTC");
714
+
Request request_1(Request::Operation::CREATE_ORDER, "bybit", "BTCUSDT", "cool correlation id for BTC");
721
715
request_1.appendParam(...);
722
-
Request request_2(Request::Operation::CREATE_ORDER, "okx", "ETH-USDT", "cool correlation id for ETH");
716
+
Request request_2(Request::Operation::CREATE_ORDER, "bybit", "ETH-USDT", "cool correlation id for ETH");
You can override exchange urls at compile time by using macros. See section "exchange REST urls", "exchange WS urls", and "exchange FIX urls" in [`include/ccapi_cpp/ccapi_macro.h`](include/ccapi_cpp/ccapi_macro.h). You can also override exchange urls at runtime. See [this example](example/src/override_exchange_url_at_runtime/main.cpp). These can be useful if you need to connect to test accounts (e.g. https://www.okx.com/docs-v5/en/#overview-demo-trading-services).
1070
+
You can override exchange urls at compile time by using macros. See section "exchange REST urls", "exchange WS urls", and "exchange FIX urls" in [`include/ccapi_cpp/ccapi_macro.h`](include/ccapi_cpp/ccapi_macro.h). You can also override exchange urls at runtime. See [this example](example/src/override_exchange_url_at_runtime/main.cpp). These can be useful if you need to connect to test accounts (e.g. https://testnet.bybit.com/).
1078
1071
1079
1072
#### Connect to a proxy
1080
1073
Instantiate `Subscription` with the desired `proxyUrl`.
0 commit comments