Skip to main content

CacheApi

Struct CacheApi 

Source
pub struct CacheApi<'a> { /* private fields */ }
Expand description

User-facing cache API.

Point reads return owned snapshots where possible, so actor code does not retain a Ref into the live Cache. Plural collection reads return owned snapshots of all matching values and are intentionally named as bulk reads. Prefer the count, ID, or has_* methods in hot paths when a full snapshot is not needed.

Implementations§

Source§

impl<'a> CacheApi<'a>

Source

pub fn calculate_unrealized_pnl(&self, position: &Position) -> Option<Money>

Returns the unrealized PnL for the position using cached market data.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn oms_type(&self, position_id: &PositionId) -> Option<OmsType>

Returns the OMS type for the position_id (if known).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn position_snapshot_bytes( &self, position_id: &PositionId, ) -> Option<Vec<Vec<u8>>>

Returns serialized position snapshot frames for the position_id.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn position_snapshot_count(&self, position_id: &PositionId) -> usize

Returns the number of stored position snapshots for the position_id.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn position_snapshots( &self, position_id: Option<&PositionId>, account_id: Option<&AccountId>, ) -> Vec<Position>

Returns position snapshots matching the optional filters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn position_snapshots_from( &self, position_id: &PositionId, skip: usize, ) -> Vec<Position>

Returns position snapshots for position_id starting from skip.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn position_snapshot_ids( &self, instrument_id: &InstrumentId, ) -> AHashSet<PositionId>

Returns position snapshot IDs for the instrument_id.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn client_order_ids( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, ) -> AHashSet<ClientOrderId>

Returns the client order IDs of all orders matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn client_order_ids_open( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, ) -> AHashSet<ClientOrderId>

Returns the client order IDs of all open orders matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn client_order_ids_closed( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, ) -> AHashSet<ClientOrderId>

Returns the client order IDs of all closed orders matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn client_order_ids_active_local( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, ) -> AHashSet<ClientOrderId>

Returns the client order IDs of all locally active orders matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn client_order_ids_emulated( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, ) -> AHashSet<ClientOrderId>

Returns the client order IDs of all emulated orders matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn client_order_ids_inflight( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, ) -> AHashSet<ClientOrderId>

Returns the client order IDs of all in-flight orders matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn position_ids( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, ) -> AHashSet<PositionId>

Returns the position IDs of all positions matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn position_open_ids( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, ) -> AHashSet<PositionId>

Returns the position IDs of all open positions matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn position_closed_ids( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, ) -> AHashSet<PositionId>

Returns the position IDs of all closed positions matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn actor_ids(&self) -> AHashSet<ComponentId>

Returns the actor IDs in the cache.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn strategy_ids(&self) -> AHashSet<StrategyId>

Returns the strategy IDs in the cache.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn exec_algorithm_ids(&self) -> AHashSet<ExecAlgorithmId>

Returns the execution algorithm IDs in the cache.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn order(&self, client_order_id: &ClientOrderId) -> Option<OrderAny>

Returns an owned copy of the order for the client_order_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn try_order( &self, client_order_id: &ClientOrderId, ) -> Result<OrderAny, OrderLookupError>

Returns an owned copy of the order for the client_order_id.

§Errors

Returns OrderLookupError::NotFound when the order is not present in the cache.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn orders_for_ids( &self, client_order_ids: &[ClientOrderId], context: &dyn Display, ) -> Vec<OrderAny>

Returns owned copies of the orders for client_order_ids.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn client_order_id( &self, venue_order_id: &VenueOrderId, ) -> Option<ClientOrderId>

Returns the client order ID for the venue_order_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn venue_order_id( &self, client_order_id: &ClientOrderId, ) -> Option<VenueOrderId>

Returns the venue order ID for the client_order_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn client_id(&self, client_order_id: &ClientOrderId) -> Option<ClientId>

Returns the client ID indexed for the client_order_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn orders( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<OrderSide>, ) -> Vec<OrderAny>

Returns owned copies of all orders matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn orders_open( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<OrderSide>, ) -> Vec<OrderAny>

Returns owned copies of all open orders matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn orders_closed( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<OrderSide>, ) -> Vec<OrderAny>

Returns owned copies of all closed orders matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn orders_active_local( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<OrderSide>, ) -> Vec<OrderAny>

Returns owned copies of all locally active orders matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn orders_emulated( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<OrderSide>, ) -> Vec<OrderAny>

Returns owned copies of all emulated orders matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn orders_inflight( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<OrderSide>, ) -> Vec<OrderAny>

Returns owned copies of all in-flight orders matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn orders_for_position(&self, position_id: &PositionId) -> Vec<OrderAny>

Returns owned copies of all orders for the position_id.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn order_exists(&self, client_order_id: &ClientOrderId) -> bool

Returns whether an order with the client_order_id exists.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn is_order_open(&self, client_order_id: &ClientOrderId) -> bool

Returns whether an order with the client_order_id is open.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn is_order_closed(&self, client_order_id: &ClientOrderId) -> bool

Returns whether an order with the client_order_id is closed.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn is_order_active_local(&self, client_order_id: &ClientOrderId) -> bool

Returns whether an order with the client_order_id is locally active.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn is_order_emulated(&self, client_order_id: &ClientOrderId) -> bool

Returns whether an order with the client_order_id is emulated.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn is_order_inflight(&self, client_order_id: &ClientOrderId) -> bool

Returns whether an order with the client_order_id is in-flight.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn is_order_pending_cancel_local( &self, client_order_id: &ClientOrderId, ) -> bool

Returns whether an order with the client_order_id is PENDING_CANCEL locally.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn orders_open_count( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<OrderSide>, ) -> usize

Returns the count of all open orders matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn orders_closed_count( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<OrderSide>, ) -> usize

Returns the count of all closed orders matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn orders_active_local_count( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<OrderSide>, ) -> usize

Returns the count of all locally active orders matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn orders_emulated_count( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<OrderSide>, ) -> usize

Returns the count of all emulated orders matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn orders_inflight_count( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<OrderSide>, ) -> usize

Returns the count of all in-flight orders matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn orders_total_count( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<OrderSide>, ) -> usize

Returns the count of all orders matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn has_orders_open( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<OrderSide>, ) -> bool

Returns whether any open order matches the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn has_orders_closed( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<OrderSide>, ) -> bool

Returns whether any closed order matches the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn has_orders_active_local( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<OrderSide>, ) -> bool

Returns whether any locally active order matches the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn has_orders_emulated( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<OrderSide>, ) -> bool

Returns whether any emulated order matches the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn has_orders_inflight( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<OrderSide>, ) -> bool

Returns whether any in-flight order matches the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn has_orders( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<OrderSide>, ) -> bool

Returns whether any order matches the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn order_list(&self, order_list_id: &OrderListId) -> Option<OrderList>

Returns an owned copy of the order list for the order_list_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn try_order_list( &self, order_list_id: &OrderListId, ) -> Result<OrderList, OrderListLookupError>

Returns an owned copy of the order list for the order_list_id.

§Errors

Returns OrderListLookupError::NotFound when the order list is not present in the cache.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn order_lists( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, ) -> Vec<OrderList>

Returns owned copies of all order lists matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn order_list_exists(&self, order_list_id: &OrderListId) -> bool

Returns whether an order list with the order_list_id exists.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn orders_for_exec_algorithm( &self, exec_algorithm_id: &ExecAlgorithmId, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<OrderSide>, ) -> Vec<OrderAny>

Returns owned copies of all orders associated with the exec_algorithm_id.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn orders_for_exec_spawn( &self, exec_spawn_id: &ClientOrderId, ) -> Vec<OrderAny>

Returns owned copies of all orders with the exec_spawn_id.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn exec_spawn_total_quantity( &self, exec_spawn_id: &ClientOrderId, active_only: bool, ) -> Option<Quantity>

Returns the total order quantity for the exec_spawn_id.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn exec_spawn_total_filled_qty( &self, exec_spawn_id: &ClientOrderId, active_only: bool, ) -> Option<Quantity>

Returns the total filled quantity for all orders with the exec_spawn_id.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn exec_spawn_total_leaves_qty( &self, exec_spawn_id: &ClientOrderId, active_only: bool, ) -> Option<Quantity>

Returns the total leaves quantity for all orders with the exec_spawn_id.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn position(&self, position_id: &PositionId) -> Option<Position>

Returns an owned copy of the position for the position_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn try_position( &self, position_id: &PositionId, ) -> Result<Position, PositionLookupError>

Returns an owned copy of the position for the position_id.

§Errors

Returns PositionLookupError::NotFound when the position is not present in the cache.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn position_for_order( &self, client_order_id: &ClientOrderId, ) -> Option<Position>

Returns an owned copy of the position for the client_order_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn position_id(&self, client_order_id: &ClientOrderId) -> Option<PositionId>

Returns the position ID for the client_order_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn positions( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<PositionSide>, ) -> Vec<Position>

Returns owned copies of all positions matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn positions_open( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<PositionSide>, ) -> Vec<Position>

Returns owned copies of all open positions matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn positions_closed( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<PositionSide>, ) -> Vec<Position>

Returns owned copies of all closed positions matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn position_exists(&self, position_id: &PositionId) -> bool

Returns whether a position with the position_id exists.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn is_position_open(&self, position_id: &PositionId) -> bool

Returns whether a position with the position_id is open.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn is_position_closed(&self, position_id: &PositionId) -> bool

Returns whether a position with the position_id is closed.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn positions_open_count( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<PositionSide>, ) -> usize

Returns the count of all open positions matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn positions_closed_count( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<PositionSide>, ) -> usize

Returns the count of all closed positions matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn positions_total_count( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<PositionSide>, ) -> usize

Returns the count of all positions matching the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn has_positions_open( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<PositionSide>, ) -> bool

Returns whether any open position matches the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn has_positions_closed( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<PositionSide>, ) -> bool

Returns whether any closed position matches the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn has_positions( &self, venue: Option<&Venue>, instrument_id: Option<&InstrumentId>, strategy_id: Option<&StrategyId>, account_id: Option<&AccountId>, side: Option<PositionSide>, ) -> bool

Returns whether any position matches the optional filter parameters.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn strategy_id_for_order( &self, client_order_id: &ClientOrderId, ) -> Option<StrategyId>

Returns the strategy ID for the client_order_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn strategy_id_for_position( &self, position_id: &PositionId, ) -> Option<StrategyId>

Returns the strategy ID for the position_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn get(&self, key: &str) -> Result<Option<Bytes>>

Returns the general cache value for the key (if found).

§Errors

Returns an error if the key is invalid.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn price( &self, instrument_id: &InstrumentId, price_type: PriceType, ) -> Option<Price>

Returns the price for the instrument_id and price_type (if found).

§Panics

Panics if the cache is already mutably borrowed, or if price_type is [PriceType::Mid] and the quote price precision is already at the maximum fixed precision.

Source

pub fn quotes(&self, instrument_id: &InstrumentId) -> Option<Vec<QuoteTick>>

Returns all quotes for the instrument_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn trades(&self, instrument_id: &InstrumentId) -> Option<Vec<TradeTick>>

Returns all trades for the instrument_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn mark_prices( &self, instrument_id: &InstrumentId, ) -> Option<Vec<MarkPriceUpdate>>

Returns all mark price updates for the instrument_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn index_prices( &self, instrument_id: &InstrumentId, ) -> Option<Vec<IndexPriceUpdate>>

Returns all index price updates for the instrument_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn funding_rates( &self, instrument_id: &InstrumentId, ) -> Option<Vec<FundingRateUpdate>>

Returns all funding rate updates for the instrument_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn instrument_statuses( &self, instrument_id: &InstrumentId, ) -> Option<Vec<InstrumentStatus>>

Returns all instrument status updates for the instrument_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn bars(&self, bar_type: &BarType) -> Option<Vec<Bar>>

Returns all bars for the bar_type (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn order_book(&self, instrument_id: &InstrumentId) -> Option<OrderBook>

Returns an owned copy of the order book for the instrument_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn try_order_book( &self, instrument_id: &InstrumentId, ) -> Result<OrderBook, OrderBookLookupError>

Returns an owned copy of the order book for the instrument_id.

§Errors

Returns OrderBookLookupError::NotFound when the order book is not present in the cache.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn own_order_book( &self, instrument_id: &InstrumentId, ) -> Option<OwnOrderBook>

Returns an owned copy of the own order book for the instrument_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn try_own_order_book( &self, instrument_id: &InstrumentId, ) -> Result<OwnOrderBook, OwnOrderBookLookupError>

Returns an owned copy of the own order book for the instrument_id.

§Errors

Returns OwnOrderBookLookupError::NotFound when the own order book is not present in the cache.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn quote(&self, instrument_id: &InstrumentId) -> Option<QuoteTick>

Returns the latest quote for the instrument_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn quote_at_index( &self, instrument_id: &InstrumentId, index: usize, ) -> Option<QuoteTick>

Returns the quote at index for the instrument_id (if found).

Index 0 is the most recent.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn trade(&self, instrument_id: &InstrumentId) -> Option<TradeTick>

Returns the latest trade for the instrument_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn trade_at_index( &self, instrument_id: &InstrumentId, index: usize, ) -> Option<TradeTick>

Returns the trade at index for the instrument_id (if found).

Index 0 is the most recent.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn mark_price( &self, instrument_id: &InstrumentId, ) -> Option<MarkPriceUpdate>

Returns the latest mark price update for the instrument_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn index_price( &self, instrument_id: &InstrumentId, ) -> Option<IndexPriceUpdate>

Returns the latest index price update for the instrument_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn funding_rate( &self, instrument_id: &InstrumentId, ) -> Option<FundingRateUpdate>

Returns the latest funding rate update for the instrument_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn instrument_status( &self, instrument_id: &InstrumentId, ) -> Option<InstrumentStatus>

Returns the latest instrument status update for the instrument_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn bar(&self, bar_type: &BarType) -> Option<Bar>

Returns the latest bar for the bar_type (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn bar_at_index(&self, bar_type: &BarType, index: usize) -> Option<Bar>

Returns the bar at index for the bar_type (if found).

Index 0 is the most recent.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn book_update_count(&self, instrument_id: &InstrumentId) -> usize

Returns the order book update count for the instrument_id.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn quote_count(&self, instrument_id: &InstrumentId) -> usize

Returns the quote tick count for the instrument_id.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn trade_count(&self, instrument_id: &InstrumentId) -> usize

Returns the trade tick count for the instrument_id.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn bar_count(&self, bar_type: &BarType) -> usize

Returns the bar count for the bar_type.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn has_order_book(&self, instrument_id: &InstrumentId) -> bool

Returns whether the cache contains an order book for the instrument_id.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn has_quote_ticks(&self, instrument_id: &InstrumentId) -> bool

Returns whether the cache contains quotes for the instrument_id.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn has_trade_ticks(&self, instrument_id: &InstrumentId) -> bool

Returns whether the cache contains trades for the instrument_id.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn has_bars(&self, bar_type: &BarType) -> bool

Returns whether the cache contains bars for the bar_type.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn get_xrate( &self, venue: Venue, from_currency: Currency, to_currency: Currency, price_type: PriceType, ) -> Option<Decimal>

Returns the exchange rate for the given currencies and price type (if available).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn get_mark_xrate( &self, from_currency: Currency, to_currency: Currency, ) -> Option<f64>

Returns the mark exchange rate for the currency pair (if set).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn yield_curve(&self, key: &str) -> Option<Box<dyn Fn(f64) -> f64>>

Returns the yield curve for the key (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn greeks(&self, instrument_id: &InstrumentId) -> Option<GreeksData>

Returns an owned copy of the greeks data for the instrument_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn option_greeks( &self, instrument_id: &InstrumentId, ) -> Option<OptionGreeks>

Returns exchange-provided option greeks for the instrument_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn currency(&self, code: &Ustr) -> Option<Currency>

Returns the currency for the code (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn try_currency(&self, code: &Ustr) -> Result<Currency, CurrencyLookupError>

Returns the currency for the code.

§Errors

Returns CurrencyLookupError::NotFound when the currency is not present in the cache.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn instrument(&self, instrument_id: &InstrumentId) -> Option<InstrumentAny>

Returns an owned copy of the instrument for the instrument_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn try_instrument( &self, instrument_id: &InstrumentId, ) -> Result<InstrumentAny, InstrumentLookupError>

Returns an owned copy of the instrument for the instrument_id.

§Errors

Returns InstrumentLookupError::NotFound when the instrument is not present in the cache.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn instrument_ids(&self, venue: Option<&Venue>) -> Vec<InstrumentId>

Returns the instrument IDs in the cache, optionally filtered by venue.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn instruments( &self, venue: &Venue, underlying: Option<&Ustr>, ) -> Vec<InstrumentAny>

Returns owned copies of all instruments for the venue.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn instruments_by_parent( &self, venue: &Venue, root: &Ustr, class: InstrumentClass, ) -> Vec<InstrumentAny>

Returns owned copies of all instruments for the venue, parent root, and instrument class.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn bar_types( &self, instrument_id: Option<&InstrumentId>, price_type: Option<&PriceType>, aggregation_source: AggregationSource, ) -> Vec<BarType>

Returns the bar types in the cache, optionally filtered by instrument and price type.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn synthetic( &self, instrument_id: &InstrumentId, ) -> Option<SyntheticInstrument>

Returns an owned copy of the synthetic instrument for the instrument_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn try_synthetic( &self, instrument_id: &InstrumentId, ) -> Result<SyntheticInstrument, SyntheticInstrumentLookupError>

Returns an owned copy of the synthetic instrument for the instrument_id.

§Errors

Returns SyntheticInstrumentLookupError::NotFound when the synthetic instrument is not present in the cache.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn synthetic_ids(&self) -> Vec<InstrumentId>

Returns the synthetic instrument IDs in the cache.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn synthetics(&self) -> Vec<SyntheticInstrument>

Returns owned copies of all synthetic instruments in the cache.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn pool(&self, instrument_id: &InstrumentId) -> Option<Pool>

Returns an owned copy of the pool for the instrument_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn pool_ids(&self, venue: Option<&Venue>) -> Vec<InstrumentId>

Returns the pool instrument IDs in the cache, optionally filtered by venue.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn pools(&self, venue: Option<&Venue>) -> Vec<Pool>

Returns owned copies of all pools in the cache, optionally filtered by venue.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn pool_profiler( &self, instrument_id: &InstrumentId, ) -> Option<PoolProfiler>

Returns an owned copy of the pool profiler for the instrument_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn pool_profiler_ids(&self, venue: Option<&Venue>) -> Vec<InstrumentId>

Returns the pool profiler instrument IDs in the cache, optionally filtered by venue.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn pool_profilers(&self, venue: Option<&Venue>) -> Vec<PoolProfiler>

Returns owned copies of all pool profilers in the cache, optionally filtered by venue.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn account(&self, account_id: &AccountId) -> Option<AccountAny>

Returns an owned copy of the account for the account_id (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn try_account( &self, account_id: &AccountId, ) -> Result<AccountAny, AccountLookupError>

Returns an owned copy of the account for the account_id.

§Errors

Returns AccountLookupError::NotFound when the account is not present in the cache.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn account_for_venue(&self, venue: &Venue) -> Option<AccountAny>

Returns an owned copy of the account for the venue (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn account_id(&self, venue: &Venue) -> Option<AccountId>

Returns the account ID for the venue (if found).

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn accounts(&self, account_id: &AccountId) -> Vec<AccountAny>

Returns owned copies of all accounts matching the account_id.

§Panics

Panics if the cache is already mutably borrowed.

Source

pub fn accounts_all(&self) -> Vec<AccountAny>

Returns owned copies of every account in the cache.

§Panics

Panics if the cache is already mutably borrowed.

Trait Implementations§

Source§

impl<'a> Debug for CacheApi<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for CacheApi<'a>

§

impl<'a> !Send for CacheApi<'a>

§

impl<'a> !Sync for CacheApi<'a>

§

impl<'a> !UnwindSafe for CacheApi<'a>

§

impl<'a> Freeze for CacheApi<'a>

§

impl<'a> Unpin for CacheApi<'a>

§

impl<'a> UnsafeUnpin for CacheApi<'a>

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.

§

impl<T> Instrument for T

§

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

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

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.

§

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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