once the lean's child has crossed, changin lean's price has no effect on the child

This commit is contained in:
Taha Afzal committed 2019-05-13 17:53:19 -04:00
1 parent 21ee7c6af5
commit 8575d92373
2 files changed
+15 -4

No files matched your search

@@ -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());
@@ -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();