System ¶
- class NautilusKernel ( name : str , config : NautilusKernelConfig , loop : asyncio.events.AbstractEventLoop | None = None , loop_sig_callback : collections.abc.Callable | None = None ) ¶
-
Bases:
object
Provides the core Nautilus system kernel.
The kernel is common between
backtest
,sandbox
andlive
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’).
-
- 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 : collections.abc.Callable | 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 :
-
str
- property machine_id : str ¶
-
Return the kernels machine ID.
- Returns :
-
str
- 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 log : LoggerAdapter ¶
-
Return the kernels logger adapter.
- Returns :
-
LoggerAdapter
- 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 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
- 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.