quantity connected, fills reported, limit set as default

This commit is contained in:
Mohammad Arham committed 2024-04-01 07:46:36 -04:00
1 parent cb1dfb257d
commit fae9c3e59e
1 file changed
+16 -11
@@ -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<CustomOrderDefinition> &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<uint32_t>(params, "n_ticks");
auto custom_ord = get_if<CustomOrderDefinition>(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<QuotingAlgoParams>(
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();
}
}