pub struct AccountEventIndexer {
pub map: Arc<ExecutionInstrumentMap>,
}Fields§
§map: Arc<ExecutionInstrumentMap>Implementations§
Source§impl AccountEventIndexer
impl AccountEventIndexer
pub const fn new(map: Arc<ExecutionInstrumentMap>) -> AccountEventIndexer
Source§impl AccountEventIndexer
impl AccountEventIndexer
pub fn account_event( &self, event: UnindexedAccountEvent, ) -> Result<AccountEvent, IndexError>
pub fn snapshot( &self, snapshot: UnindexedAccountSnapshot, ) -> Result<AccountSnapshot, IndexError>
pub fn asset_balance( &self, balance: AssetBalance<AssetNameExchange>, ) -> Result<AssetBalance<AssetIndex>, IndexError>
pub fn asset_balance_update( &self, update: AssetBalanceUpdate<AssetNameExchange>, ) -> Result<AssetBalanceUpdate<AssetIndex>, IndexError>
Sourcepub fn isolated_instrument_state(
&self,
state: IsolatedInstrumentState<AssetNameExchange>,
) -> Result<IsolatedInstrumentState<AssetIndex>, IndexError>
pub fn isolated_instrument_state( &self, state: IsolatedInstrumentState<AssetNameExchange>, ) -> Result<IsolatedInstrumentState<AssetIndex>, IndexError>
Index the per-pair isolated state’s base/quote asset names to indices.
§Errors
Returns IndexError if either the base or quote asset is not registered in the map —
matching the fail-fast behaviour of top-level Self::asset_balance.
Sourcepub fn fill_recovery_gap(
&self,
gap: FillRecoveryGap<InstrumentNameExchange>,
) -> Result<FillRecoveryGap<InstrumentIndex>, IndexError>
pub fn fill_recovery_gap( &self, gap: FillRecoveryGap<InstrumentNameExchange>, ) -> Result<FillRecoveryGap<InstrumentIndex>, IndexError>
Index a FillRecoveryGap’s instruments.
§Errors
Returns IndexError if any instrument is not registered in the map. The whole gap fails
rather than dropping that instrument, which would understate what is missing. A venue names
only the instruments its stream was opened with, so this fails only for a stream opened
with an instrument the map does not hold.
Sourcepub fn cash_flow(
&self,
flow: CashFlow<AssetNameExchange, InstrumentNameExchange>,
) -> Result<CashFlow<AssetIndex, InstrumentIndex>, IndexError>
pub fn cash_flow( &self, flow: CashFlow<AssetNameExchange, InstrumentNameExchange>, ) -> Result<CashFlow<AssetIndex, InstrumentIndex>, IndexError>
Sourcepub fn notice(
&self,
exchange: ExchangeIndex,
notice: AccountNotice<InstrumentNameExchange>,
) -> AccountNotice<InstrumentIndex>
pub fn notice( &self, exchange: ExchangeIndex, notice: AccountNotice<InstrumentNameExchange>, ) -> AccountNotice<InstrumentIndex>
Index an AccountNotice’s instrument, when it names one.
Never fails. A notice naming an instrument that is not in the map is kept, with its
instrument set to None and a warn: a notice changes no state, so dropping one about a
margin call or liquidation would cost more than losing its attribution.
Sourcepub fn instrument_balance_update(
&self,
update: InstrumentBalanceUpdate<AssetNameExchange, InstrumentNameExchange>,
) -> Result<InstrumentBalanceUpdate, IndexError>
pub fn instrument_balance_update( &self, update: InstrumentBalanceUpdate<AssetNameExchange, InstrumentNameExchange>, ) -> Result<InstrumentBalanceUpdate, IndexError>
Index an InstrumentBalanceUpdate’s instrument and asset keys.
§Errors
Returns IndexError if the instrument or the asset is not registered in the map.
pub fn order_snapshot( &self, order: UnindexedOrderSnapshot, ) -> Result<OrderSnapshot, IndexError>
pub fn order_response_cancel( &self, response: OrderResponseCancel<ExchangeId, AssetNameExchange, InstrumentNameExchange>, ) -> Result<OrderResponseCancel, IndexError>
pub fn order_key(&self, key: UnindexedOrderKey) -> Result<OrderKey, IndexError>
Sourcepub fn order_state(&self, state: UnindexedOrderState) -> OrderState
pub fn order_state(&self, state: UnindexedOrderState) -> OrderState
Index an UnindexedOrderState to an OrderState.
Used by ExecutionManager to index open_order responses. Never fails: an order state
carries no key, and the error of a failed open is indexed by Self::order_error.
Sourcepub fn api_error(&self, error: UnindexedApiError) -> ApiError
pub fn api_error(&self, error: UnindexedApiError) -> ApiError
Index an UnindexedApiError returned for an order request (open or cancel).
Never fails. An error carries the venue’s answer to a request, and the caller must
receive that answer, so a name the ExecutionInstrumentMap does not hold degrades the
error instead of discarding it (and the order response or client error carrying it). Each
degrade logs a warn! naming what was dropped:
ApiError::BalanceInsufficientkeeps its variant, with the assetNone.ApiError::AssetInvalidandApiError::InstrumentInvalidhave no index to carry, so they becomeApiError::OrderRejectedholding their own message, which keeps the name and the venue’s text.
For an error from any other request, use Self::client_error, which degrades to
ApiError::RequestRejected instead.
pub fn order_request<Kind>(
&self,
order: &OrderEvent<Kind, ExchangeIndex, InstrumentIndex>,
) -> Result<OrderEvent<Kind, ExchangeId, &InstrumentNameExchange>, KeyError>where
Kind: Clone,
Sourcepub fn order_error(&self, error: UnindexedOrderError) -> OrderError
pub fn order_error(&self, error: UnindexedOrderError) -> OrderError
Index an UnindexedOrderError. Never fails: see Self::api_error.
Sourcepub fn client_error(&self, error: UnindexedClientError) -> ClientError
pub fn client_error(&self, error: UnindexedClientError) -> ClientError
Index an UnindexedClientError. Never fails: like Self::api_error, but an
unresolvable ApiError::AssetInvalid or ApiError::InstrumentInvalid becomes
ApiError::RequestRejected, since the request need not have been an order.
Sourcepub fn account_stream_init_error(
&self,
error: UnindexedAccountStreamInitError,
) -> AccountStreamInitError
pub fn account_stream_init_error( &self, error: UnindexedAccountStreamInitError, ) -> AccountStreamInitError
Index an UnindexedAccountStreamInitError. Never fails, as Self::client_error.
Sourcepub fn reinit_failure(
&self,
failure: AccountReinitFailure<AssetNameExchange, InstrumentNameExchange>,
) -> AccountReinitFailure
pub fn reinit_failure( &self, failure: AccountReinitFailure<AssetNameExchange, InstrumentNameExchange>, ) -> AccountReinitFailure
Index an AccountReinitFailure. Never fails, as Self::client_error.
Sourcepub fn trade_amendment(
&self,
amendment: TradeAmendment<AssetNameExchange, InstrumentNameExchange>,
) -> Result<TradeAmendment<AssetIndex, InstrumentIndex>, IndexError>
pub fn trade_amendment( &self, amendment: TradeAmendment<AssetNameExchange, InstrumentNameExchange>, ) -> Result<TradeAmendment<AssetIndex, InstrumentIndex>, IndexError>
Index a TradeAmendment. A replacement trade is indexed as trade indexes
one, so an amendment fails where its trade would.
Sourcepub fn trade(
&self,
trade: Trade<AssetNameExchange, InstrumentNameExchange>,
) -> Result<Trade<AssetIndex, InstrumentIndex>, IndexError>
pub fn trade( &self, trade: Trade<AssetNameExchange, InstrumentNameExchange>, ) -> Result<Trade<AssetIndex, InstrumentIndex>, IndexError>
Index a trade, converting fee asset and computing fees_quote.
Computes fees_quote based on fee asset relationship to instrument:
- Fee in quote asset:
fees_quote = Some(fees) - Fee in base asset:
fees_quote = Some(fees * price) - Fee in third-party asset (e.g., BNB):
fees_quote = None
§A fee asset that is not in the map
The trade is kept, with its fee zeroed: fees is 0 in the instrument’s quote asset and
fees_quote is None. A warn names the fee’s asset and amount. Dropping the trade would
leave the engine’s position different from the venue’s, which costs far more than one
unknown fee. The warn is per trade, so an account that pays every fee in an unregistered
asset logs one per fill until the asset is registered. Two cases reach this:
- An asset the account pays fees in but no instrument implies, such as BNB on Binance spot
with “pay fees with BNB” turned on. Register it with
IndexedInstrumentsBuilder::add_assetto keep its fee. - The
"UNKNOWN"placeholder some integrations use when the venue gave no fee asset: IBKRfetch_tradesfor an execution IB sent no commission report for, and Binance when a report omitscommissionAsset.
§Errors
Returns IndexError if the trade’s instrument is not in the map.
Trait Implementations§
Source§impl Clone for AccountEventIndexer
impl Clone for AccountEventIndexer
Source§impl Debug for AccountEventIndexer
impl Debug for AccountEventIndexer
Auto Trait Implementations§
impl Freeze for AccountEventIndexer
impl RefUnwindSafe for AccountEventIndexer
impl Send for AccountEventIndexer
impl Sync for AccountEventIndexer
impl Unpin for AccountEventIndexer
impl UnsafeUnpin for AccountEventIndexer
impl UnwindSafe for AccountEventIndexer
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<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.