Skip to main content

OrderFlowInput

Struct OrderFlowInput 

Source
pub struct OrderFlowInput(/* private fields */);
Expand description

A bounded, thread-safe source shared by a stream study and its feed subscription.

The chart connects these automatically. Hosts without a feed can push validated historical and live events through the same handle, in chronological order, then recalculate the study. Clones share the source, including when a study is cloned for presentation or undo.

At most 11,000 bars are retained: the bar after that drops the oldest at once, down to the newest 10,000, which still cover the longest flow sum. A study recalculated after a drop has no values for the dropped bars, and a cumulative one, such as FilteredCvd, starts again from the oldest retained bar. The chart recalculates the studies on a source in full after each drop, once per 1,001 new bars, and otherwise updates them from the first changed bar. At most 100,000 events per rolling window are retained; an overflowing window gives no value until the missing events have expired, rather than understating the rate.

Besides the fixed aggregations of OrderFlowKind, a source can hold each bar’s executions by price (footprint) or its last synchronized book (book) for a host’s study. These keep at most 11,000 bars and 110,000 price rows, footprint levels or book levels; past either, the oldest bars go at once, down to 10,000 bars and 100,000 rows, and the chart recalculates their studies in full.

During a chart replay every reader stops at the cutoff (see OrderFlowBars).

Implementations§

Source§

impl OrderFlowInput

Source

pub fn new(kind: OrderFlowKind) -> Self

An empty source for this fixed aggregation.

Source

pub fn footprint() -> Self

An empty source of each bar’s executions by price, one level per instrument tick, as Footprint aggregates them, for a study to read with footprints_from. It keeps nothing until it has a tick size (set_tick_size; the chart gives it its instrument’s), and only bars of an interval measured in time: under a clock without a timeframe, or with a tick, volume, range or delta interval, it ignores executions. An execution older than the one before it is left out, as from the chart’s footprint.

Source

pub fn book(levels: usize) -> Self

An empty source of the last synchronized book of each bar, its nearest levels on each side (clamped to 1..=100), for a study to read with books_from. A bar without a synchronized update keeps no book, and neither does one whose last update was a loss. An update with an invalid level, or older than the source’s last, is ignored. Only bars of an interval measured in time are kept, and an order filter does not apply.

Source

pub fn with_order_filter(self, filter: OrderFilter) -> Self

The same source, with book size summed over the individual orders filter accepts. The feed must send order events; with aggregate depth only, or when the filter needs a participant or placement time that no held order has, a book size bar has no value (NaN), instead of an unfiltered one. Other aggregations ignore it. A filter that accepts every order is the same as none.

Source

pub fn services(&self) -> &'static [FeedService]

Feed services read by this source. Book size with an order filter needs individual orders; executions need trade-side classification only for side-dependent outputs.

Source

pub fn clear(&self)

Clears values on a new symbol, interval or subscription. The aggregation, order filter, tick size and any replay cutoff stay.

Source

pub fn set_tick_size(&self, tick_size: Option<f64>)

Sets the instrument tick size that footprint levels and range intervals count in. A size that is not finite and positive counts as none; a footprint source keeps nothing without one. Another size clears the footprint, whose levels no longer apply. Fixed sources use it for range bars. The chart sets its instrument’s when connecting or subscribing the source.

Source

pub fn values(&self) -> BTreeMap<DateTime<Utc>, [f64; 3]>

Copies the retained bar outputs in time order. Missing outputs are NaN. During a chart replay, as OrderFlowBars::bars: nothing from the cutoff’s bar on, except that bar’s output of the executions before the cutoff, when known.

Source

pub fn footprints_from( &self, open: DateTime<Utc>, ) -> OrderFlowBars<FootprintBar>

Copies the bars of a footprint source that open at or after open, with what they cover. Empty for other sources.

Source

pub fn books_from(&self, open: DateTime<Utc>) -> OrderFlowBars<BarBook>

Copies the books of a book source for the bars that open at or after open, with what they cover. Empty for other sources.

Source

pub fn push_quote(&self, clock: &BarClock, quote: &Level1Quote, tick_size: f64)

Adds a quote. Invalid quotes, tick sizes and timestamps older than this stream are ignored. Crossed quotes are retained, so their spread can be negative. Footprint and book sources ignore it.

Source

pub fn push_trade(&self, clock: &BarClock, trade: &Tick)

Adds an execution already deduplicated by the host or chart’s feed. A footprint source adds it at its price level; a book source ignores it. Fixed sources on tick, volume, range and delta intervals use the same allocations as super::aggregate_trades. Push every execution from the same grouping anchor as the chart, including into quote and book size sources, so later updates belong to the current bar. Range intervals need set_tick_size first. A split fill contributes only its allocated size to each bar, with size filters tested against the original execution.

Source

pub fn advance_time(&self, clock: &BarClock, now: DateTime<Utc>)

Expires rolling rates and movement during an idle part of a bar with stream data. A bar without that data remains missing. Hosts without a feed call this on a heartbeat.

Source

pub fn push_book( &self, clock: &BarClock, time: DateTime<Utc>, book: Option<&OrderBook>, )

Adds a synchronized book, or marks its loss with None. A loss clears the current bar’s book values and breaks the inside-market movement path until it is seeded again. A book source keeps the nearest levels as its bar’s book.

Trait Implementations§

Source§

impl Clone for OrderFlowInput

Source§

fn clone(&self) -> OrderFlowInput

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

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.