pub struct StrategyCore {
pub config: StrategyConfig,
/* private fields */
}Expand description
The core component of a Strategy, managing data, orders,
and state.
This struct is intended to be held as a member within a user’s custom strategy struct.
Use the nautilus_strategy! macro to provide the trait accessors required by
Strategy, StrategyNative, and
DataActor. It does not deref to
[DataActorCore]; normal strategy logic should use facade methods on the
strategy value.
Fields§
§config: StrategyConfigThe strategy configuration.
Implementations§
Source§impl StrategyCore
impl StrategyCore
Sourcepub fn new(config: StrategyConfig) -> Self
pub fn new(config: StrategyConfig) -> Self
Creates a new StrategyCore instance.
Sourcepub fn config(&self) -> &StrategyConfig
pub fn config(&self) -> &StrategyConfig
Returns the strategy configuration.
Sourcepub fn change_id(&mut self, strategy_id: StrategyId)
pub fn change_id(&mut self, strategy_id: StrategyId)
Changes the strategy ID before registration.
Sourcepub fn change_order_id_tag(&mut self, order_id_tag: &str)
pub fn change_order_id_tag(&mut self, order_id_tag: &str)
Changes the order ID tag before registration.
Sourcepub fn order_id_tag(&self) -> Option<&str>
pub fn order_id_tag(&self) -> Option<&str>
Returns the runtime order ID tag.
Sourcepub fn strategy_id(&self) -> Option<StrategyId>
pub fn strategy_id(&self) -> Option<StrategyId>
Returns the runtime strategy ID.
Sourcepub fn register(
&mut self,
trader_id: TraderId,
clock: Rc<RefCell<dyn Clock>>,
cache: Rc<RefCell<Cache>>,
portfolio: Rc<RefCell<Portfolio>>,
) -> Result<()>
pub fn register( &mut self, trader_id: TraderId, clock: Rc<RefCell<dyn Clock>>, cache: Rc<RefCell<Cache>>, portfolio: Rc<RefCell<Portfolio>>, ) -> Result<()>
Registers the strategy with the trading engine components.
This is typically called by the framework when the strategy is added to an engine.
§Errors
Returns an error if registration with the actor core fails.
Sourcepub fn reset_market_exit_state(&mut self)
pub fn reset_market_exit_state(&mut self)
Resets the market exit state.