Added enums for usage of quote order for hedging and hooke dup the code to it
This commit is contained in:
1 parent
05ca21d517
commit
07a059fb5d
6 files changed
+67
-20
No files matched your search
@@ -85,7 +85,7 @@ inline Price better_price (api::Side side, Price p1, Price p2){
|
||||
|
||||
// returns true if p1 is a better order price than p2
|
||||
// ie lower when buying, higher when selling
|
||||
inline bool better_order_price (api::Side side, Price p1, Price p2){
|
||||
inline bool same_or_better_order_price (api::Side side, Price p1, Price p2){
|
||||
return is_equal_or_better(side, p2, p1);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,9 @@ public:
|
||||
const bts::api::Security& security() const { return _leg_contract.security(); }
|
||||
double price_multiplier() const { return _leg_contract.price_multiplier(); }
|
||||
double size_multiplier() const { return _leg_contract.quantity(); }
|
||||
double tick_size() const { return _leg_contract.security().contract_spec().low_tick(); }
|
||||
double tick_size() const {
|
||||
return _leg_contract.security().contract_spec().low_tick();
|
||||
}
|
||||
bool is_active_quoting() const {return _leg_params.is_active_quoting();}
|
||||
bool is_net_change() const{
|
||||
return _price_calc==bts::api::SyntheticContract::PRICECALC_NET_CHANGE;
|
||||
@@ -56,6 +58,9 @@ public:
|
||||
uint32_t n_queue_holder_orders() const{
|
||||
return _leg_params.quote_params().n_queue_holder_orders();
|
||||
}
|
||||
bts::spark::UseSpreaderQuoteForHedging use_quote_for_hedging() const{
|
||||
return _leg_params.quote_params().use_quote_for_hedging();
|
||||
}
|
||||
};
|
||||
|
||||
}}
|
||||
@@ -90,6 +90,9 @@ public:
|
||||
Price last_reported_order_price() const{
|
||||
return _last_reported_order_price;
|
||||
}
|
||||
Quantity last_reported_order_quantity() const{
|
||||
return _last_reported_order_qty;
|
||||
}
|
||||
// if the last fill was a status change
|
||||
// this will be zero
|
||||
Quantity last_update_filled_quantity () const {
|
||||
|
||||
+46
-14
@@ -50,9 +50,7 @@ void QuoterWorkingStateWorker::on_other_leg_quoter_fill (
|
||||
Price hedge_price,
|
||||
Quantity hedge_qty){
|
||||
bool q_to_h = hedge_qty.value() > 0 &&
|
||||
_use_quoting_order_to_hedge(
|
||||
_quoter->_child_order_state.out_price(),
|
||||
hedge_price);
|
||||
_use_quoting_order_to_hedge(hedge_price,hedge_qty);
|
||||
// decide how to send hedge
|
||||
_quoter->_incorporate_other_leg_fill (leg_index,
|
||||
filled_quantity,
|
||||
@@ -118,17 +116,51 @@ void QuoterWorkingStateWorker::_modify_order (Price price, Quantity quantity){
|
||||
_quoter->_modify_order(price, quantity);
|
||||
}
|
||||
}
|
||||
bool QuoterWorkingStateWorker::_use_quoting_order_to_hedge(Price q_price,
|
||||
Price h_price) const{
|
||||
bool QuoterWorkingStateWorker::_use_quoting_order_to_hedge(Price h_price,
|
||||
Quantity h_qty) const{
|
||||
const LegPropertyData& leg = _quoter->_this_leg_data;
|
||||
const SpreaderChildOrderState& q_ord = _quoter->_child_order_state;
|
||||
// check to see if the order is in transition ?
|
||||
bool q_better = securities::better_order_price(_quoter->_this_leg_data.trading_side(),
|
||||
q_price, h_price);
|
||||
LOG(OrderMan, Info, "QuoterWorkingStateWorker::_use_quoting_order_to_hedge "
|
||||
"{} side:{} q:{} h:{}",
|
||||
q_better,
|
||||
_quoter->_this_leg_data.trading_side(),
|
||||
q_price,
|
||||
h_price);
|
||||
return q_better;
|
||||
auto q_for_h = leg.use_quote_for_hedging();
|
||||
bool q_better = securities::same_or_better_order_price(
|
||||
_quoter->_this_leg_data.trading_side(),
|
||||
q_ord.last_reported_order_price(),
|
||||
h_price) &&
|
||||
// this is to make sure that the hedge price
|
||||
// is also worse than anything in flight
|
||||
securities::same_or_better_order_price(
|
||||
_quoter->_this_leg_data.trading_side(),
|
||||
q_ord.out_price(),
|
||||
h_price);
|
||||
bool rv;
|
||||
switch(q_for_h){
|
||||
case spark::UseSpreaderQuoteForHedging::NEVER:
|
||||
rv = false;
|
||||
break;
|
||||
case spark::UseSpreaderQuoteForHedging::WHEN_CANT_OVERHEDGE:
|
||||
rv = q_better &&
|
||||
// max fill potential <= hedge qty
|
||||
h_qty.value() >= SpreaderUtils::subtract_quanitities(
|
||||
q_ord.out_quantity().value(),
|
||||
q_ord.current_fills().value()) &&
|
||||
h_qty.value() >= SpreaderUtils::subtract_quanitities(
|
||||
q_ord.last_reported_order_quantity().value(),
|
||||
q_ord.current_fills().value());
|
||||
break;
|
||||
case spark::UseSpreaderQuoteForHedging::ALWAYS:
|
||||
rv = q_better;
|
||||
break;
|
||||
default:
|
||||
bts_assert(false);
|
||||
rv = false;
|
||||
break;
|
||||
}
|
||||
// LOG(OrderMan, Info, "QuoterWorkingStateWorker::_use_quoting_order_to_hedge "
|
||||
// "{} side:{} q:{} h:{}",
|
||||
// q_better,
|
||||
// _quoter->_this_leg_data.trading_side(),
|
||||
// q_price,
|
||||
// h_price);
|
||||
return rv;
|
||||
}
|
||||
}}
|
||||
+2
-2
@@ -39,7 +39,7 @@ private:
|
||||
// iii. if reprice (ie qty changed or price changed beyond the threshold) => requote
|
||||
void _longpath_analyze_and_act ();
|
||||
void _modify_order (Price price, Quantity quantity);
|
||||
bool _use_quoting_order_to_hedge(Price q_price,
|
||||
Price h_price) const;
|
||||
bool _use_quoting_order_to_hedge(Price h_price,
|
||||
Quantity h_qty) const;
|
||||
};
|
||||
}}
|
||||
@@ -31,6 +31,12 @@ message RulePriority
|
||||
int32 priority = 20;
|
||||
}
|
||||
|
||||
enum UseSpreaderQuoteForHedging
|
||||
{
|
||||
NEVER = 0;
|
||||
WHEN_CANT_OVERHEDGE = 1;
|
||||
ALWAYS = 2;
|
||||
}
|
||||
|
||||
message LegSpreaderParams
|
||||
{
|
||||
@@ -46,7 +52,7 @@ message LegSpreaderParams
|
||||
PreHedgeParams pre_hedge_params = 50;
|
||||
PostHedgeParams post_hedge_params = 60;
|
||||
MarketDataType market_data_type = 70;
|
||||
//reserve LegMarketDataCalculation leg_md_calc = 80;
|
||||
//reserve LegMarketDataCalculation leg_md_calc = 80;
|
||||
}
|
||||
|
||||
// /*************************************************************************************************
|
||||
@@ -74,7 +80,8 @@ message QuoteParams
|
||||
// and the user can embed a QHO here)
|
||||
uint32 n_queue_holder_orders=2000;
|
||||
// this is the show quantity on the quoter order
|
||||
NullableQuantity show_quantity = 2010;
|
||||
NullableQuantity show_quantity = 2010;
|
||||
UseSpreaderQuoteForHedging use_quote_for_hedging = 2020;
|
||||
}
|
||||
|
||||
/*************************************Quote MuteZone***********************************
|
||||
|
||||
Reference in new issue
Block a user