Adding comments to SpreaderUtils
This commit is contained in:
1 parent
69dcfdb2bd
commit
fe647044f8
2 files changed
+31
-14
No files matched your search
@@ -25,6 +25,8 @@ struct LegData{
|
||||
OrderKey order_key;
|
||||
ChildState order_state;
|
||||
Book book;
|
||||
Quantity top_delete;
|
||||
Quantity cover_payup;
|
||||
LegData (size_t index_a,
|
||||
SecurityKey sec_key_a,
|
||||
api::Side side_a,
|
||||
@@ -36,7 +38,9 @@ struct LegData{
|
||||
order_template (order_template_a),
|
||||
order_key(null_order_key()),
|
||||
order_state(),
|
||||
book()
|
||||
book(),
|
||||
top_delete(0),
|
||||
cover_payup(0)
|
||||
{
|
||||
}
|
||||
const BookSide& opp_md() const{
|
||||
@@ -131,7 +135,7 @@ void PyramidAlgo::do_update(const api::orderman::Update& update) {
|
||||
case PyramidAlgo::Status::WAITING_FOR_MD:
|
||||
me->out_price = Price(update.price());
|
||||
me->out_qty = Quantity(update.quantity());
|
||||
// TODO, check is qty >= filled (filled >=0 in the case of attach)
|
||||
// TODO, check if qty >= filled (filled >=0 in the case of attach)
|
||||
break;
|
||||
case PyramidAlgo::Status::WORKING:
|
||||
me->out_price = Price(update.price());
|
||||
@@ -242,8 +246,10 @@ PyramidAlgo::_get_creation_params(const CustomOrderDefinition& cod,
|
||||
}
|
||||
|
||||
std::tuple<PyramidAlgo::PyramidAlgoParams,bool,std::string>
|
||||
PyramidAlgo::_get_update_params(const Update&,
|
||||
PyramidAlgo::_get_update_params(const Update& update,
|
||||
const PyramidAlgoParams& curr_params){
|
||||
auto rv = _convert_params(update.custom());
|
||||
// TODO: compare contracts and dont allow them to change
|
||||
return std::make_tuple(curr_params,true,std::string(""));
|
||||
}
|
||||
|
||||
@@ -307,12 +313,25 @@ bool PyramidAlgo::_working_state_met() const{
|
||||
const auto& ps = l.opp_md()[0];
|
||||
cover_sum += ps.price();
|
||||
}
|
||||
// TODO, check for delete
|
||||
return !os::is_nan(cover_sum) &&
|
||||
((me->side == api::Side::SIDE_BUY &&
|
||||
me->out_price.value() <= cover_sum) ||
|
||||
(me->side == api::Side::SIDE_SELL &&
|
||||
me->out_price.value() >= cover_sum));
|
||||
bool rv = !os::is_nan(cover_sum) &&
|
||||
((me->side == api::Side::SIDE_BUY &&
|
||||
me->out_price.value() <= cover_sum) ||
|
||||
(me->side == api::Side::SIDE_SELL &&
|
||||
me->out_price.value() >= cover_sum));
|
||||
if (!rv){
|
||||
// price condition does not met, but if the
|
||||
// cum qty at the top leg price is > threashold
|
||||
// then the condition is met ()
|
||||
const auto& top_leg = me->legs[0];
|
||||
Quantity cumm_level_qty;
|
||||
SpreaderUtils::find_qty_upto_price_level(top_leg.book,
|
||||
top_leg.side,
|
||||
Price(me->out_price),
|
||||
0.0,
|
||||
cumm_level_qty);
|
||||
rv = cumm_level_qty.value() > top_leg.top_delete.value();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
api::Side PyramidAlgo::_opp (api::Side side){
|
||||
|
||||
@@ -238,11 +238,9 @@ public:
|
||||
}
|
||||
}
|
||||
// CRITICAL PATH (for hedging)
|
||||
// travserses the book to locate the target_price,
|
||||
// and finds the qty at the target price and the
|
||||
// cum qty upto that price.
|
||||
// returns false if the target_price is not found.
|
||||
// this is used to find the qty and cumm_qty
|
||||
// travserses the book to locate the target_price,
|
||||
// and finds the cumm qty up to that level (last our arg)
|
||||
// Returns false if the target_price is not found.
|
||||
static bool find_qty_upto_price_level (const Book& book,
|
||||
api::Side book_side,
|
||||
Price target_price,
|
||||
|
||||
Reference in new issue
Block a user