|
Slick Sim 0.10.1
Exchange simulator that shadows real venues for risk-free strategy testing
|
Classes | |
| struct | MatchContext |
| State one match() call carries through its fills. More... | |
Enumerations | |
| enum class | Reach : uint8_t { Queue , Level } |
| How far into a price level an aggressor reaches. More... | |
Functions | |
| bool | isSelfMatch (const Order *incoming_order, const Order *book_order) |
| bool | handleSelfMatch (MatchingEngine &engine, const Order *incoming_order, Order *book_order, OrderBook &book, slick::sim::time_t request_time, uint64_t event_time, uint64_t seq_num, SelfMatchPreventionMode smp_mode) |
| template<Side SIDE, Reach REACH> | |
| bool | wouldSelfMatch (const Order *order, price_t order_price, qty_t order_qty, OrderBook &book) |
| template<Side SIDE> | |
| bool | canFillCompletely (const Order *order, price_t order_price, qty_t order_qty, OrderBook &book, SelfMatchPreventionMode smp_mode) |
| template<Side SIDE, Reach REACH> | |
| std::optional< OrdRejectReason > | prepareOrder (MatchingEngine &engine, Order *order, price_t order_price, qty_t order_qty, OrderBook &book, slick::sim::time_t request_time, SelfMatchPreventionMode smp_mode) |
| Everything a client order goes through before it matches: the CANCEL_NEWEST pre-check, the ack, the FOK pre-check, and applying a pending replace. | |
| template<Side SIDE> | |
| void | recordTrade (MatchContext &ctx, uint64_t aggressor_id, uint64_t book_order_id, price_t price, qty_t trade_qty, qty_t phantom_qty) |
| Adds one fill to the trade summaries, which are aggregated per price level: a new summary when the price changes, otherwise one more leg on the current one. | |
| template<Side SIDE> | |
| bool | fillResting (MatchContext &ctx, Order *order, uint64_t book_order_id, Order *full_book_order, price_t price, qty_t trade_qty, qty_t remaining) |
| One fill of a client order against a resting order. | |
| template<Side SIDE> | |
| bool | fillRestingFromFeed (MatchContext &ctx, uint64_t aggressor_id, uint64_t book_order_id, price_t price, qty_t trade_qty, qty_t &qty) |
| One fill of market-data liquidity against a resting order. | |
| void | cancelUnrestableRemainder (MatchingEngine &engine, const Order *order, qty_t remaining, slick::sim::time_t request_time) |
| What cannot rest is cancelled: an IOC's remainder, and a market order's, which would otherwise rest at NULL_PRICE. | |
|
strong |
How far into a price level an aggressor reaches.
FIFO trades the queue front to back until its quantity runs out. Pro-rata allocates across the whole level, so every order on a level it reaches may trade.
| Enumerator | |
|---|---|
| Queue | |
| Level | |
Definition at line 21 of file match_common.hpp.
|
inline |
What cannot rest is cancelled: an IOC's remainder, and a market order's, which would otherwise rest at NULL_PRICE.
Definition at line 366 of file match_common.hpp.
References slick::sim::Order::id, slick::sim::Order::restsRemainder(), slick::sim::OrderIdentity::symbol, and slick::sim::utils::fixed_string< N >::view().
| bool slick::sim::engine::detail::canFillCompletely | ( | const Order * | order, |
| price_t | order_price, | ||
| qty_t | order_qty, | ||
| OrderBook & | book, | ||
| SelfMatchPreventionMode | smp_mode ) |
Definition at line 119 of file match_common.hpp.
References slick::sim::CANCEL_NEWEST, slick::sim::OrderBook::findOrder(), slick::sim::utils::isPriceBetterOrEqual(), isSelfMatch(), slick::sim::NONE, slick::sim::NULL_PRICE, slick::sim::OrderIdentity::symbol, and slick::sim::utils::fixed_string< N >::view().
Referenced by prepareOrder().
| bool slick::sim::engine::detail::fillResting | ( | MatchContext & | ctx, |
| Order * | order, | ||
| uint64_t | book_order_id, | ||
| Order * | full_book_order, | ||
| price_t | price, | ||
| qty_t | trade_qty, | ||
| qty_t | remaining ) |
One fill of a client order against a resting order.
remaining is the aggressor's quantity after this fill, so reaching 0 closes the book's batch. full_book_order is the resting order's Order, or nullptr for phantom liquidity. Returns false when the book declines the execution: the aggressor has already been filled and reported by then, so the caller stops rather than unwinding.
Definition at line 288 of file match_common.hpp.
References slick::sim::engine::detail::MatchContext::book, slick::sim::OrderBook::deleteOrder(), slick::sim::engine::detail::MatchContext::engine, slick::sim::engine::detail::MatchContext::event_time, slick::sim::OrderBook::executeOrder(), slick::sim::utils::executeOrder(), slick::sim::Order::id, slick::sim::Order::leaves_quantity, slick::sim::engine::MatchingEngine::publishOrderExecution(), recordTrade(), slick::sim::engine::detail::MatchContext::seq_num, slick::sim::OrderIdentity::symbol, and slick::sim::utils::fixed_string< N >::view().
| bool slick::sim::engine::detail::fillRestingFromFeed | ( | MatchContext & | ctx, |
| uint64_t | aggressor_id, | ||
| uint64_t | book_order_id, | ||
| price_t | price, | ||
| qty_t | trade_qty, | ||
| qty_t & | qty ) |
One fill of market-data liquidity against a resting order.
There is no aggressor Order to fill or report. qty is the aggressor's remaining quantity: it is decremented by the fill, and restored when the book declines it, in which case this returns false and the caller stops.
Definition at line 331 of file match_common.hpp.
References slick::sim::engine::detail::MatchContext::book, slick::sim::OrderBook::deleteOrder(), slick::sim::engine::detail::MatchContext::engine, slick::sim::engine::detail::MatchContext::event_time, slick::sim::OrderBook::executeOrder(), slick::sim::OrderBook::findOrder(), slick::sim::engine::MatchingEngine::publishOrderExecution(), recordTrade(), slick::sim::engine::detail::MatchContext::seq_num, slick::sim::OrderBook::symbolName(), slick::sim::to_price_double(), slick::sim::to_qty_double(), and slick::sim::utils::fixed_string< N >::view().
|
inline |
Definition at line 40 of file match_common.hpp.
References slick::sim::CANCEL_NEWEST, slick::sim::CANCEL_RESTING, slick::sim::Order::client_id, slick::sim::OrderBook::deleteOrder(), slick::sim::OrderBook::freeOrder(), slick::sim::Order::id, slick::sim::NONE, slick::sim::OrderIdentity::order_id, slick::sim::OrderIdentity::symbol, and slick::sim::utils::fixed_string< N >::view().
|
inline |
Definition at line 25 of file match_common.hpp.
References slick::sim::Order::client_id.
Referenced by canFillCompletely(), and wouldSelfMatch().
| std::optional< OrdRejectReason > slick::sim::engine::detail::prepareOrder | ( | MatchingEngine & | engine, |
| Order * | order, | ||
| price_t | order_price, | ||
| qty_t | order_qty, | ||
| OrderBook & | book, | ||
| slick::sim::time_t | request_time, | ||
| SelfMatchPreventionMode | smp_mode ) |
Everything a client order goes through before it matches: the CANCEL_NEWEST pre-check, the ack, the FOK pre-check, and applying a pending replace.
Returns the reject reason when the order is finished here, or nullopt when it goes on to match its leaves_quantity.
Definition at line 174 of file match_common.hpp.
References slick::sim::CANCEL_NEWEST, canFillCompletely(), slick::sim::Order::cum_quantity, slick::sim::FILL_OR_KILL, slick::sim::FOK_CANNOT_FILL, slick::sim::Order::id, slick::sim::Order::leaves_quantity, slick::sim::NONE, slick::sim::PENDING_NEW, slick::sim::PENDING_REPLACE, slick::sim::Order::price, slick::sim::Order::quantity, slick::sim::SMP, slick::sim::Order::status, slick::sim::OrderIdentity::symbol, slick::sim::Order::time_in_force, slick::sim::utils::fixed_string< N >::view(), and wouldSelfMatch().
| void slick::sim::engine::detail::recordTrade | ( | MatchContext & | ctx, |
| uint64_t | aggressor_id, | ||
| uint64_t | book_order_id, | ||
| price_t | price, | ||
| qty_t | trade_qty, | ||
| qty_t | phantom_qty ) |
Adds one fill to the trade summaries, which are aggregated per price level: a new summary when the price changes, otherwise one more leg on the current one.
Trades[0] is the aggressor's running total and Trades[1..] the resting orders it hit; num_orders grows with Trades, as publishTradeSummary needs.
Definition at line 253 of file match_common.hpp.
References slick::sim::TradeSummaryInfo::aggressor_side, slick::sim::engine::detail::MatchContext::event_time, slick::sim::engine::detail::MatchContext::last_fill_price, slick::sim::engine::detail::MatchContext::legs_hint, slick::sim::engine::MatchingEngine::nextTradeId(), slick::sim::TradeSummaryInfo::num_orders, slick::sim::opposite_side(), slick::sim::TradeSummaryInfo::phantom_qty, slick::sim::TradeSummaryInfo::price, slick::sim::TradeSummaryInfo::qty, slick::sim::engine::detail::MatchContext::summaries, slick::sim::TradeSummaryInfo::timestamp, slick::sim::TradeSummaryInfo::trade_id, and slick::sim::TradeSummaryInfo::Trades.
Referenced by fillResting(), and fillRestingFromFeed().
| bool slick::sim::engine::detail::wouldSelfMatch | ( | const Order * | order, |
| price_t | order_price, | ||
| qty_t | order_qty, | ||
| OrderBook & | book ) |
Definition at line 82 of file match_common.hpp.
References slick::sim::OrderBook::findOrder(), slick::sim::utils::isPriceBetterOrEqual(), isSelfMatch(), Level, slick::sim::NULL_PRICE, and Queue.
Referenced by prepareOrder().