Skip to main content

ExecutionAlgorithmCore

Struct ExecutionAlgorithmCore 

Source
pub struct ExecutionAlgorithmCore {
    pub actor: DataActorCore,
    pub config: ExecutionAlgorithmConfig,
    pub exec_algorithm_id: ExecAlgorithmId,
    /* private fields */
}
Expand description

The core component of an ExecutionAlgorithm.

This struct manages the internal state for execution algorithms including spawn ID tracking and strategy subscriptions. It wraps a DataActorCore to provide data actor capabilities.

User algorithms should hold this as a member and use the nautilus_execution_algorithm! macro to provide native runtime wiring. Direct access to this core is native runtime wiring and belongs behind ExecutionAlgorithmNative.

Fields§

§actor: DataActorCore

The underlying data actor core.

§config: ExecutionAlgorithmConfig

The execution algorithm configuration.

§exec_algorithm_id: ExecAlgorithmId

The execution algorithm ID.

Implementations§

Source§

impl ExecutionAlgorithmCore

Source

pub fn new(config: ExecutionAlgorithmConfig) -> Self

Creates a new ExecutionAlgorithmCore instance.

§Panics

Panics if config.exec_algorithm_id is None.

Source

pub fn register( &mut self, trader_id: TraderId, clock: Rc<RefCell<dyn Clock>>, cache: Rc<RefCell<Cache>>, ) -> Result<()>

Registers the execution algorithm with the trading engine components.

§Errors

Returns an error if registration with the actor core fails.

Source

pub fn id(&self) -> ExecAlgorithmId

Returns the execution algorithm ID.

Source

pub fn spawn_client_order_id( &mut self, primary_id: &ClientOrderId, ) -> ClientOrderId

Generates the next spawn client order ID for a primary order.

The generated ID follows the pattern: {primary_id}-E{sequence}.

Source

pub fn spawn_sequence(&self, primary_id: &ClientOrderId) -> Option<u32>

Returns the current spawn sequence for a primary order, if any.

Source

pub fn is_strategy_subscribed(&self, strategy_id: &StrategyId) -> bool

Checks if a strategy has been subscribed to for events.

Source

pub fn add_subscribed_strategy(&mut self, strategy_id: StrategyId)

Marks a strategy as subscribed for events.

Source

pub fn store_strategy_event_handlers( &mut self, strategy_id: StrategyId, handlers: StrategyEventHandlers, )

Stores the event handlers for a strategy subscription.

Source

pub fn take_strategy_event_handlers( &mut self, ) -> IndexMap<StrategyId, StrategyEventHandlers>

Takes and returns all stored strategy event handlers, clearing the internal map.

Source

pub fn clear_spawn_ids(&mut self)

Clears all spawn tracking state.

Source

pub fn clear_subscribed_strategies(&mut self)

Clears all strategy subscriptions.

Source

pub fn track_pending_spawn_reduction( &mut self, spawn_id: ClientOrderId, quantity: Quantity, )

Tracks a pending spawn reduction for potential restoration.

Source

pub fn take_pending_spawn_reduction( &mut self, spawn_id: &ClientOrderId, ) -> Option<Quantity>

Removes and returns the pending spawn reduction for an order, if any.

Source

pub fn clear_pending_spawn_reductions(&mut self)

Clears all pending spawn reductions.

Source

pub fn reset(&mut self)

Resets the core to its initial state.

Note: This clears handler storage but does NOT unsubscribe from msgbus. Call unsubscribe_all_strategy_events first to properly unsubscribe.

Source

pub fn get_order(&self, client_order_id: &ClientOrderId) -> Result<OrderAny>

Returns the order for the given client order ID from the cache.

§Errors

Returns an error if the order is not found in the cache.

Source

pub fn get_orders_for_list( &self, order_list: &OrderList, ) -> Result<Vec<OrderAny>>

Returns all orders for the given order list from the cache.

§Errors

Returns an error if any order is not found in the cache.

Trait Implementations§

Source§

impl DataActorNative for ExecutionAlgorithmCore

Source§

fn core(&self) -> &DataActorCore

Returns the actor core.
Source§

fn core_mut(&mut self) -> &mut DataActorCore

Returns the mutable actor core.
Source§

fn clock_mut(&mut self) -> RefMut<'_, dyn Clock + 'static>

Returns the mutable clock borrow for the actor. Read more
Source§

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

Returns a clone of the reference-counted clock. Read more
Source§

fn cache_ref(&self) -> Ref<'_, Cache>

Returns a read-only cache borrow. Read more
Source§

fn cache_rc(&self) -> Rc<RefCell<Cache>>

Returns a clone of the reference-counted cache. Read more
Source§

impl Debug for ExecutionAlgorithmCore

Source§

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

Formats the value using the given formatter. Read more
Source§

impl ExecutionAlgorithmNative for ExecutionAlgorithmCore

Source§

fn exec_algorithm_core(&self) -> &ExecutionAlgorithmCore

Returns the execution algorithm core.
Source§

fn exec_algorithm_core_mut(&mut self) -> &mut ExecutionAlgorithmCore

Returns the mutable execution algorithm core.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.