Slick Sim 0.10.1
Exchange simulator that shadows real venues for risk-free strategy testing
Loading...
Searching...
No Matches
slick::sim::engine::ProRataMatchingEngine Class Reference

Pro-rata matching: at each price level an aggressor that cannot take the whole level is split across its orders by size, not by queue position. More...

#include <matching_engine/pro_rata_matching_engine.hpp>

Inheritance diagram for slick::sim::engine::ProRataMatchingEngine:
Collaboration diagram for slick::sim::engine::ProRataMatchingEngine:

Classes

struct  Allocation
 One resting order's share of an aggressor at a level. More...

Public Member Functions

 ProRataMatchingEngine (slick::queue< OrderResponse > &response_queue, const ProRataConfig &config={})
 ~ProRataMatchingEngine () override=default
MatchingEngine::Type type () const noexcept override
const ProRataConfig & config () const noexcept
std::tuple< OrdRejectReason, std::vector< TradeSummaryInfo > > match (Order *order, price_t order_price, qty_t order_qty, OrderBook &book, time_t request_time, time_t event_time, uint64_t seq_num=0, SelfMatchPreventionMode smp_mode=SelfMatchPreventionMode::NONE) override
std::vector< TradeSummaryInfo > match (Side side, uint64_t order_id, price_t price, qty_t &qty, OrderBook &book, time_t event_time, uint64_t seq_num=0) override
Public Member Functions inherited from slick::sim::engine::MatchingEngine
 MatchingEngine (slick::queue< OrderResponse > &response_queue)
virtual ~MatchingEngine ()=default
void publishOrderAck (const Order *order, time_t request_time)
void publishOrderExecution (const Order *order, bool aggressor)
 aggressor: the order crossed the spread, as opposed to resting and being hit.
void publishOrderModify (const Order *order, price_t new_price, qty_t new_qty, time_t request_time)
void publishOrderCancel (const Order *order, time_t request_time)

Additional Inherited Members

Public Types inherited from slick::sim::engine::MatchingEngine
enum  Type : uint8_t { FIFO , ProRata , __count__ }
Static Public Member Functions inherited from slick::sim::engine::MatchingEngine
static uint64_t nextTradeId () noexcept
Protected Attributes inherited from slick::sim::engine::MatchingEngine
slick::queue< OrderResponse > & response_queue_
Static Protected Attributes inherited from slick::sim::engine::MatchingEngine
static std::atomic< uint64_t > next_trade_id_ {1}

Detailed Description

Pro-rata matching: at each price level an aggressor that cannot take the whole level is split across its orders by size, not by queue position.

Per level, for incoming quantity Q against orders of total T:

  • Q >= T fills every order, as FIFO would.
  • Otherwise fifo_percent of Q (rounded down to lots) goes FIFO first, then the rest is split in proportion to each order's remaining size, rounded down to lots, with shares under min_allocation dropped to 0, and whatever is left goes FIFO with no minimum. Each resting order gets one fill per aggressor per level, in queue order.

One instance serves every symbol of a venue and is only ever called from the exchange thread, so its scratch buffer needs no synchronisation.

Definition at line 23 of file pro_rata_matching_engine.hpp.

Constructor & Destructor Documentation

◆ ProRataMatchingEngine()

ProRataMatchingEngine::ProRataMatchingEngine ( slick::queue< OrderResponse > & response_queue,
const ProRataConfig & config = {} )

◆ ~ProRataMatchingEngine()

slick::sim::engine::ProRataMatchingEngine::~ProRataMatchingEngine ( )
overridedefault

Member Function Documentation

◆ config()

const ProRataConfig & slick::sim::engine::ProRataMatchingEngine::config ( ) const
inlinenoexcept

Definition at line 40 of file pro_rata_matching_engine.hpp.

Referenced by ProRataMatchingEngine().

◆ match() [1/2]

std::tuple< OrdRejectReason, std::vector< TradeSummaryInfo > > ProRataMatchingEngine::match ( Order * order,
price_t order_price,
qty_t order_qty,
OrderBook & book,
time_t request_time,
time_t event_time,
uint64_t seq_num = 0,
SelfMatchPreventionMode smp_mode = SelfMatchPreventionMode::NONE )
overridevirtual

◆ match() [2/2]

std::vector< TradeSummaryInfo > ProRataMatchingEngine::match ( Side side,
uint64_t order_id,
price_t price,
qty_t & qty,
OrderBook & book,
time_t event_time,
uint64_t seq_num = 0 )
overridevirtual

Implements slick::sim::engine::MatchingEngine.

Definition at line 180 of file pro_rata_matching_engine.cpp.

References slick::sim::BUY.

◆ type()

MatchingEngine::Type slick::sim::engine::ProRataMatchingEngine::type ( ) const
inlineoverridevirtualnoexcept

The documentation for this class was generated from the following files: