minicheddar / crypto-stream Goto Github PK
View Code? Open in Web Editor NEWHigh performance market data handlers for cryptocurrency exchanges
License: MIT License
High performance market data handlers for cryptocurrency exchanges
License: MIT License
Add support for Huobi futures
Implement futures trade detail
stream
https://huobiapi.github.io/docs/dm/v1/en/#subscribe-trade-detail-data
Implement futures market depth
stream
https://huobiapi.github.io/docs/dm/v1/en/#subscribe-incremental-market-depth-data
Whilst ping/pongs are handled per exchange task, if a websocket connection is dropped it does not automatically reconnect.
Add support for automatic reconnect with exponential back-off (to avoid rate limiting)
Rust does not allow ordering of f32
/f64
s as part of std. This prevents using f64
as a key in BTreeMap<f64, OrderbookLevel>
.
For now, we should just use this (https://crates.io/crates/ordered-float), but I'm curious on the performance difference between.
PartialOrd
for floats as aboveDecimal
f64
, but converting to Decimal
when returning MarketDataKind:L2Update/Snapshot
u64
with a mantissa on the number of floating points as a separate piece of metadata (like smart contracts)This is definitely a low-priority premature micro-optimisation!
Add support for Kraken cryptocurrency exchange
spot trade stream
https://docs.kraken.com/websockets/#message-trade
spot orderbook depth stream
https://docs.kraken.com/websockets/#message-book
futures trade stream
https://support.kraken.com/hc/en-us/articles/360022839771-Trade
futures orderbook depth stream
https://support.kraken.com/hc/en-us/articles/360022635912-Book
Add support for Huobi cryptocurrency exchange
Implement spot trade detail stream
https://huobiapi.github.io/docs/spot/v1/en/#trade-detail
Implement spot market by price stream
https://huobiapi.github.io/docs/spot/v1/en/#market-by-price-refresh-update
Implement futures trade detail stream
https://huobiapi.github.io/docs/dm/v1/en/#subscribe-trade-detail-data
Implement futures market depth stream
https://huobiapi.github.io/docs/dm/v1/en/#subscribe-incremental-market-depth-data
Each exchange connector has been (deliberately) duplicated to expedite development speed.
Once the initial set of exchanges have been implemented, there may be an opportunity to break out common integration code to a re-usable set of components.
No attempt has been made to optimise the performance of the market data handlers.
We should commit some baseline benchmarks, and profile the code to see where the hot spots are.
There is some good guidance to Rust performance optimisation in the perf-book
:
https://nnethercote.github.io/perf-book/introduction.html
serde_json
deserialisation is likely the bottleneck here; but I'm also interested to understand the performance characteristics of tokio::spawn_blocking
vs thread::spawn
(as opposed to what we are currently doing with tokio::spawn
)
We are also doing lots of unnecessary Arc<HashMap<Instrument, WebsocketSubscription>>
lookups on each market data event to populate the MarketData.Instrument
field.
As there are no immediate plans to build a cross-exchange symbol map; we can probably just replace the Instrument
type with the symbol ticker String
, and save a bunch of locks and HashMap
lookups.
Add support for Bybit cryptocurrency exchange
spot trade stream
https://bybit-exchange.github.io/docs/spot/v3/#t-websockettrade
spot orderbook depth stream
https://bybit-exchange.github.io/docs/spot/v3/#t-websocketdepth
perpetual futures trade stream
https://bybit-exchange.github.io/docs/futuresV2/linear/#t-websockettrade
perpetual futures orderbook depth stream
https://bybit-exchange.github.io/docs/futuresV2/linear/#t-websocketorderbook25
Add support for Kucoin cryptocurrency exchange
spot trade stream
https://docs.kucoin.com/#match-execution-data
spot orderbook depth stream
https://docs.kucoin.com/#level2-5-best-ask-bid-orders
futures trade stream
https://docs.kucoin.com/futures/#execution-data
futures orderbook depth stream
https://docs.kucoin.com/futures/#message-channel-for-the-5-best-ask-bid-full-data-of-level-2
Add support for Gate.io cryptocurrency exchange:
spot trades channel
https://www.gate.io/docs/developers/apiv4/ws/en/#public-trades-channel
spot orderbook channel
https://www.gate.io/docs/developers/apiv4/ws/en/#order-book-channel
perpetual futures trades channel
https://www.gate.io/docs/developers/futures/ws/en/#trades-api
perpetual futures orderbook channel
https://www.gate.io/docs/developers/futures/ws/en/#order-book-api
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.