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: DataActorCoreThe underlying data actor core.
config: ExecutionAlgorithmConfigThe execution algorithm configuration.
exec_algorithm_id: ExecAlgorithmIdThe execution algorithm ID.
Implementations§
Source§impl ExecutionAlgorithmCore
impl ExecutionAlgorithmCore
Sourcepub fn new(config: ExecutionAlgorithmConfig) -> Self
pub fn new(config: ExecutionAlgorithmConfig) -> Self
Sourcepub fn register(
&mut self,
trader_id: TraderId,
clock: Rc<RefCell<dyn Clock>>,
cache: Rc<RefCell<Cache>>,
) -> Result<()>
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.
Sourcepub fn id(&self) -> ExecAlgorithmId
pub fn id(&self) -> ExecAlgorithmId
Returns the execution algorithm ID.
Sourcepub fn spawn_client_order_id(
&mut self,
primary_id: &ClientOrderId,
) -> ClientOrderId
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}.
Sourcepub fn spawn_sequence(&self, primary_id: &ClientOrderId) -> Option<u32>
pub fn spawn_sequence(&self, primary_id: &ClientOrderId) -> Option<u32>
Returns the current spawn sequence for a primary order, if any.
Sourcepub fn is_strategy_subscribed(&self, strategy_id: &StrategyId) -> bool
pub fn is_strategy_subscribed(&self, strategy_id: &StrategyId) -> bool
Checks if a strategy has been subscribed to for events.
Sourcepub fn add_subscribed_strategy(&mut self, strategy_id: StrategyId)
pub fn add_subscribed_strategy(&mut self, strategy_id: StrategyId)
Marks a strategy as subscribed for events.
Sourcepub fn store_strategy_event_handlers(
&mut self,
strategy_id: StrategyId,
handlers: StrategyEventHandlers,
)
pub fn store_strategy_event_handlers( &mut self, strategy_id: StrategyId, handlers: StrategyEventHandlers, )
Stores the event handlers for a strategy subscription.
Sourcepub fn take_strategy_event_handlers(
&mut self,
) -> IndexMap<StrategyId, StrategyEventHandlers>
pub fn take_strategy_event_handlers( &mut self, ) -> IndexMap<StrategyId, StrategyEventHandlers>
Takes and returns all stored strategy event handlers, clearing the internal map.
Sourcepub fn clear_spawn_ids(&mut self)
pub fn clear_spawn_ids(&mut self)
Clears all spawn tracking state.
Sourcepub fn clear_subscribed_strategies(&mut self)
pub fn clear_subscribed_strategies(&mut self)
Clears all strategy subscriptions.
Sourcepub fn track_pending_spawn_reduction(
&mut self,
spawn_id: ClientOrderId,
quantity: Quantity,
)
pub fn track_pending_spawn_reduction( &mut self, spawn_id: ClientOrderId, quantity: Quantity, )
Tracks a pending spawn reduction for potential restoration.
Sourcepub fn take_pending_spawn_reduction(
&mut self,
spawn_id: &ClientOrderId,
) -> Option<Quantity>
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.
Sourcepub fn clear_pending_spawn_reductions(&mut self)
pub fn clear_pending_spawn_reductions(&mut self)
Clears all pending spawn reductions.
Sourcepub fn reset(&mut self)
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.