Skip to main content

Module exchange

Module exchange 

Source
Expand description

Exchange adapter trait and exchange-facing DTOs.

Adapters implement Exchange to translate canonical bot commands into concrete exchange API calls. The engine owns retries, state transitions, and event generation; adapters return structured results and errors.

§Example

use bot_core::{
    ClientOrderId, InstrumentId, MarketIndex, OrderInput, OrderSide, Price, Qty, TimeInForce,
};
use rust_decimal::Decimal;

let input = OrderInput {
    instrument: InstrumentId::new("BTC-PERP"),
    market_index: MarketIndex::new(0),
    client_id: ClientOrderId::new("client-1"),
    side: OrderSide::Buy,
    price: Price::new(Decimal::new(65_000, 0)),
    qty: Qty::new(Decimal::new(1, 3)),
    tif: TimeInForce::Gtc,
    post_only: true,
    reduce_only: false,
};

assert!(input.post_only);

Structs§

AccountBalance
Account balance reported by an exchange.
ExchangePosition
Position reported by an exchange.
Fill
A fill from userFills
OrderInput
Input parameters for placing an order.

Enums§

ExchangeError
Errors returned by exchange operations.
PlaceOrderResult
Result of placing an order

Traits§

Exchange
Exchange adapter trait - what each exchange must implement.