Skip to content
/ dior Public

Christian Dior πŸ’ƒπŸ•ΊπŸ‘—πŸ‘”πŸ“ˆπŸ“‰ - (Order Matching Engine) - match hundreds of thousands of orders per second

License

Notifications You must be signed in to change notification settings

stoqey/dior

Repository files navigation

Christian Dior

Order Matching Engine - match hundreds of thousands of orders per second

Tech

  • Couchbase for Orders/Trades storage
  • Influx for marketdata storage quote/query
  • uWebsocket for TCP/UDP
  • Order types
    • market order - execute an order as fast as possible, cross the spread
    • limit order - execute an order with a limit on bid/ask price (e.g. $x or less for a bid, or $y or more for an ask)
  • Order params
    • AON - all or nothing, don't allow partial fills
    • IOC - immediate or cancel, immediately fill what's possible, cancel the rest
    • FOK - AON+IOC, immediately match an order in full (without partial fills) or cancel it

TODO

  • βœ… stop orders
  • βœ… GFD, GTC, GTD parameters
  • logic surrounding the order book - trading hours, pre/after market restrictions
  • basic middle & back office functionalities - risk assessment, limits
  • βœ… Websocket: TCP/UDP server that accepts orders
  • βœ… HTTP: TCP/UDP server that accepts orders
  • βœ… reporting market volume, share price
  • βœ… reporting acknowledgments & updates to clients (share price, displayed/hidden orders...)
  • Master-slave cluster, auto-re-elect master
  • Same-sync
  • Tradebook cronjobs

Market behaviour

Market orders are always given priority above all other orders, then sorted according to time of arrival.

  • orders are FIFO based
    • bids - price (descending), time (ascending)
    • asks - price (ascending), time (ascending)
    • quantity does not matter in sorting

When a match occurs between two limit orders the price is set on the bid price. Bid of $25 and ask of $24 will be matched at $25.

Architecture

Order book & trade books are per-instrument objects, one order book can only handle one instrument.

  • OrderBook (Order model) - stores active orders in memory, db & handles order matching

  • TradeBook (Trade model) - stores daily trades in memory, db & provides additional data about trading

  • Historical Orders (OrderRecord model) - persistent storage of all historical orders

OrderBook

  • Order model/collection is used to persist all orders in couchbase
  • All orders whether active/or not are stored in couchbase under the Order collection
  • When an Order has been filled it is deleted from the Order collection and a copy of it is stored in OrderRecords

TradeBook

  • All trades are saved in the Trade collection of couchbase

Acknowledgements

Stoqey Inc

About

Christian Dior πŸ’ƒπŸ•ΊπŸ‘—πŸ‘”πŸ“ˆπŸ“‰ - (Order Matching Engine) - match hundreds of thousands of orders per second

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published