From b0886f6b3d736bfdf8fa91e595dea7adc89fcdcc Mon Sep 17 00:00:00 2001 From: Taha Afzal Date: Mon, 10 Jun 2019 15:58:10 -0400 Subject: [PATCH] First check in, needs to be retofitted to QHO now --- src/lib/api/services/OrderService.proto | 1 + .../orders/spreader_orders/spreader/LegPropertyData.h | 6 +++++- .../spreader_orders/spreader/SingleLegQuoter.cpp | 10 ++++++---- .../orders/spreader_orders/spreader/SingleLegQuoter.h | 1 + .../orders/spreader_orders/spreader/SpreaderUtils.cpp | 7 ++++++- src/lib/sparkproto/SparkProtos.proto | 5 ++++- 6 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/lib/api/services/OrderService.proto b/src/lib/api/services/OrderService.proto index 5c03be00b..f9cdf3114 100644 --- a/src/lib/api/services/OrderService.proto +++ b/src/lib/api/services/OrderService.proto @@ -184,6 +184,7 @@ message QueueHolderDefinition{ // orders behind the top one (so value // of 1 means 2 orders in all) uint32 n_queue_orders = 1; + spark.NullableQuantity show_quantity = 2; CustomOrderDefinition child=10; } message OCOOrderDefinition { diff --git a/src/lib/orderman/orders/spreader_orders/spreader/LegPropertyData.h b/src/lib/orderman/orders/spreader_orders/spreader/LegPropertyData.h index 37b379209..98417fa9c 100644 --- a/src/lib/orderman/orders/spreader_orders/spreader/LegPropertyData.h +++ b/src/lib/orderman/orders/spreader_orders/spreader/LegPropertyData.h @@ -43,8 +43,12 @@ public: bts::spark::LegSpreaderParams::MarketDataType md_type() const { return _leg_params.market_data_type(); } + bool has_show_qty () const{ + //return _leg_params.quote_params().has_show_quantity(); + return true; + } uint32_t show_qty () const{ - return _leg_params.quote_params().show_quantity()+1; + return _leg_params.quote_params().show_quantity().quantity()+2; } uint32_t n_queue_holder_orders() const{ return _leg_params.quote_params().n_queue_holder_orders(); diff --git a/src/lib/orderman/orders/spreader_orders/spreader/SingleLegQuoter.cpp b/src/lib/orderman/orders/spreader_orders/spreader/SingleLegQuoter.cpp index 0dfd881ab..9e12f330a 100644 --- a/src/lib/orderman/orders/spreader_orders/spreader/SingleLegQuoter.cpp +++ b/src/lib/orderman/orders/spreader_orders/spreader/SingleLegQuoter.cpp @@ -20,6 +20,8 @@ _two_legged (n_spreader_legs == 2), _active_quoting(this_leg_property.is_active_quoting()), _hidden_order(this_leg_property.leg_params().has_quote_params() && this_leg_property.leg_params().quote_params().has_quote_hidden()), +_force_show_qty(this_leg_property.n_queue_holder_orders()==0 && + this_leg_property.has_show_qty()), _is_permenantly_cancelled (false), _irrecoverable_error(false), _n_spreader_legs (n_spreader_legs), @@ -50,6 +52,7 @@ SingleLegQuoter::SingleLegQuoter(SingleLegQuoter&& other) _two_legged (other._two_legged), _active_quoting(other._active_quoting), _hidden_order(other._hidden_order), +_force_show_qty(other._force_show_qty), _is_permenantly_cancelled (other._is_permenantly_cancelled), _irrecoverable_error(other._irrecoverable_error), _n_spreader_legs (other._n_spreader_legs), @@ -164,10 +167,9 @@ void SingleLegQuoter::_incorporate_other_leg_fill (size_t, Quantity hedge_reduct void SingleLegQuoter::_compute_price_quantity(Price& price, Quantity& quantity){ Quantity remaining_quantity = _price_quantity_state.remaining_to_fill(); - remaining_quantity = _this_leg_data.show_qty()==0 ? - remaining_quantity : - Quantity(std::min(remaining_quantity.value(), - _this_leg_data.show_qty())); + if(_force_show_qty) + remaining_quantity = Quantity(std::min(remaining_quantity.value(), + _this_leg_data.show_qty())); if (_two_legged){ size_t other_leg_index = _this_leg_data.leg_index() == 0 ? 1 : 0; SpreaderUtils::compute_price_quantity_2_legs (_price_quantity_state.target_spread_price(), diff --git a/src/lib/orderman/orders/spreader_orders/spreader/SingleLegQuoter.h b/src/lib/orderman/orders/spreader_orders/spreader/SingleLegQuoter.h index cd8f7a5c1..2d63aaee0 100644 --- a/src/lib/orderman/orders/spreader_orders/spreader/SingleLegQuoter.h +++ b/src/lib/orderman/orders/spreader_orders/spreader/SingleLegQuoter.h @@ -40,6 +40,7 @@ private: const bool _two_legged; const bool _active_quoting; const bool _hidden_order; + const bool _force_show_qty; bool _is_permenantly_cancelled; bool _irrecoverable_error; // this is a config constant. if the quoter diff --git a/src/lib/orderman/orders/spreader_orders/spreader/SpreaderUtils.cpp b/src/lib/orderman/orders/spreader_orders/spreader/SpreaderUtils.cpp index d6079fb3b..0170be94c 100644 --- a/src/lib/orderman/orders/spreader_orders/spreader/SpreaderUtils.cpp +++ b/src/lib/orderman/orders/spreader_orders/spreader/SpreaderUtils.cpp @@ -46,12 +46,17 @@ bool SpreaderUtils::resolve_synthetic_spread (const SpreaderPreActivationOrderSe quoter_order_def.set_side(leg_order_side); quoter_order_def.set_sub_type(bts::api::orderman::OrderSubType::ORDER_SUB_TYPE_QUOTING_LEG); - uint32_t n_queue_holder_orders=leg_params.quote_params().n_queue_holder_orders(); + const auto& quote_params=leg_params.quote_params(); + uint32_t n_queue_holder_orders=quote_params.n_queue_holder_orders(); if(n_queue_holder_orders>0){ api::orderman::QueueHolderDefinition qho_order_def; qho_order_def.set_n_queue_orders(n_queue_holder_orders); qho_order_def.mutable_child()->mutable_limit()->MergeFrom (api::orderman::LimitOrderDefinition()); quoter_order_def.mutable_custom_def()->mutable_queue_holder()->MergeFrom (qho_order_def); + if(quote_params.has_show_quantity() && + quote_params.show_quantity().quantity()>0){ + qho_order_def.mutable_show_quantity()->CopyFrom(quote_params.show_quantity()); + } } else{ quoter_order_def.mutable_custom_def()->mutable_limit()->MergeFrom (api::orderman::LimitOrderDefinition()); diff --git a/src/lib/sparkproto/SparkProtos.proto b/src/lib/sparkproto/SparkProtos.proto index 600a7b1e2..105f617d1 100644 --- a/src/lib/sparkproto/SparkProtos.proto +++ b/src/lib/sparkproto/SparkProtos.proto @@ -16,6 +16,9 @@ message QuantityMeasure } } +message NullableQuantity{ + uint32 quantity = 10; +} // /*************************************************************************************************/ // /*************************************************************************************************/ // /*************************************Spreader Parameters*****************************************/ @@ -71,7 +74,7 @@ message QuoteParams // and the user can embed a QHO here) uint32 n_queue_holder_orders=2000; // this is the show quantity on the quoter order - uint32 show_quantity = 2010; + NullableQuantity show_quantity = 2010; } /*************************************Quote MuteZone***********************************