pub struct Footprint { /* private fields */ }Expand description
Footprint — the buy/sell volume profile of a bar, bucketed by price.
A footprint (a.k.a. bid/ask or volume cluster chart) decomposes the volume traded within a bar across the price levels at which it printed, splitting each level into buy-initiated (ask-lifting) and sell-initiated (bid-hitting) volume. It exposes where inside a bar the activity happened and which side was the aggressor there — the basis for absorption, imbalance and point-of-control analysis that a single OHLCV bar hides.
Each trade is assigned to the price bucket round(price / tick_size); its
size is added to that bucket’s ask volume for a buy and bid volume for a
sell. Every update returns the complete footprint accumulated since the
last reset, as a FootprintOutput whose levels are sorted ascending
by price. Call reset at each bar (or session) boundary to start a fresh
footprint.
Input = Trade, Output = FootprintOutput. Ready after the first trade.
§Example
use wickra_core::{Footprint, Indicator, Side, Trade};
let mut fp = Footprint::new(1.0).unwrap();
fp.update(Trade::new(100.2, 2.0, Side::Buy, 0).unwrap());
let out = fp.update(Trade::new(100.7, 3.0, Side::Sell, 1).unwrap()).unwrap();
// Two buckets: 100 (ask 2) and 101 (bid 3).
assert_eq!(out.levels.len(), 2);
assert_eq!(out.levels[0].price, 100.0);
assert_eq!(out.levels[0].ask_vol, 2.0);
assert_eq!(out.levels[1].price, 101.0);
assert_eq!(out.levels[1].bid_vol, 3.0);Implementations§
Trait Implementations§
Source§impl Indicator for Footprint
impl Indicator for Footprint
Source§type Input = Trade
type Input = Trade
f64 for a price, or Candle / Tick).Source§type Output = FootprintOutput
type Output = FootprintOutput
Source§fn update(&mut self, trade: Trade) -> Option<FootprintOutput>
fn update(&mut self, trade: Trade) -> Option<FootprintOutput>
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 Footprint
impl RefUnwindSafe for Footprint
impl Send for Footprint
impl Sync for Footprint
impl Unpin for Footprint
impl UnsafeUnpin for Footprint
impl UnwindSafe for Footprint
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