pub struct HttpDatafeed { /* private fields */ }Expand description
A reusable feed for a server exposing /config, /symbols, /search and /history.
Implements both Datafeed and SymbolSearch, so the same Arc can supply chart data
and the host’s symbol search dialog. Subscriptions refresh bars every five seconds,
retry recoverable failures with backoff and stop on unsubscribe or chart drop. An HTTP
request already in flight may finish, but its answer is discarded after cancellation.
use egui_charts::{ChartBuilder, data::http::HttpDatafeed};
use std::sync::Arc;
let feed = Arc::new(HttpDatafeed::new("https://data.example.com"));
let chart = ChartBuilder::new().with_symbol("SAMPLE").with_feed(feed).build();Implementations§
Trait Implementations§
Source§impl Datafeed for HttpDatafeed
impl Datafeed for HttpDatafeed
Source§fn capabilities(&self, reply: Reply<FeedCapabilities>)
fn capabilities(&self, reply: Reply<FeedCapabilities>)
What the feed offers as a whole, before any symbol is resolved: the intervals, exchanges
and symbol classes its selectors may offer, and the optional services it supplies. The
chart asks once when it attaches the feed and keeps the answer in
Chart::feed_capabilities (requires widget). The default
answers FeedCapabilities::default, which reports nothing and so restricts nothing.Source§fn resolve(&self, symbol: &str, reply: Reply<Instrument>)
fn resolve(&self, symbol: &str, reply: Reply<Instrument>)
Describes
symbol. The default reports Instrument::new of the symbol.
Fill Instrument::profile_resolutions to suggest the bars volume profile studies and
drawings read.Source§fn resolve_converted(
&self,
symbol: &str,
conversion: &str,
reply: Reply<Instrument>,
)
fn resolve_converted( &self, symbol: &str, conversion: &str, reply: Reply<Instrument>, )
Describes
symbol with its prices converted to conversion, the currency or unit the
host chose with Chart::set_conversion (requires widget). Label the
instrument with the converted currency and
unit. The library converts nothing: the default answers
FeedError::NotSupported, which shows no data rather than unconverted data under a
converted choice.Source§fn history(&self, request: HistoryRequest, reply: Reply<HistoryPage>)
fn history(&self, request: HistoryRequest, reply: Reply<HistoryPage>)
Up to
request.count bars of the range [request.since, request.before), the newest ones
when there are more. Either end left None is unbounded: without before the range
reaches the latest bar.Source§fn subscribe(&self, subscription: Subscription)
fn subscribe(&self, subscription: Subscription)
Starts pushing live updates into
subscription.sink until unsubscribe. The default does
nothing, which gives a history-only chart.Source§fn unsubscribe(&self, id: SubscriptionId)
fn unsubscribe(&self, id: SubscriptionId)
Stops what
subscribe started. Pushes that arrive afterwards are ignored. The default does
nothing; a producer can then poll Sink::is_active to know when to stop. Read moreSource§fn trades(&self, request: TradeRequest, reply: Reply<TradePage>)
fn trades(&self, request: TradeRequest, reply: Reply<TradePage>)
Up to
request.count trades of the range [request.since, request.before), the newest
ones when there are more, so order flow survives a reload and follows the view back in
time. The default answers FeedError::NotSupported.Source§fn options_volume(&self, query: OptionsVolumeQuery, sink: OptionsVolumeSink)
fn options_volume(&self, query: OptionsVolumeQuery, sink: OptionsVolumeSink)
Push complete options-volume snapshots for the underlying and inclusive expiry range.
Each push replaces the previous figures, including an empty snapshot. Sum contracts
across the requested expiries at each strike. Stop when
sink.is_active() is false.
The default supplies none; the library never fetches options data itself.Source§fn option_expiries(&self, underlying: &str, reply: Reply<Vec<NaiveDate>>)
fn option_expiries(&self, underlying: &str, reply: Reply<Vec<NaiveDate>>)
Listed expiry dates for
underlying, in ascending order with no duplicates.
The default answers FeedError::NotSupported. Both options methods are declared by
FeedService::OptionChain; the host supplies the data.Source§fn option_chain(&self, query: OptionChainQuery, sink: OptionChainSink)
fn option_chain(&self, query: OptionChainQuery, sink: OptionChainSink)
Push complete snapshots of the listed contracts in
query’s inclusive expiry range.
Without as_of, keep pushing until the sink is inactive.
With it, push one snapshot for that instant or report FeedError::NotSupported.
Unknown figures stay absent. See OptionQuote for units and OptionChainSink::push
for validation. The default reports FeedError::NotSupported to the sink. Read moreSource§fn option_exposure(&self, query: OptionExposureQuery, sink: OptionExposureSink)
fn option_exposure(&self, query: OptionExposureQuery, sink: OptionExposureSink)
Push complete exposure snapshots for the underlying, inclusive expiry range and kind.
Without
as_of, keep pushing until the sink is inactive;
with it, answer once for that instant or report FeedError::NotSupported (the default).
Declared by FeedService::OptionExposure. The host supplies the data and model. Read moreSource§fn depth_history(&self, request: DepthRequest, reply: Reply<DepthPage>)
fn depth_history(&self, request: DepthRequest, reply: Reply<DepthPage>)
One page of recorded depth on the requested grid. The default answers
FeedError::NotSupported; live-only feeds need not implement this method.Source§fn metrics(&self, symbol: &str, reply: Reply<Vec<MetricSeries>>)
fn metrics(&self, symbol: &str, reply: Reply<Vec<MetricSeries>>)
Metrics offered for
symbol, in display order. The default offers none.
The host publishes the values; the library computes no instrument metrics.Source§fn metric_history(&self, request: MetricRequest, reply: Reply<MetricPage>)
fn metric_history(&self, request: MetricRequest, reply: Reply<MetricPage>)
Metric history. The default answers
FeedError::NotSupported.Source§fn subscribe_metric(&self, subscription: MetricSubscription)
fn subscribe_metric(&self, subscription: MetricSubscription)
Start publishing metric points until
Self::unsubscribe. The default does nothing.Source§fn price_targets(&self, symbol: &str, reply: Reply<PriceTargets>)
fn price_targets(&self, symbol: &str, reply: Reply<PriceTargets>)
Analyst price targets for
symbol. The default answers FeedError::NotSupported,
which leaves the chart without targets and shows no error.Source§fn symbol_details(&self, symbol: &str, reply: Reply<SymbolDetails>)
fn symbol_details(&self, symbol: &str, reply: Reply<SymbolDetails>)
Key statistics and the company or contract profile of
symbol, for the symbol details
panel. The default answers FeedError::NotSupported, and the panel then shows neither.Source§fn news(&self, query: NewsQuery, reply: Reply<Vec<NewsStory>>)
fn news(&self, query: NewsQuery, reply: Reply<Vec<NewsStory>>)
Up to
query.limit stories, newest first, for the news and highlights panels. Answer
FeedError::NotSupported (the default) to have the panels say the feed has none.Source§fn calendar(&self, query: CalendarQuery, reply: Reply<Vec<CalendarEvent>>)
fn calendar(&self, query: CalendarQuery, reply: Reply<Vec<CalendarEvent>>)
The events of one calendar that pass
query’s filters, in time order, for the calendar
panel. Answer FeedError::NotSupported (the default) to have the panel say the feed has
none.Source§fn screen(&self, query: ScreenerQuery, reply: Reply<Vec<ScreenerRow>>)
fn screen(&self, query: ScreenerQuery, reply: Reply<Vec<ScreenerRow>>)
Up to
query.limit symbols that meet every filter of query, sorted as it asks, each
with the values of its columns, for the screener. The feed does the screening. Answer
FeedError::InvalidData for a filter it cannot apply, and FeedError::NotSupported
(the default) to have the panel say the feed has none.Source§fn hotlist(&self, query: HotlistQuery, reply: Reply<Vec<HotlistEntry>>)
fn hotlist(&self, query: HotlistQuery, reply: Reply<Vec<HotlistEntry>>)
Up to
query.limit symbols of the hotlist query.list, in the list’s order, for the
hotlists panel. Answer FeedError::NotSupported (the default) to have the panel say the
feed has none.Source§fn screen_text(&self, query: ScreenerQuery, reply: Reply<ScreenerTextAnswer>)
fn screen_text(&self, query: ScreenerQuery, reply: Reply<ScreenerTextAnswer>)
As
screen, for a query whose text describes the screen in words. The
feed interprets the text with the other criteria and answers the rows with an explanation
of how it understood them. Answer FeedError::NotSupported (the default) to have the
panel say the feed takes no descriptions, and FeedError::InvalidData for one it cannot
interpret.Source§fn request_depth_snapshot(&self, id: SubscriptionId)
fn request_depth_snapshot(&self, id: SubscriptionId)
The order book of subscription
id was lost to a gap, an unusable update or a book deeper
than the limit: push a new snapshot with Sink::push_depth_snapshot, and keep pushing
deltas while it is fetched. The snapshot may be older than the latest delta: the chart
holds the deltas pushed while the book waits and applies those numbered above the
snapshot. Called once per loss: after an unusable snapshot the chart does not ask
again, and the book stays empty until the feed pushes a usable one or the subscription
restarts. The default does nothing, for feeds without depth.Source§impl Drop for HttpDatafeed
impl Drop for HttpDatafeed
Source§impl SymbolSearch for HttpDatafeed
Available on crate feature http only.
impl SymbolSearch for HttpDatafeed
Available on crate feature
http only.Source§fn search(&self, query: SymbolQuery, reply: Reply<Vec<Instrument>>)
fn search(&self, query: SymbolQuery, reply: Reply<Vec<Instrument>>)
Up to
query.limit instruments matching query, best first.Auto Trait Implementations§
impl !Freeze for HttpDatafeed
impl RefUnwindSafe for HttpDatafeed
impl Send for HttpDatafeed
impl Sync for HttpDatafeed
impl Unpin for HttpDatafeed
impl UnsafeUnpin for HttpDatafeed
impl UnwindSafe for HttpDatafeed
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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 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> ⓘ
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