pub struct TradeResult {Show 14 fields
pub position_id: PositionId,
pub symbol: String,
pub side: Side,
pub entry_price: f64,
pub exit_price: f64,
pub size: f64,
pub pnl: f64,
pub commission: f64,
pub swap: f64,
pub gross_pnl: Option<f64>,
pub open_ts: NaiveDateTime,
pub close_ts: NaiveDateTime,
pub close_reason: CloseReason,
pub group: Option<GroupId>,
}Expand description
Result of a single closed trade (or partial close).
Fields§
§position_id: PositionId§symbol: String§side: Side§entry_price: f64§exit_price: f64§size: f64§pnl: f64Realized profit and loss for this close, already net of commission and swap.
commission: f64Account-currency commission settled on this row and already subtracted from pnl.
This close’s own exit commission always settles here. The row that fully closes a position additionally settles that position’s entry commission, because entry commission belongs to the position rather than to any one close. Summing this column over a position therefore reproduces CompletedPosition::commission_total, while an individual row of a partially closed position carries only its own exit commission.
swap: f64Account-currency swap settled on this row and already subtracted from pnl.
Swap accrues to a position rather than to a close, so it settles entirely on the row that fully closes the position and is zero on every other row.
gross_pnl: Option<f64>Profit and loss before commission and swap, present only when either was settled.
open_ts: NaiveDateTime§close_ts: NaiveDateTime§close_reason: CloseReason§group: Option<GroupId>Group this position belonged to (for per-group reporting).