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
*[Known Issues and Workarounds](#known-issues-and-workarounds)
54
-
*[Contributing](#contributing)
55
53
56
54
<!---toc end-->
57
55
@@ -60,14 +58,17 @@
60
58
61
59
62
60
61
+
62
+
63
+
63
64
# ccapi
64
65
* A header-only C++ library for streaming market data and executing trades directly from cryptocurrency exchanges (i.e. the connections are between your server and the exchange server without anything in-between).
65
66
* Bindings for other languages such as Python, Java, C#, Go, and Javascript are provided.
@@ -491,6 +499,7 @@ For a specific exchange and instrument, submit a simple limit order.
491
499
#include "ccapi_cpp/ccapi_session.h"
492
500
493
501
namespace ccapi {
502
+
494
503
Logger* Logger::logger = nullptr; // This line is needed.
495
504
496
505
class MyEventHandler : public EventHandler {
@@ -499,6 +508,7 @@ class MyEventHandler : public EventHandler {
499
508
std::cout << "Received an event:\n" + event.toStringPretty(2, 2) << std::endl;
500
509
}
501
510
};
511
+
502
512
} /* namespace ccapi */
503
513
504
514
using ::ccapi::MyEventHandler;
@@ -588,6 +598,7 @@ For a specific exchange and instrument, receive order updates.
588
598
#include "ccapi_cpp/ccapi_session.h"
589
599
590
600
namespace ccapi {
601
+
591
602
Logger* Logger::logger = nullptr; // This line is needed.
592
603
593
604
class MyEventHandler : public EventHandler {
@@ -611,6 +622,7 @@ class MyEventHandler : public EventHandler {
611
622
}
612
623
}
613
624
};
625
+
614
626
} /* namespace ccapi */
615
627
616
628
using ::ccapi::MyEventHandler;
@@ -832,6 +844,7 @@ For a specific exchange and instrument, submit a simple limit order.
832
844
```
833
845
#include "ccapi_cpp/ccapi_session.h"
834
846
namespace ccapi {
847
+
835
848
Logger* Logger::logger = nullptr; // This line is needed.
836
849
class MyEventHandler : public EventHandler {
837
850
public:
@@ -858,6 +871,7 @@ class MyEventHandler : public EventHandler {
858
871
}
859
872
}
860
873
};
874
+
861
875
} /* namespace ccapi */
862
876
using ::ccapi::MyEventHandler;
863
877
using ::ccapi::Session;
@@ -963,6 +977,7 @@ An example can be found [here](example/src/market_data_advanced_subscription/mai
963
977
964
978
#### Thread safety
965
979
* The following methods are implemented to be thread-safe: `Session::sendRequest`, `Session::subscribe`, `Session::sendRequestByFix`, `Session::subscribeByFix`, `Session::setTimer`, all public methods in `Queue`.
980
+
* If you choose to inject an external `boost::asio::io_context` to `ServiceContext`, the `boost::asio::io_context` has to run on a single thread to ensure thread safety.
966
981
967
982
#### Enable library logging
968
983
@@ -971,6 +986,7 @@ An example can be found [here](example/src/market_data_advanced_subscription/mai
971
986
Extend a subclass, e.g. `MyLogger`, from class `Logger` and override method `logMessage`. Assign a `MyLogger` pointer to `Logger::logger`. Add one of the following macros in the compiler command line: `CCAPI_ENABLE_LOG_TRACE`, `CCAPI_ENABLE_LOG_DEBUG`, `CCAPI_ENABLE_LOG_INFO`, `CCAPI_ENABLE_LOG_WARN`, `CCAPI_ENABLE_LOG_ERROR`, `CCAPI_ENABLE_LOG_FATAL`. Enable logging if you'd like to inspect raw responses/messages from the exchange for troubleshooting purposes.
@@ -985,6 +1001,7 @@ class MyLogger final : public Logger {
985
1001
986
1002
MyLogger myLogger;
987
1003
Logger* Logger::logger = &myLogger;
1004
+
988
1005
} /* namespace ccapi */
989
1006
```
990
1007
@@ -1005,14 +1022,8 @@ sessionPtr->setTimer(
1005
1022
## Performance Tuning
1006
1023
* Turn on compiler optimization flags (e.g. `cmake -DCMAKE_BUILD_TYPE=Release ...`).
1007
1024
* Enable link time optimization (e.g. in CMakeLists.txt `set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)` before a target is created). Note that link time optimization is only applicable to static linking.
1008
-
* Shorten constant strings used as key names in the returned `Element` (e.g. in CmakeLists.txt `add_compile_definitions(CCAPI_BEST_BID_N_PRICE="b")`).
1009
1025
* Only enable the services and exchanges that you need.
1010
1026
* Handle events in ["batching" mode](#handle-events-in-immediate-vs-batching-mode) if your application (e.g. market data archiver) isn't latency sensitive.
1011
1027
1012
1028
## Known Issues and Workarounds
1013
1029
* Kraken invalid nonce errors. Give the API key a nonce window (https://support.kraken.com/hc/en-us/articles/360001148023-What-is-a-nonce-window-). We use unix timestamp with microsecond resolution as nonce and therefore a nonce window of 500000 translates to a tolerance of 0.5 second.
1014
-
1015
-
## Contributing
1016
-
* (Required) Create a new branch from the `develop` branch and submit a pull request to the `develop` branch.
1017
-
* (Optional) C++ code style: https://google.github.io/styleguide/cppguide.html. See file [.clang-format](.clang-format).
0 commit comments