pub struct TradeSignAutocorrelation { /* private fields */ }Expand description
Trade-Sign Autocorrelation — the lag-1 autocorrelation of the trade sign
(+1 buy, −1 sell), measuring how strongly signed order flow persists.
s_t = +1 if the trade is a buy, −1 if a sell
ρ1 = mean over the window of ( s_t · s_{t−1} ) ∈ [−1, +1]In real markets trade signs are strongly positively autocorrelated: a buy tends to be followed by another buy (and a sell by a sell), because large parent orders are split into many child trades and because of order-splitting and herding. A high reading therefore indicates persistent directional pressure — a footprint of informed or algorithmic execution — while a reading near zero signals balanced, uninformed flow and a negative reading signals alternating (bid-ask bounce) flow.
The output is the mean product of consecutive signs, bounded in [−1, +1]. The
first value lands after period trades. Each update is O(period).
§Example
use wickra_core::{Indicator, Side, Trade, TradeSignAutocorrelation};
let mut indicator = TradeSignAutocorrelation::new(20).unwrap();
let mut last = None;
for i in 0..40 {
let side = if i % 2 == 0 { Side::Buy } else { Side::Sell };
last = indicator.update(Trade::new(100.0, 1.0, side, i).unwrap());
}
// Perfectly alternating signs -> autocorrelation -1.
assert!((last.unwrap() + 1.0).abs() < 1e-9);Implementations§
Source§impl TradeSignAutocorrelation
impl TradeSignAutocorrelation
Trait Implementations§
Source§impl Clone for TradeSignAutocorrelation
impl Clone for TradeSignAutocorrelation
Source§impl Debug for TradeSignAutocorrelation
impl Debug for TradeSignAutocorrelation
Source§impl Indicator for TradeSignAutocorrelation
impl Indicator for TradeSignAutocorrelation
Source§type Input = Trade
type Input = Trade
f64 for a price, or Candle / Tick).Source§fn update(&mut self, trade: Trade) -> Option<f64>
fn update(&mut self, trade: Trade) -> Option<f64>
None if there is no value for this input. Read moreSource§fn reset(&mut self)
fn reset(&mut self)
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
None output can be produced.Source§fn is_ready(&self) -> bool
fn is_ready(&self) -> bool
Source§fn name(&self) -> &'static str
fn name(&self) -> &'static str
Source§fn batch_nan_into(&mut self, inputs: &[Self::Input], out: &mut [f64])
fn batch_nan_into(&mut self, inputs: &[Self::Input], out: &mut [f64])
Source§fn batch_fast_into(&mut self, inputs: &[Self::Input], out: &mut [f64])
fn batch_fast_into(&mut self, inputs: &[Self::Input], out: &mut [f64])
batch_nan_into, but
an indicator with a vectorised kernel may reassociate its arithmetic to
run it in SIMD lanes. Each value then agrees with the exact batch to within
the tolerance the indicator documents (a few units in the last place), not
bit for bit; warmup positions, NaN placement and the output length are
identical. The kernels are deterministic: the same input produces the same
bits on every platform, with or without SIMD hardware. Read moreAuto Trait Implementations§
impl Freeze for TradeSignAutocorrelation
impl RefUnwindSafe for TradeSignAutocorrelation
impl Send for TradeSignAutocorrelation
impl Sync for TradeSignAutocorrelation
impl Unpin for TradeSignAutocorrelation
impl UnsafeUnpin for TradeSignAutocorrelation
impl UnwindSafe for TradeSignAutocorrelation
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