Config
Backtest
parse_filters_expr(s: str | None)
Parse a pyarrow.dataset filter expression from a string.
>>> parse_filters_expr('field("Currency") == "CHF"')
<pyarrow.dataset.Expression (Currency == "CHF")>
>>> parse_filters_expr("print('hello')")
>>> parse_filters_expr("None")
class BacktestVenueConfig
Bases: NautilusConfig
Represents a venue configuration for one specific backtest engine.
- Parameters:
- name (str) – The name of the venue.
- oms_type (str) – The order management system type for the exchange. If
HEDGING
will generate new position IDs. - account_type (str) – The account type for the exchange.
- starting_balances (list [Money | str ]) – The starting account balances (specify one for a single asset account).
- base_currency (Currency | str , optional) – The account base currency for the exchange. Use
None
for multi-currency accounts. - default_leverage (float , optional) – The account default leverage (for margin accounts).
- leverages (dict *[*str , float ] , optional) – The instrument specific leverage configuration (for margin accounts).
- book_type (str) – The default order book type.
- routing (bool , default False) – If multi-venue routing should be enabled for the execution client.
- frozen_account (bool , default False) – If the account for this exchange is frozen (balances will not change).
- reject_stop_orders (bool , default True) – If stop orders are rejected on submission if trigger price is in the market.
- support_gtd_orders (bool , default True) – If orders with GTD time in force will be supported by the venue.
- support_contingent_orders (bool , default True) – If contingent orders will be supported/respected by the venue. If False, then it’s expected the strategy will be managing any contingent orders.
- use_position_ids (bool , default True) – If venue position IDs will be generated on order fills.
- use_random_ids (bool , default False) – If all venue generated identifiers will be random UUID4’s.
- use_reduce_only (bool , default True) – If the reduce_only execution instruction on orders will be honored.
- bar_execution (bool , default True) – If bars should be processed by the matching engine(s) (and move the market).
- bar_adaptive_high_low_ordering (bool , default False) – Determines whether the processing order of bar prices is adaptive based on a heuristic.
This setting is only relevant when bar_execution is True.
If False, bar prices are always processed in the fixed order: Open, High, Low, Close.
If True, the processing order adapts with the heuristic:
- If High is closer to Open than Low then the processing order is Open, High, Low, Close.
- If Low is closer to Open than High then the processing order is Open, Low, High, Close.
- trade_execution (bool , default False) – If trades should be processed by the matching engine(s) (and move the market).
- modules (list [ImportableActorConfig ] , optional) – The simulation modules for the venue.
- fill_model (ImportableFillModelConfig , optional) – The fill model for the venue.
- latency_model (ImportableLatencyModelConfig , optional) – The latency model for the venue.
- fee_model (ImportableFeeModelConfig , optional) – The fee model for the venue.
name : str
oms_type : str
account_type : str
starting_balances : list[str]
base_currency : str | None
default_leverage : float
leverages : dict[str, float] | None
book_type : str
routing : bool
frozen_account : bool
reject_stop_orders : bool
support_gtd_orders : bool
support_contingent_orders : bool
use_position_ids : bool
use_random_ids : bool
use_reduce_only : bool
bar_execution : bool
bar_adaptive_high_low_ordering : bool
trade_execution : bool
modules : list[ImportableActorConfig] | None
fill_model : ImportableFillModelConfig | None
latency_model : ImportableLatencyModelConfig | None
fee_model : ImportableFeeModelConfig | None
dict() → dict[str, Any]
Return a dictionary representation of the configuration.
- Return type: dict[str, Any]
classmethod fully_qualified_name() → str
Return the fully qualified name for the NautilusConfig class.
- Return type: str
property id : str
Return the hashed identifier for the configuration.
- Return type: str
json() → bytes
Return serialized JSON encoded bytes.
- Return type: bytes
json_primitives() → dict[str, Any]
Return a dictionary representation of the configuration with JSON primitive types as values.
- Return type: dict[str, Any]
classmethod json_schema() → dict[str, Any]
Generate a JSON schema for this configuration class.
- Return type: dict[str, Any]
classmethod parse(raw: bytes | str) → Any
Return a decoded object of the given cls.
- Parameters:
- cls (type) – The type to decode to.
- raw (bytes or str) – The raw bytes or JSON string to decode.
- Return type: Any
validate() → bool
Return whether the configuration can be represented as valid JSON.
- Return type: bool
class BacktestDataConfig
Bases: NautilusConfig
Represents the data configuration for one specific backtest run.
- Parameters:
- catalog_path (str) – The path to the data catalog.
- data_cls (str) – The data type for the configuration.
- catalog_fs_protocol (str , optional) – The fsspec filesystem protocol for the catalog.
- catalog_fs_storage_options (dict , optional) – The fsspec storage options.
- instrument_id (InstrumentId | str , optional) – The instrument ID for the data configuration.
- start_time (str or int , optional) – The start time for the data configuration. Can be an ISO 8601 format datetime string, or UNIX nanoseconds integer.
- end_time (str or int , optional) – The end time for the data configuration. Can be an ISO 8601 format datetime string, or UNIX nanoseconds integer.
- filter_expr (str , optional) – The additional filter expressions for the data catalog query.
- client_id (str , optional) – The client ID for the data configuration.
- metadata (dict or callable , optional) – The metadata for the data catalog query.
- bar_spec (BarSpecification | str , optional) – The bar specification for the data catalog query.
- instrument_ids (list [InstrumentId | str ] , optional) – The instrument IDs for the data catalog query. Can be used if instrument_id is not specified. If bar_spec is specified an equivalent list of bar_types will be constructed.
- bar_types (list [BarType | str ] , optional) – The bar types for the data catalog query. Can be used if instrument_id is not specified.
catalog_path : str
data_cls : str
catalog_fs_protocol : str | None
catalog_fs_storage_options : dict | None
instrument_id : InstrumentId | None
start_time : str | int | None
end_time : str | int | None
filter_expr : str | None
client_id : str | None
metadata : dict | Any | None
bar_spec : str | None
instrument_ids : list[str] | None
bar_types : list[str] | None
property data_type : type
Return a type for the specified data_cls for the configuration.
- Return type: type
property query : dict[str, Any]
Return a catalog query object for the configuration.
- Return type: dict[str, Any]
property start_time_nanos : int
Return the data configuration start time in UNIX nanoseconds.
Will be zero if no start_time was specified.
- Return type: int
property end_time_nanos : int
Return the data configuration end time in UNIX nanoseconds.
Will be sys.maxsize if no end_time was specified.
- Return type: int