Skip to content

Simple Smart Order Router for crypto market

License

Notifications You must be signed in to change notification settings

weltam/crypto_sor

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crypto_sor

Example consolidated order book and simulated Smart Order Router (SOR) for crypto markets. This application is a companion to the associated blog post which is recommended reading to understand what it does.

Check out cryptosor.info to see it live.

This application is not production ready, and should not be used for trading. It is for educational purposes only, and the author accepts no responsibility for any losses incurred.

Overview

This system consists of two processes: a backend server and front end UI, which are located in the server and client directories respectively.

Server

The server connects to the public WebSocket feed of several exchanges, and will source order book depth information. It uses this to maintain a consolidated order book for each of the symbols it listens to. The server exposes an API via a fastify HTTP server.

Client

The client is a create-react-app generated React application that uses information from the server to display the consolidated order book, and allows simulated orders to be placed.

Running

Server

  1. Install dependencies
    cd server
    yarn install
    
  2. Start the server
    yarn dev
    
  3. Server will start listening on port 8080

Client

  1. Install dependencies
    cd client
    yarn install
    
  2. Start the client
    yarn start
    
  3. Client can be accessed by pointing your browser to http://localhost:3000.

Testing

Due to this being an example application there is limited testing, however tests for the server can be run as follows:

cd server
yarn test

Potential Improvements

  • Currently the order book is not super efficient, as it uses priority queues, and potentially an array based model might be better (though more complex).
  • The order book is just fetched every second using REST. This is simple, but obviously is inefficient. This should be done via a WebSocket connection and the publishing of partials and updates.
  • Load could be reduced by pulling an order book snapshot frequently and storing it in a cache. This would be more efficient for matching.
  • Better handling and monitoring of WebSocket connections to improve data quality and integrity.
  • Improve typing around exchange messages as well as the typing on the front end.

Supported Markets

  • FTX
  • Coinbase
  • Binance
  • Kraken
  • OKX

Supported Symbols

  • BTC/USD
  • ETH/USD
  • BNB/USD
  • SOL/USD
  • ADA/USD
  • XRP/USD
  • LUNA/USD
  • DOGE/USD

About

Simple Smart Order Router for crypto market

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 96.2%
  • HTML 1.9%
  • CSS 1.6%
  • Other 0.3%