TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/nkaz001/hftbacktest/llms.txt
Use this file to discover all available pages before exploring further.
types module defines the core types used throughout HftBacktest, including orders, events, and the main Bot trait.
Order Management
Order
Represents an order in the system.qty- Total order quantityleaves_qty- Remaining unfilled quantityexec_qty- Quantity filled in the last execution (only when executed)exec_price_tick- Execution price in ticks (only when executed)price_tick- Order price in tickstick_size- Tick size of the assetexch_timestamp- Exchange processing timestamplocal_timestamp- Local send/receive timestamporder_id- Unique order identifierq- Queue model data (backtesting only,()in live)maker- Whether executed as maker (only when executed)order_type- Order type (Limit, Market)req- Request status (New, Canceled, None)status- Current order statusside- Buy or Selltime_in_force- Time-in-force (GTC, GTX, FOK, IOC)
price()- Returns the order price (price_tick * tick_size)exec_price()- Returns the execution price (exec_price_tick * tick_size)cancellable()- Returns true if the order can be canceledactive()- Returns true if the order is active in the marketpending()- Returns true if the order has an ongoing requestupdate(order)- Updates this order with values from another order
OrderRequest
Simplified order structure for submissions in live trading.OrderId
Type alias for order identifiers.Enumerations
Side
Represents the side of an order or trade.Buy- Buy order or trade initiated by buyerSell- Sell order or trade initiated by sellerNone- No side specifiedUnsupported- Unsupported side value from connector
Status
Order status enumeration.TimeInForce
Order time-in-force options.OrdType
Order type enumeration.Events
Event
Feed event data structure.ev- Event flags (combination of event type constants)exch_ts- Exchange timestamplocal_ts- Local receipt timestamppx- Priceqty- Quantityorder_id- Order ID (for Level-3 Market-By-Order feeds)ival- Reserved for additional i64 valuefval- Reserved for additional f64 value
is(event)- Checks if this event matches the given event type
Event Type Constants
Event flags are bit flags that can be combined:State Management
StateValues
Provides state values for tracking bot performance.position is currently populated correctly.
Bot Trait
The core trait implemented by bothBacktest and LiveBot.
current_timestamp()- Current timestamp (backtest time or actual time)num_assets()- Number of registered assetsposition(asset_no)- Current position for the assetstate_values(asset_no)- State values (balance, fees, etc.)depth(asset_no)- Market depth for the assetlast_trades(asset_no)- Recent market tradesorders(asset_no)- Active and recent orderssubmit_buy_order(...)/submit_sell_order(...)- Submit orderscancel(asset_no, order_id, wait)- Cancel an orderelapse(duration)- Advance time by durationwait_next_feed(...)- Wait for next market data
ElapseResult
Result type returned by time-related methods.Recorder Trait
Provides recording functionality for bot statistics.Error Types
BuildError
Errors that can occur during builder operations.Constants
Time Constants
elapse() to continue until the end of data.