Async Rust client for the Ironbeam futures trading API. Targets low-latency order execution and real-time streaming.
- 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 builders —
OrderBuilder,SymbolSearchParams - Fully async (
tokio), zerounwrap()in library code
[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=...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?;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(¶ms).await?;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(...).
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 "es {
println!("{}: last={:?} bid={:?} ask={:?}", q.symbol, q.last_price, q.bid, q.ask);
}
}
StreamEvent::Depth(depths) => { /* ... */ }
StreamEvent::Trades(trades) => { /* ... */ }
_ => {}
}
}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 simulationMIT — see LICENSE.
