ironbeam-rs 0.2.0

Async Rust client for the Ironbeam futures trading API
Documentation

Build License:MIT crates.io Documentation Coverage Status

ironbeam-rs

Async Rust client for the Ironbeam futures trading API. Targets low-latency order execution and real-time streaming.

Features

  • REST API — accounts, market data, orders, info, simulation
  • WebSocket streaming — real-time quotes, depth, trades, indicators
  • Built-in rate limiting — configurable requests-per-second throttle
  • Type-safe buildersOrderBuilder, SymbolSearchParams
  • Fully async (tokio), zero unwrap() in library code

Quick Start

[dependencies]
ironbeam-rs = "0.1"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
use ironbeam_rs::client::{Client, Credentials};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::builder()
        .credentials(Credentials {
            username: "user".into(),
            password: "pass".into(),
            api_key: "key".into(),
        })
        .demo()
        .rate_limit(8)
        .connect()
        .await?;

    let accounts = client.all_accounts().await?;
    println!("Accounts: {accounts:?}");

    client.logout().await?;
    Ok(())
}

Set credentials via environment variables:

export IRONBEAM_USERNAME=...
export IRONBEAM_PASSWORD=...
export IRONBEAM_API_KEY=...

Account Data

use ironbeam_rs::types::BalanceType;

let accounts = client.all_accounts().await?;
let account_id = &accounts[0];

let balances = client.balance(account_id, BalanceType::CurrentOpen).await?;
for b in &balances {
    println!("{}: cash={:?} equity={:?}", b.currency_code, b.cash_balance, b.total_equity);
}

let positions = client.positions(account_id).await?;
let risks = client.risk(account_id).await?;
let fills = client.fills(account_id).await?;

Market Data

use ironbeam_rs::client::SymbolSearchParams;

// Quotes and depth
let quotes = client.quotes(&["XCME:ES.U26"]).await?;
let depths = client.depth(&["XCME:ES.U26"]).await?;

// Historical trades
let now = time::OffsetDateTime::now_utc();
let trades = client.trades("XCME:ES.U26", now - time::Duration::HOUR, now, 50, true).await?;

// Symbol search
let params = SymbolSearchParams::new().text("GOLD").limit(5);
let symbols = client.symbols(&params).await?;

Orders

use ironbeam_rs::client::OrderBuilder;
use ironbeam_rs::types::{OrderSide, DurationType, OrderStatusType};

// Place a limit order
let order = OrderBuilder::limit("XCME:ES.U26", OrderSide::Buy, 1.0, 4500.0, DurationType::Day)
    .stop_loss(4480.0)
    .take_profit(4550.0);
let resp = client.place_order("ACC001", &order).await?;

// Query and cancel
let orders = client.orders("ACC001", OrderStatusType::Any).await?;
if let Some(id) = resp.order_id.as_deref() {
    client.cancel_order("ACC001", id).await?;
}

Order types: OrderBuilder::market(...), limit(...), stop(...), stop_limit(...).

Streaming

use ironbeam_rs::client::stream::StreamEvent;

let mut stream = client.stream().start().await?;
stream.subscribe_quotes(&["XCME:ES.U26"]).await?;

while let Some(event) = stream.next().await {
    match event? {
        StreamEvent::Quotes(quotes) => {
            for q in &quotes {
                println!("{}: last={:?} bid={:?} ask={:?}", q.symbol, q.last_price, q.bid, q.ask);
            }
        }
        StreamEvent::Depth(depths) => { /* ... */ }
        StreamEvent::Trades(trades) => { /* ... */ }
        _ => {}
    }
}

Examples

cargo run --example account
cargo run --example info
cargo run --example market
cargo run --example orders
cargo run --example streaming_market_data -- quote
cargo run --example streaming_indicators
cargo run --example simulation

License

MIT — see LICENSE.