SPARK-1659 Update producer api to handle implied markets (push early for emumba)
This commit is contained in:
1 parent
7bda1cc1cc
commit
dd5b489e8f
8 files changed
+16
-11
No files matched your search
@@ -209,10 +209,15 @@ void MDProducerHandle::mark_deleted() {
|
||||
TimeStamp ts = TimeStamp::now();
|
||||
cdata().deleted = true;
|
||||
std::array<PriceSize,COCONUT_MAX_DEPTH> blank;
|
||||
std::array<PriceSize,COCONUT_MAX_IMPLIED_DEPTH> 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
|
||||
|
||||
@@ -34,8 +34,8 @@ public:
|
||||
}
|
||||
void set_legs(const std::vector<security_key>& 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<PriceSize,COCONUT_MAX_DEPTH>& bids, std::array<PriceSize,COCONUT_MAX_DEPTH>& 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<PriceSize,COCONUT_MAX_DEPTH>& bids, std::array<PriceSize,COCONUT_MAX_DEPTH>& 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<PriceSize,COCONUT_IMPLIED_DEPTH>& bids, std::array<PriceSize,COCONUT_IMPLIED_DEPTH>& asks, uint32_t seq=0) {
|
||||
void update_implied(TimeStamp time, std::array<PriceSize,COCONUT_MAX_IMPLIED_DEPTH>& bids, std::array<PriceSize,COCONUT_MAX_IMPLIED_DEPTH>& asks, uint32_t seq=0) {
|
||||
if (has_depth()) {
|
||||
auto& book = hdepth();
|
||||
book.set_time(TimeStamp::invalid());
|
||||
|
||||
@@ -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> 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<PriceLevel, COCONUT_MAX_DEPTH> direct; // 240
|
||||
std::array<PriceLevel, COCONUT_IMPLIED_DEPTH> implied; // 48
|
||||
std::array<PriceLevel, COCONUT_MAX_IMPLIED_DEPTH> implied; // 48
|
||||
uint8_t status; // 1
|
||||
|
||||
const PriceLevel* at(uint32_t depth) const {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -38,7 +38,7 @@ void setup_market(MDProducerHandle producer, const vector<PS>& 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<PS> bids, const vector<PS>& asks) {
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user