diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 302eaab..0ab39e1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,6 +3,7 @@ target_link_libraries(kraken PRIVATE common_options) add_subdirectory(book) add_subdirectory(csv) +add_subdirectory(engine) add_subdirectory(parse) add_subdirectory(utils) @@ -11,6 +12,7 @@ configure_file(config.h.in config.h) target_link_libraries(kraken PRIVATE book csv + engine parse ) diff --git a/src/engine/CMakeLists.txt b/src/engine/CMakeLists.txt new file mode 100644 index 0000000..9f28434 --- /dev/null +++ b/src/engine/CMakeLists.txt @@ -0,0 +1,10 @@ +add_library(engine STATIC + engine-listener.cc + engine-listener.hh +) + +target_link_libraries(engine PRIVATE + book +) + +target_link_libraries(engine PRIVATE common_options) diff --git a/src/engine/engine-listener.cc b/src/engine/engine-listener.cc new file mode 100644 index 0000000..4f3d35f --- /dev/null +++ b/src/engine/engine-listener.cc @@ -0,0 +1,7 @@ +#include "engine-listener.hh" + +namespace kraken::engine { + +EngineListener::~EngineListener() = default; + +} // namespace kraken::engine diff --git a/src/engine/engine-listener.hh b/src/engine/engine-listener.hh new file mode 100644 index 0000000..f8f61aa --- /dev/null +++ b/src/engine/engine-listener.hh @@ -0,0 +1,38 @@ +#pragma once + +#include + +#include "book/order.hh" + +namespace kraken::engine { + +/// Listener interface which is called by the engine on trading events. +struct EngineListener { + virtual ~EngineListener(); + + /// Called when a new trade or cancel order has been acknowledged. + virtual void on_acknowledgement(User user, UserOrderId id) = 0; + + /// Called when an order is invalid. + virtual void on_bad_order(User user, UserOrderId id) = 0; + + /// Called when the top of the book changes. + virtual void on_top_of_book_change(Side side, Price price, + Quantity total_quantity) + = 0; + /// Called when the top of the book changes, no orders remaining on a side. + virtual void on_top_of_book_change(Side side) = 0; + + /// Called when an order is rejected by the engine for crossing the book. + virtual void on_rejection(User user, UserOrderId id) = 0; + + /// Called when an order is matched by the engine. + virtual void on_match(User user_buy, UserOrderId id_bid, User user_sell, + UserOrderId id_ask, Price price, Quantity quantity) + = 0; + + /// Called when a flush order is processed. + virtual void on_flush() = 0; +}; + +} // namespace kraken::engine