diff --git a/src/server/sparkd/spreader/SpreaderBase.h b/src/server/sparkd/spreader/SpreaderBase.h index 1e2494add..86035033a 100644 --- a/src/server/sparkd/spreader/SpreaderBase.h +++ b/src/server/sparkd/spreader/SpreaderBase.h @@ -9,7 +9,8 @@ namespace bts { namespace spreader { - +// OrderState abstraction for all order types (Spreader and Limit at +// the moment) class OrderState { public: orderman::OrderKey key; @@ -19,6 +20,7 @@ public: std::string error_msg; }; +// a market data update class Book { public: size_t n_levels() const; @@ -31,37 +33,65 @@ public: Quantity quantity; }; +// a class used to speed up order generation. it will include +// pre-generated FIX for parts of the order that are known ahead of +// time. class OrderTemplate ; -class SpreaderUpdate {}; +// whatever the spreader needs to operate. this must include all the +// elements used in make_order_template() class SpreaderCreate {}; +// whatever is supported for spreader changes +class SpreaderUpdate {}; + class SpreaderBase { public: + // called once and only once, before any other calls virtual void init (orderman::OrderKey my_key,SpreaderCreate const&) = 0; - virtual void on_disconnect() = 0; + // called if the execution venue is working, even if it the + // connection event happened before the spreader was created. in + // other words, on_connect() is always called. Spreader should + // start by assuming the venue is disconnected virtual void on_connect() = 0; + // called if the venue disconnects. will only be called if there + // was previous on_connect() + virtual void on_disconnect() = 0; + // supports late join, i.e. even if there is no new market data + // since the spreader was created a bootstrap market data event + // will be artifially generated. virtual void on_md(api::Security const&s, Book const&b) = 0; + // called whenever a child order updates virtual void on_child_order ( OrderState const&state, std::vector const&fills) = 0; + // called at an unspecified rate as long as the spreader is active + // (i.e. OrderSTatus != CANCELED, REJECTED, EXPIRED, FILLED) virtual void on_time(TimeStamp const&ts) = 0; + // Called when the user hits update or cancel in the shell virtual void on_user_update (SpreaderUpdate const&) = 0; virtual void on_user_cancel () = 0; protected: - // provided + // call this whenever the Spreader changes its OrderState void report_state(OrderState const&); + // call this once at the start. callbacks will continue until the + // spreader reports terminal state (CANCELED, REJECTED, EXPIRED, + // FILLED) void subscribe_md(std::vector const &securities); - + // call this when spining a new order. for speed create a template + // object before with the things that do not commonly change. orderman::OrderKey create_child(OrderTemplate const&t, Price price, Quantity quantity); + // call this to update an order you previously created void update_child(orderman::OrderKey, Price price, Quantity quantity); + // call this to cancel an order you previously created void cancel_child(orderman::OrderKey); + // use this to accelarate the creation of new orders OrderTemplate const& make_order_template(api::Security const&, AccountName const &, orderman::OperatorID const &, @@ -72,3 +102,4 @@ protected: }; }} +