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 *[*str ]) – The starting account balances (specify one for a single asset account).
- base_currency (Currency , 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).
- bar_execution (bool , default True) – If bars should be processed by the matching engine(s) (and move the market).
- 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.
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
bar_execution : 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
modules : list[ImportableActorConfig] | 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 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 , 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 , optional) – The metadata for the data catalog query.
- bar_spec (str , optional) – The bar specification for the data catalog query.
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 | None
bar_spec : 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 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
data_engine : DataEngineConfig
risk_engine : RiskEngineConfig
exec_engine : ExecEngineConfig
run_analysis : bool
actors : list[ImportableActorConfig]
cache : CacheConfig | None
catalogs : list[DataCatalogConfig]
controller : ImportableControllerConfig | None
dict() → dict[str, Any]
Return a dictionary representation of the configuration.
- Return type: dict[str, Any]
emulator : OrderEmulatorConfig | None
exec_algorithms : list[ImportableExecAlgorithmConfig]
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
instance_id : UUID4 | None
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]
load_state : bool
logging : LoggingConfig | None
loop_debug : bool
message_bus : MessageBusConfig | None
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
save_state : bool
strategies : list[ImportableStrategyConfig]
streaming : StreamingConfig | None
timeout_connection : PositiveFloat
timeout_disconnection : PositiveFloat
timeout_portfolio : PositiveFloat
timeout_post_stop : PositiveFloat
timeout_reconciliation : PositiveFloat
validate() → bool
Return whether the configuration can be represented as valid JSON.
- Return type: bool
class BacktestRunConfig
Bases: NautilusConfig
Represents the configuration for one specific backtest run.
This includes a backtest engine with its actors and strategies, with the external inputs of venues and data.
- Parameters:
- venues (list [BacktestVenueConfig ]) – The venue configurations for the backtest run.
- data (list [BacktestDataConfig ]) – The data configurations for the backtest run.
- engine (BacktestEngineConfig) – The backtest engine configuration (the core system kernel).
- chunk_size (int , optional) – The number of data points to process in each chunk during streaming mode. If None, the backtest will run without streaming, loading all data at once.
- dispose_on_completion (bool , default True) – If the backtest engine should be disposed on completion of the run. If True, then will drop data and all state. If False, then will only drop data.
- start (datetime or str or int , optional) – The start datetime (UTC) for the backtest run.
If
None
engine runs from the start of the data. - end (datetime or str or int , optional) – The end datetime (UTC) for the backtest run.
If
None
engine runs to the end of the data.
venues : list[BacktestVenueConfig]
data : list[BacktestDataConfig]
engine : BacktestEngineConfig | None
chunk_size : int | None
dispose_on_completion : bool
start : str | int | None
end : str | int | 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 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 SimulationModuleConfig
Bases: ActorConfig
Configuration for SimulationModule
instances.
component_id : ComponentId | 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 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 FXRolloverInterestConfig
Bases: SimulationModuleConfig
Provides an FX rollover interest simulation module.
- Parameters: rate_data (pd.DataFrame) – The interest rate data for the internal rollover interest calculator.
rate_data : pd.DataFrame
component_id : ComponentId | 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 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
Cache
class CacheConfig
Bases: NautilusConfig
Configuration for Cache
instances.
- Parameters:
- database (DatabaseConfig , optional) – The configuration for the cache backing database.
- encoding (str , {'msgpack' , 'json'} , default 'msgpack') – The encoding for database operations, controls the type of serializer used.
- timestamps_as_iso8601 – If timestamps should be persisted as ISO 8601 strings. If False then will persit as UNIX nanoseconds.
- False (default) – If timestamps should be persisted as ISO 8601 strings. If False then will persit as UNIX nanoseconds.
- buffer_interval_ms (PositiveInt , optional) – The buffer interval (milliseconds) between pipelined/batched transactions. The recommended range if using buffered pipeling is [10, 1000] milliseconds, with a good compromise being 100 milliseconds.
- use_trader_prefix (bool , default True) – If a ‘trader-’ prefix is used for keys.
- use_instance_id (bool , default False) – If the traders instance ID is used for keys.
- flush_on_start (bool , default False) – If database should be flushed on start.
- drop_instruments_on_reset (bool , default True) – If instruments data should be dropped from the caches memory on reset.
- tick_capacity (PositiveInt , default 10_000) – The maximum length for internal tick dequeues.
- bar_capacity (PositiveInt , default 10_000) – The maximum length for internal bar dequeues.
database : DatabaseConfig | None
encoding : str
timestamps_as_iso8601 : bool
buffer_interval_ms : Annotated[int, msgspec.Meta(gt=0)] | None
use_trader_prefix : bool
use_instance_id : bool
flush_on_start : bool
drop_instruments_on_reset : bool
tick_capacity : Annotated[int, msgspec.Meta(gt=0)]
bar_capacity : Annotated[int, msgspec.Meta(gt=0)]
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 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
Common
exception InvalidConfiguration
Bases: RuntimeError
Raised when there is a violation of a configuration condition, making it invalid.
add_note()
Exception.add_note(note) – add a note to the exception
args
with_traceback()
Exception.with_traceback(tb) – set self._traceback_ to tb and return self.
resolve_path(path: str) → type
resolve_config_path(path: str) → type[NautilusConfig]
msgspec_encoding_hook(obj: Any) → Any
msgspec_decoding_hook(obj_type: type, obj: Any) → Any
register_config_encoding(type_: type, encoder: Callable) → None
register_config_decoding(type_: type, decoder: Callable) → None
tokenize_config(obj: NautilusConfig) → str
class NautilusConfig
Bases: Struct
The base class for all Nautilus configuration objects.
property id : str
Return the hashed identifier for the configuration.
- Return type: str
classmethod fully_qualified_name() → str
Return the fully qualified name for the NautilusConfig class.
- Return type: str
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
dict() → dict[str, Any]
Return a dictionary representation of the configuration.
- Return type: dict[str, Any]
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]
validate() → bool
Return whether the configuration can be represented as valid JSON.
- Return type: bool
class DatabaseConfig
Bases: NautilusConfig
Configuration for database connections.
- Parameters:
- type (str , {'redis'} , default 'redis') – The database type.
- host (str , optional) – The database host address. If None then should use the typical default.
- port (int , optional) – The database port. If None then should use the typical default.
- username (str , optional) – The account username for the database connection.
- password (str , optional) – The account password for the database connection. If a value is provided then it will be redacted in the string repr for this object.
- ssl (bool , default False) – If database should use an SSL enabled connection.
- timeout (int , default 20) – The timeout (seconds) to wait for a new connection.
type : str
host : str | None
port : int | None
username : str | None
password : str | None
ssl : bool
timeout : int | 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 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 MessageBusConfig
Bases: NautilusConfig
Configuration for MessageBus
instances.
- Parameters:
- database (DatabaseConfig , optional) – The configuration for the message bus backing database.
- encoding (str , {'msgpack' , 'json'} , default 'msgpack') – The encoding for database operations, controls the type of serializer used.
- timestamps_as_iso8601 – If timestamps should be persisted as ISO 8601 strings. If False then will persit as UNIX nanoseconds.
- False (default) – If timestamps should be persisted as ISO 8601 strings. If False then will persit as UNIX nanoseconds.
- buffer_interval_ms (PositiveInt , optional) – The buffer interval (milliseconds) between pipelined/batched transactions. The recommended range if using buffered pipeling is [10, 1000] milliseconds, with a good compromise being 100 milliseconds.
- autotrim_mins (int , optional) – The lookback window in minutes for automatic stream trimming. The actual window may extend up to one minute beyond the specified value since streams are trimmed at most once every minute. Note that this feature requires Redis version 6.2 or higher; otherwise it will result in a command syntax error.
- use_trader_prefix (bool , default True) – If a ‘trader-’ prefix is used for stream names.
- use_trader_id (bool , default True) – If the traders ID is used for stream names.
- use_instance_id (bool , default False) – If the traders instance ID is used for stream names.
- streams_prefix (str , default 'stream') – The prefix for externally published stream names (must have a database config). If use_trader_id and use_instance_id are both false, then it becomes possible for many traders to be configured to write to the same streams.
- stream_per_topic (bool , default True) – If True, messages will be written to separate streams per topic. If False, all messages will be written to the same stream.
- external_streams (list *[*str ] , optional) – The external stream keys the node will listen to for publishing deserialized message payloads on the internal message bus.
- types_filter (list *[*type ] , optional) – A list of serializable types not to publish externally.
- heartbeat_interval_secs (PositiveInt , optional) – The heartbeat interval (seconds) to use for trading node health.
database : DatabaseConfig | None
encoding : str
timestamps_as_iso8601 : bool
buffer_interval_ms : Annotated[int, msgspec.Meta(gt=0)] | None
autotrim_mins : int | None
use_trader_prefix : bool
use_trader_id : bool
use_instance_id : bool
streams_prefix : str
stream_per_topic : bool
external_streams : list[str] | None
types_filter : list[type] | None
heartbeat_interval_secs : Annotated[int, msgspec.Meta(gt=0)] | 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 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 InstrumentProviderConfig
Bases: NautilusConfig
Configuration for InstrumentProvider
instances.
- Parameters:
- load_all (bool , default False) – If all venue instruments should be loaded on start.
- load_ids (frozenset [InstrumentId ] , optional) – The list of instrument IDs to be loaded on start (if load_all_instruments is False).
- filters (frozendict or dict *[*str , Any ] , optional) – The venue specific instrument loading filters to apply.
- filter_callable (str , optional) – A fully qualified path to a callable that takes a single argument, instrument and returns a bool, indicating whether the instrument should be loaded
- log_warnings (bool , default True) – If parser warnings should be logged.
load_all : bool
load_ids : frozenset[InstrumentId] | None
filters : dict[str, Any] | None
filter_callable : str | None
log_warnings : 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 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 OrderEmulatorConfig
Bases: NautilusConfig
Configuration for OrderEmulator
instances.
- Parameters: debug (bool , default False) – If debug mode is active (will provide extra debug logging).
debug : 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 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 ActorConfig
Bases: NautilusConfig
The base model for all actor configurations.
- Parameters:
component_id (ComponentId , optional) – The component ID. If
None
then the identifier will be taken from type(self)._name_.
component_id : ComponentId | 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 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 ImportableActorConfig
Bases: NautilusConfig
Configuration for an actor instance.
- Parameters:
- actor_path (str) – The fully qualified name of the Actor class.
- config_path (str) – The fully qualified name of the Actor Config class.
- config (dict) – The actor configuration.
actor_path : str
config_path : str
config : dict
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 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 ActorFactory
Bases: object
Provides actor creation from importable configurations.
static create(config: ImportableActorConfig)
Create an actor from the given configuration.
- Parameters: config (ImportableActorConfig) – The configuration for the building step.
- Return type: Actor
- Raises: TypeError – If config is not of type ImportableActorConfig.
class LoggingConfig
Bases: NautilusConfig
Configuration for standard output and file logging for a NautilusKernel
instance.
- Parameters:
- log_level (str , default "INFO") – The minimum log level to write to stdout. Will always write ERROR level logs to stderr (unless bypass_logging is True).
- log_level_file (str , optional) – The minimum log level to write to a log file.
If
None
then no file logging will occur. - log_directory (str , optional) – The path to the log file directory.
If
None
then will write to the current working directory. - log_file_name (str , optional) – The custom log file name (will use a ‘.log’ suffix for plain text or ‘.json’ for JSON). This will override automatic naming, and no daily file rotation will occur.
- log_file_format (str { 'JSON' } , optional) – The log file format. If
None
(default) then will log in plain text. - log_colors (bool , default True) – If ANSI codes should be used to produce colored log lines.
- log_component_levels (dict *[*str , LogLevel ]) – The additional per component log level filters, where keys are component IDs (e.g. actor/strategy IDs) and values are log levels.
- bypass_logging (bool , default False) – If all logging should be bypassed.
- print_config (bool , default False) – If the core logging configuration should be printed to stdout at initialization.
- use_pyo3 (bool , default False) – If the logging system should be initialized via pyo3, this isn’t recommended for backtesting as the performance is much lower but can be useful for seeing logs originating from Rust.
- clear_log_file (bool , default False) – If the log file name should be cleared before being used (e.g. for testing).
Only applies if log_file_name is not
None
.
log_level : str
log_level_file : str | None
log_directory : str | None
log_file_name : str | None
log_file_format : str | None
log_colors : bool
log_component_levels : dict[str, str] | None
bypass_logging : bool
print_config : bool
use_pyo3 : bool
clear_log_file : 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 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 ImportableFactoryConfig
Bases: NautilusConfig
Represents an importable (JSON) factory config.
path : str
create()
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 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 ImportableConfig
Bases: NautilusConfig
Represents an importable configuration (typically live data client or live execution client).
path : str
config : dict
factory : ImportableFactoryConfig | None
static is_importable(data: dict) → bool
create()
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 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
Data
class DataEngineConfig
Bases: NautilusConfig
Configuration for DataEngine
instances.
- Parameters:
- time_bars_build_with_no_updates (bool , default True) – If time bar aggregators will build and emit bars with no new market updates.
- time_bars_timestamp_on_close (bool , default True) – If time bar aggregators will timestamp ts_event on bar close. If False, then will timestamp on bar open.
- time_bars_interval_type (str , default 'left-open') – Determines the type of interval used for time aggregation.
- ‘left-open’: start time is excluded and end time is included (default).
- ‘right-open’: start time is included and end time is excluded.
- time_bars_origins (dict [BarAggregation , pd.Timedelta | pd.DateOffset ] , optional) – A dictionary mapping time bar aggregations to their origin time offsets.
- validate_data_sequence (bool , default False) – If data objects timestamp sequencing will be validated and handled.
- buffer_deltas (bool , default False) – If order book deltas should be buffered until the F_LAST flag is set for a delta.
- external_clients (list [ClientId ] , optional) – The client IDs declared for external stream processing. The data engine will not attempt to send data commands to these client IDs.
- debug (bool , default False) – If debug mode is active (will provide extra debug logging).
time_bars_build_with_no_updates : bool
time_bars_timestamp_on_close : bool
time_bars_interval_type : str
time_bars_origins : dict | None
validate_data_sequence : bool
buffer_deltas : bool
external_clients : list[ClientId] | None
debug : 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 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
Execution
class ExecEngineConfig
Bases: NautilusConfig
Configuration for ExecutionEngine
instances.
- Parameters:
- load_cache (bool , default True) – If the cache should be loaded on initialization.
- snapshot_orders (bool , default False) – If order state snapshot lists are persisted to a backing database. Snapshots will be taken at every order state update (when events are applied).
- snapshot_positions (bool , default False) – If position state snapshot lists are persisted to a backing database. Snapshots will be taken at position opened, changed and closed (when events are applied). To include the unrealized PnL in the snapshot then quotes for the positions instrument must be available in the cache.
- snapshot_positions_interval_secs (PositiveFloat , optional) – The interval (seconds) at which additional position state snapshots are persisted to a
backing database.
If
None
then no additional snapshots will be taken. To include unrealized PnL in these snapshots, quotes for the position’s instrument must be available in the cache. - debug (bool , default False) – If debug mode is active (will provide extra debug logging).
load_cache : bool
snapshot_orders : bool
snapshot_positions : bool
snapshot_positions_interval_secs : Annotated[float, msgspec.Meta(gt=0.0)] | None
debug : 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 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 ExecAlgorithmConfig
Bases: NautilusConfig
The base model for all execution algorithm configurations.
- Parameters:
exec_algorithm_id (ExecAlgorithmId , optional) – The unique ID for the execution algorithm.
If not
None
then will become the execution algorithm ID.
exec_algorithm_id : ExecAlgorithmId | 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 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 ImportableExecAlgorithmConfig
Bases: NautilusConfig
Configuration for an execution algorithm instance.
- Parameters:
- exec_algorithm_path (str) – The fully qualified name of the execution algorithm class.
- config_path (str) – The fully qualified name of the config class.
- config (dict *[*str , Any ]) – The execution algorithm configuration.
exec_algorithm_path : str
config_path : str
config : dict[str, Any]
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