diff --git a/src/lib/md/MDProducerHandle.cpp b/src/lib/md/MDProducerHandle.cpp index 3af9741da..a63d1b826 100644 --- a/src/lib/md/MDProducerHandle.cpp +++ b/src/lib/md/MDProducerHandle.cpp @@ -209,10 +209,15 @@ void MDProducerHandle::mark_deleted() { TimeStamp ts = TimeStamp::now(); cdata().deleted = true; std::array blank; + std::array iblank; for (size_t x = 0; x < blank.size(); ++x) { blank[x] = PriceSize::NO_MARKET; + if (x < COCONUT_MAX_IMPLIED_DEPTH) { + iblank[x] = PriceSize::NO_MARKET; + } } - update_book(ts, blank, blank, 0); + update_direct(ts, blank, blank, 0); + update_implied(ts, iblank, iblank, 0); } }}//namespace diff --git a/src/lib/md/MDProducerHandle.h b/src/lib/md/MDProducerHandle.h index 4203c1fe4..e98ce4efb 100644 --- a/src/lib/md/MDProducerHandle.h +++ b/src/lib/md/MDProducerHandle.h @@ -34,8 +34,8 @@ public: } void set_legs(const std::vector& legs); - void update_bbo(TimeStamp time, const PriceSize bid_price, const PriceSize ask_price, uint16_t seq=0); // hot - void update_book(TimeStamp time, std::array& bids, std::array& asks, uint32_t seq=0) { + void update_bbo(TimeStamp time, const PriceSize bid_price, const PriceSize ask_price, uint16_t seq=0); + void update_direct(TimeStamp time, std::array& bids, std::array& asks, uint32_t seq=0) { if (!has_depth()) { update_bbo(time, bids[0], asks[0], seq); } @@ -51,7 +51,7 @@ public: hheader().direct_count += 1; } } - void update_implied(TimeStamp time, std::array& bids, std::array& asks, uint32_t seq=0) { + void update_implied(TimeStamp time, std::array& bids, std::array& asks, uint32_t seq=0) { if (has_depth()) { auto& book = hdepth(); book.set_time(TimeStamp::invalid()); diff --git a/src/lib/md/Shm/MDStructure.h b/src/lib/md/Shm/MDStructure.h index c9fa769ac..e443184a4 100644 --- a/src/lib/md/Shm/MDStructure.h +++ b/src/lib/md/Shm/MDStructure.h @@ -52,7 +52,7 @@ class HotEntry { static_assert(sizeof(HotEntry) <= CACHE_LINE, "HotEntry should be small"); const uint32_t COCONUT_MAX_DEPTH = 10; -const uint32_t COCONUT_IMPLIED_DEPTH = 2; +const uint32_t COCONUT_MAX_IMPLIED_DEPTH = 2; class HotDepthEntry { std::atomic timestamp; // 8 public: @@ -68,7 +68,7 @@ class HotDepthEntry { security_key key; // 4 NOTE: key is at a different offset than it is in HotEntry uint32_t sequence; // 4 std::array direct; // 240 - std::array implied; // 48 + std::array implied; // 48 uint8_t status; // 1 const PriceLevel* at(uint32_t depth) const { diff --git a/src/lib/md/relay/RelayClient.cpp b/src/lib/md/relay/RelayClient.cpp index f3aac8fb3..7345f7172 100644 --- a/src/lib/md/relay/RelayClient.cpp +++ b/src/lib/md/relay/RelayClient.cpp @@ -60,7 +60,7 @@ class RelayProducer : public IRelayWriter { bids[x] = book_at(update.book().bids(), x); asks[x] = book_at(update.book().asks(), x); } - handle.update_book(updated, bids, asks); + handle.update_direct(updated, bids, asks); } if (update.has_misc()) { auto& misc = update.misc(); diff --git a/src/lib/md/test/synthetic_book_merge_tests.cpp b/src/lib/md/test/synthetic_book_merge_tests.cpp index 8616446a9..215db620f 100644 --- a/src/lib/md/test/synthetic_book_merge_tests.cpp +++ b/src/lib/md/test/synthetic_book_merge_tests.cpp @@ -38,7 +38,7 @@ void setup_market(MDProducerHandle producer, const vector& bids, const vecto std::transform(bids.begin(), bids.end(), bids_a.begin(), [](const PS& ps) { return PriceSize::from_double<7>(ps.price, ps.size); }); std::transform(asks.begin(), asks.end(), asks_a.begin(), [](const PS& ps) { return PriceSize::from_double<7>(ps.price, ps.size); }); - producer.update_book(ts, bids_a, asks_a); + producer.update_direct(ts, bids_a, asks_a); } void expect_market(const MDConsumerHandle& handle, const vector bids, const vector& asks) { diff --git a/src/sdk/example/example.cpp b/src/sdk/example/example.cpp index 817869e1b..d38cb424c 100644 --- a/src/sdk/example/example.cpp +++ b/src/sdk/example/example.cpp @@ -69,7 +69,7 @@ void produce() }; // Update book - this call does not use locks so should not be called concurrently - producer_handles[0].update_book(utils::TimeStamp::now(), bids, asks); + producer_handles[0].update_direct(utils::TimeStamp::now(), bids, asks); } int main() diff --git a/src/server/sparkd/exchange_sim/ExchangeSimApplication.cpp b/src/server/sparkd/exchange_sim/ExchangeSimApplication.cpp index 1f2f4c8ce..8d38f9301 100644 --- a/src/server/sparkd/exchange_sim/ExchangeSimApplication.cpp +++ b/src/server/sparkd/exchange_sim/ExchangeSimApplication.cpp @@ -473,7 +473,7 @@ void ExchangeSimApplication::update_md(std::string const &sec_desc) { return md::PriceSize::from_double<7>( bs.first.value() * price_factor, bs.second.value()); }); - handle.update_book(utils::TimeStamp::now(), bids_temp, asks_temp); + handle.update_direct(utils::TimeStamp::now(), bids_temp, asks_temp); auto new_trades = matcher.get_new_trades(); for (auto &t : new_trades) diff --git a/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Listener.cpp b/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Listener.cpp index e8468f865..fa2b252cf 100644 --- a/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Listener.cpp +++ b/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Listener.cpp @@ -246,7 +246,7 @@ void MDP3Listener::flush_books() { // Write all book updates to shared memory and reset for the next packet for (auto& entry : _book_updates) { uint16_t sequence = (_latest_sequence & 0xFFFF); - entry.handle.update_book(_packet_arrived, entry.bids, entry.asks, sequence); + entry.handle.update_direct(_packet_arrived, entry.bids, entry.asks, sequence); } // Reset pending updates _book_updates.clear();