pub struct Instrument {
pub symbol: Symbol,
pub exchange: Option<Exchange>,
pub figi: Option<Figi>,
pub isin: Option<Isin>,
pub kind: AssetKind,
}Expand description
Logical instrument identity for a security.
Fields§
§symbol: SymbolCanonical ticker symbol.
exchange: Option<Exchange>Optional trading venue context for disambiguation.
figi: Option<Figi>Optional global identifier (preferred).
isin: Option<Isin>Optional global identifier (fallback).
kind: AssetKindAsset class and behavior.
Implementations§
Source§impl Instrument
impl Instrument
Sourcepub const fn new(symbol: Symbol, kind: AssetKind) -> Instrument
pub const fn new(symbol: Symbol, kind: AssetKind) -> Instrument
Construct an instrument from a validated symbol and asset kind.
Sourcepub fn from_symbol(
symbol: impl AsRef<str>,
kind: AssetKind,
) -> Result<Instrument, DomainError>
pub fn from_symbol( symbol: impl AsRef<str>, kind: AssetKind, ) -> Result<Instrument, DomainError>
Construct a new Instrument with just a symbol and kind.
§Errors
Returns DomainError::InvalidSymbol if the provided symbol violates canonical invariants.
Sourcepub fn from_symbol_and_exchange(
symbol: impl AsRef<str>,
exchange: Exchange,
kind: AssetKind,
) -> Result<Instrument, DomainError>
pub fn from_symbol_and_exchange( symbol: impl AsRef<str>, exchange: Exchange, kind: AssetKind, ) -> Result<Instrument, DomainError>
Construct a new Instrument with symbol, exchange, and kind.
§Errors
Returns DomainError::InvalidSymbol if the provided symbol violates canonical invariants.
Sourcepub fn from_figi(
figi: &str,
symbol: Symbol,
kind: AssetKind,
) -> Result<Instrument, DomainError>
pub fn from_figi( figi: &str, symbol: Symbol, kind: AssetKind, ) -> Result<Instrument, DomainError>
Construct a new Instrument for a security identified by a FIGI and symbol.
§Errors
Returns DomainError::InvalidFigi if FIGI validation fails.
Sourcepub fn unique_key(&self) -> String
pub fn unique_key(&self) -> String
Returns a stable, namespaced identity key for this instrument.
The key includes the asset kind and identifier source so instruments that
share a raw symbol (for example, an equity and a crypto asset both named
BTC) do not collapse to the same key. Symbol payloads include their
byte length to avoid delimiter collisions with symbols that contain
characters such as @.
This is a synthetic composite key and is always returned as an owned
String. Use Self::display_key when a compact display identifier
is needed.
Sourcepub fn display_key(&self) -> Cow<'_, str>
pub fn display_key(&self) -> Cow<'_, str>
Returns the best available compact identifier for display (FIGI > ISIN > SYMBOL@EXCHANGE > SYMBOL).
Trait Implementations§
Source§impl Clone for Instrument
impl Clone for Instrument
Source§fn clone(&self) -> Instrument
fn clone(&self) -> Instrument
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Columnar for Instrument
impl Columnar for Instrument
Source§fn columnar_to_dataframe(items: &[Instrument]) -> Result<DataFrame, PolarsError>
fn columnar_to_dataframe(items: &[Instrument]) -> Result<DataFrame, PolarsError>
Source§fn columnar_from_refs(items: &[&Instrument]) -> Result<DataFrame, PolarsError>
fn columnar_from_refs(items: &[&Instrument]) -> Result<DataFrame, PolarsError>
Source§impl Debug for Instrument
impl Debug for Instrument
Source§impl<'de> Deserialize<'de> for Instrument
impl<'de> Deserialize<'de> for Instrument
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Instrument, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Instrument, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for Instrument
impl Display for Instrument
impl Eq for Instrument
Source§impl Hash for Instrument
impl Hash for Instrument
Source§impl PartialEq for Instrument
impl PartialEq for Instrument
Source§impl Serialize for Instrument
impl Serialize for Instrument
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Instrument
Source§impl ToDataFrame for Instrument
impl ToDataFrame for Instrument
Source§fn to_dataframe(&self) -> Result<DataFrame, PolarsError>
fn to_dataframe(&self) -> Result<DataFrame, PolarsError>
Source§fn empty_dataframe() -> Result<DataFrame, PolarsError>
fn empty_dataframe() -> Result<DataFrame, PolarsError>
Auto Trait Implementations§
impl Freeze for Instrument
impl RefUnwindSafe for Instrument
impl Send for Instrument
impl Sync for Instrument
impl Unpin for Instrument
impl UnsafeUnpin for Instrument
impl UnwindSafe for Instrument
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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> ⓘ
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> ⓘ
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 moreSource§impl<T> Key for Twhere
T: Clone,
impl<T> Key for Twhere
T: Clone,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read moreSource§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.