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)[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.

initial_snapshot(data)[source]

Sets the initial snapshot.

Parameters:

data (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)]) – The initial snapshot file path, or a NumPy array of the initial snapshot.

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.

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.

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.

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:

HashMapMarketDepthBacktest

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:

ROIVectorMarketDepthBacktest