Skip to content

leafyoung/algo_challenge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Challenge

Test

Server

cargo run --release --bin server

Client

cargo run --release --bin client

TODO

  • Test Binance & Bitstamp with cli
  • Connect to Exchange's Websocket
  • Connect to two exchanges' websocket feeds at the same time
  • Aggregation
  • gRPC server
  • Optimize

Design

BinanceClient  ---[Orderbook]---\                                        /---> Client A
                                |---> Manager ---[Summary]---> gRPC Server ---> Client B
BitstampClient ---[Orderbook]---/                                        \---> Client C
  • Summary is merged from two order books. When one of the orderbook gets updated, it will be merged the another and sent to gRPC server.

Reference

wscat cli

wscat -c wss://stream.binance.com:9443/ws/btcusdt@ticker
wscat -c wss://stream.binance.com:9443/ws/ethbtc@depth10@100ms

# 10 levels
wscat -c wss://stream.binance.com:9443/ws/ethbtc@depth20@100ms
wscat -c wss://stream.binance.com:9443/ws/btcusdt
wscat -c wss://stream.binance.com:9443/ws
{ "method": "SUBSCRIBE",   "params": [ "btcusdt@depth20@100ms"  ],  "id": 1 }
{ "method": "SUBSCRIBE",   "params": [     "btcusdt@aggTrade",     "btcusdt@depth"  ],  "id": 1 }
{ "method": "UNSUBSCRIBE",   "params": [     "btcusdt@depth"   ],   "id": 312 }
{ "method": "LIST_SUBSCRIPTIONS", "id": 3 }
  • Test with Bitstamp with cli
# 100 levels
wscat -c wss://ws.bitstamp.net
{ "event": "bts:subscribe", "data": { "channel": "order_book_btcusd" } }

Docs

  1. Docs for Websocket connection: https://github.com/binance/binance-spot-api-docs/blob/master/web-socket-streams.md Example API feed: https://api.binance.com/api/v3/depth?symbol=ETHBTC Websocket connection URL for Binance: wss://stream.binance.com:9443/ws/ethbtc@depth20@100ms wss://stream.binance.com:9443

  2. Bitstamp Docs: https://www.bitstamp.net/websocket/v2/ Example API feed: https://www.bitstamp.net/api/v2/order_book/ethbtc/ Example Websocket usage: https://www.bitstamp.net/s/webapp/examples/order_book_v2.htm https://assets.bitstamp.net/static/webapp/examples/order_book_v2.3610acefe104f01a8dcd4fda1cb88403f368526b.html

About

algo challenge

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published