Enum StrategyEvent
pub enum StrategyEvent {
Config {
initial_capital: f64,
commission_type: CommissionType,
commission_value: f64,
margin_long: f64,
margin_short: f64,
slippage: f64,
pyramiding: u32,
risk_free_rate: f64,
process_orders_on_close: bool,
calc_on_order_fills: bool,
close_entries_rule: CloseEntriesRule,
},
OrderSubmitted {
id: String,
direction: Direction,
order_type: OrderType,
quantity: f64,
comment: String,
},
OrderFilled {
id: String,
direction: Direction,
price: f64,
quantity: f64,
commission: f64,
comment: String,
},
OrderCancelled {
id: String,
},
TradeOpened {
entry_id: String,
entry_comment: String,
direction: Direction,
entry_price: f64,
quantity: f64,
commission: f64,
bar_index: usize,
bar_time: i64,
},
TradeClosed {Show 13 fields
entry_id: String,
exit_id: String,
exit_comment: String,
exit_price: f64,
profit: f64,
profit_percent: f64,
max_runup: f64,
max_runup_percent: f64,
max_drawdown: f64,
max_drawdown_percent: f64,
commission: f64,
bar_index: usize,
bar_time: i64,
},
OpenTradeUpdated {
entry_id: String,
profit: f64,
profit_percent: f64,
max_runup: f64,
max_runup_percent: f64,
max_drawdown: f64,
max_drawdown_percent: f64,
},
EquitySnapshot {
equity: f64,
buy_hold_equity: f64,
},
DailyReturn {
date: i32,
return_percent: f64,
},
MarginCall {
direction: Direction,
position_size: f64,
liquidation_price: f64,
},
RiskFlatten {
reason: String,
},
}Expand description
Events emitted by the strategy engine during execution.
These events can be consumed by a
StrategyAccumulator to reconstruct a full
StrategyReport.
Variants§
Config
Strategy configuration snapshot, emitted once on the first bar.
Fields
commission_type: CommissionTypeCommission calculation mode.
close_entries_rule: CloseEntriesRuleEntry close rule.
OrderSubmitted
An order has been submitted.
Fields
OrderFilled
An order has been filled.
Fields
OrderCancelled
An order has been cancelled.
TradeOpened
A new position has been opened.
Fields
TradeClosed
A position has been closed.
Fields
entry_id: StringEntry order identifier (matches
TradeOpened::entry_id).
OpenTradeUpdated
Per-bar update of an open trade’s unrealized P&L and excursions.
Static fields (direction, entry_price, quantity, commission) are
available from the corresponding TradeOpened.
Fields
entry_id: StringEntry order identifier (matches
TradeOpened::entry_id).
EquitySnapshot
Per-bar equity snapshot for curve reconstruction.
The drawdown curve can be derived by tracking peak equity:
drawdown = peak_equity - equity.
DailyReturn
Daily return for Sharpe / Sortino calculation.
Fields
MarginCall
Margin call event.
Fields
RiskFlatten
Risk-management forced liquidation.
Trait Implementations§
§impl Clone for StrategyEvent
impl Clone for StrategyEvent
§fn clone(&self) -> StrategyEvent
fn clone(&self) -> StrategyEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for StrategyEvent
impl Debug for StrategyEvent
§impl<'de> Deserialize<'de> for StrategyEvent
impl<'de> Deserialize<'de> for StrategyEvent
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<StrategyEvent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<StrategyEvent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Serialize for StrategyEvent
impl Serialize for StrategyEvent
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for StrategyEvent
impl RefUnwindSafe for StrategyEvent
impl Send for StrategyEvent
impl Sync for StrategyEvent
impl Unpin for StrategyEvent
impl UnsafeUnpin for StrategyEvent
impl UnwindSafe for StrategyEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.