SPARK-309 (n legged hedge)

This commit is contained in:
Taha Afzal committed 2017-12-21 17:38:52 -05:00
1 parent c7018ce54c
commit 4668fa126d
4 files changed
+26 -5

No files matched your search

@@ -286,15 +286,20 @@ void SpreaderOrder::_compute_hedge_price_quantity(size_t filled_leg_index,
size_t hedge_leg_index,
Price& hedge_price, Quantity& hedge_quantity)
{
// 2 cases
SpreaderLegData& filled_leg_data = _bookkeeping_data.get_leg_data(filled_leg_index);
SpreaderLegData& hedged_leg_data = _bookkeeping_data.get_leg_data(filled_leg_index);
if (_bookkeeping_data.count() == 2)
{
SpreaderUtils::compute_hedge_price_size_2_legs (_bookkeeping_data.price(),
_bookkeeping_data.get_leg_data (filled_leg_index).leg_property_data(), fill_price, fill_quantity,
_bookkeeping_data.get_leg_data (hedge_leg_index).leg_property_data(), hedge_price, hedge_quantity);
filled_leg_data.leg_property_data(), fill_price, fill_quantity,
hedged_leg_data.leg_property_data(), hedge_price, hedge_quantity);
}
else
{
{
Price driver_price = hedged_leg_data.quoter()->driver_price(hedge_leg_index);
SpreaderUtils::compute_hedge_price_size_n_legs (filled_leg_data.leg_property_data(), fill_price, fill_quantity, driver_price,
hedged_leg_data.leg_property_data(), hedge_price, hedge_quantity);
}
}
void SpreaderOrder::_report_state (api::orderman::OrderStatus order_status, std::string* msg)
@@ -91,6 +91,11 @@ bool SingleLegQuoter::is_active_order() const
}
bool SingleLegQuoter::is_terminal_state () const {return _worker->state() == QuoterState::END;}
bool SingleLegQuoter::accept_modifications() const { return _worker->state() == QuoterState::WAITING_FOR_SIZE || _worker->state() == QuoterState::WORKING; }
Price SingleLegQuoter::driver_price (size_t leg_idx) const
{
bts_assert (leg_idx < _n_spreader_legs);
return _drivers_commited[leg_idx].driver_price;
}
void SingleLegQuoter::_incorporate_other_leg_fill (size_t leg_index, Quantity filled_quantity)
{
double this_leg_reduction_d = SpreaderUtils::get_equivelant_size (_spreader.get_leg_data(leg_index), filled_quantity, _this_leg_data);
+4 -1
View File
@@ -93,7 +93,10 @@ public:
bool is_terminal_state () const;
// the quoter returns true if it is in a state where orders
// can be modified
bool accept_modifications() const;
bool accept_modifications() const;
// for a given leg, returns the driver price that was used
// to price the current order
Price driver_price (size_t leg_idx) const;
friend QuoterStartStateWorker;
friend QuoterWaitingForSizeStateWorker;
friend QuoterWaitingForFirstAckWorker;
@@ -292,6 +292,7 @@ public:
if (idx != quoting_leg_index)
sum += driver_vector[idx].driver_price.value() * spreader.get_leg_data (idx).price_multiplier();
double rv = (target_spread_price.value() - sum)/quoting_leg_data.price_multiplier();
rv = bts::securities::raw_round_to_quote_price (rv, quoting_leg_data.tick_size(), quoting_leg_data.trading_side());
return Price(rv);
}
// each driver entry has the quoting quantity it can support.
@@ -308,5 +309,12 @@ public:
rv = driver_vector[idx].quoter_leg_quantity;
return rv;
}
static void compute_hedge_price_size_n_legs (const LegPropertyData& quote_filled_leg, Price, Quantity quote_fill_quantity,
Price driver_price, const LegPropertyData& hedge_leg,
Price& out_hedge_price, Quantity& out_hedge_quantity)
{
out_hedge_price = Price(bts::securities::raw_round_to_quote_price (driver_price.value(), hedge_leg.tick_size(), hedge_leg.trading_side()));
out_hedge_quantity = Quantity (get_equivelant_size (quote_filled_leg, quote_fill_quantity, hedge_leg));
}
};
}}