Engine¶
The execution engine applies intents to a broker, producing orders and fills. Brokers cover simulation and live trading; the order primitives describe what is sent and what comes back.
Engine¶
signalflow.Engine ¶
Folds fills into balances + positions and values the book in target.
Source code in src/signalflow/engine/engine.py
equity ¶
Value the book in target, carrying forward the last-known price for
any held asset missing from prices (gappy/staggered multi-asset data).
Source code in src/signalflow/engine/engine.py
Brokers¶
signalflow.SimBroker
dataclass
¶
Bases: Broker
Simulated fills with flat fee + slippage; next-available close pricing.
signalflow.ExchangeBroker
dataclass
¶
Bases: Broker
Base for live venue brokers. Subclass and implement execute.
signalflow.BinanceBroker
dataclass
¶
BinanceBroker(quote: str = 'USDT', api_key: str = '', api_secret: str = '', base_url: str = 'https://testnet.binance.vision', recv_window: int = 5000, timeout: float = 20.0)
Bases: ExchangeBroker
Live Binance spot venue: signed REST market orders (testnet by default).
Set base_url to https://api.binance.com for production. Requires
api_key/api_secret; only reachable through Flow.live(armed=True).
Order primitives¶
signalflow.Intent
dataclass
¶
Intent(pair: str, kind: IntentKind, side: Side, qty: float | None = None, notional: float | None = None, limit_price: float | None = None, reason: str = '')
A strategy proposal for a pair (not yet an order).
signalflow.Order
dataclass
¶
Order(pair: str, side: Side, qty: float, type: OrderType = OrderType.MARKET, limit_price: float | None = None, ts: object = None, reason: str = '')
A concrete order handed to a broker.
signalflow.Fill
dataclass
¶
Fill(pair: str, ts: object, side: Side, qty: float, price: float, fee: float = 0.0, fee_asset: str = 'USDT')
An executed order - the single source of truth the Engine folds.