pub struct ExecutionInstrumentMap {
pub exchange: Keyed<ExchangeIndex, ExchangeId>,
pub assets: FnvIndexSet<ExchangeAsset<Asset>>,
pub instruments: FnvIndexSet<Instrument<Keyed<ExchangeIndex, ExchangeId>, AssetIndex>>,
/* private fields */
}Expand description
Indexed instrument map used to associate the internal Barter representation of instruments and
assets with the ExecutionClient representation.
Similarly, when the execution manager received an AccountEvent
from the execution API, it needs to determine the internal representation of the associated
assets and instruments.
eg/ InstrumentNameExchange("XBT-USDT") <–> InstrumentIndex(1)
eg/ AssetNameExchange("XBT") <–> AssetIndex(1)
§Names are matched ignoring ASCII case
Self::find_asset_index and Self::find_instrument_index resolve a name the way it was
registered first, and failing that ignoring ASCII case. Venues and clients do not always spell a
name the way it was registered (usd against USD), and a name that fails to resolve loses the
event carrying it. Ignoring case cannot merge two registered names, because
IndexedInstruments rejects two on one exchange that differ only in case. The lookups in the
other direction, from an index to a name, return the registered spelling.
Fields§
§exchange: Keyed<ExchangeIndex, ExchangeId>The exchange associated with this execution map.
assets: FnvIndexSet<ExchangeAsset<Asset>>Collection of assets available by the engine with their exchange-specific representations. This holds all indexed assets.
instruments: FnvIndexSet<Instrument<Keyed<ExchangeIndex, ExchangeId>, AssetIndex>>Collection of instruments available by the engine. This holds all indexed instruments.
Implementations§
Source§impl ExecutionInstrumentMap
impl ExecutionInstrumentMap
Sourcepub fn new(
exchange: Keyed<ExchangeIndex, ExchangeId>,
instruments: &IndexedInstruments,
) -> Self
pub fn new( exchange: Keyed<ExchangeIndex, ExchangeId>, instruments: &IndexedInstruments, ) -> Self
Construct a new Self using the provided indexed assets and instruments.
Sourcepub fn exchange_assets(&self) -> impl Iterator<Item = &AssetNameExchange>
pub fn exchange_assets(&self) -> impl Iterator<Item = &AssetNameExchange>
The names of this exchange’s assets, as registered.
Sourcepub fn exchange_instruments(
&self,
) -> impl Iterator<Item = &InstrumentNameExchange>
pub fn exchange_instruments( &self, ) -> impl Iterator<Item = &InstrumentNameExchange>
The names of this exchange’s instruments, as registered.
pub fn find_exchange_id( &self, exchange: ExchangeIndex, ) -> Result<ExchangeId, KeyError>
pub fn find_exchange_index( &self, exchange: ExchangeId, ) -> Result<ExchangeIndex, IndexError>
pub fn find_asset_name_exchange( &self, asset: AssetIndex, ) -> Result<&AssetNameExchange, KeyError>
Sourcepub fn find_asset_index(
&self,
asset: &AssetNameExchange,
) -> Result<AssetIndex, IndexError>
pub fn find_asset_index( &self, asset: &AssetNameExchange, ) -> Result<AssetIndex, IndexError>
Find the AssetIndex of the asset this exchange reports as asset.
Matches the registered spelling first, and failing that ignores ASCII case, logging the
case-insensitive match at debug! with both spellings. See the
type-level note.
pub fn find_instrument_name_exchange( &self, instrument: InstrumentIndex, ) -> Result<&InstrumentNameExchange, KeyError>
Sourcepub fn find_own_instrument_name_exchange(
&self,
instrument: InstrumentIndex,
) -> Option<&InstrumentNameExchange>
pub fn find_own_instrument_name_exchange( &self, instrument: InstrumentIndex, ) -> Option<&InstrumentNameExchange>
The name this exchange knows instrument by, or None when the instrument is listed on a
different exchange or instrument is not indexed. The two are not told apart.
Unlike Self::find_instrument_name_exchange, which resolves any indexed instrument
whatever its exchange, this answers “does this exchange trade it?”. Use it to decide which
venue an instrument-keyed event belongs to.
Sourcepub fn find_instrument_index(
&self,
instrument: &InstrumentNameExchange,
) -> Result<InstrumentIndex, IndexError>
pub fn find_instrument_index( &self, instrument: &InstrumentNameExchange, ) -> Result<InstrumentIndex, IndexError>
Find the InstrumentIndex of the instrument this exchange reports as instrument.
Matches the registered spelling first, and failing that ignores ASCII case, logging the
case-insensitive match at debug! with both spellings. See the
type-level note.
Trait Implementations§
Source§impl Clone for ExecutionInstrumentMap
impl Clone for ExecutionInstrumentMap
Source§impl Debug for ExecutionInstrumentMap
impl Debug for ExecutionInstrumentMap
impl Eq for ExecutionInstrumentMap
Source§impl PartialEq for ExecutionInstrumentMap
impl PartialEq for ExecutionInstrumentMap
impl StructuralPartialEq for ExecutionInstrumentMap
Auto Trait Implementations§
impl Freeze for ExecutionInstrumentMap
impl RefUnwindSafe for ExecutionInstrumentMap
impl Send for ExecutionInstrumentMap
impl Sync for ExecutionInstrumentMap
impl Unpin for ExecutionInstrumentMap
impl UnsafeUnpin for ExecutionInstrumentMap
impl UnwindSafe for ExecutionInstrumentMap
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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.Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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> 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 moreimpl<T> JsonSchemaMaybe for T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.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> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.