pub struct Ichimoku { /* private fields */ }Expand description
Ichimoku Kinko Hyo indicator.
Standard parameters are (9, 26, 52, 26). The first fully-populated output
(every field Some) appears after senkou_b_period + displacement - 1
candles — 77 bars at the defaults — because Senkou B needs its own 52-bar
midpoint and a 26-bar history of those midpoints to displace from.
§Example
use wickra_core::{Candle, Ichimoku, Indicator};
let mut ichi = Ichimoku::classic();
for i in 0..120 {
let p = 100.0 + f64::from(i);
let candle = Candle::new(p, p + 2.0, p - 2.0, p + 1.0, 0.0, i64::from(i)).unwrap();
ichi.update(candle);
}
let out = ichi.value().unwrap();
assert!(out.tenkan.is_some() && out.kijun.is_some());
assert!(out.senkou_a.is_some() && out.senkou_b.is_some());
assert!(out.chikou.is_some());Implementations§
Source§impl Ichimoku
impl Ichimoku
Sourcepub fn new(
tenkan_period: usize,
kijun_period: usize,
senkou_b_period: usize,
displacement: usize,
) -> Result<Self>
pub fn new( tenkan_period: usize, kijun_period: usize, senkou_b_period: usize, displacement: usize, ) -> Result<Self>
Construct an Ichimoku indicator with custom periods.
tenkan_period is the short midpoint window (default 9), kijun_period
the medium (default 26), senkou_b_period the long (default 52), and
displacement the forward/backward shift in bars (default 26).
§Errors
Returns Error::PeriodZero if any of tenkan_period, kijun_period,
senkou_b_period, or displacement is zero, and Error::InvalidPeriod
if the periods are not in strictly increasing order
(tenkan < kijun < senkou_b).
Sourcepub const fn periods(&self) -> (usize, usize, usize, usize)
pub const fn periods(&self) -> (usize, usize, usize, usize)
Configured periods as (tenkan, kijun, senkou_b, displacement).
Sourcepub const fn value(&self) -> Option<IchimokuOutput>
pub const fn value(&self) -> Option<IchimokuOutput>
Most recent output if at least one bar has been consumed.
Trait Implementations§
Source§impl Indicator for Ichimoku
impl Indicator for Ichimoku
Source§type Input = Candle
type Input = Candle
f64 for a price, or Candle / Tick).Source§type Output = IchimokuOutput
type Output = IchimokuOutput
Source§fn update(&mut self, candle: Candle) -> Option<IchimokuOutput>
fn update(&mut self, candle: Candle) -> Option<IchimokuOutput>
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 Ichimoku
impl RefUnwindSafe for Ichimoku
impl Send for Ichimoku
impl Sync for Ichimoku
impl Unpin for Ichimoku
impl UnsafeUnpin for Ichimoku
impl UnwindSafe for Ichimoku
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