diff --git a/src/lib/orderman/orders/algo/algo_orders/LeanAlgo.cpp b/src/lib/orderman/orders/algo/algo_orders/LeanAlgo.cpp index a7f0a870b..6a86c4671 100644 --- a/src/lib/orderman/orders/algo/algo_orders/LeanAlgo.cpp +++ b/src/lib/orderman/orders/algo/algo_orders/LeanAlgo.cpp @@ -28,6 +28,7 @@ struct LeanAlgo::PImpl { Book curr_book; Price out_price = Price(os::nan()); Quantity out_qty = Quantity(0); + Price cross_price = Price(os::nan()); }; LeanAlgo::LeanAlgo() : me(new PImpl()) {} @@ -79,7 +80,8 @@ void LeanAlgo::do_update(const api::orderman::Update &update) { return; } Update child_update; - child_update.set_price(update.price()); + Price price_to_pass = _get_price_to_pass(Price(update.price())); + child_update.set_price(price_to_pass.value()); child_update.set_quantity(update.quantity()); if (update.has_custom()) { auto &lean_update = update.custom().lean(); @@ -195,6 +197,13 @@ LeanAlgo::MarketChange LeanAlgo::_market_change() const{ else return MarketChange::SIZE_CHANGE; } +Price LeanAlgo::_get_price_to_pass (Price price) const{ + // if it has crossed once, then the + // child order is always passed that price + if(!os::is_nan(me->cross_price.value())) + return me->cross_price; + return price; +} // actions //////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// void LeanAlgo::_analyze_and_act() { @@ -298,8 +307,9 @@ void LeanAlgo::_udpate_out_price_qty(Price price, Quantity qty){ } bool LeanAlgo::_modify_price_price_qty(Price price, Quantity qty){ if(me->out_price.value()!=price.value() || - me->out_qty.value()!=qty.value()){ - _udpate_out_price_qty(price,qty); + me->out_qty.value()!=qty.value()){ + _udpate_out_price_qty(price,qty); + me->cross_price = price; Update child_update; child_update.set_price(price.value()), child_update.set_quantity(qty.value()); diff --git a/src/lib/orderman/orders/algo/algo_orders/LeanAlgo.h b/src/lib/orderman/orders/algo/algo_orders/LeanAlgo.h index 56bda12d3..09aea41ba 100644 --- a/src/lib/orderman/orders/algo/algo_orders/LeanAlgo.h +++ b/src/lib/orderman/orders/algo/algo_orders/LeanAlgo.h @@ -34,7 +34,8 @@ class LeanAlgo : public IAlgoOrder { api::Side _opp_side() const; bool _within_chase_band(Price price) const; Price _chase_limit() const; - MarketChange _market_change() const; + MarketChange _market_change() const; + Price _get_price_to_pass (Price price) const; void _analyze_and_act(); bool _try_cross(Price); void _go_furthest_possible();