Skip to main content
Version: nightly

System

class NautilusKernel

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 }.

property loop : AbstractEventLoop

Return the kernels event loop.

  • Return type: AbstractEventLoop

property loop_sig_callback : Callable | None

Return the kernels signal handling callback.

  • Return type: Callable or None

property executor : ThreadPoolExecutor | None

Return the kernels default executor.

  • Return type: ThreadPoolExecutor or None

property name : str

Return the kernels name.

  • Return type: str

property trader_id : TraderId

Return the kernels trader ID.

property machine_id : str

Return the kernels machine ID.

  • Return type: str

property instance_id : UUID4

Return the kernels instance ID.

property ts_created : int

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

  • Return type: uint64_t

property load_state : bool

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

  • Return type: bool

property save_state : bool

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

  • Return type: bool

property clock : Clock

Return the kernels clock.

property logger : Logger

Return the kernels logger.

property msgbus : MessageBus

Return the kernels message bus.

property msgbus_serializer : MessageBus

Return the kernels message bus serializer (if created).

  • Return type: MsgSpecSerializer or None

property msgbus_database : MessageBus

Return the kernels message bus database (if created).

  • Return type: RedisMessageBusDatabase or None

property cache : CacheFacade

Return the kernels read-only cache instance.

property portfolio : PortfolioFacade

Return the kernels read-only portfolio instance.

property data_engine : DataEngine

Return the kernels data engine.

property risk_engine : RiskEngine

Return the kernels risk engine.

property exec_engine : ExecutionEngine

Return the kernels execution engine.

property emulator : OrderEmulator

Return the kernels order emulator.

property trader : Trader

Return the kernels trader instance.

property writer : StreamingFeatherWriter | None

Return the kernels writer.

  • Return type: StreamingFeatherWriter or None

property catalogs : dict[str, ParquetDataCatalog]

Return the kernel’s list of data catalogs.

get_log_guard() → LogGuard | LogGuard | None

Return the global logging systems log guard.

May return None if the logging system was already initialized.

  • Return type: 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.