pub trait PluginStrategy:
'static
+ Send
+ Sized {
const TYPE_NAME: &'static str;
Show 52 methods
// Required method
fn new(
host: *const HostVTable,
ctx: *const HostContext,
config_json: &str,
) -> Self;
// Provided methods
fn on_start(&mut self) -> Result<()> { ... }
fn on_stop(&mut self) -> Result<()> { ... }
fn on_resume(&mut self) -> Result<()> { ... }
fn on_reset(&mut self) -> Result<()> { ... }
fn on_dispose(&mut self) -> Result<()> { ... }
fn on_degrade(&mut self) -> Result<()> { ... }
fn on_fault(&mut self) -> Result<()> { ... }
fn on_time_event(&mut self, event: &TimeEvent) -> Result<()> { ... }
fn on_data(&mut self, data: PluginCustomDataRef) -> Result<()> { ... }
fn on_instrument(&mut self, instrument: &InstrumentAny) -> Result<()> { ... }
fn on_book_deltas(&mut self, deltas: &OrderBookDeltas) -> Result<()> { ... }
fn on_book(&mut self, book: &OrderBook) -> Result<()> { ... }
fn on_quote(&mut self, quote: &QuoteTick) -> Result<()> { ... }
fn on_trade(&mut self, trade: &TradeTick) -> Result<()> { ... }
fn on_bar(&mut self, bar: &Bar) -> Result<()> { ... }
fn on_mark_price(&mut self, mark_price: &MarkPriceUpdate) -> Result<()> { ... }
fn on_index_price(&mut self, index_price: &IndexPriceUpdate) -> Result<()> { ... }
fn on_funding_rate(
&mut self,
funding_rate: &FundingRateUpdate,
) -> Result<()> { ... }
fn on_option_greeks(&mut self, greeks: &OptionGreeks) -> Result<()> { ... }
fn on_option_chain(&mut self, chain: &OptionChainSlice) -> Result<()> { ... }
fn on_instrument_status(&mut self, status: &InstrumentStatus) -> Result<()> { ... }
fn on_instrument_close(&mut self, close: &InstrumentClose) -> Result<()> { ... }
fn on_signal(&mut self, signal: &Signal) -> Result<()> { ... }
fn on_order_initialized(&mut self, event: &OrderInitialized) -> Result<()> { ... }
fn on_order_submitted(&mut self, event: &OrderSubmitted) -> Result<()> { ... }
fn on_order_accepted(&mut self, event: &OrderAccepted) -> Result<()> { ... }
fn on_order_rejected(&mut self, event: &OrderRejected) -> Result<()> { ... }
fn on_order_filled(&mut self, event: &OrderFilled) -> Result<()> { ... }
fn on_order_canceled(&mut self, event: &OrderCanceled) -> Result<()> { ... }
fn on_order_expired(&mut self, event: &OrderExpired) -> Result<()> { ... }
fn on_order_triggered(&mut self, event: &OrderTriggered) -> Result<()> { ... }
fn on_order_denied(&mut self, event: &OrderDenied) -> Result<()> { ... }
fn on_order_emulated(&mut self, event: &OrderEmulated) -> Result<()> { ... }
fn on_order_released(&mut self, event: &OrderReleased) -> Result<()> { ... }
fn on_order_pending_update(
&mut self,
event: &OrderPendingUpdate,
) -> Result<()> { ... }
fn on_order_pending_cancel(
&mut self,
event: &OrderPendingCancel,
) -> Result<()> { ... }
fn on_order_modify_rejected(
&mut self,
event: &OrderModifyRejected,
) -> Result<()> { ... }
fn on_order_cancel_rejected(
&mut self,
event: &OrderCancelRejected,
) -> Result<()> { ... }
fn on_order_updated(&mut self, event: &OrderUpdated) -> Result<()> { ... }
fn on_position_opened(&mut self, event: &PositionOpened) -> Result<()> { ... }
fn on_position_changed(&mut self, event: &PositionChanged) -> Result<()> { ... }
fn on_position_closed(&mut self, event: &PositionClosed) -> Result<()> { ... }
fn on_market_exit(&mut self) -> Result<()> { ... }
fn on_historical_book_deltas(
&mut self,
deltas: &[OrderBookDelta],
) -> Result<()> { ... }
fn on_historical_book_depth(
&mut self,
depths: &[OrderBookDepth10],
) -> Result<()> { ... }
fn on_historical_quotes(&mut self, quotes: &[QuoteTick]) -> Result<()> { ... }
fn on_historical_trades(&mut self, trades: &[TradeTick]) -> Result<()> { ... }
fn on_historical_bars(&mut self, bars: &[Bar]) -> Result<()> { ... }
fn on_historical_mark_prices(
&mut self,
mark_prices: &[MarkPriceUpdate],
) -> Result<()> { ... }
fn on_historical_index_prices(
&mut self,
index_prices: &[IndexPriceUpdate],
) -> Result<()> { ... }
fn on_historical_funding_rates(
&mut self,
funding_rates: &[FundingRateUpdate],
) -> Result<()> { ... }
}Expand description
Author-facing trait for a plug-in strategy.
Strategies receive every callback an actor does plus position and order
lifecycle events, and they have access to a HostContext pointer
they can use to issue order commands through the host.
Every callback has a no-op default. Override only what you need.
Required Associated Constants§
Required Methods§
Sourcefn new(
host: *const HostVTable,
ctx: *const HostContext,
config_json: &str,
) -> Self
fn new( host: *const HostVTable, ctx: *const HostContext, config_json: &str, ) -> Self
Constructs a fresh strategy instance bound to the supplied host
vtable and instance context. Implementations typically store both
pointers in fields so that order-command callbacks (submit_order,
cancel_order, modify_order) can be issued through
host.submit_order(ctx, ...) etc.
config_json is the per-instance JSON configuration the host
constructed from the user’s TOML or builder API. The string is
empty when no instance-specific configuration is supplied.
Provided Methods§
fn on_start(&mut self) -> Result<()>
fn on_stop(&mut self) -> Result<()>
fn on_resume(&mut self) -> Result<()>
fn on_reset(&mut self) -> Result<()>
fn on_dispose(&mut self) -> Result<()>
fn on_degrade(&mut self) -> Result<()>
fn on_fault(&mut self) -> Result<()>
fn on_time_event(&mut self, event: &TimeEvent) -> Result<()>
fn on_data(&mut self, data: PluginCustomDataRef) -> Result<()>
fn on_instrument(&mut self, instrument: &InstrumentAny) -> Result<()>
fn on_book_deltas(&mut self, deltas: &OrderBookDeltas) -> Result<()>
fn on_book(&mut self, book: &OrderBook) -> Result<()>
fn on_quote(&mut self, quote: &QuoteTick) -> Result<()>
fn on_trade(&mut self, trade: &TradeTick) -> Result<()>
fn on_bar(&mut self, bar: &Bar) -> Result<()>
fn on_mark_price(&mut self, mark_price: &MarkPriceUpdate) -> Result<()>
fn on_index_price(&mut self, index_price: &IndexPriceUpdate) -> Result<()>
fn on_funding_rate(&mut self, funding_rate: &FundingRateUpdate) -> Result<()>
fn on_option_greeks(&mut self, greeks: &OptionGreeks) -> Result<()>
fn on_option_chain(&mut self, chain: &OptionChainSlice) -> Result<()>
fn on_instrument_status(&mut self, status: &InstrumentStatus) -> Result<()>
fn on_instrument_close(&mut self, close: &InstrumentClose) -> Result<()>
fn on_signal(&mut self, signal: &Signal) -> Result<()>
fn on_order_initialized(&mut self, event: &OrderInitialized) -> Result<()>
fn on_order_submitted(&mut self, event: &OrderSubmitted) -> Result<()>
fn on_order_accepted(&mut self, event: &OrderAccepted) -> Result<()>
fn on_order_rejected(&mut self, event: &OrderRejected) -> Result<()>
fn on_order_filled(&mut self, event: &OrderFilled) -> Result<()>
fn on_order_canceled(&mut self, event: &OrderCanceled) -> Result<()>
fn on_order_expired(&mut self, event: &OrderExpired) -> Result<()>
fn on_order_triggered(&mut self, event: &OrderTriggered) -> Result<()>
fn on_order_denied(&mut self, event: &OrderDenied) -> Result<()>
fn on_order_emulated(&mut self, event: &OrderEmulated) -> Result<()>
fn on_order_released(&mut self, event: &OrderReleased) -> Result<()>
fn on_order_pending_update(&mut self, event: &OrderPendingUpdate) -> Result<()>
fn on_order_pending_cancel(&mut self, event: &OrderPendingCancel) -> Result<()>
fn on_order_modify_rejected( &mut self, event: &OrderModifyRejected, ) -> Result<()>
fn on_order_cancel_rejected( &mut self, event: &OrderCancelRejected, ) -> Result<()>
fn on_order_updated(&mut self, event: &OrderUpdated) -> Result<()>
fn on_position_opened(&mut self, event: &PositionOpened) -> Result<()>
fn on_position_changed(&mut self, event: &PositionChanged) -> Result<()>
fn on_position_closed(&mut self, event: &PositionClosed) -> Result<()>
fn on_market_exit(&mut self) -> Result<()>
fn on_historical_book_deltas(&mut self, deltas: &[OrderBookDelta]) -> Result<()>
fn on_historical_book_depth( &mut self, depths: &[OrderBookDepth10], ) -> Result<()>
fn on_historical_quotes(&mut self, quotes: &[QuoteTick]) -> Result<()>
fn on_historical_trades(&mut self, trades: &[TradeTick]) -> Result<()>
fn on_historical_bars(&mut self, bars: &[Bar]) -> Result<()>
fn on_historical_mark_prices( &mut self, mark_prices: &[MarkPriceUpdate], ) -> Result<()>
fn on_historical_index_prices( &mut self, index_prices: &[IndexPriceUpdate], ) -> Result<()>
fn on_historical_funding_rates( &mut self, funding_rates: &[FundingRateUpdate], ) -> Result<()>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".