Skip to main content

StrategyNative

Trait StrategyNative 

Source
pub trait StrategyNative {
    // Required methods
    fn strategy_core(&self) -> &StrategyCore;
    fn strategy_core_mut(&mut self) -> &mut StrategyCore;

    // Provided methods
    fn order_factory(&mut self) -> RefMut<'_, OrderFactory> { ... }
    fn order_factory_rc(&self) -> Rc<RefCell<OrderFactory>> { ... }
    fn portfolio_rc(&self) -> Rc<RefCell<Portfolio>> { ... }
}
Expand description

Native-only access to internal strategy runtime state.

Use this trait from engine, runtime, testkit, or opt-in native strategy code when direct access to host runtime objects matters for an explicit latency-sensitive path, or when host integration code needs access below the facade API.

Do not import this trait in strategy code intended to run through Python or the plug-in authoring surface. Those surfaces should use facade methods such as order() and portfolio(), because native borrows, Rc<RefCell<_>>, and core references do not cross those boundaries.

Required Methods§

Source

fn strategy_core(&self) -> &StrategyCore

Returns the strategy core.

Source

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

Returns the mutable strategy core.

Provided Methods§

Source

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

Returns a mutable borrow of the order factory.

§Panics

Panics if the strategy has not been registered.

Source

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

Returns a clone of the reference-counted order factory.

§Panics

Panics if the strategy has not been registered.

Source

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

Returns a clone of the reference-counted portfolio.

§Panics

Panics if the strategy has not been registered.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§