|
Slick Sim 0.10.1
Exchange simulator that shadows real venues for risk-free strategy testing
|
Tracks the orders reported to one gateway. More...
#include <order_gateway/order_store.hpp>
Public Member Functions | |
| OrderStore ()=default | |
| Projection only. | |
| OrderStore (slick::queue< OrderResponse > &response_queue) | |
| Self-draining, with its own cursor. | |
| void | drain (int max_batch=4096) |
| Applies every response published since the last call. | |
| std::vector< const Order * > | orders_of (std::string_view user_id) const |
| The orders belonging to one user, most recently created first. | |
| const Order * | find (std::string_view order_id) const |
| size_t | size () const noexcept |
| void | apply (const OrderResponse &response) |
| Folds one execution report into the order it describes, creating it on first sight. | |
Tracks the orders reported to one gateway.
Order books belong to the exchange thread, so reading them from a gateway's event loop would race. Replaying OrderResponse messages reconstructs each order's identity and state without reading exchange-owned data.
Each gateway has its own store. slick::queue readers have independent cursors, so draining the store does not disturb request handlers polling for replies. All access stays on the gateway's uWebSockets loop thread; the store has no internal synchronisation.
Definition at line 23 of file order_store.hpp.
|
default |
Projection only.
For a gateway that already drains the response stream for its own purposes and can feed apply() from that same read - taking a second cursor would mean reading every response twice to no benefit.
|
inlineexplicit |
Self-draining, with its own cursor.
For a gateway that has no continuous reader of its own and needs to catch up on demand.
Definition at line 32 of file order_store.hpp.
|
inline |
Folds one execution report into the order it describes, creating it on first sight.
Public so tests can drive it without standing up a queue.
Definition at line 82 of file order_store.hpp.
References slick::sim::Order::avg_fill_price, slick::sim::OrderResponse::avg_fill_price, slick::sim::Order::cancel_message, slick::sim::CANCELED, slick::sim::OrderIdentity::client_order_id, slick::sim::OrderResponse::client_order_id, slick::sim::Order::created_time, slick::sim::OrderResponse::creation_time, slick::sim::OrderResponse::cum_qty, slick::sim::Order::cum_quantity, slick::sim::OrderResponse::exec_type, slick::sim::Order::filled_value, slick::sim::Order::last_fill_price, slick::sim::OrderResponse::last_fill_price, slick::sim::Order::last_fill_qty, slick::sim::Order::last_fill_time, slick::sim::OrderResponse::last_qty, slick::sim::Order::last_update_time, slick::sim::OrderResponse::leaves_qty, slick::sim::Order::leaves_quantity, slick::sim::Order::num_fills, slick::sim::OrderIdentity::order_id, slick::sim::OrderResponse::order_id, slick::sim::OrderResponse::order_status, slick::sim::OrderResponse::order_type, slick::sim::PENDING_CANCEL, slick::sim::Order::pending_cancel, slick::sim::Order::post_only, slick::sim::OrderResponse::post_only, slick::sim::Order::price, slick::sim::OrderResponse::price, slick::sim::Order::product_type, slick::sim::OrderResponse::qty, slick::sim::Order::quantity, slick::sim::Order::reject_message, slick::sim::REJECTED, slick::sim::Order::side, slick::sim::OrderResponse::side, slick::sim::SPOT, slick::sim::Order::status, slick::sim::utils::fixed_string< N >::str(), slick::sim::OrderIdentity::symbol, slick::sim::OrderResponse::symbol, slick::sim::Order::time_in_force, slick::sim::OrderResponse::time_in_force, slick::sim::OrderResponse::timestamp, slick::sim::to_price_double(), slick::sim::to_qty_double(), slick::sim::TRADE, slick::sim::Order::type, slick::sim::OrderIdentity::user_id, and slick::sim::OrderResponse::user_id.
Referenced by drain().
|
inline |
Applies every response published since the last call.
A no-op on a store constructed without a queue, whose owner feeds it through apply() instead.
Bounded per call so a caller on the event loop cannot be stalled indefinitely by a backlog; whatever is left is picked up by the next drain.
Definition at line 41 of file order_store.hpp.
|
inline |
Definition at line 73 of file order_store.hpp.
|
inline |
The orders belonging to one user, most recently created first.
Definition at line 55 of file order_store.hpp.
|
inlinenoexcept |
Definition at line 78 of file order_store.hpp.
Referenced by drain().