pub struct CompositeProfile { /* private fields */ }Expand description
Composite Profile — a multi-session volume profile reduced to its point of control and value area, built over a long composite window.
build a `bins`-bucket volume profile over the last `period` candles
POC = bin with the most volume
expand from the POC, always adding the heavier adjacent bin, until the
accumulated volume reaches `value_area_pct` of the total
VAH / VAL = the highest / lowest price includedA composite profile merges many sessions into one structure to reveal the dominant value area and control price across a longer horizon — the levels that matter for swing positioning rather than a single day. The point of control is the fairest price (heaviest trade); the value area (classically 70% of volume) brackets where the market spent most of its time. Price inside the value area is “in balance”; acceptance outside it signals a value migration.
The first value lands after period candles; each update rebuilds the
profile in O(period · bins).
§Example
use wickra_core::{Candle, Indicator, CompositeProfile};
let mut indicator = CompositeProfile::new(100, 50, 0.70).unwrap();
let mut last = None;
for i in 0..150 {
let base = 100.0 + (f64::from(i) * 0.1).sin() * 8.0;
let c = Candle::new(base, base + 1.0, base - 1.0, base, 1_000.0, 0).unwrap();
last = indicator.update(c);
}
assert!(last.is_some());Implementations§
Source§impl CompositeProfile
impl CompositeProfile
Sourcepub fn new(period: usize, bins: usize, value_area_pct: f64) -> Result<Self>
pub fn new(period: usize, bins: usize, value_area_pct: f64) -> Result<Self>
Construct a Composite Profile.
§Errors
Returns Error::PeriodZero if period or bins is zero, or
Error::InvalidParameter if value_area_pct is not in (0, 1].
Sourcepub const fn value(&self) -> Option<CompositeProfileOutput>
pub const fn value(&self) -> Option<CompositeProfileOutput>
Current value if available.
Trait Implementations§
Source§impl Clone for CompositeProfile
impl Clone for CompositeProfile
Source§fn clone(&self) -> CompositeProfile
fn clone(&self) -> CompositeProfile
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CompositeProfile
impl Debug for CompositeProfile
Source§impl Indicator for CompositeProfile
impl Indicator for CompositeProfile
Source§type Input = Candle
type Input = Candle
f64 for a price, or Candle / Tick).Source§type Output = CompositeProfileOutput
type Output = CompositeProfileOutput
Source§fn update(&mut self, candle: Candle) -> Option<CompositeProfileOutput>
fn update(&mut self, candle: Candle) -> Option<CompositeProfileOutput>
None if the indicator is still warming up.Source§fn reset(&mut self)
fn reset(&mut self)
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
None output can be produced.Auto Trait Implementations§
impl Freeze for CompositeProfile
impl RefUnwindSafe for CompositeProfile
impl Send for CompositeProfile
impl Sync for CompositeProfile
impl Unpin for CompositeProfile
impl UnsafeUnpin for CompositeProfile
impl UnwindSafe for CompositeProfile
Blanket Implementations§
Source§impl<T> BatchExt for Twhere
T: Indicator,
impl<T> BatchExt for Twhere
T: Indicator,
Source§fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
None during warmup) per input.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