mkipnis / DistributedATS

DistributedATS is a FIX Protocol based multi matching engine exchange(CLOB) that integrates QuickFIX and LiquiBook over DDS
Other
68 stars 21 forks source link
algotrading clob crypto crypto-exchange darkpool darkpools fix fixgateway fixprotocol hft hft-trading market marketdata matching-engine matching-engines matchingengine order-book orderbook quickfix

Distributed ATS

DistributedATS is a FIX Protocol-based alternative trading system that integrates QuickFIX and LiquiBook over FastDDS. This project simplifies the process of communication between multiple FIX gateways and multiple matching engines(CLOB) in real-time. FIX Gateways communicate with clients via FIX and Matching Engines and Middleware(Data Service) components via topic-based DDS IDL Pub/Sub mechanism.

Components

N|Solid See: CryptoCLOB

Dependencies

Dependency Component
FastDDS DDS/Middleware
QuickFIX FIXGateway
LiquiBook MatchingEngine
SQLite3 DataService

Sample Exchanges

MultiMatchingEngineATS - Two Matching Engines, three FIX Gateways, and two Data Services. The first matching engine consumes and processes orders from the instrument group MARKET_Y, the second from the instrument MARKET_Z

USTreasuryCLOB - A single Matching Engine, three FIX Gateways, and two Data Services. The matching engine consumes and processes orders from the instrument group MARKET_UST that covers 300+ instruments (OrderBooks)

CryptoCLOB - Three Matching Engines, three FIX Gateways, and two Data Services. The first matching engine consumes and processes orders from the instrument group BTC_MARKET, the second from the instrument ETH_MARKET, and the third from OTHER_COIN_MARKET

Other Utilities

Sample Clients

High Level Data Flow Overview

Overview

FIX Messages, Topics, Sources and Destinations

FIX Message DDS Topic Source Destination Content Description
Login(A) LOGON_TOPIC FIXGateway DataService Converted to IDL FIX Login
Login(A) LOGON_TOPIC DataService FIXGateway Successfully Authenticated FIX Session by a Data Service
Logout(5) LOGOUT_TOPIC DataService FIXGateway Unsuccessfully Authenticate FIX Session by Data Service
NewOrderSingle(D) NEW_ORDER_SINGLE_TOPIC FIXGateway MatchingEngine New order single
ExecutionReport(8) EXECUTION_REPORT_TOPIC MatchingEngine FIXGateway Execution Report to be sent to a client
ExecutionReport(8) EXECUTION_REPORT_TOPIC MatchingEngine DataService Execution Report to be store to service Order Mass Status Requests
OrderCancel Request(F) ORDERCANCEL REQUEST_TOPIC FIXGateway MatchingEngine Converted to IDL Cancel Request from FIX Client
OrderCancel Reject(9) ORDER_CANCELREJECT TOPIC MatchingEngine FIXGateway IDL Cancel Reject, if order can't be cancelled
OrderCancelReplace Request(G) ORDERCANCEL REPLACE_REQUEST_TOPIC_NAME FIXGateway MatchingEngine Converted to IDL Cancel Replace Request from FIX Client
MassCancel Request(q) ORDER_MASSCANCEL REQUEST_TOPIC FIXGateway MatchingEngines Mass Cancel requested by FIX Client or FIX Client Logout/Disconnect
MassCancel Report(r) ORDER_MASSCANCEL REPORT_TOPIC MatchingEngines FIXGateway Results of Mass Cancel Request
MarketData Request(V) MARKET_DATA_REQUEST _TOPIC FIXGateway DataService Request for the current state of Order Book(Top 5 levels)
MarketDataSnapshotFull Refresh(W) MARKET_DATA_SNAPSHOT _FULL_REFRESH_TOPIC DataService FIXGateway Current Market Data Snapshot(Top 5 levels)
MarketDataSnapshotFull Refresh(W) MARKET_DATA_SNAPSHOT _FULL_REFRESH_TOPIC Data Service MatchingEngine OpeningPrices
MarketDataIncremental Refresh(X) MARKET_DATA_SNAPSHOT _FULL_REFRESH_TOPIC MatchingEngine FIXGateway Incremental Market Data Request(Top 5 levels)
MarketDataIncremental Refresh(X) MARKET_DATA_SNAPSHOT _FULL_REFRESH_TOPIC MatchingEngine FIXGateway Incremental Market Data Request(Top 5 levels)
Security ListRequest(x) SECURITY_LIST_REQUEST _TOPIC FIXGateway DataService FIX Client initiated Security List Request
SecurityList(y) SECURITY_LIST_TOPIC DataService FIXGateway Security list reply for FIX Client Request
SecuritList Request(x) SECURITY_LIST_REQUEST _TOPIC MatchingEngine DataService Security List Request for Order Book setup
SecurityList(y) SECURITY_LIST_TOPIC DataService MatchingEngine Security List for OrderBook Setup
OrderMassStatus Request(AF) ORDER_MASSSTATUS REQUEST_TOPIC FIXGateway DataService Initiated by FIX Client Mass Status Request

Autogeneration of IDL from QuickFIX XML

GenTools is a utility that generates DDS IDL, FIX to IDL, and IDL to FIX adapters and IDL logger helper classes from QuickFIX's XML data dictionary.

Building Distributed ATS and it's dependencies

download_deps_and_build_all.sh

Docker

docker-compose.yml

version: '2'
services:
  # Core: Matching Engines, Data Services, FIX Gateways 
  distributed_ats:
    image: ghcr.io/mkipnis/distributed_ats:latest
    command: ["bash", "-c", "cd /opt/DistributedATS/; . ./distributed_ats_env.sh; cd MiscATS/CryptoCLOB/scripts; ./start_ats.sh"]
    # volumes: # Users and Instruments
    #   - "./data:/opt/DistributedATS/DataService/sql/sqlite"
    ports: # FIX Gateways
      - "15001:15001"
      - "16001:16001"
      - "17001:17001"

  # Front-End : Tomcat/Spring/React
  distributed_ats_webtrader:
    image: ghcr.io/mkipnis/distributed_ats_webtrader:latest
    ports:
      - "8080:8080"

Upon starting the dockerized instance, open your browser and go to http://localhost:8080. Then, use either CRYPTO_TRADER_1, CRYPTO_TRADER_2, CRYPTO_TRADER_3, or CRYPTO_TRADER_4 as the username to log in with the password "TEST".