#cryptocurrency #blockchain #trading #websocket

crypto-ws-client

A versatile websocket client that supports many cryptocurrency exchanges

52 stable releases

2.5.23 Aug 31, 2021
2.5.14 Jul 15, 2021
2.4.1 Mar 22, 2021
1.7.8 Jan 21, 2021
0.4.0 Dec 31, 2020

#280 in Magic Beans

Download history 72/week @ 2021-05-30 102/week @ 2021-06-06 4/week @ 2021-06-13 4/week @ 2021-06-20 117/week @ 2021-06-27 15/week @ 2021-07-04 29/week @ 2021-07-11 194/week @ 2021-07-18 97/week @ 2021-07-25 182/week @ 2021-08-01 12/week @ 2021-08-08 209/week @ 2021-08-15 117/week @ 2021-08-22 95/week @ 2021-08-29 48/week @ 2021-09-05 64/week @ 2021-09-12

397 downloads per month
Used in crypto-crawler

Apache-2.0

195KB
4.5K SLoC

crypto-ws-client

A versatile websocket client that supports many cryptocurrency exchanges.

Usage

use crypto_ws_client::{BinanceSpotWSClient, WSClient};

fn main() {
    let mut ws_client = BinanceSpotWSClient::new(Box::new(|msg| println!("{}", msg)), None);
    let channels = vec!["btcusdt@aggTrade".to_string(), "btcusdt@depth".to_string(),];
    ws_client.subscribe(&channels);
    ws_client.run(None);
}

Contribution

How to add support for a new exchange

1. Add a new file under src/clients/

Define a struct in the file, with the same name as the file.

Define a channels_to_commands() function which can convert raw channels to subscribe/unsubscribe commands.

Define a customized on_misc_msg() to handle misc messages.

Use define_client! macro to implement the WSClient trait.

2. Add a new file under tests/

Add a new file under tests/ and put some integration tests in it.

Dependencies

~10–15MB
~375K SLoC