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
impl OrderFlowInput
Sourcepub fn new(kind: OrderFlowKind) -> Self
pub fn new(kind: OrderFlowKind) -> Self
An empty source for this fixed aggregation.
Sourcepub fn footprint() -> Self
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.
Sourcepub fn book(levels: usize) -> Self
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.
Sourcepub fn with_order_filter(self, filter: OrderFilter) -> Self
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.
Sourcepub fn services(&self) -> &'static [FeedService]
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.
Sourcepub fn clear(&self)
pub fn clear(&self)
Clears values on a new symbol, interval or subscription. The aggregation, order filter, tick size and any replay cutoff stay.
Sourcepub fn set_tick_size(&self, tick_size: Option<f64>)
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.
Sourcepub fn values(&self) -> BTreeMap<DateTime<Utc>, [f64; 3]>
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.
Sourcepub fn footprints_from(
&self,
open: DateTime<Utc>,
) -> OrderFlowBars<FootprintBar>
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.
Sourcepub fn books_from(&self, open: DateTime<Utc>) -> OrderFlowBars<BarBook>
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.
Sourcepub fn push_quote(&self, clock: &BarClock, quote: &Level1Quote, tick_size: f64)
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.
Sourcepub fn push_trade(&self, clock: &BarClock, trade: &Tick)
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.
Sourcepub fn advance_time(&self, clock: &BarClock, now: DateTime<Utc>)
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.
Sourcepub fn push_book(
&self,
clock: &BarClock,
time: DateTime<Utc>,
book: Option<&OrderBook>,
)
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
impl Clone for OrderFlowInput
Source§fn clone(&self) -> OrderFlowInput
fn clone(&self) -> OrderFlowInput
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for OrderFlowInput
impl RefUnwindSafe for OrderFlowInput
impl Send for OrderFlowInput
impl Sync for OrderFlowInput
impl Unpin for OrderFlowInput
impl UnsafeUnpin for OrderFlowInput
impl UnwindSafe for OrderFlowInput
Blanket Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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