Skip to main content

Price

Struct Price 

Source
#[non_exhaustive]
pub struct Price<F: Format = Both> {
Show 40 fields pub max_age: Option<i64>, pub pre_market_change_percent: Option<F::Value<f64>>, pub pre_market_change: Option<F::Value<f64>>, pub pre_market_time: Option<i64>, pub pre_market_price: Option<F::Value<f64>>, pub pre_market_source: Option<String>, pub post_market_change_percent: Option<F::Value<f64>>, pub post_market_change: Option<F::Value<f64>>, pub post_market_time: Option<i64>, pub post_market_price: Option<F::Value<f64>>, pub post_market_source: Option<String>, pub regular_market_change_percent: Option<F::Value<f64>>, pub regular_market_change: Option<F::Value<f64>>, pub regular_market_time: Option<i64>, pub price_hint: Option<F::Value<i64>>, pub regular_market_price: Option<F::Value<f64>>, pub regular_market_day_high: Option<F::Value<f64>>, pub regular_market_day_low: Option<F::Value<f64>>, pub regular_market_volume: Option<F::Value<i64>>, pub average_daily_volume10_day: Option<F::Value<i64>>, pub average_daily_volume3_month: Option<F::Value<i64>>, pub regular_market_previous_close: Option<F::Value<f64>>, pub regular_market_source: Option<String>, pub regular_market_open: Option<F::Value<f64>>, pub exchange: Option<String>, pub exchange_name: Option<String>, pub exchange_data_delayed_by: Option<i32>, pub market_state: Option<String>, pub quote_type: Option<String>, pub symbol: Option<String>, pub underlying_symbol: Option<String>, pub short_name: Option<String>, pub long_name: Option<String>, pub currency: Option<String>, pub quote_source_name: Option<String>, pub currency_symbol: Option<String>, pub from_currency: Option<String>, pub to_currency: Option<String>, pub last_market: Option<String>, pub market_cap: Option<F::Value<i64>>,
}
Expand description

Detailed pricing data for a stock

Includes current price, pre/post market data, volume, market cap, and exchange information.

The type parameter F controls how numeric fields are represented:

  • Price / Price<Both>default; fields hold FormattedValue<T>
  • Price<Raw> — fields hold T directly (e.g. Option<f64>)
  • Price<Pretty> — fields hold Option<String> (human-readable)

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§max_age: Option<i64>

Maximum age of the data in seconds

§pre_market_change_percent: Option<F::Value<f64>>

Pre-market change percentage

§pre_market_change: Option<F::Value<f64>>

Pre-market change value

§pre_market_time: Option<i64>

Pre-market time as Unix timestamp

§pre_market_price: Option<F::Value<f64>>

Pre-market price

§pre_market_source: Option<String>

Pre-market data source

§post_market_change_percent: Option<F::Value<f64>>

Post-market change percentage

§post_market_change: Option<F::Value<f64>>

Post-market change value

§post_market_time: Option<i64>

Post-market time as Unix timestamp

§post_market_price: Option<F::Value<f64>>

Post-market price

§post_market_source: Option<String>

Post-market data source

§regular_market_change_percent: Option<F::Value<f64>>

Regular market change percentage

§regular_market_change: Option<F::Value<f64>>

Regular market change value

§regular_market_time: Option<i64>

Regular market time as Unix timestamp

§price_hint: Option<F::Value<i64>>

Price hint for decimal places

§regular_market_price: Option<F::Value<f64>>

Current regular market price

§regular_market_day_high: Option<F::Value<f64>>

Regular market day high

§regular_market_day_low: Option<F::Value<f64>>

Regular market day low

§regular_market_volume: Option<F::Value<i64>>

Regular market volume

§average_daily_volume10_day: Option<F::Value<i64>>

Average daily volume over 10 days

§average_daily_volume3_month: Option<F::Value<i64>>

Average daily volume over 3 months

§regular_market_previous_close: Option<F::Value<f64>>

Regular market previous close

§regular_market_source: Option<String>

Regular market data source

§regular_market_open: Option<F::Value<f64>>

Regular market open price

§exchange: Option<String>

Exchange code (e.g., “NMS” for NASDAQ)

§exchange_name: Option<String>

Exchange name (e.g., “NasdaqGS”)

§exchange_data_delayed_by: Option<i32>

Exchange data delay in seconds

§market_state: Option<String>

Current market state (e.g., “REGULAR”, “POST”, “PRE”)

§quote_type: Option<String>

Quote type (e.g., “EQUITY”, “ETF”, “MUTUALFUND”)

§symbol: Option<String>

Stock symbol

§underlying_symbol: Option<String>

Underlying symbol (for derivatives)

§short_name: Option<String>

Short name of the security

§long_name: Option<String>

Long name of the security

§currency: Option<String>

Currency code (e.g., “USD”)

§quote_source_name: Option<String>

Quote source name

§currency_symbol: Option<String>

Currency symbol (e.g., “$”)

§from_currency: Option<String>

From currency (for currency pairs)

§to_currency: Option<String>

To currency (for currency pairs)

§last_market: Option<String>

Last market

§market_cap: Option<F::Value<i64>>

Market capitalization

Implementations§

Source§

impl Price<Both>

Source

pub fn into_raw(self) -> Price<Raw>

Convert into a Raw view, extracting .raw from each FormattedValue field.

Source

pub fn as_raw(&self) -> Price<Raw>

Clone and convert into a Raw view.

Source

pub fn into_pretty(self) -> Price<Pretty>

Convert into a Pretty view, extracting .fmt from each FormattedValue field.

Source

pub fn as_pretty(&self) -> Price<Pretty>

Clone and convert into a Pretty view.

Source§

impl Price<Both>

Source

pub fn current_price(&self) -> Option<f64>

Returns the current price (regular market price)

Source

pub fn day_change(&self) -> Option<f64>

Returns the day’s change in price

Source

pub fn day_change_percent(&self) -> Option<f64>

Returns the day’s change as a percentage

Source

pub fn day_range(&self) -> Option<(f64, f64)>

Returns the day’s trading range as (low, high)

Source

pub fn is_market_open(&self) -> bool

Returns whether the market is currently open

Source

pub fn is_pre_market(&self) -> bool

Returns whether this is in pre-market trading

Source

pub fn is_post_market(&self) -> bool

Returns whether this is in post-market trading

Source

pub fn live_price(&self) -> Option<f64>

Returns the most relevant current price based on market state

Returns post-market price if in post-market, pre-market price if in pre-market, otherwise regular market price.

Trait Implementations§

Source§

impl<F: Clone + Format> Clone for Price<F>
where F::Value<f64>: Clone, F::Value<i64>: Clone,

Source§

fn clone(&self) -> Price<F>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F: Debug + Format> Debug for Price<F>
where F::Value<f64>: Debug, F::Value<i64>: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<F: Default + Format> Default for Price<F>
where F::Value<f64>: Default, F::Value<i64>: Default,

Source§

fn default() -> Price<F>

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

impl<'de, F: Format> Deserialize<'de> for Price<F>

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<Price> for Price<Raw>

Source§

fn from(v: Price<Both>) -> Self

Converts to this type from the input type.
Source§

impl From<Price> for Price<Pretty>

Source§

fn from(v: Price<Both>) -> Self

Converts to this type from the input type.
Source§

impl<F: PartialEq + Format> PartialEq for Price<F>
where F::Value<f64>: PartialEq, F::Value<i64>: PartialEq,

Source§

fn eq(&self, other: &Price<F>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<F: Format> Serialize for Price<F>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<F: PartialEq + Format> StructuralPartialEq for Price<F>
where F::Value<f64>: PartialEq, F::Value<i64>: PartialEq,

Source§

impl<F: Format> Translatable for Price<F>

Source§

fn visit_translatable(&mut self, visit: &mut dyn FnMut(&mut String))

Visit every translatable string field in a stable order.
Source§

fn after_translate(&mut self)

Hook invoked after translations have been written back, for types that maintain derived text (e.g. a transcript’s joined full text).

Auto Trait Implementations§

§

impl<F> Freeze for Price<F>
where Option<<F as Format>::Value<f64>>: Freeze, Option<<F as Format>::Value<i64>>: Freeze,

§

impl<F> RefUnwindSafe for Price<F>
where Option<<F as Format>::Value<f64>>: RefUnwindSafe, Option<<F as Format>::Value<i64>>: RefUnwindSafe,

§

impl<F> Send for Price<F>
where Option<<F as Format>::Value<f64>>: Send, Option<<F as Format>::Value<i64>>: Send,

§

impl<F> Sync for Price<F>
where Option<<F as Format>::Value<f64>>: Sync, Option<<F as Format>::Value<i64>>: Sync,

§

impl<F> Unpin for Price<F>
where Option<<F as Format>::Value<f64>>: Unpin, Option<<F as Format>::Value<i64>>: Unpin,

§

impl<F> UnsafeUnpin for Price<F>
where Option<<F as Format>::Value<f64>>: UnsafeUnpin, Option<<F as Format>::Value<i64>>: UnsafeUnpin,

§

impl<F> UnwindSafe for Price<F>
where Option<<F as Format>::Value<f64>>: UnwindSafe, Option<<F as Format>::Value<i64>>: UnwindSafe,

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

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Key for T
where T: Clone,

Source§

fn align() -> usize

The alignment necessary for the key. Must return a power of two.
Source§

fn size(&self) -> usize

The size of the key in bytes.
Source§

unsafe fn init(&self, ptr: *mut u8)

Initialize the key in the given memory location. Read more
Source§

unsafe fn get<'a>(ptr: *const u8) -> &'a T

Get a reference to the key from the given memory location. Read more
Source§

unsafe fn drop_in_place(ptr: *mut u8)

Drop the key in place. Read more
Source§

impl<T> PlanCallbackArgs for T

Source§

impl<T> PlanCallbackOut for T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more