pub struct OvernightIntradayReturn { /* private fields */ }Expand description
Overnight / intraday return decomposition, re-anchored at each local day
boundary of Candle::timestamp shifted by
utc_offset_minutes.
The first session yields no output (there is no prior close to anchor the overnight leg); from the second session onward every bar reports both components.
§Example
use wickra_core::{Candle, Indicator, OvernightIntradayReturn};
let hour = 3_600_000;
let mut oi = OvernightIntradayReturn::new(0);
// Day 1 closes at 100.
assert!(oi.update(Candle::new(99.0, 101.0, 98.0, 100.0, 1.0, 0).unwrap()).is_none());
// Day 2 opens 110 (overnight +10%), closes 121 (intraday +10%).
let v = oi.update(Candle::new(110.0, 122.0, 109.0, 121.0, 1.0, 24 * hour).unwrap()).unwrap();
assert!((v.overnight - 0.10).abs() < 1e-9);
assert!((v.intraday - 0.10).abs() < 1e-9);Implementations§
Source§impl OvernightIntradayReturn
impl OvernightIntradayReturn
Sourcepub const fn new(utc_offset_minutes: i32) -> OvernightIntradayReturn
pub const fn new(utc_offset_minutes: i32) -> OvernightIntradayReturn
Construct the indicator with the given UTC offset (minutes).
Sourcepub const fn utc_offset_minutes(&self) -> i32
pub const fn utc_offset_minutes(&self) -> i32
Configured UTC offset in minutes.
Sourcepub const fn value(&self) -> Option<OvernightIntradayReturnOutput>
pub const fn value(&self) -> Option<OvernightIntradayReturnOutput>
Most recent decomposition if at least one day boundary has been crossed.
Trait Implementations§
Source§impl Clone for OvernightIntradayReturn
impl Clone for OvernightIntradayReturn
Source§fn clone(&self) -> OvernightIntradayReturn
fn clone(&self) -> OvernightIntradayReturn
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 moreSource§impl Debug for OvernightIntradayReturn
impl Debug for OvernightIntradayReturn
Source§impl Indicator for OvernightIntradayReturn
impl Indicator for OvernightIntradayReturn
Source§type Input = Candle
type Input = Candle
Type of one input data point (typically
f64 for a price, or Candle / Tick).Source§type Output = OvernightIntradayReturnOutput
type Output = OvernightIntradayReturnOutput
Type of one output value.
Source§fn update(&mut self, candle: Candle) -> Option<OvernightIntradayReturnOutput>
fn update(&mut self, candle: Candle) -> Option<OvernightIntradayReturnOutput>
Feed one new data point into the indicator and return the freshly computed
output, or
None if the indicator is still warming up.Source§fn reset(&mut self)
fn reset(&mut self)
Reset all internal state, leaving the indicator equivalent to a freshly
constructed instance with the same parameters.
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
Number of inputs required before the first non-
None output can be produced.Auto Trait Implementations§
impl Freeze for OvernightIntradayReturn
impl RefUnwindSafe for OvernightIntradayReturn
impl Send for OvernightIntradayReturn
impl Sync for OvernightIntradayReturn
impl Unpin for OvernightIntradayReturn
impl UnsafeUnpin for OvernightIntradayReturn
impl UnwindSafe for OvernightIntradayReturn
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>>
Run the indicator over a slice of inputs in order, returning one output (or
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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