Trading Strategies¶
All strategies are hosted in engine/strategies/ and run inside a single NautilusTrader TradingNode.
MeanReversionStrategy¶
File: engine/strategies/strategies_binance.py
Strategy ID: mean_reversion
EMA crossover on 1-minute Binance kline bars.
Logic¶
- Subscribe to
BTCUSDT.BINANCE-1-MINUTE-LAST-EXTERNALbars - Maintain a fast EMA (3 bars) and slow EMA (8 bars)
- On each bar: if fast crosses above slow → BUY; crosses below → SELL
- Orders are LIMIT IOC at current mid price
- Cancel all open orders before placing a new one (cancel-and-replace)
- Max 1 open order at a time
Configuration¶
class MeanReversionConfig(StrategyConfig):
order_qty: float = 0.002 # BTC per order
fast_period: int = 3 # fast EMA bars
slow_period: int = 8 # slow EMA bars
max_open_orders: int = 1
strategy_id: str = "mean_reversion"
Emitted Metrics¶
| Metric | Type | Description |
|---|---|---|
strategy_latency_us |
gauge | Time from signal to submit_order() in microseconds |
order_ack_rtt_us |
gauge | Round-trip time to OrderAccepted event |
fill_report_lag_us |
gauge | Lag between fill event and report (ts_init - ts_event) |
trade_pnl_usdt |
gauge | Per-trade realized PnL in USDT |
HourlyBuyStrategy¶
File: engine/strategies/strategies_binance.py
Strategy ID: hourly_buy
Time-based DCA strategy that buys at each whole UTC hour.
Logic¶
- Subscribe to
BTCUSDT.BINANCEquote ticks for mid-price tracking - Fire a recurring timer every
check_interval_secs(default: 60s) - At the first minute of hour
n, place a MARKET BUY fornBTC - Hour 0 (midnight) triggers a 1 BTC buy; hour 23 triggers a 24 BTC buy
Configuration¶
class HourlyBuyConfig(StrategyConfig):
instrument_id: str = "BTCUSDT.BINANCE"
strategy_id: str = "hourly_buy"
check_interval_secs: int = 60
Emitted Metrics¶
| Metric | Type | Description |
|---|---|---|
strategy_latency_us |
gauge | Time from timer callback to order submission |
order_ack_rtt_us |
gauge | Round-trip time to OrderAccepted |
fill_report_lag_us |
gauge | Fill report delivery lag |
trade_pnl_usdt |
gauge | Per-fill incremental PnL vs previous fill price |
Latency Strategies¶
File: engine/strategies/strategies_latency.py
Three additional strategies instrumented specifically for latency benchmarking across different order types and market conditions. They follow the same metric-emission pattern as the strategies above.
Database Integration¶
All strategies use db/strategy_startup.py:resolve_strategy() on on_start() to find-or-create their Strategy row in PostgreSQL. The DatabaseActor persists fills, orders, signals, and audit events asynchronously.