Cache

Struct Cache 

Source
pub struct Cache { /* private fields */ }
Expand description

A common in-memory Cache for market and execution related data.

Implementations§

Source§

impl Cache

Source

pub fn new( config: Option<CacheConfig>, database: Option<Box<dyn CacheDatabaseAdapter>>, ) -> Self

Creates a new Cache instance with optional configuration and database adapter.

§Note

Uses provided CacheConfig or defaults, and optional CacheDatabaseAdapter for persistence.

Source

pub fn memory_address(&self) -> String

Returns the cache instances memory address.

Source

pub fn cache_general(&mut self) -> Result<()>

Clears and reloads general entries from the database into the cache.

§Errors

Returns an error if loading general cache data fails.

Source

pub async fn cache_all(&mut self) -> Result<()>

Loads all core caches (currencies, instruments, accounts, orders, positions) from the database.

§Errors

Returns an error if loading all cache data fails.

Source

pub async fn cache_currencies(&mut self) -> Result<()>

Clears and reloads the currency cache from the database.

§Errors

Returns an error if loading currencies cache fails.

Source

pub async fn cache_instruments(&mut self) -> Result<()>

Clears and reloads the instrument cache from the database.

§Errors

Returns an error if loading instruments cache fails.

Source

pub async fn cache_synthetics(&mut self) -> Result<()>

Clears and reloads the synthetic instrument cache from the database.

§Errors

Returns an error if loading synthetic instruments cache fails.

Source

pub async fn cache_accounts(&mut self) -> Result<()>

Clears and reloads the account cache from the database.

§Errors

Returns an error if loading accounts cache fails.

Source

pub async fn cache_orders(&mut self) -> Result<()>

Clears and reloads the order cache from the database.

§Errors

Returns an error if loading orders cache fails.

Source

pub async fn cache_positions(&mut self) -> Result<()>

Clears and reloads the position cache from the database.

§Errors

Returns an error if loading positions cache fails.

Source

pub fn build_index(&mut self)

Clears the current cache index and re-build.

Source

pub const fn has_backing(&self) -> bool

Returns whether the cache has a backing database.

Source

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

Source

pub fn check_integrity(&mut self) -> bool

Checks integrity of data within the cache.

All data should be loaded from the database prior to this call. If an error is found then a log error message will also be produced.

§Panics

Panics if failure calling system clock.

Source

pub fn check_residuals(&self) -> bool

Checks for any residual open state and log warnings if any are found.

‘Open state’ is considered to be open orders and open positions.

Source

pub fn purge_closed_orders(&mut self, ts_now: UnixNanos, buffer_secs: u64)

Purges all closed orders from the cache that are older than buffer_secs.

Only orders that have been closed for at least this amount of time will be purged. A value of 0 means purge all closed orders regardless of when they were closed.

Source

pub fn purge_closed_positions(&mut self, ts_now: UnixNanos, buffer_secs: u64)

Purges all closed positions from the cache that are older than buffer_secs.

Source

pub fn purge_order(&mut self, client_order_id: ClientOrderId)

Purges the order with the client_order_id from the cache (if found).

All OrderFilled events for the order will also be purged from any associated position.

Source

pub fn purge_position(&mut self, position_id: PositionId)

Purges the position with the position_id from the cache (if found).

Source

pub fn purge_account_events(&mut self, ts_now: UnixNanos, lookback_secs: u64)

Purges all account state events which are outside the lookback window.

Only events which are outside the lookback window will be purged. A value of 0 means purge all account state events.

Source

pub fn clear_index(&mut self)

Clears the caches index.

Source

pub fn reset(&mut self)

Resets the cache.

All stateful fields are reset to their initial value.

Source

pub fn dispose(&mut self)

Dispose of the cache which will close any underlying database adapter.

§Panics

Panics if closing the database connection fails.

Source

pub fn flush_db(&mut self)

Flushes the caches database which permanently removes all persisted data.

§Panics

Panics if flushing the database connection fails.

Source

pub fn add(&mut self, key: &str, value: Bytes) -> Result<()>

Adds a raw bytes value to the cache under the key.

The cache stores only raw bytes; interpretation is the caller’s responsibility.

§Errors

Returns an error if persisting the entry to the backing database fails.

Source

pub fn add_order_book(&mut self, book: OrderBook) -> Result<()>

Adds an OrderBook to the cache.

§Errors

Returns an error if persisting the order book to the backing database fails.

Source

pub fn add_own_order_book(&mut self, own_book: OwnOrderBook) -> Result<()>

Adds an OwnOrderBook to the cache.

§Errors

Returns an error if persisting the own order book fails.

Source

pub fn add_pool(&mut self, pool: Pool) -> Result<()>

Adds a Pool to the cache.

§Errors

This function currently does not return errors but follows the same pattern as other add methods for consistency.

Source

pub fn add_mark_price(&mut self, mark_price: MarkPriceUpdate) -> Result<()>

Adds the mark_price update to the cache.

§Errors

Returns an error if persisting the mark price to the backing database fails.

Source

pub fn add_index_price(&mut self, index_price: IndexPriceUpdate) -> Result<()>

Adds the index_price update to the cache.

§Errors

Returns an error if persisting the index price to the backing database fails.

Source

pub fn add_funding_rate( &mut self, funding_rate: FundingRateUpdate, ) -> Result<()>

Adds the funding_rate update to the cache.

§Errors

Returns an error if persisting the funding rate update to the backing database fails.

Source

pub fn add_quote(&mut self, quote: QuoteTick) -> Result<()>

Adds the quote tick to the cache.

§Errors

Returns an error if persisting the quote tick to the backing database fails.

Source

pub fn add_quotes(&mut self, quotes: &[QuoteTick]) -> Result<()>

Adds the quotes to the cache.

§Errors

Returns an error if persisting the quote ticks to the backing database fails.

Source

pub fn add_trade(&mut self, trade: TradeTick) -> Result<()>

Adds the trade tick to the cache.

§Errors

Returns an error if persisting the trade tick to the backing database fails.

Source

pub fn add_trades(&mut self, trades: &[TradeTick]) -> Result<()>

Adds the give trades to the cache.

§Errors

Returns an error if persisting the trade ticks to the backing database fails.

Source

pub fn add_bar(&mut self, bar: Bar) -> Result<()>

Adds the bar to the cache.

§Errors

Returns an error if persisting the bar to the backing database fails.

Source

pub fn add_bars(&mut self, bars: &[Bar]) -> Result<()>

Adds the bars to the cache.

§Errors

Returns an error if persisting the bars to the backing database fails.

Source

pub fn add_greeks(&mut self, greeks: GreeksData) -> Result<()>

Adds the greeks data to the cache.

§Errors

Returns an error if persisting the greeks data to the backing database fails.

Source

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

Gets the greeks data for the instrument_id.

Source

pub fn add_yield_curve(&mut self, yield_curve: YieldCurveData) -> Result<()>

Adds the yield_curve data to the cache.

§Errors

Returns an error if persisting the yield curve data to the backing database fails.

Source

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

Gets the yield curve for the key.

Source

pub fn add_currency(&mut self, currency: Currency) -> Result<()>

Adds the currency to the cache.

§Errors

Returns an error if persisting the currency to the backing database fails.

Source

pub fn add_instrument(&mut self, instrument: InstrumentAny) -> Result<()>

Adds the instrument to the cache.

§Errors

Returns an error if persisting the instrument to the backing database fails.

Source

pub fn add_synthetic(&mut self, synthetic: SyntheticInstrument) -> Result<()>

Adds the synthetic instrument to the cache.

§Errors

Returns an error if persisting the synthetic instrument to the backing database fails.

Source

pub fn add_account(&mut self, account: AccountAny) -> Result<()>

Adds the account to the cache.

§Errors

Returns an error if persisting the account to the backing database fails.

Source

pub fn add_venue_order_id( &mut self, client_order_id: &ClientOrderId, venue_order_id: &VenueOrderId, overwrite: bool, ) -> Result<()>

Indexes the client_order_id with the venue_order_id.

The overwrite parameter determines whether to overwrite any existing cached identifier.

§Errors

Returns an error if the existing venue order ID conflicts and overwrite is false.

Source

pub fn add_order( &mut self, order: OrderAny, position_id: Option<PositionId>, client_id: Option<ClientId>, replace_existing: bool, ) -> Result<()>

Adds the order to the cache indexed with any given identifiers.

§Parameters

override_existing: If the added order should ‘override’ any existing order and replace it in the cache. This is currently used for emulated orders which are being released and transformed into another type.

§Errors

Returns an error if not replace_existing and the order.client_order_id is already contained in the cache.

Source

pub fn add_position_id( &mut self, position_id: &PositionId, venue: &Venue, client_order_id: &ClientOrderId, strategy_id: &StrategyId, ) -> Result<()>

Indexes the position_id with the other given IDs.

§Errors

Returns an error if indexing position ID in the backing database fails.

Source

pub fn add_position( &mut self, position: Position, _oms_type: OmsType, ) -> Result<()>

Adds the position to the cache.

§Errors

Returns an error if persisting the position to the backing database fails.

Source

pub fn update_account(&mut self, account: AccountAny) -> Result<()>

Updates the account in the cache.

§Errors

Returns an error if updating the account in the database fails.

Source

pub fn update_order(&mut self, order: &OrderAny) -> Result<()>

Updates the order in the cache.

§Errors

Returns an error if updating the order in the database fails.

Source

pub fn update_order_pending_cancel_local(&mut self, order: &OrderAny)

Updates the order as pending cancel locally.

Source

pub fn update_position(&mut self, position: &Position) -> Result<()>

Updates the position in the cache.

§Errors

Returns an error if updating the position in the database fails.

Source

pub fn snapshot_position(&mut self, position: &Position) -> Result<()>

Creates a snapshot of the position by cloning it, assigning a new ID, serializing it, and storing it in the position snapshots.

§Errors

Returns an error if serializing or storing the position snapshot fails.

Source

pub fn snapshot_position_state( &mut self, position: &Position, open_only: Option<bool>, ) -> Result<()>

Creates a snapshot of the position state in the database.

§Errors

Returns an error if snapshotting the position state fails.

Source

pub fn snapshot_order_state(&self, order: &OrderAny) -> Result<()>

Snapshots the order state in the database.

§Errors

Returns an error if snapshotting the order state fails.

Source

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

Returns the ClientOrderIds of all orders.

Source

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

Returns the ClientOrderIds of all open orders.

Source

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

Returns the ClientOrderIds of all closed orders.

Source

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

Returns the ClientOrderIds of all emulated orders.

Source

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

Returns the ClientOrderIds of all in-flight orders.

Source

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

Returns PositionIds of all positions.

Source

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

Returns the PositionIds of all open positions.

Source

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

Returns the PositionIds of all closed positions.

Source

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

Returns the ComponentIds of all actors.

Source

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

Returns the StrategyIds of all strategies.

Source

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

Returns the ExecAlgorithmIds of all execution algorithms.

Source

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

Gets a reference to the order with the client_order_id (if found).

Source

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

Gets a reference to the order with the client_order_id (if found).

Source

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

Gets a reference to the client order ID for the venue_order_id (if found).

Source

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

Gets a reference to the venue order ID for the client_order_id (if found).

Source

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

Gets a reference to the client ID indexed for then client_order_id (if found).

Source

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

Returns references to all orders matching the optional filter parameters.

Source

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

Returns references to all open orders matching the optional filter parameters.

Source

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

Returns references to all closed orders matching the optional filter parameters.

Source

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

Returns references to all emulated orders matching the optional filter parameters.

Source

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

Returns references to all in-flight orders matching the optional filter parameters.

Source

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

Returns references to all orders for the position_id.

Source

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

Returns whether an order with the client_order_id exists.

Source

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

Returns whether an order with the client_order_id is open.

Source

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

Returns whether an order with the client_order_id is closed.

Source

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

Returns whether an order with the client_order_id is emulated.

Source

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

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

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.

Source

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

Returns the count of all open orders.

Source

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

Returns the count of all closed orders.

Source

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

Returns the count of all emulated orders.

Source

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

Returns the count of all in-flight orders.

Source

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

Returns the count of all orders.

Source

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

Returns the order list for the order_list_id.

Source

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

Returns all order lists matching the optional filter parameters.

Source

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

Returns whether an order list with the order_list_id exists.

Source

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

Returns references to all orders associated with the exec_algorithm_id matching the optional filter parameters.

Source

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

Returns references to all orders with the exec_spawn_id.

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.

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.

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.

Source

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

Returns a reference to the position with the position_id (if found).

Source

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

Returns a reference to the position for the client_order_id (if found).

Source

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

Returns a reference to the position ID for the client_order_id (if found).

Source

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

Returns a reference to all positions matching the optional filter parameters.

Source

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

Returns a reference to all open positions matching the optional filter parameters.

Source

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

Returns a reference to all closed positions matching the optional filter parameters.

Source

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

Returns whether a position with the position_id exists.

Source

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

Returns whether a position with the position_id is open.

Source

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

Returns whether a position with the position_id is closed.

Source

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

Returns the count of all open positions.

Source

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

Returns the count of all closed positions.

Source

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

Returns the count of all positions.

Source

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

Gets a reference to the strategy ID for the client_order_id (if found).

Source

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

Gets a reference to the strategy ID for the position_id (if found).

Source

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

Gets a reference to the general value for the key (if found).

§Errors

Returns an error if the key is invalid.

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).

Source

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

Gets all quotes for the instrument_id.

Source

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

Gets all trades for the instrument_id.

Source

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

Gets all mark price updates for the instrument_id.

Source

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

Gets all index price updates for the instrument_id.

Source

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

Gets all bars for the bar_type.

Source

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

Gets a reference to the order book for the instrument_id.

Source

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

Gets a reference to the order book for the instrument_id.

Source

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

Gets a reference to the own order book for the instrument_id.

Source

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

Gets a reference to the own order book for the instrument_id.

Source

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

Gets a reference to the pool for the instrument_id.

Source

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

Gets a mutable reference to the pool for the instrument_id.

Source

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

Gets a reference to the latest quote for the instrument_id.

Source

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

Gets a reference to the latest trade for the instrument_id.

Source

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

Gets a referenece to the latest mark price update for the instrument_id.

Source

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

Gets a referenece to the latest index price update for the instrument_id.

Source

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

Gets a reference to the funding rate update for the instrument_id.

Source

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

Gets a reference to the latest bar for the bar_type.

Source

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

Gets the order book update count for the instrument_id.

Source

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

Gets the quote tick count for the instrument_id.

Source

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

Gets the trade tick count for the instrument_id.

Source

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

Gets the bar count for the instrument_id.

Source

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

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

Source

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

Returns whether the cache contains quotes for the instrument_id.

Source

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

Returns whether the cache contains trades for the instrument_id.

Source

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

Returns whether the cache contains bars for the bar_type.

Source

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

Source

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

Returns the mark exchange rate for the given currency pair, or None if not set.

Source

pub fn set_mark_xrate( &mut self, from_currency: Currency, to_currency: Currency, xrate: f64, )

Sets the mark exchange rate for the given currency pair and automatically sets the inverse rate.

§Panics

Panics if xrate is not positive.

Source

pub fn clear_mark_xrate( &mut self, from_currency: Currency, to_currency: Currency, )

Clears the mark exchange rate for the given currency pair.

Source

pub fn clear_mark_xrates(&mut self)

Clears all mark exchange rates.

Source

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

Returns a reference to the instrument for the instrument_id (if found).

Source

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

Returns references to all instrument IDs for the venue.

Source

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

Returns references to all instruments for the venue.

Source

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

Returns references to all bar types contained in the cache.

Source

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

Returns a reference to the synthetic instrument for the instrument_id (if found).

Source

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

Returns references to instrument IDs for all synthetic instruments contained in the cache.

Source

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

Returns references to all synthetic instruments contained in the cache.

Source

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

Returns a reference to the account for the account_id (if found).

Source

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

Returns a reference to the account for the venue (if found).

Source

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

Returns a reference to the account ID for the venue (if found).

Source

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

Returns references to all accounts for the account_id.

Source

pub fn update_own_order_book(&mut self, order: &OrderAny)

Updates the own order book with an order.

This method adds, updates, or removes an order from the own order book based on the order’s current state.

Trait Implementations§

Source§

impl Debug for Cache

Source§

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

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

impl Default for Cache

Source§

fn default() -> Self

Creates a new default Cache instance.

Source§

impl<'py> IntoPyObject<'py> for Cache

Source§

type Target = Cache

The Python output type
Source§

type Output = Bound<'py, <Cache as IntoPyObject<'py>>::Target>

The smart pointer type to use. Read more
Source§

type Error = PyErr

The type returned in the event of a conversion error.
Source§

fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>

Performs the conversion.
Source§

impl PyClass for Cache

Source§

type Frozen = False

Whether the pyclass is frozen. Read more
Source§

impl PyClassImpl for Cache

Source§

const IS_BASETYPE: bool = false

#[pyclass(subclass)]
Source§

const IS_SUBCLASS: bool = false

#[pyclass(extends=…)]
Source§

const IS_MAPPING: bool = false

#[pyclass(mapping)]
Source§

const IS_SEQUENCE: bool = false

#[pyclass(sequence)]
Source§

const IS_IMMUTABLE_TYPE: bool = false

#[pyclass(immutable_type)]
Source§

type BaseType = PyAny

Base class
Source§

type ThreadChecker = ThreadCheckerImpl

This handles following two situations: Read more
Source§

type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild

Immutable or mutable
Source§

type Dict = PyClassDummySlot

Specify this class has #[pyclass(dict)] or not.
Source§

type WeakRef = PyClassDummySlot

Specify this class has #[pyclass(weakref)] or not.
Source§

type BaseNativeType = PyAny

The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict.
Source§

fn items_iter() -> PyClassItemsIter

Source§

fn doc(py: Python<'_>) -> PyResult<&'static CStr>

Rendered class doc
Source§

fn lazy_type_object() -> &'static LazyTypeObject<Self>

§

fn dict_offset() -> Option<isize>

§

fn weaklist_offset() -> Option<isize>

Source§

impl PyClassNewTextSignature<Cache> for PyClassImplCollector<Cache>

Source§

fn new_text_signature(self) -> Option<&'static str>

Source§

impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a Cache

Source§

type Holder = Option<PyRef<'py, Cache>>

Source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

Source§

impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a mut Cache

Source§

type Holder = Option<PyRefMut<'py, Cache>>

Source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

Source§

impl PyMethods<Cache> for PyClassImplCollector<Cache>

Source§

fn py_methods(self) -> &'static PyClassItems

Source§

impl PyTypeInfo for Cache

Source§

const NAME: &'static str = "Cache"

Class name.
Source§

const MODULE: Option<&'static str>

Module name, if any.
Source§

fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject

Returns the PyTypeObject instance for this type.
§

fn type_object(py: Python<'_>) -> Bound<'_, PyType>

Returns the safe abstraction over the type object.
§

fn is_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type or a subclass of this type.
§

fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type.
Source§

impl DerefToPyAny for Cache

Auto Trait Implementations§

§

impl Freeze for Cache

§

impl !RefUnwindSafe for Cache

§

impl !Send for Cache

§

impl !Sync for Cache

§

impl Unpin for Cache

§

impl !UnwindSafe for Cache

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

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
§

impl<'py, T> IntoPyObjectExt<'py> for T
where T: IntoPyObject<'py>,

§

fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>

Converts self into an owned Python object, dropping type information.
§

fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>

Converts self into an owned Python object, dropping type information and unbinding it from the 'py lifetime.
§

fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>

Converts self into a Python object. Read more
Source§

impl<'py, T> IntoPyObjectNautilusExt<'py> for T
where T: IntoPyObjectExt<'py>,

Source§

fn into_py_any_unwrap(self, py: Python<'py>) -> Py<PyAny>

Convert self into a [PyObject] while panicking if the conversion fails. Read more
§

impl<T> PyTypeCheck for T
where T: PyTypeInfo,

§

const NAME: &'static str = <T as PyTypeInfo>::NAME

Name of self. This is used in error messages, for example.
§

fn type_check(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of Self, which may include a subtype. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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