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::booksource holds it. - Calendar
Event - One calendar event, its figures already formatted for display.
- Calendar
Query - The events a calendar panel asks
Datafeed::calendarfor. The feed applies the filters. - Combined
Trade - 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.
- Consumed
Order - Size taken from one resting order, or from an unidentified one, at one price.
- Depth
Column - 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. - Depth
History - Columns of the order book of one chart, oldest first. Turn it on with
Chart::set_depth_historyand read it withChart::depth_history. - Depth
History Config - How a
DepthHistorysamples the order book. - Depth
Page - Recorded depth columns. Empty pages end paging, including when
end_of_historyis false, unless they name where older columns continue withcontinue_before. - Depth
Request - One page of recorded depth for a symbol, using the same price and time grid as live columns.
- Feed
Capabilities - What a feed offers as a whole, answered by
Datafeed::capabilities. Each list distinguishesNone, which the feed does not report and so restricts nothing, fromSomeof an empty list, which it reports as offering none. Usedeclareswhen a service needs explicit confirmation. - Feed
State - 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.
- Footprint
Bar - One bar’s executed volume and intrabar delta path, starting at zero.
- Footprint
Level - Executed volume at one grouped price, with sells on the bid and buys on the ask.
- History
Page - One page of history. A page without bars ends scroll-back like
end_of_historydoes, unless it names where older bars continue withcontinue_before, so a feed that pages by time window can answer an empty window such as a weekend. - History
Request - A request for one page of history.
- Hotlist
Entry - One symbol of a hotlist, with its last price and its change since the previous close.
- Hotlist
Query - The symbols of one hotlist that a hotlists panel asks
Datafeed::hotlistfor. - Metric
Page - 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.
- Metric
Point - A metric’s value from this instant until the next published point. Non-finite values are rejected, like invalid price bars.
- Metric
Request - Up to
countmetric points strictly beforebefore, or the latest when absent. Include the point in effect before the chart’s first bar when paging back. - Metric
Series - One metric offered for an instrument, identified by a host-owned key.
- Metric
Subscription - A live metric stream, stopped through
super::Datafeed::unsubscribe. Push withSink::push_metric; timestamps are retained without price-bar aggregation. - News
Query - The stories a news or highlights panel asks
Datafeed::newsfor. - News
Story - One story, already formatted for display.
- Node
Sensitivity - How
studies::TradeProfile::nodes(requiresstudies) chooses volume nodes. - Option
Chain - The latest option chain for one query, independent of egui. Clones share the subscription; dropping the last handle makes its sink inactive.
- Option
Chain Query - Contracts requested for one underlying, live or at a historical instant.
- Option
Chain Sink - A feed’s destination for complete chain snapshots. Cheap to clone. Only the latest accepted rows and error are retained; updates never queue.
- Option
Exposure - A complete exposure observation, supplied by a feed or computed from an option chain.
- Option
Exposure Handle - The latest exposure for one query, independent of egui. Clones share the subscription; dropping the last handle makes its sink inactive.
- Option
Exposure Query - Exposure requested for one underlying and inclusive expiry range.
- Option
Exposure Row - Exposure at one expiry and strike, in the snapshot’s units. Unknown sides stay absent.
- Option
Exposure Sink - A feed’s destination for complete exposure snapshots. Cheap to clone. Updates replace the latest snapshot without queuing or adding to computed gamma.
- Option
Quote - 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. - Options
Volume - Traded contract volume at one strike, summed over the requested expiries. This is turnover, not open interest, premium or the underlying’s bar volume.
- Options
Volume Query - Options whose traded contract volumes the host sums at each strike.
- Options
Volume Sink - 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.
- Order
Filter - 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.
- Order
Flow Bars - Bars copied from an
OrderFlowInputat one moment, with what they cover. - Order
Flow Input - A bounded, thread-safe source shared by a stream study and its feed subscription.
- Order
Queue - The per-order book, including queue order. Snapshot and event methods on
Sinkmaintain it;Chart::order_queuereads it. At most 10,000 orders per side, with bounded resync buffering. - Order
Size Tiers - Two sizes that mark an individual resting order as notable and as large.
- Price
Targets - 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. - Recording
Reader - 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.
- Recording
Writer - 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.
- Replay
Clock - 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.
- Replay
Driver - A recording-backed feed and playback driver for every symbol in one session.
- Replay
Event - 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. - Resting
Order - One resting order. Snapshot order establishes queue priority at each price.
- Screener
Column - A column the screener shows, filters and sorts by.
- Screener
Column Set - A named set of columns the user switches between, such as
"Overview"or"Performance". - Screener
Filter - One condition every row must meet.
- Screener
Query - The rows a screener asks
Datafeed::screenfor. The feed filters, sorts and limits. - Screener
Row - One symbol that passes the screen, with one formatted value per query column.
- Screener
Text Answer - What a feed answers for a screen that has a text description.
- Screener
Universe - 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.
- Study
Data - 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.
- Study
Data Request - 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.
- Study
Profile - One price-row profile placed over a half-open span of chart bars.
- Subscription
- A live subscription: push its updates into
sinkuntilDatafeed::unsubscribegetsid. - Subscription
Id - Identifies a subscription. Unique within the process, so one feed can serve many charts.
- Symbol
Details - 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.
- Trade
Page - One page of trades. A page without trades ends scroll-back like
end_of_historydoes, unless it names where older trades continue withcontinue_before. - Trade
Request - A request for one page of trades.
- Volume
Profile - Volume traded at each price row of bars or host-supplied option strikes.
- Volume
Profile Config - Row layout and display settings shared by volume profile studies and drawings.
Enums§
- Calendar
Kind - The calendar an event belongs to.
- Feed
Error - Why a feed or another service could not answer.
- Feed
Status - Connection state of a live subscription.
- Importance
- How much an economic event is expected to move the market.
- Market
Event - Recorded market data. Book sequencing is independent of the replay’s merge sequence.
- Option
Exposure Kind - The sensitivity described by an exposure snapshot. Only gamma is computed locally.
- Option
Kind - The right conveyed by an option contract.
- Order
Event - A sequenced change to one resting order. Unknown ids or invalid changes lose the book.
- Order
Filter Unavailable - Why an order-level view cannot be built.
- Order
Flow Kind - Fixed stream aggregation performed before a feed coalesces its updates for painting.
- Order
Size Tier - How an order’s size compares with
OrderSizeTiers. - Profile
Display - Volume shown in each price row of a profile built from bars.
- Profile
Source - Where a
VolumeProfile’s volumes come from. - Screener
Op - 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. - Maybe
Send Send + Syncon 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_tradesdoes, 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
tofrombarsof intervalfrom, which must be in time order. Pass timeframes for UTC boundaries, orBarClockvalues 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.