Options 'books' can optionally be built from quotes now
This commit is contained in:
1 parent
14af01182c
commit
ad0c4b25a5
1 file changed
+29
-1
@@ -146,6 +146,14 @@ void copy_books(
|
||||
}
|
||||
}
|
||||
|
||||
void copy_books(
|
||||
emumba::market_data::price px, double qty, MDArray &to, bool clear = true) {
|
||||
if (clear) {
|
||||
clear_books(to);
|
||||
}
|
||||
to[0] = PriceSize{convert_price(px), convert_qty(qty)};
|
||||
}
|
||||
|
||||
inline EmumbaSecurityData *get_security(
|
||||
EmumbaSecurityIndex &sec_map, uint64_t id) {
|
||||
EmumbaSecurityData *rv = sec_map.get_security(id);
|
||||
@@ -199,6 +207,7 @@ struct SecurityAuxData {
|
||||
};
|
||||
|
||||
struct EmMDListener::PImpl {
|
||||
bool use_quote_for_options = true;
|
||||
bts::persistence::IDGenerator id_gen = {};
|
||||
emumba::deribit_connector::deribit_handler *handler = nullptr;
|
||||
EmumbaSecurityIndex &index;
|
||||
@@ -366,7 +375,21 @@ void EmMDListener::on_security_statistics(
|
||||
void EmMDListener::on_quote(
|
||||
// this is the top of book change
|
||||
__attribute__((unused)) const emumba::market_data::quote "e,
|
||||
__attribute__((unused)) const void *ptr) {}
|
||||
__attribute__((unused)) const void *ptr) {
|
||||
EmumbaSecurityData *sec_data = _find_security(quote.sec_id);
|
||||
if (sec_data == nullptr) {
|
||||
LOG(md, Error, "EmMDListener::on_quote could not find desc:{}",
|
||||
extract_security_desc(quote.sec_id));
|
||||
return;
|
||||
}
|
||||
if (me->use_quote_for_options &&
|
||||
sec_data->handle.security().type == api::SECURITYTYPE_OPTION) {
|
||||
copy_books(quote.best_bid_price, quote.best_bid_amount, me->bids);
|
||||
copy_books(quote.best_ask_price, quote.best_ask_amount, me->asks);
|
||||
sec_data->handle.update_direct(
|
||||
utils::TimeStamp::now(), me->bids, me->asks);
|
||||
}
|
||||
}
|
||||
|
||||
void _log_book(
|
||||
EmumbaSecurityData *s_data, const emumba::market_data::order_book &book) {
|
||||
@@ -387,6 +410,11 @@ void EmMDListener::on_book(
|
||||
extract_security_desc(book.sec_id));
|
||||
return;
|
||||
}
|
||||
if (me->use_quote_for_options &&
|
||||
sec_data->handle.security().type == api::SECURITYTYPE_OPTION) {
|
||||
// using on_quotes for option books for now
|
||||
return;
|
||||
}
|
||||
LOG(md, Diag, "EmMDListener::on_book id:{}",
|
||||
extract_security_desc(book.sec_id));
|
||||
_log_book(sec_data, book);
|
||||
|
||||
Reference in new issue
Block a user