ferr 0.1.11

Crypto CEX connector framework
Documentation

ferr

Work in Progress -- Currently in early development. Not ready for use.

docs.rs Crates.io License: MIT

A Rust library for market data and order management on crypto CEXs.

Supported Exchanges

Exchange WebSocket REST
Bybit Implemented Implemented
Binance Not yet implemented Not yet implemented
OKX Not yet implemented Not yet implemented
Bitget Not yet implemented Not yet implemented

Features

WebSocket Market Data

  • Real-time trades, tickers, and orderbook (top of book)
  • Funding rates and open interest
  • Mark price and index price
  • Automatic reconnection with exponential backoff
  • Automatic subscription resumption after reconnect
  • Broadcast channels for multi-consumer support

REST API

  • Trading: Place, modify, and cancel orders
  • Account: Balance, positions, and trade history
  • Market Data: Historical klines/OHLCV

General

  • Unified error types across all exchanges
  • Rate limit tracking per exchange
  • Testnet support
  • Perpetual and spot markets (USDT pairs only)

Example usage

[dependencies]
ferr = "0.1.11"
tokio = { version = "1.50.0", features = ["full"] }

WebSocket: Stream Ticker Data

use ferr::{
    exchanges::bybit::ws::client::BybitWsClient,
    traits::ws::WsMarketData,
    types::common::MarketType,
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = BybitWsClient::new();
    let mut rx = client.subscribe_ticker("BTCUSDT", MarketType::Perp).await?;

    while let Ok(ticker) = rx.recv().await {
        println!(
            "{} | last: {} | bid: {} | ask: {}",
            ticker.symbol, ticker.last, ticker.bid, ticker.ask
        );
    }

    Ok(())
}