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 (OmsType | str) – The order management system type for the exchange. If 
HEDGINGwill generate new position IDs. - account_type (AccountType | 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 
Nonefor 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).
 - margin_model (MarginModelConfig , optional) – The margin calculation model configuration. Default ‘leveraged’.
 - 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.
 - book_type (str , default 'L1_MBP') – The default order book type.
 - routing (bool , default False) – If multi-venue routing should be enabled for the execution client.
 - 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).
 - allow_cash_borrowing (bool , default False) – If borrowing is allowed for cash accounts (negative balances).
 - frozen_account (bool , default False) – If the account for this exchange is frozen (balances will not change).
 
 
name : str
oms_type : OmsType | str
account_type : AccountType | str
starting_balances : list[str]
base_currency : str | None
default_leverage : float
leverages : dict[str, float] | None
margin_model : MarginModelConfig | None
modules : list[ImportableActorConfig] | None
fill_model : ImportableFillModelConfig | None
latency_model : ImportableLatencyModelConfig | None
fee_model : ImportableFeeModelConfig | None
book_type : BookType | str
routing : 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
allow_cash_borrowing : bool
frozen_account : bool
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.
 - catalog_fs_rust_storage_options (dict , optional) – The fsspec storage options for the Rust backend.
 - 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
catalog_fs_rust_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
 
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 BacktestEngineConfig
Bases: NautilusKernelConfig
Configuration for BacktestEngine instances.
- Parameters:
- trader_id (TraderId) – The trader ID for the node (must be a name and ID tag separated by a hyphen).
 - log_level (str , default "INFO") – The stdout log level for the node.
 - loop_debug (bool , default False) – If the asyncio event loop should be in debug mode.
 - cache (CacheConfig , optional) – The cache configuration.
 - data_engine (DataEngineConfig , optional) – The live data engine configuration.
 - risk_engine (RiskEngineConfig , optional) – The live risk engine configuration.
 - exec_engine (ExecEngineConfig , optional) – The live execution engine configuration.
 - streaming (StreamingConfig , optional) – The configuration for streaming to feather files.
 - strategies (list [ImportableStrategyConfig ]) – The strategy configurations for the kernel.
 - actors (list [ImportableActorConfig ]) – The actor configurations for the kernel.
 - exec_algorithms (list [ImportableExecAlgorithmConfig ]) – The execution algorithm configurations for the kernel.
 - controller (ImportableControllerConfig , optional) – The trader controller for the kernel.
 - load_state (bool , default True) – If trading strategy state should be loaded from the database on start.
 - save_state (bool , default True) – If trading strategy state should be saved to the database on stop.
 - bypass_logging (bool , default False) – If logging should be bypassed.
 - run_analysis (bool , default True) – If post backtest performance analysis should be run.
 
 
environment : Environment
trader_id : TraderId
cache : CacheConfig | None
data_engine : DataEngineConfig | None
risk_engine : RiskEngineConfig | None
exec_engine : ExecEngineConfig | None
run_analysis : bool
actors : list[ImportableActorConfig]
catalogs : list[DataCatalogConfig]
controller : ImportableControllerConfig | None
dict() → dict[str, Any]
Return a dictionary representation of the configuration.
- Return type: dict[str, Any]