Skip to main content

Footprint

Struct Footprint 

Source
pub struct Footprint { /* private fields */ }
Expand description

Trade aggregation for one instrument, shared by footprints and delta studies.

Build once for historical trades and call push for live executions. Trades must be chronological, with exchange order preserved for equal timestamps, so delta highs and lows are exact. Replay corrections by rebuilding, rather than silently approximating their intrabar path. The host deduplicates ids (the chart’s feed already does).

Implementations§

Source§

impl Footprint

Source

pub fn new( clock: BarClock, tick_size: f64, ticks_per_row: u32, ) -> Result<Self, FeedError>

Creates an empty aggregation. tick_size must be finite and positive, and ticks_per_row nonzero. Prices round to the nearest integer tick, then group downwards, including negative prices. Grouping never changes trade-side totals.

Source

pub fn complete_from(&self) -> Option<DateTime<Utc>>

Open of the oldest bar whose executions are all held: earlier bars were cut by the budget or by trades dropped from the host’s store, or may lack trades that never arrived, and must not be shown as complete.

Source

pub fn set_size_filter(&mut self, min: f64, max: f64) -> Result<(), FeedError>

Restricts executions to this inclusive size range, before aggregation. Must be called before adding trades. Invalid ranges return an error without changing it.

Source

pub fn tick_size(&self) -> f64

Instrument tick size before price-row grouping.

Source

pub fn price_step(&self) -> f64

Height of one grouped price row.

Source

pub fn level_of(&self, price: f64) -> Option<i64>

The level a trade at price falls in: the nearest tick, grouped downwards. None when the price is not finite or the level overflows.

Source

pub fn bars(&self) -> &BTreeMap<DateTime<Utc>, FootprintBar>

Aggregated bars in chronological order.

Source

pub fn bar_at(&self, time: DateTime<Utc>) -> Option<&FootprintBar>

The aggregated bar containing time, using the same UTC slots as trade aggregation. Accepts a bar stamped anywhere inside its slot, as the feed history contract does.

Source

pub fn profile(&self, first: DateTime<Utc>, last: DateTime<Utc>) -> FootprintBar

The executions of the bars that contain first through last, inclusive, as one bar opening with the first of them: the exact profile of a span of the chart. Bars before complete_from are left out, as their executions are not all held. Empty when no complete bar traded there or last precedes first.

Source

pub fn push(&mut self, trade: &Tick) -> Result<bool, FeedError>

Adds an execution, returning whether it passed the size filter. Invalid, out-of-order or overflowing input returns an error and changes nothing. Unknown side stays unknown. Zero-sized executions are ignored.

Trait Implementations§

Source§

impl Clone for Footprint

Source§

fn clone(&self) -> Footprint

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Footprint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> MaybeSend for T
where T: Send + Sync + ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.