diff --git a/src/lib/orderman/orders/algo/algo_orders/SniperAlgo.cpp b/src/lib/orderman/orders/algo/algo_orders/SniperAlgo.cpp index b54780a6e..b171a2c46 100644 --- a/src/lib/orderman/orders/algo/algo_orders/SniperAlgo.cpp +++ b/src/lib/orderman/orders/algo/algo_orders/SniperAlgo.cpp @@ -39,7 +39,8 @@ struct SecData{ // keeping last 2 books to see book evolution (not used currently) private: Book current_book, last_book; - std::optional look_ahead_book = std::nullopt; + Book look_ahead_book; + bool use_look_ahead_book = false; public: // all polygons that have a leg with this security are in this vector std::vector polygons; @@ -53,25 +54,21 @@ struct SecData{ buy_template(*buy_template), sell_template(*sell_template) { } void set_book(const Book& bk){ - look_ahead_book = std::nullopt; + use_look_ahead_book = false; last_book = current_book; current_book = bk; } const Book& get_current_book(){ - if(look_ahead_book.has_value()) - return look_ahead_book.value(); - return current_book; + return use_look_ahead_book ? look_ahead_book : current_book; } void on_trade_signal(api::Side agg_side, Price last_price, Quantity last_qty){ - auto res = SpreaderUtils::compute_book_from_sweep( + use_look_ahead_book = SpreaderUtils::compute_book_from_sweep( current_book, agg_side, last_price,last_qty, - look_ahead_book.value()); - if(!res) - look_ahead_book = std::nullopt; + look_ahead_book); } }; @@ -704,6 +701,8 @@ void SniperAlgo::_fire_orders(SecData& sec_data){ } me->last_shot_time = TimeUtil::GetCurrentTime(); me->n_working_polygons++; + // cxl algo after each send, we will bring it back manually + me->algo_services->complete(); }; for(SniperPolygon* p : sec_data.polygons){ if(me->n_working_polygons < me->max_no_working_polygons){