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
+12-20Lines changed: 12 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
1
# Some breaking changes introduced
2
-
* Rename "PRICE_TIMES_QUANTITY_MIN" to "QUOTE_QUANTITY_MIN". Rename "CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY" to "CUMULATIVE_FILLED_QUOTE_QUANTITY".
2
+
* The return type of `EventHandler::processEvent` has been changed from `bool` to `void`.
3
+
* Please read [Handle events in "immediate" vs. "batching" mode](#handle-events-in-immediate-vs-batching-mode).
3
4
4
5
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
5
6
@@ -57,6 +58,8 @@
57
58
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
58
59
59
60
61
+
62
+
60
63
# ccapi
61
64
* 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).
62
65
* Bindings for other languages such as Python, Java, C#, Go, and Javascript are provided.
@@ -225,9 +228,8 @@ Logger* Logger::logger = nullptr; // This line is needed.
if (event.getType() == Event::Type::AUTHORIZATION_STATUS) {
841
840
std::cout << "Received an event of type AUTHORIZATION_STATUS:\n" + event.toStringPretty(2, 2) << std::endl;
842
841
auto message = event.getMessageList().at(0);
@@ -857,7 +856,6 @@ class MyEventHandler : public EventHandler {
857
856
} else if (event.getType() == Event::Type::FIX) {
858
857
std::cout << "Received an event of type FIX:\n" + event.toStringPretty(2, 2) << std::endl;
859
858
}
860
-
return true;
861
859
}
862
860
};
863
861
} /* namespace ccapi */
@@ -955,21 +953,16 @@ Bye
955
953
#### Handle events in "immediate" vs. "batching" mode
956
954
957
955
In general there are 2 ways to handle events.
958
-
* When a `Session` is instantiated with an `eventHandler` argument, it will handle events in immediate mode. The `processEvent` method in the `eventHandler` will be invoked immediately when an `Event` is available.
959
-
* When a `Session` is instantiated without an `eventHandler` argument, it will handle events in batching mode. The evetns will be batched into an internal `Queue<Event>` and can be retrieved by
956
+
* When a `Session` is instantiated with an `eventHandler` argument, it will handle events in immediate mode. The `processEvent` method in the `eventHandler` will be invoked immediately when an `Event` is available, and the invocation will run on the thread where `boost::asio::io_context` runs. When a `Session` is instantiated with an `eventHandler` and an `eventDispatcher` argument, it will also handle events in immediate mode. The `processEvent` method in the `eventHandler` will also be invoked immediately when an `Event` is available, but the invocation will run in the thread(s) provided by the `eventDispatcher` therefore not blocking the thread where `boost::asio::io_context` runs. `EventHandler`s and/or `EventDispatcher`s can be shared among different sessions. Otherwise, different sessions are independent from each other.
957
+
An example can be found [here](example/src/market_data_advanced_subscription/main.cpp).
958
+
* When a `Session` is instantiated without an `eventHandler` argument, it will handle events in batching mode. The events will be batched into an internal `Queue<Event>` and can be retrieved by
An example can be found [here](example/src/market_data_advanced_subscription/main.cpp).
964
963
965
964
#### Thread safety
966
965
* The following methods are implemented to be thread-safe: `Session::sendRequest`, `Session::subscribe`, `Session::sendRequestByFix`, `Session::subscribeByFix`, `Session::setTimer`, all public methods in `Queue`.
967
-
* The `processEvent` method in the `eventHandler` is invoked on one of the internal threads in the `eventDispatcher`. A default `EventDispatcher` with 1 internal thread will be created if no `eventDispatcher` argument is provided in `Session` instantiation. To dispatch events to multiple threads, instantiate `EventDispatcher` with `numDispatcherThreads` set to be the desired number. `EventHandler`s and/or `EventDispatcher`s can be shared among different sessions. Otherwise, different sessions are independent from each other.
An example can be found [here](example/src/market_data_advanced_subscription/main.cpp).
973
966
974
967
#### Enable library logging
975
968
@@ -1015,7 +1008,6 @@ sessionPtr->setTimer(
1015
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")`).
1016
1009
* Only enable the services and exchanges that you need.
1017
1010
* Handle events in ["batching" mode](#handle-events-in-immediate-vs-batching-mode) if your application (e.g. market data archiver) isn't latency sensitive.
1018
-
* Define macro `CCAPI_USE_SINGLE_THREAD`. It reduces locking overhead for single threaded applications.
1019
1011
1020
1012
## Known Issues and Workarounds
1021
1013
* 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.
0 commit comments