class NautilusKernel ( name : str , config : NautilusKernelConfig , loop : | None = None , loop_sig_callback : | None = None )

Bases: object

Provides the core Nautilus system kernel.

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

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

  • config ( NautilusKernelConfig ) – The configuration for the kernel instance.

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

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

Raises :
  • ValueError – If name is not a valid string.

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

  • InvalidConfiguration – If any configuration object is mismatched with the environment context, (live configurations for ‘backtest’, or backtest configurations for ‘live’).

  • InvalidConfiguration – If LoggingConfig.bypass_logging is set true in a LIVE context.

property environment : Environment

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

Returns :


property loop : AbstractEventLoop

Return the kernels event loop.

Returns :


property loop_sig_callback : | None

Return the kernels signal handling callback.

Returns :

Callable or None

property executor : concurrent.futures.thread.ThreadPoolExecutor | None

Return the kernels default executor.

Returns :

ThreadPoolExecutor or None

property name : str

Return the kernels name.

Returns :


property trader_id : TraderId

Return the kernels trader ID.

Returns :


property machine_id : str

Return the kernels machine ID.

Returns :


property instance_id : UUID4

Return the kernels instance ID.

Returns :


property ts_created : int

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

Returns :


property load_state : bool

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

Returns :


property save_state : bool

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

Returns :


property clock : Clock

Return the kernels clock.

Returns :


property logger : Logger

Return the kernels logger.

Returns :


property msgbus : MessageBus

Return the kernels message bus.

Returns :


property cache : CacheFacade

Return the kernels read-only cache instance.

Returns :


property portfolio : PortfolioFacade

Return the kernels read-only portfolio instance.

Returns :


property data_engine : DataEngine

Return the kernels data engine.

Returns :


property risk_engine : RiskEngine

Return the kernels risk engine.

Returns :


property exec_engine : ExecutionEngine

Return the kernels execution engine.

Returns :


property emulator : OrderEmulator

Return the kernels order emulator.

Returns :


property trader : Trader

Return the kernels trader instance.

Returns :


property writer : nautilus_trader.persistence.writer.StreamingFeatherWriter | None

Return the kernels writer.

Returns :

StreamingFeatherWriter or None

property catalog : nautilus_trader.persistence.catalog.parquet.ParquetDataCatalog | None

Return the kernels data catalog.

Returns :

ParquetDataCatalog or None

get_log_guard ( ) nautilus_trader.core.nautilus_pyo3.common.LogGuard | nautilus_trader.common.component.LogGuard | None

Return the global logging systems log guard.

May return None if the logging system was already initialized.

Returns :

nautilus_pyo3.LogGuard | LogGuard | None

start ( ) None

Start the Nautilus system kernel.

async start_async ( ) None

Start the Nautilus system kernel in an asynchronous context with an event loop.

Raises :

RuntimeError – If no event loop has been assigned to the kernel.

async stop ( ) None

Stop the Nautilus system kernel.

async stop_async ( ) None

Stop the Nautilus system kernel asynchronously.

After a specified delay the internal Trader residual state will be checked.

If save strategy is configured, then strategy states will be saved.

Raises :

RuntimeError – If no event loop has been assigned to the kernel.

dispose ( ) None

Dispose of the Nautilus kernel, releasing system resources.

Calling this method multiple times has the same effect as calling it once (it is idempotent). Once called, it cannot be reversed, and no other methods should be called on this instance.

cancel_all_tasks ( ) None

Cancel all tasks currently running for the Nautilus kernel.

Raises :

RuntimeError – If no event loop has been assigned to the kernel.