pub struct Marubozu { /* private fields */ }Expand description
Marubozu — a single-bar strong-continuation candle with body equal to range and (almost) no shadows.
range = high − low
upper_shadow = high − max(open, close)
lower_shadow = min(open, close) − low
shadows OK = upper_shadow <= tol * range && lower_shadow <= tol * rangeWhen the shadow tolerance is satisfied the output is +1.0 for a bullish
Marubozu (close > open) and −1.0 for a bearish one (close < open). Any
candle whose shadows exceed the tolerance — or whose body is zero — yields
0.0.
shadow_tolerance defaults to 0.05 (5 % of the bar range allowed on each
side) and must lie in [0, 1).
§Signed ±1 encoding
This detector already emits the uniform candlestick sign convention shared
across the pattern family — +1.0 bullish, −1.0 bearish, 0.0 no
pattern — so it drops straight into a machine-learning feature matrix where
the bullish and bearish variants of the pattern occupy a single dimension.
§Example
use wickra_core::{Candle, Indicator, Marubozu};
let mut indicator = Marubozu::new();
// Bullish marubozu: open == low, close == high.
let candle = Candle::new(10.0, 12.0, 10.0, 12.0, 1.0, 0).unwrap();
assert_eq!(indicator.update(candle), Some(1.0));Implementations§
Source§impl Marubozu
impl Marubozu
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Construct a Marubozu detector with the default 5 % shadow tolerance.
Sourcepub fn with_tolerance(shadow_tolerance: f64) -> Result<Self>
pub fn with_tolerance(shadow_tolerance: f64) -> Result<Self>
Construct a Marubozu detector with a custom shadow tolerance.
shadow_tolerance must lie in [0, 1).
Sourcepub fn shadow_tolerance(&self) -> f64
pub fn shadow_tolerance(&self) -> f64
Configured shadow tolerance.
Trait Implementations§
Source§impl Indicator for Marubozu
impl Indicator for Marubozu
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 Marubozu
impl RefUnwindSafe for Marubozu
impl Send for Marubozu
impl Sync for Marubozu
impl Unpin for Marubozu
impl UnsafeUnpin for Marubozu
impl UnwindSafe for Marubozu
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