QuoterStartStateWorker

This commit is contained in:
Taha Afzal committed 2017-11-03 11:36:18 -04:00
1 parent 4f850c85a7
commit ae99bb3f03
4 files changed
+56 -12

No files matched your search

@@ -55,5 +55,6 @@ public:
Price out_price() const { return _out_price; }
Quantity out_quantity() const { return _out_quantity; }
Quantity remaining_to_fill() const;
bool target_reached () const {return remaining_to_fill().value() == 0; }
};
}}
@@ -393,6 +393,14 @@ void SingleLegQuoter::_handle_events_in_END(const EventData & event_data)
bts_assert(false);
}
void SingleLegQuoter::_incorporate_other_leg_fill (size_t leg_index, Quantity filled_quantity)
{
bts_assert (leg_index != _this_leg_index);
double this_leg_reduction_d = _get_equivelant_quantity (leg_index, filled_quantity);
Quantity this_leg_reduction = Quantity (this_leg_reduction_d);
_price_quantity_state.add_hedged_reduction (this_leg_reduction);
}
void SingleLegQuoter::_fire_event(const EventData& event_data)
{
if (_state == QuoterState::WORKING)
+2 -1
View File
@@ -225,13 +225,14 @@ private:
/**********************External Event Handling in END**************************/
void _handle_events_in_END(const EventData& event_data);
/*******************************************************************************/
void _incorporate_other_leg_fill (size_t leg_index, Quantity filled_quantity);
// based on the state, calles the appropriate
// function to handle the event data
void _fire_event(const EventData& event_data);
// using the size ratios returns the size of this leg, corresponding
// to the size of an other leg.
double _get_equivelant_quantity(size_t leg_index, Quantity quantity);
// this is the function that computed the quoting price and the
// this is the function that computes the quoting price and the
// quantity for this leg. it uses the book of the other legs,
// the lean ratio and the quoting parameters to come up with
// the outgoing price and size. there is an n_leg case and an
@@ -2,6 +2,7 @@
#include "server/sparkd/orderman/md/Book.h"
#include "server/sparkd/spreader/quoter/quoter_states/QuoterStartStateWorker.h"
#include "server/sparkd/spreader/quoter/quoter_states/QuoterState.h"
#include "server/sparkd/spreader/SingleLegQuoter.h"
namespace bts{
namespace orderman{
@@ -12,22 +13,55 @@ void QuoterStartStateWorker::build_once (SingleLegQuoter* quoter)
_quoter = quoter;
}
void QuoterStartStateWorker::init ()
{}
{
LOG(OrderMan, Diag, "QuoterStartStateWorker::init key: {}", _quoter->_child_order.order_key().value());
_quoter->_transform_to_WAITING_FOR_SIZE();
}
void QuoterStartStateWorker::on_order_update (const SpreaderOrderUpdateMessage&)
{}
{
// no order has been sent as yet, so there is no way to get a callback
bts_assert_msg (false, "QuoterStartStateWorker::on_order_update is an illegal operation");
}
void QuoterStartStateWorker::on_book (bts::orderman::TickToTradeCorID, size_t, const bts::orderman::Book&)
{}
{
// no book updates can be sent before init, which causes the state to change
bts_assert_msg (false, "QuoterStartStateWorker::on_book is an illegal operation");
}
void QuoterStartStateWorker::cancel()
{}
{
// since no order has been sent for this leg, cancel just takes
// it to the end state
LOG(OrderMan, Diag, "QuoterStartStateWorker::cancel key: {}, transforming to end", _quoter->_child_order.order_key().value());
_quoter->_transform_to_END ();
}
void QuoterStartStateWorker::terminate()
{}
{
// termination is the same behaviour in any state
LOG(OrderMan, Diag, "QuoterStartStateWorker::terminate key: {}, transforming to end", _quoter->_child_order.order_key().value());
_quoter->_transform_to_END ();
}
void QuoterStartStateWorker::on_time(const TimeStamp&)
{}
void QuoterStartStateWorker::other_leg_quoter_fill (size_t, Quantity)
{}
void QuoterStartStateWorker::update_spreader_order_price (Price)
{}
void QuoterStartStateWorker::update_spreader_order_quantity (Quantity)
{}
void QuoterStartStateWorker::other_leg_quoter_fill (size_t leg_index, Quantity filled_quantity)
{
LOG(OrderMan, Diag, "QuoterStartStateWorker::other_leg_quoter_fill key: {}, leg_index {} filled_quantity {}",
_quoter->_child_order.order_key().value(), leg_index, filled_quantity.value());
_quoter->_incorporate_other_leg_fill (leg_index, filled_quantity);
if (_quoter->_price_quantity_state.target_reached())
{
LOG(OrderMan, Diag, "QuoterStartStateWorker::other_leg_quoter_fill key: {}, target reached, transforming to end", _quoter->_child_order.order_key().value());
_quoter->_transform_to_END ();
}
}
void QuoterStartStateWorker::update_spreader_order_price (Price price)
{
LOG(OrderMan, Diag, "QuoterStartStateWorker::update_spreader_order_price key: {}, price {}", _quoter->_child_order.order_key().value(), price.value());
_quoter->_price_quantity_state.update_target_spread_price (price);
}
void QuoterStartStateWorker::update_spreader_order_quantity (Quantity quantity)
{
LOG(OrderMan, Diag, "QuoterStartStateWorker::update_spreader_order_quantity key: {}, quantity {}", _quoter->_child_order.order_key().value(), quantity.value());
_quoter->_price_quantity_state.update_target_leg_quantity (quantity);
}
}}