Skip to main content

StrategyCore

Struct StrategyCore 

Source
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: StrategyConfig

The strategy configuration.

Implementations§

Source§

impl StrategyCore

Source

pub fn new(config: StrategyConfig) -> Self

Creates a new StrategyCore instance.

Source

pub fn config(&self) -> &StrategyConfig

Returns the strategy configuration.

Source

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

Changes the strategy ID before registration.

Source

pub fn change_order_id_tag(&mut self, order_id_tag: &str)

Changes the order ID tag before registration.

Source

pub fn order_id_tag(&self) -> Option<&str>

Returns the runtime order ID tag.

Source

pub fn strategy_id(&self) -> Option<StrategyId>

Returns the runtime strategy ID.

Source

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.

Source

pub fn order(&self) -> OrderApi<'_>

Returns the user-facing order creation API.

§Panics

Panics if the strategy has not been registered.

Source

pub fn reset_market_exit_state(&mut self)

Resets the market exit state.

Trait Implementations§

Source§

impl DataActorNative for StrategyCore

Source§

fn core(&self) -> &DataActorCore

Returns the actor core.
Source§

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

Returns the mutable actor core.
§

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

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

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

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

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

Returns a read-only cache borrow. Read more
§

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

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

impl Debug for StrategyCore

Source§

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

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

impl StrategyNative for StrategyCore

Source§

fn strategy_core(&self) -> &StrategyCore

Returns the strategy core.
Source§

fn strategy_core_mut(&mut self) -> &mut StrategyCore

Returns the mutable strategy core.
Source§

fn order_factory(&mut self) -> RefMut<'_, OrderFactory>

Returns a mutable borrow of the order factory. Read more
Source§

fn order_factory_rc(&self) -> Rc<RefCell<OrderFactory>>

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

fn portfolio_rc(&self) -> Rc<RefCell<Portfolio>>

Returns a clone of the reference-counted portfolio. 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
§

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

§

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.

§

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.

§

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.
§

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