From fae9c3e59ea6eaadec2ff6ae861f76007e56439b Mon Sep 17 00:00:00 2001 From: Mohammad Arham Date: Mon, 1 Apr 2024 07:46:36 -0400 Subject: [PATCH] quantity connected, fills reported, limit set as default --- .../orders/algo/algo_orders/QuotingAlgo.cpp | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/lib/orderman/orders/algo/algo_orders/QuotingAlgo.cpp b/src/lib/orderman/orders/algo/algo_orders/QuotingAlgo.cpp index 575be6c41..4613d0e0c 100644 --- a/src/lib/orderman/orders/algo/algo_orders/QuotingAlgo.cpp +++ b/src/lib/orderman/orders/algo/algo_orders/QuotingAlgo.cpp @@ -112,13 +112,18 @@ QuotingAlgo::~QuotingAlgo() {} IAlgoServices &QuotingAlgo::_algo() const { return *me->algo; } ChildTemplate *_get_child_template( IBeforeLaunchAlgoServices &serv, - const CustomOrderDefinition &cod, + const std::optional &cod, SecurityKey key, api::Side side) { OrderDefinition rv = serv.definition(); rv.set_security_key(key.value()); rv.set_side(side); - rv.mutable_custom_def()->CopyFrom(cod); + if(cod.has_value()){ + rv.mutable_custom_def()->CopyFrom(cod.value()); + return &(serv.make_child_template(rv)); + } + rv.mutable_custom_def()->mutable_limit()->MergeFrom( + api::orderman::LimitOrderDefinition()); return &(serv.make_child_template(rv)); } @@ -136,17 +141,16 @@ bool _convert_params( auto n_ticks = get_if(params, "n_ticks"); auto custom_ord = get_if(params,"child_order"); - - if (!custom_ord.has_value() || !n_ticks.has_value() || !quote_around_theo.has_value() || !quote_around_market.has_value() || quote_around_theo.value() == quote_around_market.value()){ + if ( !n_ticks.has_value() || !quote_around_theo.has_value() || !quote_around_market.has_value() || quote_around_theo.value() == quote_around_market.value()){ LOG(OrderMan, Info, - "QuotingAlgo::convert_params failed n_ticks:{}, quote_around_theo:{}, quote_around_market:{}, child_order:{}", - n_ticks.has_value(), quote_around_theo.has_value(), quote_around_market.has_value(), custom_ord.has_value()); + "QuotingAlgo::convert_params failed n_ticks:{}, quote_around_theo:{}, quote_around_market:{}", + n_ticks.has_value(), quote_around_theo.has_value(), quote_around_market.has_value()); return false; } auto key = SecurityKey(serv.security().id()); auto side = serv.definition().side(); ChildTemplate *child_template = - _get_child_template(serv, custom_ord.value(), key , side); + _get_child_template(serv, custom_ord, key , side); out_p = std::make_unique( key, serv.security().glbx().security_desc(), @@ -300,7 +304,7 @@ void QuotingAlgo::_fire_orders(double price){ } Update update; update.set_price(price); - update.set_quantity(1); + update.set_quantity(me->algo->quantity().value()); _algo().update_child(me->child_order_key,update); } @@ -319,9 +323,10 @@ void QuotingAlgo::do_update( } void QuotingAlgo::on_child_change(OrderKey key, const ChildState &state) { - if(me->child_order_key==key && state.status != bts::orderman::ChildStatus::WORKING){ - - _cxl_and_end(false, "completed"); + if(me->child_order_key==key){ + me->algo->update_fill_state(state.total_fills, state.last_price); + if(state.status != bts::orderman::ChildStatus::WORKING) + me->algo->complete(); } }