#trading #backtesting #crypto #stocks #investment

barter-data

High performance & normalised WebSocket intergration for leading cryptocurrency exchanges - batteries included

18 releases

0.3.1 Jan 2, 2022
0.3.0 Jan 2, 2022
0.2.11 Dec 30, 2021
0.2.10 Nov 27, 2021
0.1.6 Nov 5, 2021

#56 in Simulation

Download history 74/week @ 2021-10-30 12/week @ 2021-11-06 171/week @ 2021-11-13 85/week @ 2021-11-20 81/week @ 2021-11-27 52/week @ 2021-12-04 28/week @ 2021-12-11 16/week @ 2021-12-18 31/week @ 2021-12-25 63/week @ 2022-01-01 15/week @ 2022-01-08

133 downloads per month
Used in barter

MIT license

38KB
678 lines

Barter-Data

A high-performance WebSocket integration library for streaming public data from leading cryptocurrency exchanges - batteries included. It is:

  • Normalised: Barter-Data's unified interface for consuming public WebSocket data means every Exchange returns a normalised data model.
  • Real-Time: Barter-Data utilises real-time WebSocket integrations enabling the consumption of normalised tick-by-tick data.
  • Easy: Barter-Data's simple ExchangeClient interface allows for easy & quick setup.
  • Extensible: Barter-Data is highly extensible, and therefore easy to contribute to via new integrations!

Note: Barter-Data is recommended for use with the Barter.

Crates.io MIT licensed Build Status Discord chat

API Documentation | Chat

Overview

Barter-Data is a high-performance WebSocket integration library for streaming public data from leading cryptocurrency exchanges. It presents an easy to use, extensible, interface that can deliver normalised exchange data in real-time. At a high level, it provides a few major components:

  • ConnectionHandler that manages the WebSocket connection (ping-pongs, re-connections, rate-limiting) and actions subscription requests on behalf of an Exchange Client implementation (eg/ Binance Exchange Client).
  • Unified ExchangeClient trait that enables easy extensibility, ease of use, and the delivery of a normalised data model to downstream consumers.

Example

Binance tick-by-tick Trade consumer with Barter-Data.

use barter_data::client::binance::Binance;
use barter_data::client::ClientConfig;
use barter_data::ExchangeClient;
use tokio_stream::StreamExt;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Initialise new Binance Exchange Client
    let mut binance = Binance::init().await?;
    
    // Subscribe & consume normalised Trade stream
    let mut trade_stream = binance
        .consume_trades(String::from("btcusdt"))
        .await?;
    
    // Loop over arriving Trades
    while let Some(trade) = trade_stream.next().await {
        // Do something with normalised Trade
        println!("{:?}", trade);
    }
}

For a larger, "real world" example, see the Barter repository.

Getting Help

Firstly, see if the answer to your question can be found in the API Documentation. If the answer is not there, I'd be happy to help to Chat and try answer your question via Discord.

Contributing

Thanks for your help in improving the Barter ecosystem! Please do get in touch on the discord to discuss development, new features, and the future roadmap.

Related Projects

In addition to the Barter-Data crate, the Barter project also maintains:

  • Barter: High-performance, extensible & modular trading components with batteries-included. Contains a pre-built trading Engine that can serve as a live-trading or backtesting system.

Roadmap

  • Extend the existing integrations scope to include more endpoints.
  • Implement integrations for more exchanges.

Licence

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Barter-Data by you, shall be licensed as MIT, without any additional terms or conditions.

Dependencies

~21MB
~480K SLoC