Appendix B: API Cheat SheetA quick reference to the functions and object methods you will use most often when building strategies
1. Data Subscriptions
| Method | Description |
|---|---|
self.subscribe_quote_ticks(instrument_id) | Subscribe to top-of-book (BBO) quote ticks. |
self.subscribe_trade_ticks(instrument_id) | Subscribe to tick-by-tick market trade data. |
self.subscribe_bars(bar_type) | Subscribe to aggregated bar data (OHLCV). |
self.subscribe_order_book_at_interval(instrument_id, depth, interval_ms) | Subscribe to periodic L2 order book snapshots. |
2. Order Management
| Method | Description |
|---|---|
self.order_factory.market(...) | Create a market order. |
self.order_factory.limit(...) | Create a limit order. |
self.order_factory.stop_market(...) | Create a stop market order. |
self.submit_order(order) | Submit an order to the execution engine. |
self.cancel_order(order) | Cancel a specific active order. |
self.cancel_all_orders(instrument_id) | Cancel all working orders for a specific instrument. |
3. Cache Queries
| Method | Description |
|---|---|
self.cache.instrument(instrument_id) | Retrieve instrument definitions. |
self.cache.orders_open(instrument_id) | Query all active working orders for a specific instrument. |
self.cache.positions_open(instrument_id) | Query the current open position for an instrument. |
self.cache.quote_tick(instrument_id) | Retrieve the latest quote tick snapshot. |
self.cache.bar(bar_type) | Retrieve the latest bar object. |
self.cache.account(account_id) | Query account balances and status. |
4. Portfolio
| Method | Description |
|---|---|
self.portfolio.unrealized_pnl(instrument_id) | Retrieve unrealized PnL (mark-to-market) for a specific instrument. |
self.portfolio.realized_pnl() | Retrieve total aggregate realized PnL. |
self.portfolio.is_flat(instrument_id) | Check if the position for a specific instrument is flat. |
self.portfolio.is_net_long(instrument_id) | Check if the position for a specific instrument is net long. |