-ve edge allowed, can also be modified on the fly
This commit is contained in:
1 parent
3835824d36
commit
0a94c729e5
1 file changed
+11
-6
@@ -230,8 +230,8 @@ bool is_shot_opp(api::Side poly_side, double poly_price, double min_edge){
|
||||
if(poly_side == api::Side::SIDE_SELL)
|
||||
return bts::securities::gr_than_eq(poly_price,min_edge);
|
||||
else
|
||||
return bts::securities::gr_than_eq(-1 * std::abs(min_edge),
|
||||
poly_price);
|
||||
return bts::securities::gr_than_eq(-1.0 * min_edge,
|
||||
poly_price);
|
||||
}
|
||||
|
||||
void log_polygon_eval(SniperPolygon& p, double min_edge){
|
||||
@@ -271,8 +271,7 @@ ChildTemplate* _get_ord_template (IBeforeLaunchAlgoServices& serv,
|
||||
return &(serv.make_child_template(order_def));
|
||||
}
|
||||
|
||||
bool _convert_params (IBeforeLaunchAlgoServices&,
|
||||
const CustomOrderDefinition& cod,
|
||||
bool _convert_params (const CustomOrderDefinition& cod,
|
||||
SniperAlgoParams& out_p){
|
||||
const DynamicOrderDefinition& def = cod.dynamic();
|
||||
const auto& params = def.order_params();
|
||||
@@ -314,7 +313,7 @@ OrderOpResult SniperAlgo::do_before_launch(IBeforeLaunchAlgoServices& serv){
|
||||
auto& def = serv.definition();
|
||||
if (def.has_custom_def() &&
|
||||
def.custom_def().has_dynamic() &&
|
||||
_convert_params(serv,def.custom_def(),me->algo_params) &&
|
||||
_convert_params(def.custom_def(),me->algo_params) &&
|
||||
_onetime_setup(serv,def.custom_def()))
|
||||
return {};
|
||||
return {OrderError::ORDER_ERROR_INVALID_PARAMETER,
|
||||
@@ -332,7 +331,13 @@ void SniperAlgo::do_launch_attached(IAlgoServices& algo_services,
|
||||
me->algo_services = &algo_services;
|
||||
_cxl_and_end(true, "Sniper Algo can not be attached to working orders");
|
||||
}
|
||||
void SniperAlgo::do_update(const Update&){
|
||||
void SniperAlgo::do_update(const Update& u){
|
||||
SniperAlgoParams p;
|
||||
if(_convert_params(u.custom(),p)){
|
||||
// just fill edge and throttle
|
||||
me->algo_params.min_edge = p.min_edge;
|
||||
me->algo_params.throttle_ms = p.throttle_ms;
|
||||
}
|
||||
}
|
||||
void SniperAlgo::on_book(SecurityKey key, const Book& bk) {
|
||||
auto it = me->sec_map.find(key);
|
||||
|
||||
Reference in new issue
Block a user