Barter-Integration
High-performance, low-level framework for composing flexible web integrations.
Utilised by other Barter trading ecosystem crates to build robust financial exchange integrations,
primarily for public data collection & trade execution. It is:
- Low-Level: Translates raw data streams communicated over the web into any desired data model using arbitrary data transformations.
- Flexible: Compatible with any protocol (WebSocket, FIX, Http, etc.), any input/output model, and any user defined transformations.
Core abstractions include:
- RestClient providing configurable signed Http communication between client & server.
- ExchangeStream providing configurable communication over any asynchronous stream protocols (WebSocket, FIX, etc.).
Both core abstractions provide the robust glue you need to conveniently translate between server & client data models.
See: Barter, Barter-Data & Barter-Execution
Overview
Barter-Integration is a high-performance, low-level, configurable framework for composing flexible web integrations.
RestClient
(sync private & public Http communication)
At a high level, a RestClient is has a few major components that allow it to execute RestRequests:
RequestSignerwith configurable signing logic on the target API.HttpParserthat translates API specific responses into the desired output types.
ExchangeStream
(async communication using streaming protocols such as WebSocket and FIX)
At a high level, an ExchangeStream is made up of a few major components:
- Inner Stream/Sink socket (eg/ WebSocket, FIX, etc).
- StreamParser that is capable of parsing input protocol messages (eg/ WebSocket, FIX, etc.) as exchange specific messages.
- Transformer that transforms from exchange specific message into an iterator of the desired outputs type.
Examples
Fetch Ftx Account Balances Using Signed GET request:
use ;
use Bytes;
use ;
use ;
use ;
use Deserialize;
use Error;
use mpsc;
// Configuration required to sign every Ftx `RestRequest`
;
;
/// See Barter-Execution for a comprehensive real-life example, as well as code you can use out of the
/// box to execute trades on many exchanges.
async
Consume Binance Futures tick-by-tick Trades and calculate a rolling sum of volume:
use ;
use ;
use ;
use json;
use FromStr;
use connect_async;
use debug;
// Convenient type alias for an `ExchangeStream` utilising a tungstenite `WebSocket`
type ExchangeWsStream<Exchange> = ;
// Communicative type alias for what the VolumeSum the Transformer is generating
type VolumeSum = f64;
/// See Barter-Data for a comprehensive real-life example, as well as code you can use out of the
/// box to collect real-time public market data from many exchanges.
async
/// Deserialize a `String` as the desired type.
For a larger, "real world" example, see the Barter-Data 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-Integration 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.Barter-Data: A high-performance WebSocket integration library for streaming public data from leading cryptocurrency exchanges.Barter-Execution: Financial exchange integrations for trade execution - yet to be released!
Roadmap
- Add new default StreamParser implementations to enable integration with other popular systems such as Kafka.
Licence
This project is licensed under the MIT license.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Barter-Integration by you, shall be licensed as MIT, without any additional terms or conditions.