Slick Sim 0.10.1
Exchange simulator that shadows real venues for risk-free strategy testing
Loading...
Searching...
No Matches
pro_rata_matching_engine.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "matching_engine.hpp"
4#include "matching_config.hpp"
5#include <common/order.hpp>
6#include <vector>
7
8namespace slick::sim::engine {
9
24public:
32
33 ProRataMatchingEngine(slick::queue<OrderResponse> &response_queue, const ProRataConfig &config = {});
34 ~ProRataMatchingEngine() override = default;
35
36 MatchingEngine::Type type() const noexcept override {
38 }
39
40 const ProRataConfig &config() const noexcept {
41 return config_;
42 }
43
44 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;
45 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;
46
47private:
48 template<Side SIDE>
49 std::tuple<OrdRejectReason, std::vector<TradeSummaryInfo>> matchOrder(Order* order, price_t order_price, qty_t order_qty, OrderBook &book, time_t request_time, time_t event_time, uint64_t seq_num, SelfMatchPreventionMode smp_mode);
50 template<Side SIDE>
51 std::vector<TradeSummaryInfo> matchFeed(uint64_t order_id, price_t price, qty_t &qty, OrderBook &book, time_t event_time, uint64_t seq_num);
52
56 void allocate(const slick::orderbook::detail::PriceLevelL3 &level, qty_t qty, OrderBook &book, bool resolve);
57
58 qty_t floorLot(qty_t qty) const noexcept {
59 return qty - qty % config_.lot_size;
60 }
61
62 ProRataConfig config_;
66 std::vector<Allocation> allocations_;
67};
68
69} // namespace slick::sim::engine
MatchingEngine(slick::queue< OrderResponse > &response_queue)
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
ProRataMatchingEngine(slick::queue< OrderResponse > &response_queue, const ProRataConfig &config={})
const ProRataConfig & config() const noexcept
MatchingEngine::Type type() const noexcept override
uint_fast64_t time_t
Definition types.hpp:23
SelfMatchPreventionMode
Definition order.hpp:233
int_fast64_t qty_t
Definition types.hpp:22
int_fast64_t price_t
Definition types.hpp:21
Pro-rata allocation rules. Quantities use the venue's fixed-point scale.
qty_t lot_size
allocations round down to whole lots
One resting order's share of an aggressor at a level.
Order * order
the simulator's Order; resolved only when SMP needs it
qty_t qty
allocated quantity, 0 when the order gets nothing