pub struct ProfileShape { /* private fields */ }Expand description
Profile Shape — classifies a rolling volume profile by where its point of
control (POC) sits within the range: b, P, or D (normal).
build a `bins`-bucket volume profile over the last `period` candles
poc_idx = bin with the most volume
+1 P-shape : POC in the upper third (heavy top, thin tail down) — short-covering / accumulation
−1 b-shape : POC in the lower third (heavy bottom, thin tail up) — long-liquidation / distribution
0 D/normal: POC in the middle third (balanced bell)Market Profile readers classify the day’s shape by the location of the heaviest trading. A P-shape (control high, a thin tail beneath) typically marks short-covering or the start of accumulation; a b-shape (control low, thin tail above) marks long liquidation or distribution; a D-shape is a balanced, two-sided day. Reducing the profile to this three-way code gives a compact, streaming read of market posture.
The output is +1 / 0 / −1. The first value lands after period candles;
each update rebuilds the profile in O(period · bins).
§Example
use wickra_core::{Candle, Indicator, ProfileShape};
let mut indicator = ProfileShape::new(20, 24).unwrap();
let mut last = None;
for i in 0..40 {
let base = 100.0 + (f64::from(i) * 0.3).sin() * 5.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 ProfileShape
impl ProfileShape
Sourcepub fn new(period: usize, bins: usize) -> Result<Self>
pub fn new(period: usize, bins: usize) -> Result<Self>
Construct a Profile Shape classifier.
§Errors
Returns Error::PeriodZero if period is zero, or
Error::InvalidPeriod if bins < 3 (the three-way split needs three
zones).
Trait Implementations§
Source§impl Clone for ProfileShape
impl Clone for ProfileShape
Source§fn clone(&self) -> ProfileShape
fn clone(&self) -> ProfileShape
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 ProfileShape
impl Debug for ProfileShape
Source§impl Indicator for ProfileShape
impl Indicator for ProfileShape
Source§type Input = Candle
type Input = Candle
f64 for a price, or Candle / Tick).Source§fn update(&mut self, candle: Candle) -> Option<f64>
fn update(&mut self, candle: Candle) -> Option<f64>
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 ProfileShape
impl RefUnwindSafe for ProfileShape
impl Send for ProfileShape
impl Sync for ProfileShape
impl Unpin for ProfileShape
impl UnsafeUnpin for ProfileShape
impl UnwindSafe for ProfileShape
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