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
}.
- Return type: Environment
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.
- Return type: TraderId
property machine_id : str
Return the kernels machine ID.
- Return type: str
property instance_id : UUID4
Return the kernels instance ID.
- Return type: UUID4
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.
- Return type: Clock
property logger : Logger
Return the kernels logger.
- Return type: Logger
property msgbus : MessageBus
Return the kernels message bus.
- Return type: MessageBus
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.
- Return type: CacheFacade
property portfolio : PortfolioFacade
Return the kernels read-only portfolio instance.
- Return type: PortfolioFacade
property data_engine : DataEngine
Return the kernels data engine.
- Return type: DataEngine
property risk_engine : RiskEngine
Return the kernels risk engine.
- Return type: RiskEngine
property exec_engine : ExecutionEngine
Return the kernels execution engine.
- Return type: ExecutionEngine
property emulator : OrderEmulator
Return the kernels order emulator.
- Return type: OrderEmulator
property trader : Trader
Return the kernels trader instance.
- Return type: Trader
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.
- Return type: dict[str, ParquetDataCatalog]
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.