System

class NautilusKernel ( environment : Environment , name : str , trader_id : TraderId , cache_config : CacheConfig , cache_database_config : CacheDatabaseConfig , data_config : Union [ DataEngineConfig , LiveDataEngineConfig ] , risk_config : Union [ RiskEngineConfig , LiveRiskEngineConfig ] , exec_config : Union [ ExecEngineConfig , LiveExecEngineConfig ] , instance_id : Optional [ UUID4 ] = None , emulator_config : Optional [ OrderEmulatorConfig ] = None , streaming_config : Optional [ StreamingConfig ] = None , catalog_config : Optional [ DataCatalogConfig ] = None , actor_configs : Optional [ list [ nautilus_trader.config.common.ImportableActorConfig ] ] = None , strategy_configs : Optional [ list [ nautilus_trader.config.common.ImportableStrategyConfig ] ] = None , loop : Optional [ AbstractEventLoop ] = None , loop_sig_callback : Optional [ Callable ] = None , loop_debug : bool = False , load_state : bool = False , save_state : bool = False , log_level : LogLevel = LogLevel.INFO , log_level_file : LogLevel = LogLevel.DEBUG , log_file_path : Optional [ str ] = None , log_rate_limit : int = 100000 , bypass_logging : bool = False )

Bases: object

Provides the core Nautilus system kernel.

The kernel is common between backtest, sandbox and live environment context types.

Parameters :
  • environment (Environment { BACKTEST , SANDBOX , LIVE }) – The environment context for the kernel.

  • name ( str ) – The name for the kernel (will prepend all log messages).

  • trader_id ( str ) – The trader ID for the kernel (must be a name and ID tag separated by a hyphen).

  • cache_config ( CacheConfig ) – The cache configuration for the kernel.

  • cache_database_config ( CacheDatabaseConfig ) – The cache database configuration for the kernel.

  • data_config ( Union [ DataEngineConfig , LiveDataEngineConfig ] ) – The live data engine configuration for the kernel.

  • risk_config ( Union [ RiskEngineConfig , LiveRiskEngineConfig ] ) – The risk engine configuration for the kernel.

  • exec_config ( Union [ ExecEngineConfig , LiveExecEngineConfig ] ) – The execution engine configuration for the kernel.

  • emulator_config ( Union [ ExecEngineConfig , LiveExecEngineConfig ] ) – The order emulator configuration for the kernel.

  • streaming_config ( StreamingConfig , optional ) – The configuration for streaming to feather files.

  • catalog_config ( DataCatalogConfig , optional ) – The data catalog configuration.

  • actor_configs ( list [ ImportableActorConfig ] , optional ) – The list of importable actor configs.

  • strategy_configs ( list [ ImportableStrategyConfig ] , optional ) – The list of importable strategy configs.

  • loop ( AbstractEventLoop , optional ) – The event loop for the kernel.

  • loop_sig_callback ( Callable , optional ) – The callback for the signal handler.

  • loop_debug ( bool , default False ) – If the event loop should run in debug mode.

  • load_state ( bool , default False ) – If strategy state should be loaded on start.

  • save_state ( bool , default False ) – If strategy state should be saved on stop.

  • log_level ( LogLevel , default LogLevel.INFO ) – The minimum log level for write to stdout.

  • log_level_file ( LogLevel , default LogLevel.DEBUG ) – The minimum log level to write to a log file.

  • log_file_path ( str , optional ) – The optional log file path. If None then will not log to a file.

  • log_rate_limit ( int , default 100_000 ) – The maximum messages per second which can be flushed to stdout or stderr.

  • bypass_logging ( bool , default False ) – If logging to stdout should be bypassed.

Raises :
  • TypeError – If environment is not of type Environment .

  • ValueError – If name is not a valid string.

  • TypeError – If any configuration object is not of the expected type.

property environment : Environment

Return the kernels environment context { BACKTEST , SANDBOX , LIVE }.

Returns :

Environment

property loop : AbstractEventLoop

Return the kernels event loop.

Returns :

AbstractEventLoop

property loop_sig_callback : Optional [ Callable ]

Return the kernels signal handling callback.

Returns :

Callable or None

property executor : Optional [ ThreadPoolExecutor ]

Return the kernels default executor.

Returns :

ThreadPoolExecutor or None

property name : str

Return the kernels name.

Returns :

str

property trader_id : TraderId

Return the kernels trader ID.

Returns :

TraderId

property machine_id : str

Return the kernels machine ID.

Returns :

str

property instance_id : UUID4

Return the kernels instance ID.

Returns :

UUID4

property ts_created : int

Return the UNIX timestamp (nanoseconds) when the kernel was created.

Returns :

uint64_t

property load_state : bool

If the kernel has been configured to load actor and strategy state.

Returns :

bool

property save_state : bool

If the kernel has been configured to save actor and strategy state.

Returns :

bool

property clock : Clock

Return the kernels clock.

Returns :

Clock

property log : LoggerAdapter

Return the kernels logger adapter.

Returns :

LoggerAdapter

property logger : Logger

Return the kernels logger.

Returns :

Logger

property msgbus : MessageBus

Return the kernels message bus.

Returns :

MessageBus

property cache : CacheFacade

Return the kernels read-only cache instance.

Returns :

CacheFacade

property portfolio : PortfolioFacade

Return the kernels read-only portfolio instance.

Returns :

PortfolioFacade

property data_engine : DataEngine

Return the kernels data engine.

Returns :

DataEngine

property risk_engine : RiskEngine

Return the kernels risk engine.

Returns :

RiskEngine

property exec_engine : ExecutionEngine

Return the kernels execution engine.

Returns :

ExecutionEngine

property emulator : OrderEmulator

Return the kernels order emulator.

Returns :

OrderEmulator

property trader : Trader

Return the kernels trader instance.

Returns :

Trader

property writer : Optional [ StreamingFeatherWriter ]

Return the kernels writer.

Returns :

StreamingFeatherWriter or None

property catalog : Optional [ ParquetDataCatalog ]

Return the kernels data catalog.

Returns :

ParquetDataCatalog or None

dispose ( ) None

Dispose of the kernel releasing system resources.

This method is idempotent and irreversible. No other methods should be called after disposal.