|
exchange
Low-latency exchange in C++
|
Classes | |
| class | CandlestickPublisher |
| struct | Candle |
| class | ActionSpmcReceiver |
| class | ActionSpmcSender |
| class | EventMpscQueue |
| class | SharedMemory |
| struct | L1Data |
| struct | L2Data |
| struct | Order |
| class | OrderBook |
| struct | Trade |
| struct | Action |
| struct | OrderAddedAction |
| struct | OrderDownsizedAction |
| struct | OrderRemovedAction |
| struct | OrderUpsizedAction |
| struct | TradeAction |
| struct | AmendLimitOrderEvent |
| struct | CancelLimitOrderEvent |
| struct | Event |
| struct | NewLimitOrderEvent |
| struct | NewMarketOrderEvent |
| struct | AccountId |
| struct | OrderId |
| struct | Price |
| struct | Quantity |
| struct | SecurityId |
| class | Gateway |
| class | EventGenerator |
| class | MatchingEngine |
| class | OrderbookPublisher |
Typedefs | |
| using | OrderBookMap = std::map<Price, std::list<Order>, std::function<bool(const Price &, const Price &)>> |
| using | OrderLookupValue = std::pair<std::list<Order> *, std::list<Order>::iterator> |
| using | TimestampNs = std::chrono::sys_time<std::chrono::nanoseconds> |
Enumerations | |
| enum class | OrderType : uint8_t { LIMIT , MARKET } |
| enum class | Side : uint8_t { BUY , SELL } |
| enum class | TimeInForce : uint8_t { GTC , IOC , FOK } |
Functions | |
| int | archiverProcessMain () noexcept |
| int | candlestickPublisherMain () noexcept |
| void | assertOrderBookInvariants (const OrderBook &orderBook, bool onlyOrderBookAsserts=false) |
| void | assertRestingOrderInvariants (const Order &order, Side bookSide, Price priceLevel) |
| void | assertMatchingInvariants (const Order &aggressor, Quantity aggressorFilledQuantity, std::vector< std::pair< Trade, Order > > tradeRestingPairs) |
| int | executionPublisherMain () noexcept |
| int | gatewayMain () noexcept |
| std::vector< Event > | decodeEvents (std::span< const uint8_t > bytes, std::span< const SecurityId > securities) |
| std::vector< uint8_t > | encodeEvents (std::span< const Event > events, std::span< const SecurityId > securities) |
| void | serializeEventsIntoSeedsDirectory (const std::unordered_map< std::string, std::span< const Event > > &seeds) |
| void | fuzzMatchingEngine (std::span< const uint8_t > bytes) |
| void | runBinarySeed (const std::filesystem::path &path) |
| OrderId | makeOrderId (uint64_t seed) |
| int | matchingEngineMain () noexcept |
| int | orderManagerMain () noexcept |
| int | orderbookPublisherMain () noexcept |
Variables | |
| constexpr std::array | FUZZING_SECURITY_IDS {SecurityId{1}, SecurityId{2}} |
| constexpr EventGenerator::Config | EVENT_GENERATOR_CONFIG_FOR_DIFFERENTIAL_TESTING |
| using exchange::server::OrderBookMap = std::map<Price, std::list<Order>, std::function<bool(const Price &, const Price &)>> |
| using exchange::server::OrderLookupValue = std::pair<std::list<Order> *, std::list<Order>::iterator> |
| using exchange::server::TimestampNs = std::chrono::sys_time<std::chrono::nanoseconds> |
|
strong |
|
strong |
|
strong |
|
noexcept |
The starting point of the exchange archiver process.


| void exchange::server::assertMatchingInvariants | ( | const Order & | aggressor, |
| Quantity | aggressorFilledQuantity, | ||
| std::vector< std::pair< Trade, Order > > | tradeRestingPairs ) |
Calls assert() to check for these invariants:
| aggressor | The newly arrived order that matches with resting orders (before any trades are performed). |
| aggressorFilledQuantity | How much the filled quantity of the aggressor is after all trades are performed. |
| tradeRestingPairs | Pairs of the trade and the corresponding matching order (before the trade is made). |


| void exchange::server::assertOrderBookInvariants | ( | const OrderBook & | orderBook, |
| bool | onlyOrderBookAsserts = false ) |
Calls assert() to check for these invariants:
| orderBook | The orderbook to perform the assertions on. |
| onlyOrderBookAsserts | If true, it only performs the aforementioned asserts. Otherwise, it also runs the asserts to check the invariants of every resting order, described by assertRestingOrderInvariants. |


| void exchange::server::assertRestingOrderInvariants | ( | const Order & | order, |
| Side | bookSide, | ||
| Price | priceLevel ) |
Calls assert() to check for these invariants:
| order | The order to perform the assertions on. |
| bookSide | The actual book the order rests on (buy book or sell book). |
| priceLevel | The price level in the orderbook at which the order rests. |

|
noexcept |
The starting point of the exchange candlestick data publisher.


| std::vector< Event > exchange::server::decodeEvents | ( | std::span< const uint8_t > | bytes, |
| std::span< const SecurityId > | securities ) |
Decode a list of domain events from an array of bytes.
| bytes | The serialized bytes. |
| securities | The set of valid security ids. |

| std::vector< uint8_t > exchange::server::encodeEvents | ( | std::span< const Event > | events, |
| std::span< const SecurityId > | securities ) |
Encode a list of domain events into an array of bytes.
| events | The events to encode. |
| securities | The set of valid security ids. |

|
noexcept |
The starting point of the execution data publisher.


| void exchange::server::fuzzMatchingEngine | ( | std::span< const uint8_t > | bytes | ) |
A lower-level function called indirectly by the fuzzer that decodes the array of bytes into events and runs the matching engine on them.
| bytes | The encoded events to run on the matching engine. |


|
noexcept |
The starting point of the exchange server gateway.


| OrderId exchange::server::makeOrderId | ( | uint64_t | seed | ) |

|
noexcept |
The starting point of the matching engine.


|
noexcept |
The starting point of the Orderbook data publisher.


|
noexcept |
The starting point of the Order Manager.


| void exchange::server::runBinarySeed | ( | const std::filesystem::path & | path | ) |
Read the binary file and call fuzzMatchingEngine with its contents;
| path | The path of the binary file. |


| void exchange::server::serializeEventsIntoSeedsDirectory | ( | const std::unordered_map< std::string, std::span< const Event > > & | seeds | ) |
For each file name-list of events pair, it writes the file with the serialized list of events into the ./seeds directory.
| seeds | A mapping of file name to list of events. |

|
inlineconstexpr |
|
inlineconstexpr |