NautilusKernel

Struct NautilusKernel 

Source
pub struct NautilusKernel {
Show 16 fields pub name: String, pub instance_id: UUID4, pub machine_id: String, pub config: Box<dyn NautilusKernelConfig>, pub cache: Rc<RefCell<Cache>>, pub clock: Rc<RefCell<dyn Clock>>, pub portfolio: Rc<RefCell<Portfolio>>, pub log_guard: LogGuard, pub data_engine: Rc<RefCell<DataEngine>>, pub risk_engine: Rc<RefCell<RiskEngine>>, pub exec_engine: Rc<RefCell<ExecutionEngine>>, pub order_emulator: OrderEmulatorAdapter, pub trader: Trader, pub ts_created: UnixNanos, pub ts_started: Option<UnixNanos>, pub ts_shutdown: Option<UnixNanos>,
}
Expand description

Core Nautilus system kernel.

Orchestrates data and execution engines, cache, clock, and messaging across environments.

Fields§

§name: String

The kernel name (for logging and identification).

§instance_id: UUID4

The unique instance identifier for this kernel.

§machine_id: String

The machine identifier (hostname or similar).

§config: Box<dyn NautilusKernelConfig>

The kernel configuration.

§cache: Rc<RefCell<Cache>>

The shared in-memory cache.

§clock: Rc<RefCell<dyn Clock>>

The clock driving the kernel.

§portfolio: Rc<RefCell<Portfolio>>

The portfolio manager.

§log_guard: LogGuard

Guard for the logging subsystem (keeps logger thread alive).

§data_engine: Rc<RefCell<DataEngine>>

The data engine instance.

§risk_engine: Rc<RefCell<RiskEngine>>

The risk engine instance.

§exec_engine: Rc<RefCell<ExecutionEngine>>

The execution engine instance.

§order_emulator: OrderEmulatorAdapter

The order emulator for handling emulated orders.

§trader: Trader

The trader component.

§ts_created: UnixNanos

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

§ts_started: Option<UnixNanos>

The UNIX timestamp (nanoseconds) when the kernel was last started.

§ts_shutdown: Option<UnixNanos>

The UNIX timestamp (nanoseconds) when the kernel was last shutdown.

Implementations§

Source§

impl NautilusKernel

Source

pub const fn builder( name: String, trader_id: TraderId, environment: Environment, ) -> NautilusKernelBuilder

Create a new NautilusKernelBuilder for fluent configuration.

Source

pub fn new<T: NautilusKernelConfig + 'static>( name: String, config: T, ) -> Result<Self>

Create a new NautilusKernel instance.

§Errors

Returns an error if the kernel fails to initialize.

Source

pub fn generate_timestamp_ns(&self) -> UnixNanos

Source

pub fn environment(&self) -> Environment

Returns the kernel’s environment context (Backtest, Sandbox, Live).

Source

pub const fn name(&self) -> &str

Returns the kernel’s name.

Source

pub fn trader_id(&self) -> TraderId

Returns the kernel’s trader ID.

Source

pub fn machine_id(&self) -> &str

Returns the kernel’s machine ID.

Source

pub const fn instance_id(&self) -> UUID4

Returns the kernel’s instance ID.

Source

pub fn delay_post_stop(&self) -> Duration

Returns the delay after stopping the node to await residual events before final shutdown.

Source

pub const fn ts_created(&self) -> UnixNanos

Returns the UNIX timestamp (ns) when the kernel was created.

Source

pub const fn ts_started(&self) -> Option<UnixNanos>

Returns the UNIX timestamp (ns) when the kernel was last started.

Source

pub const fn ts_shutdown(&self) -> Option<UnixNanos>

Returns the UNIX timestamp (ns) when the kernel was last shutdown.

Source

pub fn load_state(&self) -> bool

Returns whether the kernel has been configured to load state.

Source

pub fn save_state(&self) -> bool

Returns whether the kernel has been configured to save state.

Source

pub fn clock(&self) -> Rc<RefCell<dyn Clock>>

Returns the kernel’s clock.

Source

pub fn cache(&self) -> Rc<RefCell<Cache>>

Returns the kernel’s cache.

Source

pub fn portfolio(&self) -> Ref<'_, Portfolio>

Returns the kernel’s portfolio.

Source

pub fn data_engine(&self) -> Ref<'_, DataEngine>

Returns the kernel’s data engine.

Source

pub const fn risk_engine(&self) -> &Rc<RefCell<RiskEngine>>

Returns the kernel’s risk engine.

Source

pub const fn exec_engine(&self) -> &Rc<RefCell<ExecutionEngine>>

Returns the kernel’s execution engine.

Source

pub const fn trader(&self) -> &Trader

Returns the kernel’s trader.

Source

pub async fn start_async(&mut self)

Starts the Nautilus system kernel.

Source

pub fn start_trader(&mut self)

Starts the trader (strategies and actors).

This should be called after clients are connected and instruments are cached.

Source

pub fn stop_trader(&mut self)

Stops the trader and its registered components.

This method initiates a graceful shutdown of trading components (strategies, actors) which may trigger residual events such as order cancellations. The caller should continue processing events after calling this method to handle these residual events.

Source

pub async fn finalize_stop(&mut self)

Finalizes the kernel shutdown after the grace period.

This method should be called after the residual events grace period has elapsed and all remaining events have been processed. It disconnects clients and stops engines.

Source

pub fn reset(&mut self)

Resets the Nautilus system kernel to its initial state.

Source

pub fn dispose(&mut self)

Disposes of the Nautilus system kernel, releasing resources.

Source

pub async fn connect_clients(&mut self) -> Result<()>

Connects all engine clients.

§Errors

Returns an error if any client fails to connect.

Source

pub async fn disconnect_clients(&mut self) -> Result<()>

Disconnects all engine clients.

§Errors

Returns an error if any client fails to disconnect.

Source

pub fn check_engines_connected(&self) -> bool

Returns true if all engine clients are connected.

Source

pub fn check_engines_disconnected(&self) -> bool

Returns true if all engine clients are disconnected.

Trait Implementations§

Source§

impl Debug for NautilusKernel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more