diff --git a/include/helix/helix.hh b/include/helix/helix.hh index 2324302..70700e8 100644 --- a/include/helix/helix.hh +++ b/include/helix/helix.hh @@ -29,8 +29,6 @@ public: { } }; -namespace core { - enum class trade_sign { buyer_initiated, seller_initiated, @@ -99,7 +97,7 @@ public: virtual void subscribe(const std::string& symbol, size_t max_orders) = 0; - virtual void register_callback(core::event_callback callback) = 0; + virtual void register_callback(event_callback callback) = 0; virtual size_t process_packet(const net::packet_view& packet) = 0; }; @@ -110,5 +108,3 @@ public: }; } - -} diff --git a/include/helix/nasdaq/binaryfile.hh b/include/helix/nasdaq/binaryfile.hh index b68070c..aabc8c5 100644 --- a/include/helix/nasdaq/binaryfile.hh +++ b/include/helix/nasdaq/binaryfile.hh @@ -20,7 +20,7 @@ namespace helix { namespace nasdaq { template -class binaryfile_session : public core::session { +class binaryfile_session : public session { Handler _handler; public: explicit binaryfile_session(void* data); @@ -29,7 +29,7 @@ public: virtual void subscribe(const std::string& symbol, size_t max_orders) override; - virtual void register_callback(core::event_callback callback) override; + virtual void register_callback(event_callback callback) override; virtual size_t process_packet(const net::packet_view& packet) override; }; @@ -53,7 +53,7 @@ void binaryfile_session::subscribe(const std::string& symbol, size_t ma } template -void binaryfile_session::register_callback(core::event_callback callback) +void binaryfile_session::register_callback(event_callback callback) { _handler.register_callback(callback); } diff --git a/include/helix/nasdaq/itch50_handler.hh b/include/helix/nasdaq/itch50_handler.hh index 6c4a9ba..8ecf16e 100644 --- a/include/helix/nasdaq/itch50_handler.hh +++ b/include/helix/nasdaq/itch50_handler.hh @@ -29,9 +29,9 @@ namespace nasdaq { class itch50_handler { private: //! Callback function for processing events. - core::event_callback _process_event; + event_callback _process_event; //! A map of order books by order book ID. - std::unordered_map order_book_id_map; + std::unordered_map order_book_id_map; //! A set of symbols that we are interested in. std::set _symbols; //! A map of pre-allocation size by symbol. @@ -40,7 +40,7 @@ public: itch50_handler(); bool is_rth_timestamp(uint64_t timestamp) const; void subscribe(std::string sym, size_t max_orders); - void register_callback(core::event_callback callback); + void register_callback(event_callback callback); size_t process_packet(const net::packet_view& packet); private: template @@ -66,7 +66,7 @@ private: void process_msg(const itch50_noii* m); void process_msg(const itch50_rpii* m); //! Generate a sweep event if execution cleared a price level. - core::event_mask sweep_event(const core::execution&) const; + event_mask sweep_event(const execution&) const; }; } diff --git a/include/helix/nasdaq/itch50_protocol.hh b/include/helix/nasdaq/itch50_protocol.hh index 589fb5a..c1b25d8 100644 --- a/include/helix/nasdaq/itch50_protocol.hh +++ b/include/helix/nasdaq/itch50_protocol.hh @@ -8,12 +8,12 @@ namespace helix { namespace nasdaq { -class itch50_protocol : public core::protocol { +class itch50_protocol : public protocol { std::string _name; public: explicit itch50_protocol(std::string name); static bool supports(const std::string& name); - virtual core::session* new_session(void *) override; + virtual session* new_session(void *) override; }; } diff --git a/include/helix/nasdaq/moldudp.hh b/include/helix/nasdaq/moldudp.hh index 3bb2bab..b064840 100644 --- a/include/helix/nasdaq/moldudp.hh +++ b/include/helix/nasdaq/moldudp.hh @@ -28,7 +28,7 @@ namespace helix { namespace nasdaq { template -class moldudp_session : public core::session { +class moldudp_session : public session { Handler _handler; uint32_t _seq_num; public: @@ -38,7 +38,7 @@ public: virtual void subscribe(const std::string& symbol, size_t max_orders) override; - virtual void register_callback(core::event_callback callback) override; + virtual void register_callback(event_callback callback) override; virtual size_t process_packet(const net::packet_view& packet) override; @@ -64,7 +64,7 @@ void moldudp_session::subscribe(const std::string& symbol, size_t max_o } template -void moldudp_session::register_callback(core::event_callback callback) +void moldudp_session::register_callback(event_callback callback) { _handler.register_callback(callback); } diff --git a/include/helix/nasdaq/moldudp64.hh b/include/helix/nasdaq/moldudp64.hh index b820255..6a8c4cc 100644 --- a/include/helix/nasdaq/moldudp64.hh +++ b/include/helix/nasdaq/moldudp64.hh @@ -21,7 +21,7 @@ namespace helix { namespace nasdaq { template -class moldudp64_session : public core::session { +class moldudp64_session : public session { Handler _handler; uint64_t _seq_num; public: @@ -31,7 +31,7 @@ public: virtual void subscribe(const std::string& symbol, size_t max_orders) override; - virtual void register_callback(core::event_callback callback) override; + virtual void register_callback(event_callback callback) override; virtual size_t process_packet(const net::packet_view& packet) override; }; @@ -56,7 +56,7 @@ void moldudp64_session::subscribe(const std::string& symbol, size_t max } template -void moldudp64_session::register_callback(core::event_callback callback) +void moldudp64_session::register_callback(event_callback callback) { _handler.register_callback(callback); } diff --git a/include/helix/nasdaq/nordic_itch_handler.hh b/include/helix/nasdaq/nordic_itch_handler.hh index 5a2ccf7..7878b1d 100644 --- a/include/helix/nasdaq/nordic_itch_handler.hh +++ b/include/helix/nasdaq/nordic_itch_handler.hh @@ -39,11 +39,11 @@ class nordic_itch_handler { //! Milliseconds since @time_sec. uint64_t time_msec; //! Callback function for processing events. - core::event_callback _process_event; + event_callback _process_event; //! A map of order books by order book ID. - std::unordered_map order_book_id_map; + std::unordered_map order_book_id_map; //! A map of order books by order ID. - std::unordered_map order_id_map; + std::unordered_map order_id_map; //! A set of symbols that we are interested in. std::set _symbols; //! A map of pre-allocation size by symbol. @@ -52,7 +52,7 @@ public: nordic_itch_handler(); bool is_rth_timestamp(uint64_t timestamp) const; void subscribe(std::string sym, size_t max_orders); - void register_callback(core::event_callback callback); + void register_callback(event_callback callback); size_t process_packet(const net::packet_view& packet); private: template @@ -74,7 +74,7 @@ private: void process_msg(const itch_broken_trade* m); void process_msg(const itch_noii* m); //! Generate a sweep event if execution cleared a price level. - core::event_mask sweep_event(const core::execution&) const; + event_mask sweep_event(const execution&) const; //! Timestamp in milliseconds uint64_t timestamp() const; }; diff --git a/include/helix/nasdaq/nordic_itch_protocol.hh b/include/helix/nasdaq/nordic_itch_protocol.hh index b4409c4..0f74ce8 100644 --- a/include/helix/nasdaq/nordic_itch_protocol.hh +++ b/include/helix/nasdaq/nordic_itch_protocol.hh @@ -8,12 +8,12 @@ namespace helix { namespace nasdaq { -class nordic_itch_protocol : public core::protocol { +class nordic_itch_protocol : public protocol { std::string _name; public: static bool supports(const std::string& name); explicit nordic_itch_protocol(std::string name); - virtual core::session* new_session(void *) override; + virtual session* new_session(void *) override; }; } diff --git a/include/helix/nasdaq/soupfile.hh b/include/helix/nasdaq/soupfile.hh index e89ae6f..b08d1bf 100644 --- a/include/helix/nasdaq/soupfile.hh +++ b/include/helix/nasdaq/soupfile.hh @@ -18,7 +18,7 @@ namespace helix { namespace nasdaq { template -class soupfile_session : public core::session { +class soupfile_session : public session { Handler _handler; public: explicit soupfile_session(void* data); @@ -27,7 +27,7 @@ public: virtual void subscribe(const std::string& symbol, size_t max_orders) override; - virtual void register_callback(core::event_callback callback) override; + virtual void register_callback(event_callback callback) override; virtual size_t process_packet(const net::packet_view& packet) override; }; @@ -51,7 +51,7 @@ void soupfile_session::subscribe(const std::string& symbol, size_t max_ } template -void soupfile_session::register_callback(core::event_callback callback) +void soupfile_session::register_callback(event_callback callback) { _handler.register_callback(callback); } diff --git a/include/helix/order_book.hh b/include/helix/order_book.hh index 944d208..11c27d4 100644 --- a/include/helix/order_book.hh +++ b/include/helix/order_book.hh @@ -21,8 +21,6 @@ namespace helix { -namespace core { - /// \addtogroup order-book /// @{ @@ -167,5 +165,3 @@ private: /// @} } - -} diff --git a/include/helix/parity/pmd_handler.hh b/include/helix/parity/pmd_handler.hh index 884300c..1205b23 100644 --- a/include/helix/parity/pmd_handler.hh +++ b/include/helix/parity/pmd_handler.hh @@ -26,11 +26,11 @@ namespace parity { // class pmd_handler { //! Callback function for processing events. - core::event_callback _process_event; + event_callback _process_event; //! A map of order books by order book ID. - std::unordered_map _order_book_id_map; + std::unordered_map _order_book_id_map; //! A map of order books by order ID. - std::unordered_map _order_id_map; + std::unordered_map _order_id_map; //! A set of symbols that we are interested in. std::set _symbols; //! Number of seconds since midnight when the trading session started. @@ -39,7 +39,7 @@ public: pmd_handler(); bool is_rth_timestamp(uint64_t timestamp) const; void subscribe(std::string sym, size_t max_orders); - void register_callback(core::event_callback callback); + void register_callback(event_callback callback); size_t process_packet(const net::packet_view& packet); private: template @@ -52,7 +52,7 @@ private: void process_msg(const pmd_order_deleted* m); void process_msg(const pmd_broken_trade* m); //! Generate a sweep event if execution cleared a price level. - core::event_mask sweep_event(const core::execution&) const; + event_mask sweep_event(const execution&) const; uint64_t to_timestamp(uint64_t nanoseconds) const; }; diff --git a/include/helix/parity/pmd_protocol.hh b/include/helix/parity/pmd_protocol.hh index d09b9f7..59c9326 100644 --- a/include/helix/parity/pmd_protocol.hh +++ b/include/helix/parity/pmd_protocol.hh @@ -11,13 +11,13 @@ namespace helix { namespace parity { -class pmd_protocol : public core::protocol { +class pmd_protocol : public protocol { std::string _name; public: static bool supports(const std::string& name); explicit pmd_protocol(std::string name); - virtual core::session* new_session(void *) override; + virtual session* new_session(void *) override; }; } diff --git a/src/event.cc b/src/event.cc index a1bd044..f98523c 100644 --- a/src/event.cc +++ b/src/event.cc @@ -2,8 +2,6 @@ namespace helix { -namespace core { - event::event(event_mask mask, uint64_t timestamp, order_book* ob, trade* t) : _mask{mask} , _timestamp{timestamp} @@ -48,5 +46,3 @@ event make_trade_event(uint64_t timestamp, trade* t, event_mask mask) } } - -} diff --git a/src/helix.cc b/src/helix.cc index f901b4a..7103381 100644 --- a/src/helix.cc +++ b/src/helix.cc @@ -12,54 +12,54 @@ using namespace std; -inline helix_order_book_t wrap(helix::core::order_book* ob) +inline helix_order_book_t wrap(helix::order_book* ob) { return reinterpret_cast(ob); } -inline helix::core::order_book* unwrap(helix_order_book_t ob) +inline helix::order_book* unwrap(helix_order_book_t ob) { - return reinterpret_cast(ob); + return reinterpret_cast(ob); } -inline helix_trade_t wrap(helix::core::trade* ob) +inline helix_trade_t wrap(helix::trade* ob) { return reinterpret_cast(ob); } -inline helix::core::trade* unwrap(helix_trade_t ob) +inline helix::trade* unwrap(helix_trade_t ob) { - return reinterpret_cast(ob); + return reinterpret_cast(ob); } -inline helix_event_t wrap(helix::core::event* ob) +inline helix_event_t wrap(helix::event* ob) { return reinterpret_cast(ob); } -inline helix::core::event* unwrap(helix_event_t ob) +inline helix::event* unwrap(helix_event_t ob) { - return reinterpret_cast(ob); + return reinterpret_cast(ob); } -inline helix_protocol_t wrap(helix::core::protocol* proto) +inline helix_protocol_t wrap(helix::protocol* proto) { return reinterpret_cast(proto); } -inline helix::core::protocol* unwrap(helix_protocol_t proto) +inline helix::protocol* unwrap(helix_protocol_t proto) { - return reinterpret_cast(proto); + return reinterpret_cast(proto); } -inline helix_session_t wrap(helix::core::session* session) +inline helix_session_t wrap(helix::session* session) { return reinterpret_cast(session); } -inline helix::core::session* unwrap(helix_session_t session) +inline helix::session* unwrap(helix_session_t session) { - return reinterpret_cast(session); + return reinterpret_cast(session); } helix_protocol_t helix_protocol_lookup(const char *name) @@ -80,8 +80,8 @@ helix_session_t helix_session_create(helix_protocol_t proto, helix_event_callback_t callback, void *data) { auto session = unwrap(proto)->new_session(data); - session->register_callback([session, callback](const helix::core::event& event) { - callback(wrap(session), wrap(const_cast(&event))); + session->register_callback([session, callback](const helix::event& event) { + callback(wrap(session), wrap(const_cast(&event))); }); return wrap(session); } @@ -178,7 +178,7 @@ helix_price_t helix_order_book_midprice(helix_order_book_t ob, size_t level) helix_trading_state_t helix_order_book_state(helix_order_book_t ob) { - using namespace helix::core; + using namespace helix; switch (unwrap(ob)->state()) { case trading_state::unknown: return HELIX_TRADING_STATE_UNKNOWN; case trading_state::halted: return HELIX_TRADING_STATE_HALTED; @@ -213,10 +213,10 @@ uint64_t helix_trade_size(helix_trade_t trade) helix_trade_sign_t helix_trade_sign(helix_trade_t trade) { switch (unwrap(trade)->sign) { - case helix::core::trade_sign::buyer_initiated: return HELIX_TRADE_SIGN_BUYER_INITIATED; - case helix::core::trade_sign::seller_initiated: return HELIX_TRADE_SIGN_SELLER_INITIATED; - case helix::core::trade_sign::crossing: return HELIX_TRADE_SIGN_CROSSING; - case helix::core::trade_sign::non_displayable: return HELIX_TRADE_SIGN_NON_DISPLAYABLE; + case helix::trade_sign::buyer_initiated: return HELIX_TRADE_SIGN_BUYER_INITIATED; + case helix::trade_sign::seller_initiated: return HELIX_TRADE_SIGN_SELLER_INITIATED; + case helix::trade_sign::crossing: return HELIX_TRADE_SIGN_CROSSING; + case helix::trade_sign::non_displayable: return HELIX_TRADE_SIGN_NON_DISPLAYABLE; } assert(0); } diff --git a/src/nasdaq/itch50_handler.cc b/src/nasdaq/itch50_handler.cc index c891268..e11865f 100644 --- a/src/nasdaq/itch50_handler.cc +++ b/src/nasdaq/itch50_handler.cc @@ -13,7 +13,6 @@ #include #include -using namespace helix::core; using namespace std; namespace helix { @@ -70,7 +69,7 @@ void itch50_handler::subscribe(std::string sym, size_t max_orders) { order_book_id_map.reserve(max_all_orders); } -void itch50_handler::register_callback(core::event_callback callback) { +void itch50_handler::register_callback(event_callback callback) { _process_event = callback; } diff --git a/src/nasdaq/itch50_protocol.cc b/src/nasdaq/itch50_protocol.cc index c92ebab..d5b6c7b 100644 --- a/src/nasdaq/itch50_protocol.cc +++ b/src/nasdaq/itch50_protocol.cc @@ -17,7 +17,7 @@ itch50_protocol::itch50_protocol(std::string name) { } -core::session* itch50_protocol::new_session(void *data) +session* itch50_protocol::new_session(void *data) { if (_name == "nasdaq-binaryfile-itch50") { return new binaryfile_session(data); diff --git a/src/nasdaq/nordic_itch_handler.cc b/src/nasdaq/nordic_itch_handler.cc index ba6de2f..4759528 100644 --- a/src/nasdaq/nordic_itch_handler.cc +++ b/src/nasdaq/nordic_itch_handler.cc @@ -12,7 +12,6 @@ #include #include -using namespace helix::core; using namespace std; namespace helix { @@ -34,7 +33,7 @@ void nordic_itch_handler::subscribe(std::string sym, size_t max_orders) order_id_map.reserve(max_all_orders); } -void nordic_itch_handler::register_callback(core::event_callback callback) +void nordic_itch_handler::register_callback(event_callback callback) { _process_event = callback; } diff --git a/src/nasdaq/nordic_itch_protocol.cc b/src/nasdaq/nordic_itch_protocol.cc index 6b2f834..563ec6b 100644 --- a/src/nasdaq/nordic_itch_protocol.cc +++ b/src/nasdaq/nordic_itch_protocol.cc @@ -19,7 +19,7 @@ bool nordic_itch_protocol::supports(const std::string& name) || name == "nasdaq-nordic-soupfile-itch"; } -core::session* nordic_itch_protocol::new_session(void *data) +session* nordic_itch_protocol::new_session(void *data) { if (_name == "nasdaq-nordic-moldudp-itch") { return new moldudp_session(data); diff --git a/src/order_book.cc b/src/order_book.cc index 2d631d9..deeda6d 100644 --- a/src/order_book.cc +++ b/src/order_book.cc @@ -8,8 +8,6 @@ using namespace std; namespace helix { -namespace core { - execution::execution(uint64_t price, side_type side, uint64_t remaining) : price{price} , side{side} @@ -225,5 +223,3 @@ uint64_t order_book::midprice(size_t level) const } } - -} diff --git a/src/parity/pmd_handler.cc b/src/parity/pmd_handler.cc index 4fefbe7..4303f30 100644 --- a/src/parity/pmd_handler.cc +++ b/src/parity/pmd_handler.cc @@ -12,7 +12,6 @@ #include #include -using namespace helix::core; using namespace std; namespace helix { @@ -48,7 +47,7 @@ bool pmd_handler::is_rth_timestamp(uint64_t timestamp) const void pmd_handler::subscribe(std::string sym, size_t max_orders) { - helix::core::order_book ob{sym, 0, max_orders}; + helix::order_book ob{sym, 0, max_orders}; ob.set_state(trading_state::trading); auto padding = PMD_INSTRUMENT_LEN - sym.size(); if (padding > 0) { @@ -58,7 +57,7 @@ void pmd_handler::subscribe(std::string sym, size_t max_orders) _order_book_id_map.emplace(sym, std::move(ob)); } -void pmd_handler::register_callback(core::event_callback callback) +void pmd_handler::register_callback(event_callback callback) { _process_event = callback; } diff --git a/src/parity/pmd_protocol.cc b/src/parity/pmd_protocol.cc index 564940e..9120e30 100644 --- a/src/parity/pmd_protocol.cc +++ b/src/parity/pmd_protocol.cc @@ -17,7 +17,7 @@ pmd_protocol::pmd_protocol(std::string name) { } -core::session* pmd_protocol::new_session(void *data) +session* pmd_protocol::new_session(void *data) { return new nasdaq::moldudp64_session(data); } diff --git a/tests/order_book_perf_test.cc b/tests/order_book_perf_test.cc index d12d02a..91bc707 100644 --- a/tests/order_book_perf_test.cc +++ b/tests/order_book_perf_test.cc @@ -2,7 +2,7 @@ #include #include -using namespace helix::core; +using namespace helix; using clock_type = std::chrono::high_resolution_clock;