Skip to main content

HttpDatafeed

Struct HttpDatafeed 

Source
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§

Source§

impl HttpDatafeed

Source

pub fn new(address: impl Into<String>) -> Self

Connects to the endpoint root at address, which may include a path prefix. A trailing slash is optional. Browser servers must allow the application’s origin.

Trait Implementations§

Source§

impl Datafeed for HttpDatafeed

Source§

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>)

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>, )

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>)

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)

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)

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 more
Source§

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)

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>>)

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)

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 more
Source§

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 more
Source§

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>>)

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>)

Metric history. The default answers FeedError::NotSupported.
Source§

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>)

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>)

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>>)

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>>)

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>>)

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>>)

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>)

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)

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

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl SymbolSearch for HttpDatafeed

Available on crate feature http only.
Source§

fn search(&self, query: SymbolQuery, reply: Reply<Vec<Instrument>>)

Up to query.limit instruments matching query, best first.

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> 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, 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, 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.