pub struct CompletedPosition {Show 26 fields
pub position_id: String,
pub symbol: String,
pub side: Side,
pub group: Option<String>,
pub trade_id: Option<String>,
pub open_ts: NaiveDateTime,
pub close_ts: NaiveDateTime,
pub entry_size: f64,
pub average_entry_price: f64,
pub net_pnl: f64,
pub gross_pnl: Option<f64>,
pub commission_total: f64,
pub swap_total: f64,
pub native_net_pnl: Option<f64>,
pub native_currency: Option<String>,
pub outcome: NetPnlOutcome,
pub pnl_epsilon: f64,
pub initial_stop: Option<f64>,
pub effective_stop: Option<EffectiveStop>,
pub risk_basis_status: RiskBasisStatus,
pub risk_tranches: Vec<RiskTranche>,
pub realized_r: Option<f64>,
pub mae: Option<f64>,
pub mfe: Option<f64>,
pub close_reasons: Vec<CloseReason>,
pub close_events: Vec<CloseEvent>,
}Expand description
Complete campaign-level outcome for one position.
Fields§
§position_id: String§symbol: String§side: Side§group: Option<String>§trade_id: Option<String>§open_ts: NaiveDateTime§close_ts: NaiveDateTime§entry_size: f64§average_entry_price: f64§net_pnl: f64Realized profit and loss net of every commission and swap charged to this position.
gross_pnl: Option<f64>Realized profit and loss before any commission or swap, present only when a cost was charged.
commission_total: f64Total account-currency commission charged on entry and exit fills.
swap_total: f64Total account-currency swap charged while the position was open.
native_net_pnl: Option<f64>§native_currency: Option<String>§outcome: NetPnlOutcome§pnl_epsilon: f64§initial_stop: Option<f64>§effective_stop: Option<EffectiveStop>§risk_basis_status: RiskBasisStatus§risk_tranches: Vec<RiskTranche>§realized_r: Option<f64>Net P&L divided by total valid initial monetary risk.
mae: Option<f64>Minimum campaign P&L observed from a zero baseline (normally <= 0).
mfe: Option<f64>Maximum campaign P&L observed from a zero baseline (normally >= 0).
close_reasons: Vec<CloseReason>Distinct close reasons in first-observed order.
close_events: Vec<CloseEvent>Implementations§
Source§impl CompletedPosition
impl CompletedPosition
pub fn from_close_events( position_id: impl Into<String>, symbol: impl Into<String>, side: Side, open_ts: NaiveDateTime, close_ts: NaiveDateTime, entry_size: f64, average_entry_price: f64, initial_stop: Option<f64>, effective_stop: Option<EffectiveStop>, risk_tranches: Vec<RiskTranche>, close_events: Vec<CloseEvent>, mae: Option<f64>, mfe: Option<f64>, epsilon: f64, ) -> Self
pub fn classify(net_pnl: f64, epsilon: f64) -> NetPnlOutcome
pub fn initial_risk(&self) -> Option<f64>
Sourcepub fn charge_position_costs(&mut self, entry_commission: f64, swap: f64)
pub fn charge_position_costs(&mut self, entry_commission: f64, swap: f64)
Fold costs that are not attributable to a single close event into the net result.
Exit commission is already subtracted from each close event’s profit and loss, so only entry commission and swap are applied here. The call is a no-op when nothing was charged, which keeps cost-free runs byte-identical to runs produced before costs existed.