Skip to main content

Module data

Module data 

Source
Expand description

Historical and streaming market data contracts, aggregation and order flow data.

Implement Datafeed to connect a chart to your backend, or use the data containers and aggregation functions independently of a widget.

§Connecting a feed

Attach a feed with ChartBuilder::with_feed. Only Datafeed::history is required. The chart calls the feed on the UI thread; implementations should return promptly, answer each request once through Reply and push live updates into the Sink of a Subscription. Replies and pushes can come from another thread, runtime or browser task. The optional http adapter connects to a host’s server; no market data provider is built in.

Subscription::clock and HistoryRequest::clock carry the same bar boundaries so history and streaming aggregation agree. Symbol search is a separate SymbolSearch service.

§Order flow and derived data

Push executions, quotes and book updates through Sink. Footprint holds executed volume at price; DepthHistory holds the book over time. ReplayDriver loads host recordings and drives subscriptions through one ReplayClock. resample aggregates bars into a longer interval, and VolumeProfile describes volume by price.

The optional feed methods provide auxiliary study data and records for host UI, including news, calendars, hotlists and screener rows. Unsupported requests use FeedError::NotSupported.

Re-exports§

pub use crate::model::Bar;
pub use crate::model::FeedService;
pub use crate::model::Timeframe;

Modules§

http
HTTP symbol metadata, column history and polling subscriptions (feature http).

Structs§

BarBook
The last synchronized order book of one bar, as an OrderFlowInput::book source holds it.
CalendarEvent
One calendar event, its figures already formatted for display.
CalendarQuery
The events a calendar panel asks Datafeed::calendar for. The feed applies the filters.
CombinedTrade
Fills of one explicitly identified aggressive order, or one fill without an order id. Only retained fills count: eviction from the raw store also removes them from this view.
ConsumedOrder
Size taken from one resting order, or from an unidentified one, at one price.
DepthColumn
The resting size at each price row of the book over [time, time + span), and the largest individual order in each row when the history samples individual orders.
DepthHistory
Columns of the order book of one chart, oldest first. Turn it on with Chart::set_depth_history and read it with Chart::depth_history.
DepthHistoryConfig
How a DepthHistory samples the order book.
DepthPage
Recorded depth columns. Empty pages end paging, including when end_of_history is false, unless they name where older columns continue with continue_before.
DepthRequest
One page of recorded depth for a symbol, using the same price and time grid as live columns.
FeedCapabilities
What a feed offers as a whole, answered by Datafeed::capabilities. Each list distinguishes None, which the feed does not report and so restricts nothing, from Some of an empty list, which it reports as offering none. Use declares when a service needs explicit confirmation.
FeedState
What the chart knows about one series’ feed, for the application to show or log.
Footprint
Trade aggregation for one instrument, shared by footprints and delta studies.
FootprintBar
One bar’s executed volume and intrabar delta path, starting at zero.
FootprintLevel
Executed volume at one grouped price, with sells on the bid and buys on the ask.
HistoryPage
One page of history. A page without bars ends scroll-back like end_of_history does, unless it names where older bars continue with continue_before, so a feed that pages by time window can answer an empty window such as a weekend.
HistoryRequest
A request for one page of history.
HotlistEntry
One symbol of a hotlist, with its last price and its change since the previous close.
HotlistQuery
The symbols of one hotlist that a hotlists panel asks Datafeed::hotlist for.
MetricPage
A page of metric history, in any order. The chart sorts and deduplicates by timestamp. A live correction of the same timestamp takes precedence over history.
MetricPoint
A metric’s value from this instant until the next published point. Non-finite values are rejected, like invalid price bars.
MetricRequest
Up to count metric points strictly before before, or the latest when absent. Include the point in effect before the chart’s first bar when paging back.
MetricSeries
One metric offered for an instrument, identified by a host-owned key.
MetricSubscription
A live metric stream, stopped through super::Datafeed::unsubscribe. Push with Sink::push_metric; timestamps are retained without price-bar aggregation.
NewsQuery
The stories a news or highlights panel asks Datafeed::news for.
NewsStory
One story, already formatted for display.
NodeSensitivity
How studies::TradeProfile::nodes (requires studies) chooses volume nodes.
OptionChain
The latest option chain for one query, independent of egui. Clones share the subscription; dropping the last handle makes its sink inactive.
OptionChainQuery
Contracts requested for one underlying, live or at a historical instant.
OptionChainSink
A feed’s destination for complete chain snapshots. Cheap to clone. Only the latest accepted rows and error are retained; updates never queue.
OptionExposure
A complete exposure observation, supplied by a feed or computed from an option chain.
OptionExposureHandle
The latest exposure for one query, independent of egui. Clones share the subscription; dropping the last handle makes its sink inactive.
OptionExposureQuery
Exposure requested for one underlying and inclusive expiry range.
OptionExposureRow
Exposure at one expiry and strike, in the snapshot’s units. Unknown sides stay absent.
OptionExposureSink
A feed’s destination for complete exposure snapshots. Cheap to clone. Updates replace the latest snapshot without queuing or adding to computed gamma.
OptionQuote
One listed contract’s observation. Unknown values stay None, including Greeks; consumers must not substitute zero. Prices use the underlying’s price units. Greeks describe one unit of the underlying, without the contract multiplier applied.
OptionsVolume
Traded contract volume at one strike, summed over the requested expiries. This is turnover, not open interest, premium or the underlying’s bar volume.
OptionsVolumeQuery
Options whose traded contract volumes the host sums at each strike.
OptionsVolumeSink
A feed’s options snapshots for one underlying and expiry query. Cheap to clone. Only the latest snapshot is retained, so updates cannot accumulate between frames.
OrderFilter
Which resting orders count when they are summed into levels, for ladders, heatmaps and the book size study. Every field narrows the set. Filters are exact: an order whose placement time or participant the feed did not supply is neither guessed at nor dropped for lacking the field it is not filtered on.
OrderFlowBars
Bars copied from an OrderFlowInput at one moment, with what they cover.
OrderFlowInput
A bounded, thread-safe source shared by a stream study and its feed subscription.
OrderQueue
The per-order book, including queue order. Snapshot and event methods on Sink maintain it; Chart::order_queue reads it. At most 10,000 orders per side, with bounded resync buffering.
OrderSizeTiers
Two sizes that mark an individual resting order as notable and as large.
PriceTargets
Consensus price targets for one symbol, in its price units. The chart accepts finite prices with low <= average <= high, a nonzero analyst count and a horizon after publication.
RecordingReader
Reads version 1 or 2 binary events, including order placement and participant metadata in version 2. Limits allocation to 16 MiB per record, rejects unknown versions, malformed values and truncated records, and distinguishes clean EOF from truncation.
RecordingWriter
Writes a compact binary recording: a version header, then length-framed events with fixed little-endian numbers, optional-id flags and UTF-8 symbols. Version 2 retains resting order participant and placement metadata. No runtime or filesystem policy is imposed; a host can use a buffered file on native targets or bytes in a browser.
ReplayClock
A deterministic clock merging all instruments by time, sequence, then symbol. Advancing uses wall-clock elapsed time times the speed, never a bar index. Hosts own the input and scheduling. Seek rebuilds trades from the start and depth from the latest preceding snapshot per symbol.
ReplayDriver
A recording-backed feed and playback driver for every symbol in one session.
ReplayEvent
One instrument’s event at an observation instant. The host supplies a merge sequence to break timestamp ties within a symbol, including ties between trades and book messages.
Reply
The answer to one request, usable from any thread. Dropping it unanswered reports FeedError::Unanswered, so a lost request never leaves the chart loading forever.
RestingOrder
One resting order. Snapshot order establishes queue priority at each price.
ScreenerColumn
A column the screener shows, filters and sorts by.
ScreenerColumnSet
A named set of columns the user switches between, such as "Overview" or "Performance".
ScreenerFilter
One condition every row must meet.
ScreenerQuery
The rows a screener asks Datafeed::screen for. The feed filters, sorts and limits.
ScreenerRow
One symbol that passes the screen, with one formatted value per query column.
ScreenerTextAnswer
What a feed answers for a screen that has a text description.
ScreenerUniverse
A market the screener screens, such as stocks, funds, bonds, coins or the pairs of one exchange, as the host names it.
Sink
Live updates for one subscription. Cheap to clone and usable from any thread; pushes never wait for the chart to catch up.
StudyData
A requested series available during calculation, sorted by time with unique bars. Metric points use their value for OHLC and zero volume, without interval aggregation. An unavailable history has no bars; it is never substituted with the chart’s prices.
StudyDataRequest
A study or drawing’s additional history and live subscription. Empty symbols and absent intervals follow the chart. The host owns symbol identifiers and supplies the market data.
StudyProfile
One price-row profile placed over a half-open span of chart bars.
Subscription
A live subscription: push its updates into sink until Datafeed::unsubscribe gets id.
SubscriptionId
Identifies a subscription. Unique within the process, so one feed can serve many charts.
SymbolDetails
Facts about one symbol as labelled values, already formatted for display, in the order to show them. Supply only what is known: the panel shows a section only when it has values.
TradePage
One page of trades. A page without trades ends scroll-back like end_of_history does, unless it names where older trades continue with continue_before.
TradeRequest
A request for one page of trades.
VolumeProfile
Volume traded at each price row of bars or host-supplied option strikes.
VolumeProfileConfig
Row layout and display settings shared by volume profile studies and drawings.

Enums§

CalendarKind
The calendar an event belongs to.
FeedError
Why a feed or another service could not answer.
FeedStatus
Connection state of a live subscription.
Importance
How much an economic event is expected to move the market.
MarketEvent
Recorded market data. Book sequencing is independent of the replay’s merge sequence.
OptionExposureKind
The sensitivity described by an exposure snapshot. Only gamma is computed locally.
OptionKind
The right conveyed by an option contract.
OrderEvent
A sequenced change to one resting order. Unknown ids or invalid changes lose the book.
OrderFilterUnavailable
Why an order-level view cannot be built.
OrderFlowKind
Fixed stream aggregation performed before a feed coalesces its updates for painting.
OrderSizeTier
How an order’s size compares with OrderSizeTiers.
ProfileDisplay
Volume shown in each price row of a profile built from bars.
ProfileSource
Where a VolumeProfile’s volumes come from.
ScreenerOp
How a screener filter compares a column’s value.

Traits§

Datafeed
Source of instrument metadata, history and live updates for a chart, given to it with ChartBuilder::with_feed.
MaybeSend
Send + Sync on native targets. No bound on wasm32, where feeds hold JavaScript handles.

Functions§

aggregate_trades
Rebuilds bars from chronological executions using the live sink’s aggregation rules. Count intervals start at the first accepted trade in trades; retain that grouping anchor when joining history to live data. Duplicate ids are ignored. Invalid or late trades and overflowing volumes return an error. Periods without executions are omitted.
aggregate_trades_with_tick_size
Rebuilds trade bars as aggregate_trades does, with an instrument tick size for range bars. The tick size must be positive and finite for a range interval.
combine_trades
Combines explicit aggressor ids, in order of their first fill. Unknown ids stay separate. Use raw fills for per-price volume. This allocates at most one entry per input fill and ignores invalid fills. A bounded input gives a bounded combined view.
resample
Builds bars of interval to from bars of interval from, which must be in time order. Pass timeframes for UTC boundaries, or BarClock values for a selected calendar timezone. Prices and volumes are expected to be finite, as stored series keep them.
resample_with_session
Builds a coarser interval using the instrument’s exchange trading hours and dates.