Skip to main content

SymbolDetailsPanel

Struct SymbolDetailsPanel 

Source
pub struct SymbolDetailsPanel { /* private fields */ }
Expand description

Details of the chart’s symbol, fed by the host’s Datafeed and Storage.

Keep it on the chart’s symbol with set_instrument, its latest quote with set_quote, such as the one WatchlistPanel::quote holds, and its average volume with set_average_volume. The quote’s last price, change, update time, extended-hours trade and session volume are shown, the extended-hours change measured from the regular last price; update times are shown in the time zone set with set_timezone, UTC by default. The header’s layout button shows or hides sections, the edit button moves to the notes, and a feed that supplies SymbolDetails::url gets a link to the instrument beside its name, and one that supplies SymbolDetails::category gets the category under it. For each new symbol the panel asks the feed for Datafeed::symbol_details and shows the statistics, on a card, and the profile it answers; an empty section, or a feed that does not support the request, shows nothing. Notes are kept in memory per symbol, and with a storage service attached they are read from and written to one StoreKind::SymbolNotes document per symbol as they are edited, one write per document at a time. Call poll each frame, even while the panel is hidden, then show while it is open. The More menu’s Financials item is reported by take_financials_request, for the host to open a FinancialsPanel with the company’s figures.

The Performance and Seasonality sections show what the host supplies. Call take_market_requests each frame: the first call for a symbol returns its MarketDetailRequests and shows both sections as loading, and the host answers with set_period_returns and set_seasonality. A host that never calls it sees neither section. Each section says whether it is loading, empty, unavailable or failed.

Implementations§

Source§

impl SymbolDetailsPanel

Source

pub fn new() -> Self

A panel without a symbol, feed or storage.

Source

pub fn set_feed(&mut self, feed: Arc<dyn Datafeed>)

Ask feed for the details of each symbol from now on, starting with the shown one.

Source

pub fn set_storage(&mut self, storage: Arc<dyn Storage>)

Keep notes in storage, reading them again from it. Edits not yet written are dropped.

Source

pub fn set_instrument(&mut self, instrument: &Instrument)

Show instrument, such as the chart’s. A new symbol clears the quote and the average volume and asks for its details and notes; the same symbol only takes the new name, exchange and currency.

Source

pub fn set_quote(&mut self, quote: Quote)

Sets the latest quote of the shown symbol. Its extended-hours trade shows below the regular price while it is set.

Source

pub fn set_average_volume(&mut self, average: f64)

Sets the average daily volume of the shown symbol over the last 30 days. With the quote’s session volume, both are drawn as a bar split in proportion to the two.

Source

pub fn set_timezone(&mut self, timezone: TimezoneId)

Shows update times in timezone, such as the chart’s.

Source

pub fn set_financials_visible(&mut self, visible: bool)

Show or hide Financials in the More menu, shown by default. Hide it when the host cannot supply company financials.

Source

pub fn take_financials_request(&mut self) -> bool

Whether the user chose Financials in the More menu since the last call.

Source

pub fn take_market_requests(&mut self) -> Vec<MarketDetailRequest>

The market detail the sections still lack for the shown symbol, each returned once; it marks them loading. Call it every frame and answer with set_period_returns and set_seasonality.

Source

pub fn set_period_returns( &mut self, symbol: &str, returns: MarketDetail<Vec<PeriodReturn>>, )

Answers the MarketDetailRequest::PeriodReturns of symbol. An answer for a symbol the panel no longer shows is ignored.

Source

pub fn set_seasonality( &mut self, symbol: &str, seasonality: MarketDetail<Seasonality>, )

Answers the MarketDetailRequest::Seasonality of symbol. An answer for a symbol the panel no longer shows is ignored.

Source

pub fn symbol(&self) -> Option<&str>

The shown symbol, if any.

Source

pub fn poll(&mut self, ctx: &Context)

Receive the feed’s and storage’s answers, write edited notes, and wake the UI when the next answer arrives.

Source

pub fn show(&mut self, ui: &mut Ui)

Render the shown symbol after poll.

Trait Implementations§

Source§

impl Default for SymbolDetailsPanel

Source§

fn default() -> SymbolDetailsPanel

Returns the “default value” for a type. Read more

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.