Refactored OM to allow speed up.
This commit is contained in:
1 parent
5e1fd41935
commit
70bcf3ff0d
10 files changed
+186
-118
No files matched your search
@@ -29,6 +29,9 @@ template <typename EV, typename KE = KeyExtractor> class ContentSubscription {
|
||||
using Key = decltype((*((KE *)nullptr))(*((EV *)nullptr)));
|
||||
using CB = std::function<void(const EV &)>;
|
||||
struct SubID {
|
||||
SubID() : k(), sid(0) {}
|
||||
SubID(Key k, uint32_t sid) : k(k), sid(sid) {}
|
||||
|
||||
Key k;
|
||||
uint32_t sid;
|
||||
bool operator==(SubID const &rhs) const {
|
||||
@@ -39,7 +42,7 @@ template <typename EV, typename KE = KeyExtractor> class ContentSubscription {
|
||||
ContentSubscription(Actor &actor)
|
||||
: _actor(&actor), _sub(_actor->subscribe<EV>(
|
||||
[this](auto const &u) { this->on_update(u); })),
|
||||
_my_subs(), _dispatching(false), _current_sub_id(0),
|
||||
_my_subs(), _dispatching(false), _current_sub_id(1),
|
||||
_pre_sub([](auto) {}) {}
|
||||
|
||||
ContentSubscription(Actor &actor, std::function<void(Key)> const &pscb)
|
||||
@@ -52,7 +55,7 @@ template <typename EV, typename KE = KeyExtractor> class ContentSubscription {
|
||||
: _actor(&actor),
|
||||
_sub(_actor->subscribe<EV>(
|
||||
tag, [this](auto const &u) { this->on_update(u); })),
|
||||
_my_subs(), _dispatching(false), _current_sub_id(0),
|
||||
_my_subs(), _dispatching(false), _current_sub_id(1),
|
||||
_pre_sub([](auto) {}) {}
|
||||
|
||||
template <class Tag>
|
||||
@@ -61,7 +64,7 @@ template <typename EV, typename KE = KeyExtractor> class ContentSubscription {
|
||||
: _actor(&actor),
|
||||
_sub(_actor->subscribe<EV>(
|
||||
tag, [this](auto const &u) { this->on_update(u); })),
|
||||
_my_subs(), _dispatching(false), _current_sub_id(0),
|
||||
_my_subs(), _dispatching(false), _current_sub_id(1),
|
||||
_pre_sub(pscb) {}
|
||||
|
||||
template <class CBT> SubID sub(Key k, CBT const &cb) {
|
||||
|
||||
@@ -1,93 +1,85 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <atomic>
|
||||
#include "lib/orderman/orderman_utils/orderman_common.h"
|
||||
#include "lib/api/services/OrderService.pb.h"
|
||||
#include "lib/orderman/orders/PreActivationOrderServices.h"
|
||||
#include "lib/orderman/actors/order_manager/OrderServices.h"
|
||||
#include "lib/logging/logging.h"
|
||||
#include "lib/orderman/actors/order_manager/ChildOrder.h"
|
||||
#include "lib/orderman/actors/order_manager/OrderServices.h"
|
||||
#include "lib/orderman/orderman_utils/orderman_common.h"
|
||||
#include "lib/orderman/orders/PreActivationOrderServices.h"
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
|
||||
class OrderBuilder
|
||||
{
|
||||
public:
|
||||
class OrderBuilder {
|
||||
public:
|
||||
OrderBuilder()
|
||||
: _parent_key(null_order_key()),
|
||||
_definition(),
|
||||
_reserve_sz(0),
|
||||
_order_stash(),
|
||||
_builder_id(),
|
||||
_order_services(nullptr)
|
||||
{}
|
||||
: _parent_key(null_order_key()), _definition(), _reserve_sz(0),
|
||||
_order_stash(), _builder_id(), _order_services(nullptr) {}
|
||||
|
||||
OrderBuilder(OrderBuilder&&src) {operator=(std::move(src));}
|
||||
OrderBuilder(OrderBuilder &&src) { operator=(std::move(src)); }
|
||||
|
||||
OrderBuilder(OrderKey parent_key, api::orderman::OrderDefinition const &def,
|
||||
PreActivationOrderServices const &srv, size_t reserve_sz = 1)
|
||||
: _parent_key(parent_key), _definition(def), _reserve_sz(reserve_sz),
|
||||
_order_stash(), _builder_id(++_current_builder_id),
|
||||
_order_services(nullptr)
|
||||
|
||||
OrderBuilder(OrderKey parent_key,
|
||||
api::orderman::OrderDefinition const&def,
|
||||
PreActivationOrderServices const &srv,
|
||||
size_t reserve_sz = 1)
|
||||
: _parent_key(parent_key),
|
||||
_definition(def) ,
|
||||
_reserve_sz(reserve_sz),
|
||||
_order_stash(),
|
||||
_builder_id(++_current_builder_id),
|
||||
_order_services(nullptr)
|
||||
|
||||
{
|
||||
bts_assert(parent_key != null_order_key());
|
||||
while (_order_stash.size() != reserve_sz)
|
||||
_order_stash.push_back(&srv.order_factory.create(parent_key,_definition));
|
||||
_order_stash.push_back(
|
||||
&srv.order_factory.create(parent_key, _definition));
|
||||
}
|
||||
|
||||
void activate(OrderServices &order_services)
|
||||
{
|
||||
void activate(OrderServices &order_services) {
|
||||
bts_assert(!_order_services);
|
||||
_order_services = &order_services;
|
||||
_order_services->order_creations.sub(_builder_id,[this] (auto const&order_ev) {
|
||||
_order_stash.insert(_order_stash.end(),order_ev.orders.begin(),order_ev.orders.end());
|
||||
});
|
||||
_order_services->subscribe_to_order_creation_reply(
|
||||
_builder_id, [this](auto const &order_ev) {
|
||||
_order_stash.insert(_order_stash.end(), order_ev.orders.begin(),
|
||||
order_ev.orders.end());
|
||||
});
|
||||
}
|
||||
|
||||
ChildOrder build()
|
||||
{
|
||||
bts_assert_msg(_order_services,"OrderBuilder::activate() must be called before orders can be built");
|
||||
|
||||
ChildOrder build() {
|
||||
bts_assert_msg(
|
||||
_order_services,
|
||||
"OrderBuilder::activate() must be called before orders can be built");
|
||||
|
||||
ChildOrder result;
|
||||
if (_order_stash.size()) {
|
||||
result = ChildOrder( *_order_stash.back(),
|
||||
*_order_services);
|
||||
result = ChildOrder(*_order_stash.back(), *_order_services);
|
||||
_order_stash.pop_back();
|
||||
}
|
||||
else {
|
||||
LOG(OrderMan,Warn,
|
||||
"Ran out of pre-allocated child orders for order {}. Will allocate directly. "
|
||||
"This will have an impact on performance", _parent_key);
|
||||
result = ChildOrder (_order_services->order_factory().create(_parent_key,_definition),
|
||||
*_order_services);
|
||||
} else {
|
||||
LOG(OrderMan, Warn,
|
||||
"Ran out of pre-allocated child orders for order {}. Will "
|
||||
"allocate directly. "
|
||||
"This will have an impact on performance",
|
||||
_parent_key);
|
||||
result = ChildOrder(
|
||||
_order_services->order_factory().create(_parent_key, _definition),
|
||||
*_order_services);
|
||||
}
|
||||
if (_reserve_sz > _order_stash.size()) {
|
||||
auto need = _reserve_sz - _order_stash.size();
|
||||
_order_services->send_order_create_req(_builder_id,_parent_key,_definition,need);
|
||||
_order_services->send_order_create_req(_builder_id, _parent_key,
|
||||
_definition, need);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
OrderBuilder& operator=(OrderBuilder &&src)
|
||||
{
|
||||
|
||||
OrderBuilder &operator=(OrderBuilder &&src) {
|
||||
move_here(src);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
void move_here(OrderBuilder &src)
|
||||
{
|
||||
private:
|
||||
void move_here(OrderBuilder &src) {
|
||||
bts_assert(!_order_services);
|
||||
_parent_key = src._parent_key;
|
||||
_definition= src._definition;
|
||||
_definition = src._definition;
|
||||
_reserve_sz = src._reserve_sz;
|
||||
_order_stash = src._order_stash;
|
||||
_builder_id = src._builder_id;
|
||||
@@ -96,15 +88,16 @@ private:
|
||||
src._order_services = nullptr;
|
||||
bts_assert(_parent_key != null_order_key());
|
||||
}
|
||||
|
||||
|
||||
OrderKey _parent_key;
|
||||
api::orderman::OrderDefinition _definition;
|
||||
size_t _reserve_sz;
|
||||
std::vector<Order*> _order_stash;
|
||||
size_t _builder_id ;
|
||||
std::vector<Order *> _order_stash;
|
||||
size_t _builder_id;
|
||||
OrderServices *_order_services;
|
||||
|
||||
|
||||
static std::atomic<size_t> _current_builder_id;
|
||||
};
|
||||
|
||||
}}
|
||||
} // namespace orderman
|
||||
} // namespace bts
|
||||
@@ -18,10 +18,10 @@ class SessionServices {
|
||||
|
||||
public:
|
||||
SessionServices(SessionServicesData &session_data)
|
||||
: exe_reports(*session_data.exe_report_subs),
|
||||
cancel_rejects(*session_data.cancel_reject_subs),
|
||||
gateway_status(*session_data.gateway_status_subs),
|
||||
_session_data(&session_data) {}
|
||||
: _exe_reports(*session_data.exe_report_subs),
|
||||
_cancel_rejects(*session_data.cancel_reject_subs),
|
||||
_gateway_status(*session_data.gateway_status_subs),
|
||||
_session_data(&session_data), _gateway_status_sub() {}
|
||||
|
||||
std::string const &session_name() const { return _session_data->session; }
|
||||
|
||||
@@ -39,30 +39,54 @@ class SessionServices {
|
||||
bool is_gateway_connected() const { return _session_data->gw_connected; }
|
||||
Governor &governor() { return _session_data->governor; }
|
||||
|
||||
EventStream<NewExecutionReportEvent> exe_reports;
|
||||
EventStream<CancelRejectEvent> cancel_rejects;
|
||||
EventStream<GatewayStatusChangeEvent, mercury::NoKey> gateway_status;
|
||||
// Subscriptions
|
||||
using ExeReportSubID = EventStream<NewExecutionReportEvent>::SubID;
|
||||
using CancelRejectSubID = EventStream<CancelRejectEvent>::SubID;
|
||||
|
||||
template <class CB>
|
||||
ExeReportSubID subscribe_to_exe_report(OrderKey k, CB &&cb) {
|
||||
return _exe_reports.sub(k, std::forward<CB>(cb));
|
||||
}
|
||||
void unsubscribe_from_exe_report(ExeReportSubID sid) {
|
||||
_exe_reports.unsub(sid);
|
||||
}
|
||||
|
||||
template <class CB>
|
||||
CancelRejectSubID subscribe_to_cancel_reject(OrderKey k, CB &&cb) {
|
||||
return _cancel_rejects.sub(k, std::forward<CB>(cb));
|
||||
}
|
||||
void unsubscribe_from_cancel_reject(CancelRejectSubID sid) {
|
||||
_cancel_rejects.unsub(sid);
|
||||
}
|
||||
|
||||
template <class CB> void subscribe_to_gateway_status(CB &&cb) {
|
||||
_gateway_status_sub = _gateway_status.sub(std::forward<CB>(cb));
|
||||
}
|
||||
void unsubscribe_from_gateway_status() {
|
||||
_gateway_status.unsub(_gateway_status_sub);
|
||||
}
|
||||
|
||||
private:
|
||||
EventStream<NewExecutionReportEvent> _exe_reports;
|
||||
EventStream<CancelRejectEvent> _cancel_rejects;
|
||||
EventStream<GatewayStatusChangeEvent, mercury::NoKey> _gateway_status;
|
||||
SessionServicesData *_session_data;
|
||||
EventStream<GatewayStatusChangeEvent, mercury::NoKey>::SubID
|
||||
_gateway_status_sub;
|
||||
};
|
||||
|
||||
class OrderServices {
|
||||
public:
|
||||
OrderServices(Order &owner, OrderServicesData &data)
|
||||
: book_updates(*data.md_subs), settlement_updates(*data.settlement_subs),
|
||||
child_updates(*data.child_order_subs), time_change(*data.time_subs),
|
||||
order_creations(*data.order_creation_subs), _owner(owner), _data(data),
|
||||
_sessions() {
|
||||
: _owner(owner), _data(data), _child_updates(*data.child_order_subs),
|
||||
_book_updates(*data.md_subs),
|
||||
_settlement_updates(*data.settlement_subs),
|
||||
_time_change(*data.time_subs), _sessions(), _child_updates_sub(),
|
||||
_time_change_sub(), _create_order_reply(*data.order_creation_subs) {
|
||||
for (auto &sd : data.sessions)
|
||||
_sessions.push_back(std::make_unique<SessionServices>(*sd));
|
||||
}
|
||||
|
||||
EventStream<BookUpdateEvent> book_updates;
|
||||
EventStream<SettlementUpdateEvent> settlement_updates;
|
||||
EventStream<OrderStateUpdateEvent, ParentKey> child_updates;
|
||||
EventStream<mercury::TimerEvent, mercury::NoKey> time_change;
|
||||
|
||||
securities::ISecurityDB &sec_db() { return _data.sec_db; }
|
||||
|
||||
mercury::TimeStampStr const &get_time_str() const {
|
||||
@@ -82,9 +106,10 @@ class OrderServices {
|
||||
"Order {} transitioned to a terminal state. Canceling all "
|
||||
"subscriptions",
|
||||
_owner.key().value());
|
||||
book_updates.unsub_all();
|
||||
child_updates.unsub_all();
|
||||
time_change.unsub_all();
|
||||
_book_updates.unsub_all();
|
||||
_child_updates.unsub_all();
|
||||
_time_change.unsub_all();
|
||||
_settlement_updates.unsub_all();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,11 +122,51 @@ class OrderServices {
|
||||
bts_assert(false);
|
||||
}
|
||||
|
||||
// Subscriptions ------------------------------
|
||||
using BookSubID = EventStream<BookUpdateEvent>::SubID;
|
||||
template <class CB> BookSubID subscribe_to_book(SecurityKey k, CB &&cb) {
|
||||
return _book_updates.sub(k, std::forward<CB>(cb));
|
||||
}
|
||||
void unsubscribe_from_book(BookSubID sid) { _book_updates.unsub(sid); }
|
||||
|
||||
using SettlementSubID = EventStream<SettlementUpdateEvent>::SubID;
|
||||
template <class CB>
|
||||
SettlementSubID subscribe_to_settlements(SecurityKey k, CB &&cb) {
|
||||
return _settlement_updates.sub(k, std::forward<CB>(cb));
|
||||
}
|
||||
void unsubscribe_from_settlements(SettlementSubID sid) {
|
||||
_settlement_updates.unsub(sid);
|
||||
}
|
||||
|
||||
template <class CB> void subscribe_to_time(CB &&cb) {
|
||||
_time_change_sub = _time_change.sub(std::forward<CB>(cb));
|
||||
}
|
||||
void unsubscribe_from_time() { _time_change.unsub(_time_change_sub); }
|
||||
|
||||
template <class CB> void subscribe_to_child_updates(CB &&cb) {
|
||||
_child_updates_sub =
|
||||
_child_updates.sub(_owner.key(), std::forward<CB>(cb));
|
||||
}
|
||||
void unsubscribe_from_child_updates() {
|
||||
_child_updates.unsub(_child_updates_sub);
|
||||
}
|
||||
// End Subscriptions ------------------------------
|
||||
|
||||
private:
|
||||
friend class OrderBuilder;
|
||||
IOrderFactory &order_factory() { return _data.order_factory; }
|
||||
|
||||
EventStream<CreateOrderReplyEvent> order_creations;
|
||||
using CreateOrderReplySubID = EventStream<CreateOrderReplyEvent>::SubID;
|
||||
|
||||
template <class CB>
|
||||
CreateOrderReplySubID subscribe_to_order_creation_reply(size_t req_id,
|
||||
CB &&cb) {
|
||||
return _create_order_reply.sub(req_id, std::forward<CB>(cb));
|
||||
}
|
||||
void unsubscribe_from_order_creation_reply(CreateOrderReplySubID sid) {
|
||||
_create_order_reply.unsub(sid);
|
||||
}
|
||||
|
||||
void send_order_create_req(size_t builder_id, OrderKey pk,
|
||||
api::orderman::OrderDefinition const &def,
|
||||
size_t n_orders) {
|
||||
@@ -141,7 +206,14 @@ class OrderServices {
|
||||
|
||||
Order &_owner;
|
||||
OrderServicesData &_data;
|
||||
EventStream<OrderStateUpdateEvent, ParentKey> _child_updates;
|
||||
EventStream<BookUpdateEvent> _book_updates;
|
||||
EventStream<SettlementUpdateEvent> _settlement_updates;
|
||||
EventStream<mercury::TimerEvent, mercury::NoKey> _time_change;
|
||||
std::vector<std::unique_ptr<SessionServices>> _sessions;
|
||||
EventStream<OrderStateUpdateEvent, ParentKey>::SubID _child_updates_sub;
|
||||
EventStream<mercury::TimerEvent, mercury::NoKey>::SubID _time_change_sub;
|
||||
EventStream<CreateOrderReplyEvent> _create_order_reply;
|
||||
};
|
||||
} // namespace orderman
|
||||
} // namespace bts
|
||||
@@ -114,10 +114,10 @@ void IcebergOrder::on_activate(Price p, Quantity q, OrderServices &services,
|
||||
me->state.set_price(p.value());
|
||||
me->state.set_quantity(q.value());
|
||||
if (me->pause_between_orders)
|
||||
services.time_change.sub(
|
||||
services.subscribe_to_time(
|
||||
[this](auto const &time) { this->on_time(time); });
|
||||
services.child_updates.sub(
|
||||
key(), [this](auto const &os) { this->on_child_order_update(os); });
|
||||
services.subscribe_to_child_updates(
|
||||
[this](auto const &os) { this->on_child_order_update(os); });
|
||||
transition(ORDER_STATUS_WORKING);
|
||||
me->working_sub_status = WorkingSubStatus::WORKING;
|
||||
send_next_child_order();
|
||||
|
||||
@@ -359,11 +359,11 @@ void NativeOrder::on_activate(Price p, Quantity q,
|
||||
// if we are here we are good.
|
||||
|
||||
// subscribe to usefull events
|
||||
me->session_services->exe_reports.sub(
|
||||
me->session_services->subscribe_to_exe_report(
|
||||
key(), [this](auto const &r) { this->on_exe_report(r); });
|
||||
me->session_services->cancel_rejects.sub(
|
||||
me->session_services->subscribe_to_cancel_reject(
|
||||
key(), [this](auto const &cr) { this->on_cancel_reject(cr); });
|
||||
me->session_services->gateway_status.sub(
|
||||
me->session_services->subscribe_to_gateway_status(
|
||||
[this](auto const &gw) { this->on_gateway_status(gw); });
|
||||
|
||||
// send out order
|
||||
@@ -408,11 +408,11 @@ void NativeOrder::on_activate(Price p, Quantity q,
|
||||
case ORDER_STATUS_WORKING:
|
||||
me->session_services = &me->services->get_session_services(
|
||||
get_native_state(me->state).routing_record().session());
|
||||
me->session_services->exe_reports.sub(
|
||||
me->session_services->subscribe_to_exe_report(
|
||||
key(), [this](auto const &r) { this->on_exe_report(r); });
|
||||
me->session_services->cancel_rejects.sub(
|
||||
me->session_services->subscribe_to_cancel_reject(
|
||||
key(), [this](auto const &cr) { this->on_cancel_reject(cr); });
|
||||
me->session_services->gateway_status.sub(
|
||||
me->session_services->subscribe_to_gateway_status(
|
||||
[this](auto const &gw) { this->on_gateway_status(gw); });
|
||||
|
||||
if (!me->session_services->is_gateway_connected())
|
||||
@@ -422,11 +422,11 @@ void NativeOrder::on_activate(Price p, Quantity q,
|
||||
case ORDER_STATUS_DISCONNECTED:
|
||||
me->session_services = &me->services->get_session_services(
|
||||
get_native_state(me->state).routing_record().session());
|
||||
me->session_services->exe_reports.sub(
|
||||
me->session_services->subscribe_to_exe_report(
|
||||
key(), [this](auto const &r) { this->on_exe_report(r); });
|
||||
me->session_services->cancel_rejects.sub(
|
||||
me->session_services->subscribe_to_cancel_reject(
|
||||
key(), [this](auto const &cr) { this->on_cancel_reject(cr); });
|
||||
me->session_services->gateway_status.sub(
|
||||
me->session_services->subscribe_to_gateway_status(
|
||||
[this](auto const &gw) { this->on_gateway_status(gw); });
|
||||
|
||||
if (me->session_services->is_gateway_connected())
|
||||
@@ -436,11 +436,11 @@ void NativeOrder::on_activate(Price p, Quantity q,
|
||||
case ORDER_STATUS_PENDING_WORKING:
|
||||
me->session_services = &me->services->get_session_services(
|
||||
get_native_state(me->state).routing_record().session());
|
||||
me->session_services->exe_reports.sub(
|
||||
me->session_services->subscribe_to_exe_report(
|
||||
key(), [this](auto const &r) { this->on_exe_report(r); });
|
||||
me->session_services->cancel_rejects.sub(
|
||||
me->session_services->subscribe_to_cancel_reject(
|
||||
key(), [this](auto const &cr) { this->on_cancel_reject(cr); });
|
||||
me->session_services->gateway_status.sub(
|
||||
me->session_services->subscribe_to_gateway_status(
|
||||
[this](auto const &gw) { this->on_gateway_status(gw); });
|
||||
break;
|
||||
|
||||
|
||||
@@ -96,9 +96,9 @@ void TimeBoxOrder::on_activate(Price p, Quantity q, OrderServices &services,
|
||||
me->child = me->child_builder.build();
|
||||
me->state.set_price(p.value());
|
||||
me->state.set_quantity(q.value());
|
||||
services.child_updates.sub(
|
||||
key(), [this](auto const &os) { this->on_child_order_update(os); });
|
||||
services.time_change.sub([this](auto) { this->on_time_change(); });
|
||||
services.subscribe_to_child_updates(
|
||||
[this](auto const &os) { this->on_child_order_update(os); });
|
||||
services.subscribe_to_time([this](auto) { this->on_time_change(); });
|
||||
transition(ORDER_STATUS_WORKING);
|
||||
break;
|
||||
|
||||
|
||||
@@ -115,15 +115,15 @@ void TriggerOrder::on_activate(Price price, Quantity qty,
|
||||
else {
|
||||
me->order_builder.activate(services);
|
||||
me->child_order = me->order_builder.build();
|
||||
services.child_updates.sub(key(),
|
||||
services.subscribe_to_child_updates(
|
||||
[this](const OrderStateUpdateEvent &os) {
|
||||
this->_on_child_order_update(os);
|
||||
});
|
||||
services.book_updates.sub(SecurityKey(me->order_def.security_key()),
|
||||
[this](const BookUpdateEvent &bk_event) {
|
||||
this->_on_book_update(bk_event);
|
||||
});
|
||||
services.time_change.sub(
|
||||
services.subscribe_to_book(SecurityKey(me->order_def.security_key()),
|
||||
[this](const BookUpdateEvent &bk_event) {
|
||||
this->_on_book_update(bk_event);
|
||||
});
|
||||
services.subscribe_to_time(
|
||||
[this](const bts::mercury::TimerEvent &te) { _on_time(te); });
|
||||
_switch_state(State::WAITING_FOR_TRIGGER);
|
||||
}
|
||||
|
||||
@@ -152,9 +152,9 @@ void BookAlgo::on_activate(Price p, Quantity q, OrderServices &services,
|
||||
me->child = me->child_builder.build();
|
||||
set_price(p.value());
|
||||
set_quantity(q.value());
|
||||
services.child_updates.sub(
|
||||
key(), [this](auto const &os) { this->on_child_order_update(os); });
|
||||
services.book_updates.sub(
|
||||
services.subscribe_to_child_updates(
|
||||
[this](auto const &os) { this->on_child_order_update(os); });
|
||||
services.subscribe_to_book(
|
||||
SecurityKey(me->def.security_key()),
|
||||
[this](auto const &b) { this->on_book_update(b); });
|
||||
transition(ORDER_STATUS_WORKING);
|
||||
|
||||
+8
-8
@@ -89,21 +89,21 @@ void SpreaderStartStateWorker::on_activate(Price price,
|
||||
{
|
||||
// 4. sub to child orders order
|
||||
// (could have hidden that inside SpreaderOrderServices by exposing events)
|
||||
order_services.order_services().child_updates.sub(_spreader->key(), [this](const bts::orderman::OrderStateUpdateEvent& os) { _spreader->_on_child_order_update (os);});
|
||||
order_services.order_services().subscribe_to_child_updates([this](const bts::orderman::OrderStateUpdateEvent& os) { _spreader->_on_child_order_update (os);});
|
||||
// 5. sub to market data
|
||||
for (size_t l_idx = 0; l_idx < _spreader->_bookkeeping_data().n_legs(); l_idx++)
|
||||
{
|
||||
const LegPropertyData& leg_prop = _spreader->_bookkeeping_data().get_leg_data(l_idx).leg_property_data();
|
||||
LOG(OrderMan, Info, "SpreaderStartStateWorker::on_activate subbing to book sec_key: {}", leg_prop.security_key());
|
||||
order_services.order_services().book_updates.sub(leg_prop.leg_security_key(),
|
||||
[this](const BookUpdateEvent& bk_event)
|
||||
{_spreader->_on_book_update (bk_event);});
|
||||
order_services.order_services().settlement_updates.sub(leg_prop.leg_security_key(),
|
||||
[this](const SettlementUpdateEvent& s_event)
|
||||
{_spreader->_on_settlement_update (s_event);});
|
||||
order_services.order_services().subscribe_to_book(leg_prop.leg_security_key(),
|
||||
[this](const BookUpdateEvent& bk_event)
|
||||
{_spreader->_on_book_update (bk_event);});
|
||||
order_services.order_services().subscribe_to_settlements(leg_prop.leg_security_key(),
|
||||
[this](const SettlementUpdateEvent& s_event)
|
||||
{_spreader->_on_settlement_update (s_event);});
|
||||
}
|
||||
// 6. sub to time
|
||||
order_services.order_services().time_change.sub([this](const bts::mercury::TimerEvent& t_event){_spreader->_on_time(t_event);});
|
||||
order_services.order_services().subscribe_to_time([this](const bts::mercury::TimerEvent& t_event){_spreader->_on_time(t_event);});
|
||||
}
|
||||
// quoters are init'ed in the next state
|
||||
_spreader->_transform_to_WAITING_FOR_INITIAL_DATA();
|
||||
|
||||
@@ -1 +1 @@
|
||||
set(sources ../../externals/linux/include/google/protobuf/descriptor.proto;../../externals/linux/include/google/protobuf/timestamp.proto;../lib/api/apicore.proto;../lib/api/apigateway.proto;../lib/api/apioptions.proto;../lib/api/services/AdminService.proto;../lib/api/services/ApiUnitTestService.proto;../lib/api/services/ErrorReportService.proto;../lib/api/services/HelloService.proto;../lib/api/services/MarketDataAuxiliaryService.proto;../lib/api/services/MarketDataRelay.proto;../lib/api/services/OrderService.proto;../lib/api/services/OutOfProcessURLListener.proto;../lib/api/services/PersistenceService.proto;../lib/api/services/PositionService.proto;../lib/api/services/ShellDiagnosticService.proto;../lib/api/services/ShellLatencyService.proto;../lib/api/services/SyntheticSecurityService.proto;../lib/api/services/UserService.proto;../lib/domain_model/Security.proto;../lib/md/protos/co2.proto;../lib/sparkproto/SparkProtos.proto;api/build.sh;api/node_modules/exit/test/fixtures/create-files.sh;api/node_modules/protobufjs/cli/node_modules/acorn-jsx/node_modules/acorn/bin/update_authors.sh;api/node_modules/watch/release.sh;api/quiet_build.sh;api/src/DynamicService.ts;api/src/ServiceContext.ts;api/src/bts_assert.ts;ui/src/Access.fs;ui/src/Accounts/ClipLimits.fs;ui/src/Accounts/ProductLimits.fs;ui/src/Accounts/SecurityLimits.fs;ui/src/Accounts/State.fs;ui/src/Accounts/Types.fs;ui/src/Accounts/View.fs;ui/src/App.fs;ui/src/Cmd.fs;ui/src/Controls/Button.fs;ui/src/Controls/DataGrid.fs;ui/src/Controls/Fields.fs;ui/src/Controls/Modal.fs;ui/src/Controls/ReactGrid.fs;ui/src/Controls/Table.fs;ui/src/Controls/nbsp.fs;ui/src/Global.fs;ui/src/Imports.fs;ui/src/Lens.fs;ui/src/Login/Login.fs;ui/src/Nav.fs;ui/src/State.fs;ui/src/Types.fs;ui/src/Users/State.fs;ui/src/Users/Types.fs;ui/src/Users/View.fs;ui/src/Util/EnumUtils.fs;ui/src/Util/JSMap.fs)
|
||||
set(sources ../../externals/linux/include/google/protobuf/descriptor.proto;../../externals/linux/include/google/protobuf/timestamp.proto;../lib/api/apicore.proto;../lib/api/apigateway.proto;../lib/api/apioptions.proto;../lib/api/services/AdminService.proto;../lib/api/services/ApiUnitTestService.proto;../lib/api/services/ErrorReportService.proto;../lib/api/services/HelloService.proto;../lib/api/services/MarketDataAuxiliaryService.proto;../lib/api/services/MarketDataRelay.proto;../lib/api/services/OrderService.proto;../lib/api/services/OutOfProcessURLListener.proto;../lib/api/services/PersistenceService.proto;../lib/api/services/PositionService.proto;../lib/api/services/ShellDiagnosticService.proto;../lib/api/services/ShellLatencyService.proto;../lib/api/services/SyntheticSecurityService.proto;../lib/api/services/UserService.proto;../lib/domain_model/Security.proto;../lib/md/protos/co2.proto;../lib/sparkproto/SparkProtos.proto;api/build.sh;api/node_modules/cssstyle/scripts/run_tests.sh;api/node_modules/exit/test/fixtures/create-files.sh;api/node_modules/protobufjs/cli/node_modules/acorn-jsx/node_modules/acorn/bin/update_authors.sh;api/node_modules/watch/release.sh;api/quiet_build.sh;api/src/DynamicService.ts;api/src/ServiceContext.ts;api/src/bts_assert.ts;ui/src/Access.fs;ui/src/Accounts/ClipLimits.fs;ui/src/Accounts/ProductLimits.fs;ui/src/Accounts/SecurityLimits.fs;ui/src/Accounts/State.fs;ui/src/Accounts/Types.fs;ui/src/Accounts/View.fs;ui/src/App.fs;ui/src/Cmd.fs;ui/src/Controls/Button.fs;ui/src/Controls/DataGrid.fs;ui/src/Controls/Fields.fs;ui/src/Controls/Modal.fs;ui/src/Controls/ReactGrid.fs;ui/src/Controls/Table.fs;ui/src/Controls/nbsp.fs;ui/src/Global.fs;ui/src/Imports.fs;ui/src/Lens.fs;ui/src/Login/Login.fs;ui/src/Nav.fs;ui/src/State.fs;ui/src/Types.fs;ui/src/Users/State.fs;ui/src/Users/Types.fs;ui/src/Users/View.fs;ui/src/Util/EnumUtils.fs;ui/src/Util/JSMap.fs)
|
||||
Reference in new issue
Block a user