Initialization
- class BacktestAsset[source]
- data(data)[source]
Sets the feed data.
- Parameters:
data (str | List[str] | ndarray[Any, dtype([('ev', '<u8'), ('exch_ts', '<i8'), ('local_ts', '<i8'), ('px', '<f8'), ('qty', '<f8'), ('order_id', '<u8'), ('ival', '<i8'), ('fval', '<f8')], align=True)] | List[ndarray[Any, dtype([('ev', '<u8'), ('exch_ts', '<i8'), ('local_ts', '<i8'), ('px', '<f8'), ('qty', '<f8'), ('order_id', '<u8'), ('ival', '<i8'), ('fval', '<f8')], align=True)]]) – A list of file paths for the feed data in .npz format, or a list of NumPy arrays containing the feed data.
- intp_order_latency(data, latency_offset=0)[source]
Uses IntpOrderLatency for the order latency model. Please see the data format. The units of the historical latencies should match the timestamp units of your data. Nanoseconds are typically used in HftBacktest.
- Parameters:
data (str | ndarray[Any, dtype[_ScalarType_co]] | List[str]) – A list of file paths for the historical order latency data in npz, or a NumPy array of the historical order latency data.
latency_offset (int) – the latency offset to adjust the order entry and response latency by the specified amount. This is particularly useful in cross-exchange backtesting, where the feed data is collected from a different site than the one where the strategy is intended to run.
- constant_latency(entry_latency, resp_latency)
Uses ConstantLatency for the order latency model. The units of the arguments should match the timestamp units of your data. Nanoseconds are typically used in HftBacktest.
- Parameters:
entry_latency – order entry latency.
resp_latency – order response latency.
- flat_per_trade_fee_model(maker_fee, taker_fee)
Uses FlatPerTradeFeeModel. A negative fee represents rebates.
- inverse_asset(contract_size)
Sets the asset as a InverseAsset.
- Parameters:
contract_size – contract size of the asset.
- l2()
Sets this asset to Level2.
- l3()
Sets this asset to Level3.
- l3_fifo_queue_model()
Uses the L3FIFOQueueModel for the queue position model.
Please find the details below.
- last_trades_capacity(capacity)
Sets the initial capacity of the vector storing the last market trades. The default value is 0, indicating that no last trades are stored.
- latency_offset(latency_offset)
Sets the latency offset to adjust the feed latency by the specified amount. This is particularly useful in cross-exchange backtesting, where the feed data is collected from a different site than the one where the strategy is intended to run.
- Parameters:
latency_offset – offset to adjust the feed latency by the specified amount. The default value is 0.
- linear_asset(contract_size)
Sets the asset as a LinearAsset.
- Parameters:
contract_size – contract size of the asset.
- log_prob_queue_model()
Uses the LogProbQueueModel for the queue position model.
Please find the details below.
- log_prob_queue_model2()
Uses the LogProbQueueModel2 for the queue position model.
Please find the details below.
- lot_size(lot_size)
Sets the lot size of the asset.
- no_partial_fill_exchange()
Uses the NoPartiallFillExchange for the exchange model.
- parallel_load(parallel_load)
Sets whether to load the next data in parallel with backtesting. This can speed up the backtest by reducing data loading time, but it also increases memory usage.
- Parameters:
preload – whether to preload the next data in parallel with backtesting. The default value is True.
- partial_fill_exchange()
Uses the PartiallFillExchange for the exchange model.
- power_prob_queue_model(n)
Uses the PowerProbQueueModel for the queue position model.
Please find the details below.
- power_prob_queue_model2(n)
Uses the PowerProbQueueModel2 for the queue position model.
Please find the details below.
- power_prob_queue_model3(n)
Uses the PowerProbQueueModel3 for the queue position model.
Please find the details below.
- risk_adverse_queue_model()
Uses the RiskAdverseQueueModel for the queue position model.
- roi_lb(roi_lb)
Sets the lower bound price of the ROIVectorMarketDepth. Only valid if ROIVectorMarketDepthBacktest is built.
- Parameters:
roi_lb – the lower bound price of the range of interest.
- roi_ub(roi_ub)
Sets the upper bound price of the ROIVectorMarketDepth. Only valid if ROIVectorMarketDepthBacktest is built.
- Parameters:
roi_ub – the upper bound price of the range of interest.
- tick_size(tick_size)
Sets the tick size of the asset.
- trading_qty_fee_model(maker_fee, taker_fee)
Uses TradingQtyFeeModel. A negative fee represents rebates.
- trading_value_fee_model(maker_fee, taker_fee)
Uses TradingValueFeeModel. A negative fee represents rebates.
- HashMapMarketDepthBacktest(assets)[source]
Constructs an instance of HashMapMarketDepthBacktest.
- Parameters:
assets (List[BacktestAsset]) – A list of backtesting assets constructed using
BacktestAsset
.- Returns:
A jit`ed HashMapMarketDepthBacktest that can be used in an
njit
function.- Return type:
- ROIVectorMarketDepthBacktest(assets)[source]
Constructs an instance of ROIVectorMarketBacktest.
- Parameters:
assets (List[BacktestAsset]) – A list of backtesting assets constructed using
BacktestAsset
.- Returns:
A jit`ed ROIVectorMarketBacktest that can be used in an
njit
function.- Return type: