pub struct PriceStats {
pub closed_count: i64,
pub win_rate: f64,
pub avg_pnl: f64,
pub total_pnl: f64,
}Expand description
Summary of price deltas within ONE instrument (or another explicitly common unit).
Fields§
§closed_count: i64§win_rate: f64§avg_pnl: f64§total_pnl: f64Implementations§
Source§impl PriceStats
impl PriceStats
Sourcepub fn compute(values: impl IntoIterator<Item = Option<f64>>) -> Self
pub fn compute(values: impl IntoIterator<Item = Option<f64>>) -> Self
closed_count counts every value, None included; win_rate = wins / closed_count, a win
being a value > 0; total_pnl sums the present values and avg_pnl = total_pnl / present count. NULL outcomes thus count as closed (and not won), but do not enter the mean,
matching stored legacy rows. All zero for no values.
Sourcepub fn merge(values: impl IntoIterator<Item = Self>) -> Self
pub fn merge(values: impl IntoIterator<Item = Self>) -> Self
Merge disjoint summaries in the same price unit: counts and totals add up, win_rate is
weighted by closed_count, and avg_pnl = total_pnl / closed_count. The present count is
not kept in a summary, so where the inputs held None values this mean differs from
PriceStats::compute over the combined values, which divides by the present count.
Trait Implementations§
Source§impl Clone for PriceStats
impl Clone for PriceStats
Source§fn clone(&self) -> PriceStats
fn clone(&self) -> PriceStats
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for PriceStats
Source§impl Debug for PriceStats
impl Debug for PriceStats
Source§impl Default for PriceStats
impl Default for PriceStats
Source§fn default() -> PriceStats
fn default() -> PriceStats
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for PriceStats
impl RefUnwindSafe for PriceStats
impl Send for PriceStats
impl Sync for PriceStats
impl Unpin for PriceStats
impl UnsafeUnpin for PriceStats
impl UnwindSafe for PriceStats
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
Mutably borrows from an owned value. Read more