Cache - Loren1166/NautilusTrader- GitHub Wiki

Cache 缓存

The cache subpackage provides common caching infrastructure. # 缓存子包提供通用的缓存基础设施。

A running Nautilus system generally uses a single centralized cache which can be accessed by many components. # 运行的 Nautilus 系统通常使用一个可以被许多组件访问的集中式缓存。

class Cache 缓存

class Cache(CacheFacade):
    """
    Provides a common object cache for market and execution related data.

    为市场和执行相关数据提供通用的对象缓存。

    Parameters:
    参数:
        database (CacheDatabaseFacade , optional) – The database adapter for the cache. If None then will bypass persistence.
        database (CacheDatabaseFacade,可选) - 缓存的数据库适配器。如果为 None,则将绕过持久化。
        config (CacheConfig , optional) – The cache configuration.
        config (CacheConfig,可选) - 缓存配置。

    Raises: TypeError – If config is not of type CacheConfig.
    引发:TypeError - 如果 config 的类型不是 CacheConfig。
    """
    def __init__(self, database: CacheDatabaseFacade | None = None, config: CacheConfig | None = None) -> None:
        ...

Properties 属性

    @property
    def bar_capacity(self):
        """
        The caches bar capacity.

        缓存的 bar 容量。

        Returns:
            int
        """
        ...

    @property
    def has_backing(self):
        """
        If the cache has a database backing.

        如果缓存有数据库支持。

        Returns:
            bool
        """
        ...

    @property
    def tick_capacity(self):
        """
        The caches tick capacity.

        缓存的 tick 容量。

        Returns:
            int
        """
        ...

Methods 方法

    def account(self, account_id: AccountId):
        """
        Return the account matching the given ID (if found).

        返回与给定 ID 匹配的账户(如果找到)。

        Parameters: account_id (AccountId) – The account ID.
        参数:account_id (AccountId) - 账户 ID。

        Return type: Account or None
        """
        ...
    
    def account_for_venue(self, venue: Venue):
        """
        Return the account matching the given client ID (if found).

        返回与给定客户端 ID 匹配的账户(如果找到)。

        Parameters: venue (Venue) – The venue for the account.
        参数:venue (Venue) - 账户的平台。

        Return type: Account or None
        """
        ...

    def account_id(self, venue: Venue) -> AccountId:
        """
        Return the account ID for the given venue (if found).

        返回给定平台的账户 ID(如果找到)。

        Parameters: venue (Venue) – The venue for the account ID.
        参数:venue (Venue) - 账户 ID 的平台。

        Return type: AccountId or None
        """
        ...

    def accounts(self) -> list:
        """
        Return all accounts in the cache.

        返回缓存中的所有账户。

        Return type: list[Account]
        """
        ...

    def actor_ids(self) -> set:
        """
        Return all actor IDs.

        返回所有 actor ID。

        Return type: set[ComponentId]
        """
        ...

    def add(self, key: str, value: bytes) -> void:
        """
        Add the given general object value to the cache.

        将给定的通用对象值添加到缓存中。

        The cache is agnostic to what the object actually is (and how it may be serialized), offering maximum flexibility.

        缓存不知道对象实际上是什么(以及它如何被序列化),提供了最大的灵活性。

        Parameters:
        参数:
            key (str) – The cache key for the object.
            key (str) - 对象的缓存键。
            value (bytes) – The object value to write.
            value (bytes) - 要写入的对象值。
        """
        ...
    
    def add_account(self, account: Account) -> void:
        """
        Add the given account to the cache.

        将给定的账户添加到缓存中。

        Parameters: account (Account) – The account to add.
        参数:account (Account) - 要添加的账户。
        Raises: ValueError – If account_id is already contained in the cache.
        引发:ValueError - 如果 account_id 已包含在缓存中。
        """
        ...

    def add_bar(self, bar: Bar) -> void:
        """
        Add the given bar to the cache.

        将给定的 bar 添加到缓存中。

        Parameters: bar (Bar) – The bar to add.
        参数:bar (Bar) - 要添加的 bar。
        """
        ...

    def add_bars(self, bars: list) -> void:
        """
        Add the given bars to the cache.

        将给定的 bar 添加到缓存中。

        Parameters: bars (list [Bar ]) – The bars to add.
        参数:bars (list [Bar ]) - 要添加的 bar。
        """
        ...

    def add_currency(self, currency: Currency) -> void:
        """
        Add the given currency to the cache.

        将给定的货币添加到缓存中。

        Parameters: currency (Currency) – The currency to add.
        参数:currency (Currency) - 要添加的货币。
        """
        ...

    def add_instrument(self, instrument: Instrument) -> void:
        """
        Add the given instrument to the cache.

        将给定的金融Instrument添加到缓存中。

        Parameters: instrument (Instrument) – The instrument to add.
        参数:instrument (Instrument) - 要添加的金融Instrument。
        """
        ...

    def add_order(self, order: Order, position_id: PositionId=None, client_id: ClientId=None, overwrite: bool=False) -> void:
        """
        Add the given order to the cache indexed with the given position ID.

        将给定的订单添加到使用给定持仓 ID 索引的缓存中。

        Parameters:
        参数:
            order (Order) – The order to add.
            order (Order) - 要添加的订单。
            position_id (PositionId , optional) – The position ID to index for the order.
            position_id (PositionId,可选) - 用于索引订单的持仓 ID。
            client_id (ClientId , optional) – The execution client ID for order routing.
            client_id (ClientId,可选) - 订单路由的执行客户端 ID。
            overwrite (bool , default False) – If the added order should ‘overwrite’ 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.
            overwrite (bool,默认 False) - 添加的订单是否应该“覆盖”任何现有订单并替换缓存中的订单。这当前用于模拟订单,这些订单正在被释放并转换为另一种类型。
        Raises: ValueError – If order.client_order_id is already contained in the cache.
        引发:ValueError - 如果 order.client_order_id 已包含在缓存中。
        """
        ...

    def add_order_book(self, order_book: OrderBook) -> void:
        """
        Add the given order book to the cache.

        将给定的订单簿添加到缓存中。

        Parameters: order_book (OrderBook) – The order book to add.
        参数:order_book (OrderBook) - 要添加的订单簿。
        """
        ...

    def add_order_list(self, order_list: OrderList) -> void:
        """
        Add the given order list to the cache.

        将给定的订单列表添加到缓存中。

        Parameters: order_list (OrderList) – The order_list to add.
        参数:order_list (OrderList) - 要添加的 order_list。
        Raises: ValueError – If order_list.id is already contained in the cache.
        引发:ValueError - 如果 order_list.id 已包含在缓存中。
        """
        ...

    def add_position(self, position: Position, oms_type: OmsType) -> void:
        """
        Add the given position to the cache.

        将给定的持仓添加到缓存中。

        Parameters:
        参数:
            position (Position) – The position to add.
            position (Position) - 要添加的持仓。
            oms_type (OmsType) – The order management system type for the position.
            oms_type (OmsType) - 持仓的订单管理系统类型。
        Raises: ValueError – If oms_type is HEDGING and a virtual position.id is already contained in the cache.
        引发:ValueError - 如果 oms_type 为 HEDGING 并且虚拟 position.id 已包含在缓存中。
        """
        ...

    def add_position_id(self, position_id: PositionId, venue: Venue, client_order_id: ClientOrderId, strategy_id: StrategyId) -> void:
        """
        Index the given position ID with the other given IDs.

        使用其他给定的 ID 为给定的持仓 ID 建立索引。

        Parameters:
        参数:
            position_id (PositionId) – The position ID to index.
            position_id (PositionId) - 要建立索引的持仓 ID。
            venue (Venue) – The venue ID to index with the position ID.
            venue (Venue) - 用于与持仓 ID 建立索引的平台 ID。
            client_order_id (ClientOrderId) – The client order ID to index with the position ID.
            client_order_id (ClientOrderId) - 用于与持仓 ID 建立索引的客户端订单 ID。
            strategy_id (StrategyId) – The strategy ID to index with the position ID.
            strategy_id (StrategyId) - 用于与持仓 ID 建立索引的策略 ID。
        """
        ...

    def add_quote_tick(self, tick: QuoteTick) -> void:
        """
        Add the given quote tick to the cache.

        将给定的报价 tick 添加到缓存中。

        Parameters: tick (QuoteTick) – The tick to add.
        参数:tick (QuoteTick) - 要添加的 tick。
        """
        ...

    def add_quote_ticks(self, ticks: list) -> void:
        """
        Add the given quote ticks to the cache.

        将给定的报价 tick 添加到缓存中。

        Parameters: ticks (list [QuoteTick ]) – The ticks to add.
        参数:ticks (list [QuoteTick ]) - 要添加的 tick。
        """
        ...

    def add_synthetic(self, synthetic: SyntheticInstrument) -> void:
        """
        Add the given synthetic instrument to the cache.

        将给定的合成金融Instrument添加到缓存中。

        Parameters: synthetic (SyntheticInstrument) – The synthetic instrument to add.
        参数:synthetic (SyntheticInstrument) - 要添加的合成金融Instrument。
        """
        ...

    def add_trade_tick(self, tick: TradeTick) -> void:
        """
        Add the given trade tick to the cache.

        将给定的交易 tick 添加到缓存中。

        Parameters: tick (TradeTick) – The tick to add.
        参数:tick (TradeTick) - 要添加的 tick。
        """
        ...

    def add_trade_ticks(self, ticks: list) -> void:
        """
        Add the given trade ticks to the cache.

        将给定的交易 tick 添加到缓存中。

        Parameters: ticks (list [TradeTick ]) – The ticks to add.
        参数:ticks (list [TradeTick ]) - 要添加的 tick。
        """
        ...

    def add_venue_order_id(self, client_order_id: ClientOrderId, venue_order_id: VenueOrderId, overwrite: bool=False) -> void:
        """
        Index the given client order ID with the given venue order ID.

        使用给定的平台订单 ID 为给定的客户端订单 ID 建立索引。

        Parameters:
        参数:
            client_order_id (ClientOrderId) – The client order ID to index.
            client_order_id (ClientOrderId) - 要建立索引的客户端订单 ID。
            venue_order_id (VenueOrderId) – The venue order ID to index.
            venue_order_id (VenueOrderId) - 要建立索引的平台订单 ID。
            overwrite (bool , default False) – If the venue order ID will ‘overwrite’ any existing indexing and replace it in the cache. This is currently used for updated orders where the venue order ID may change.
            overwrite (bool,默认 False) - 平台订单 ID 是否将“覆盖”任何现有索引并替换缓存中的索引。这当前用于更新的订单,其中平台订单 ID 可能会更改。
        Raises: ValueError – If overwrite is False and the client_order_id is already indexed with a different venue_order_id.
        引发:ValueError - 如果 overwrite 为 False 并且 client_order_id 已使用不同的 venue_order_id 建立索引。
        """
        ...

    def bar(self, bar_type: BarType, index: int=0):
        """
        Return the bar for the given bar type at the given index.

        返回给定索引处给定 bar 类型的 bar。

        Last bar if no index specified.

        如果没有指定索引,则返回最后一个 bar。

        Parameters:
        参数:
            bar_type (BarType) – The bar type to get.
            bar_type (BarType) - 要获取的 bar 类型。
            index (int , optional) – The index for the bar to get.
            index (int,可选) - 要获取的 bar 的索引。
        Returns: If no bars or no bar at index then returns None.
        返回值:如果没有 bar 或在索引处没有 bar,则返回 None。
        Return type: Bar or None
        """
        ...

    def bar_count(self, bar_type: BarType) -> int:
        """
        The count of bars for the given bar type.

        给定 bar 类型的 bar 计数。

        Parameters: bar_type (BarType) – The bar type to count.
        参数:bar_type (BarType) - 要计数的 bar 类型。
        Return type: int
        """
        ...

    def bar_types(self, instrument_id: InstrumentId=None, price_type=None, aggregation_source=AggregationSource.EXTERNAL) -> list:
        """
        Return a list of BarType for the given instrument ID and price type.

        返回给定金融Instrument ID 和价格类型的 BarType 列表。

        Parameters:
        参数:
            instrument_id (InstrumentId , optional) – The instrument ID to filter the BarType objects. If None, no filtering is done based on instrument ID.
            instrument_id (InstrumentId,可选) - 用于过滤 BarType 对象的金融Instrument ID。如果为 None,则不会根据金融Instrument ID 进行过滤。
            price_type (PriceType or None , optional) – The price type to filter the BarType objects. If None, no filtering is done based on price type.
            price_type (PriceType or None,可选) - 用于过滤 BarType 对象的价格类型。如果为 None,则不会根据价格类型进行过滤。
            aggregation_source (AggregationSource , default AggregationSource.EXTERNAL) – The aggregation source to filter the BarType objects.
            aggregation_source (AggregationSource,默认 AggregationSource.EXTERNAL) - 用于过滤 BarType 对象的聚合来源。
        Return type: list[BarType]
        """
        ...

    def bars(self, bar_type: BarType) -> list:
        """
        Return bars for the given bar type.

        返回给定 bar 类型的 bar。

        Parameters: bar_type (BarType) – The bar type for bars to get.
        参数:bar_type (BarType) - 要获取的 bar 的 bar 类型。
        Return type: list[Bar]
        """
        ...

    def book_update_count(self, instrument_id: InstrumentId) -> int:
        """
        The count of order book updates for the given instrument ID.

        给定金融Instrument ID 的订单簿更新计数。

        Will return zero if there is no book for the instrument ID.

        如果该金融Instrument ID 没有订单簿,则将返回零。

        Parameters: instrument_id (InstrumentId) – The instrument ID for the book.
        参数:instrument_id (InstrumentId) - 订单簿的金融Instrument ID。
        Return type: int
        """
        ...

    def build_index(self) -> void:
        """
        Clear the current cache index and re-build.

        清除当前缓存索引并重新构建。
        """
        ...

    def cache_accounts(self) -> void:
        """
        Clear the current accounts cache and load accounts from the cache database.

        清除当前账户缓存并从缓存数据库加载账户。
        """
        ...

    def cache_currencies(self) -> void:
        """
        Clear the current currencies cache and load currencies from the cache database.

        清除当前货币缓存并从缓存数据库加载货币。
        """
        ...

    def cache_general(self) -> void:
        """
        Clear the current general cache and load the general objects from the cache database.

        清除当前通用缓存并从缓存数据库加载通用对象。
        """
        ...

    def cache_instruments(self) -> void:
        """
        Clear the current instruments cache and load instruments from the cache database.

        清除当前金融Instrument缓存并从缓存数据库加载金融Instrument。
        """
        ...

    def cache_order_lists(self) -> void:
        """
        Clear the current order lists cache and load order lists using cached orders.

        清除当前订单列表缓存并使用缓存的订单加载订单列表。
        """
        ...

    def cache_orders(self) -> void:
        """
        Clear the current orders cache and load orders from the cache database.

        清除当前订单缓存并从缓存数据库加载订单。
        """
        ...

    def cache_positions(self) -> void:
        """
        Clear the current positions cache and load positions from the cache database.

        清除当前持仓缓存并从缓存数据库加载持仓。
        """
        ...

    def cache_synthetics(self) -> void:
        """
        Clear the current synthetic instruments cache and load synthetic instruments from the cache database.

        清除当前合成金融Instrument缓存并从缓存数据库加载合成金融Instrument。
        """
        ...

    def calculate_unrealized_pnl(self, position: Position):
        """
        """
        ...

    def check_integrity(self) -> bool:
        """
        Check 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.

        在调用此函数之前,应从数据库加载所有数据。如果发现错误,则还会生成日志错误消息。

        Returns: True if checks pass, else False.
        返回值:如果检查通过,则返回 True,否则返回 False。
        Return type: bool
        """
        ...

    def check_residuals(self) -> bool:
        """
        Check for any residual open state and log warnings if any are found.

        检查是否有任何剩余的打开状态,如果找到,则记录警告。

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

        “打开状态”被认为是打开的订单和打开的持仓。

        Returns: True if residuals exist, else False.
        返回值:如果存在剩余状态,则返回 True,否则返回 False。
        Return type: bool
        """
        ...

    def clear_index(self) -> void:
        """
        """
        ...

    def client_id(self, client_order_id: ClientOrderId):
        """
        Return the specific execution client ID matching the given client order ID (if found).

        返回与给定客户端订单 ID 匹配的特定执行客户端 ID(如果找到)。

        Return type: ClientId or None
        """
        ...

    def client_order_id(self, venue_order_id: VenueOrderId) -> ClientOrderId:
        """
        Return the client order ID matching the given venue order ID (if found).

        返回与给定平台订单 ID 匹配的客户端订单 ID(如果找到)。

        Parameters: venue_order_id (VenueOrderId) – The venue assigned order ID.
        参数:venue_order_id (VenueOrderId) - 平台分配的订单 ID。
        Return type: ClientOrderId or None
        """
        ...

    def client_order_ids(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> set:
        """
        Return all client order IDs with the given query filters.

        返回具有给定查询过滤器的所有客户端订单 ID。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
        Return type: set[ClientOrderId]
        """
        ...

    def client_order_ids_closed(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> set:
        """
        Return all closed client order IDs with the given query filters.

        返回具有给定查询过滤器的所有已关闭的客户端订单 ID。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
        Return type: set[ClientOrderId]
        """
        ...

    def client_order_ids_emulated(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> set:
        """
        Return all emulated client order IDs with the given query filters.

        返回具有给定查询过滤器的所有模拟客户端订单 ID。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
        Return type: set[ClientOrderId]
        """
        ...

    def client_order_ids_inflight(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> set:
        """
        Return all in-flight client order IDs with the given query filters.

        返回具有给定查询过滤器的所有进行中的客户端订单 ID。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
        Return type: set[ClientOrderId]
        """
        ...

    def client_order_ids_open(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> set:
        """
        Return all open client order IDs with the given query filters.

        返回具有给定查询过滤器的所有未结客户端订单 ID。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
        Return type: set[ClientOrderId]
        """
        ...

    def delete_actor(self, actor: Actor) -> void:
        """
        Delete the given actor from the cache.

        从缓存中删除给定的 actor。

        Parameters: actor (Actor) – The actor to deregister.
        参数:actor (Actor) - 要取消注册的 actor。
        Raises: ValueError – If actor is not contained in the actors index.
        引发:ValueError - 如果 actor 未包含在 actors 索引中。
        """
        ...

    def delete_strategy(self, strategy: Strategy) -> void:
        """
        Delete the given strategy from the cache.

        从缓存中删除给定的策略。

        Parameters: strategy (Strategy) – The strategy to deregister.
        参数:strategy (Strategy) - 要取消注册的策略。
        Raises: ValueError – If strategy is not contained in the strategies index.
        引发:ValueError - 如果 strategy 未包含在 strategies 索引中。
        """
        ...

    def dispose(self) -> void:
        """
        Dispose of the cache which will close any underlying database adapter.

        释放缓存,这将关闭任何底层数据库适配器。
        """
        ...

    def exec_algorithm_ids(self) -> set:
        """
        Return all execution algorithm IDs.

        返回所有执行算法 ID。

        Return type: set[ExecAlgorithmId]
        """
        ...

    def exec_spawn_total_filled_qty(self, exec_spawn_id: ClientOrderId, active_only: bool=False):
        """
        Return the total filled quantity for the given execution spawn ID (if found).

        返回给定执行生成 ID 的总成交数量(如果找到)。

        If no execution spawn ID matches then returns None.

        如果没有匹配的执行生成 ID,则返回 None。

        Parameters:
        参数:
            exec_spawn_id (ClientOrderId) – The execution algorithm spawning primary (original) client order ID.
            exec_spawn_id (ClientOrderId) - 执行算法生成的原始客户端订单 ID。
            active_only (bool , default False) – The flag to filter for active execution spawn orders only.
            active_only (bool,默认 False) - 仅过滤活动执行生成订单的标志。
        Return type: Quantity or None
        """
        ...

    def exec_spawn_total_leaves_qty(self, exec_spawn_id: ClientOrderId, active_only: bool=False):
        """
        Return the total leaves quantity for the given execution spawn ID (if found).

        返回给定执行生成 ID 的总剩余数量(如果找到)。

        If no execution spawn ID matches then returns None.

        如果没有匹配的执行生成 ID,则返回 None。

        Parameters:
        参数:
            exec_spawn_id (ClientOrderId) – The execution algorithm spawning primary (original) client order ID.
            exec_spawn_id (ClientOrderId) - 执行算法生成的原始客户端订单 ID。
            active_only (bool , default False) – The flag to filter for active execution spawn orders only.
            active_only (bool,默认 False) - 仅过滤活动执行生成订单的标志。
        Return type: Quantity or None
        """
        ...

    def exec_spawn_total_quantity(self, exec_spawn_id: ClientOrderId, active_only: bool=False):
        """
        Return the total quantity for the given execution spawn ID (if found).

        返回给定执行生成 ID 的总数量(如果找到)。

        If no execution spawn ID matches then returns None.

        如果没有匹配的执行生成 ID,则返回 None。

        Parameters:
        参数:
            exec_spawn_id (ClientOrderId) – The execution algorithm spawning primary (original) client order ID.
            exec_spawn_id (ClientOrderId) - 执行算法生成的原始客户端订单 ID。
            active_only (bool , default False) – The flag to filter for active execution spawn orders only.
            active_only (bool,默认 False) - 仅过滤活动执行生成订单的标志。
        Return type: Quantity or None
        """
        ...

    def flush_db(self) -> void:
        """
        Flush the caches database which permanently removes all persisted data.

        刷新缓存数据库,永久删除所有持久化数据。

        WARNING
        永久性数据丢失。
        """
        ...

    def get(self, key: str):
        """
        Return the general object for the given key.

        返回给定键的通用对象。

        The cache is agnostic to what the object actually is (and how it may be serialized), offering maximum flexibility.

        缓存不知道对象实际上是什么(以及它如何被序列化),提供了最大的灵活性。

        Parameters: key (str) – The cache key for the object.
        参数:key (str) - 对象的缓存键。
        Return type: bytes or None
        """
        ...

    def get_xrate(self, venue: Venue, from_currency: Currency, to_currency: Currency, price_type: PriceType=PriceType.MID):
        """
        Return the calculated exchange rate.

        返回计算的汇率。

        Parameters:
        参数:
            venue (Venue) – The venue for the exchange rate.
            venue (Venue) - 汇率的平台。
            from_currency (Currency) – The currency to convert from.
            from_currency (Currency) - 要转换的货币。
            to_currency (Currency) – The currency to convert to.
            to_currency (Currency) - 要转换为的货币。
            price_type (PriceType) – The price type for the exchange rate.
            price_type (PriceType) - 汇率的价格类型。
        Return type: double

        Raises: ValueError – If price_type is LAST.
        引发:ValueError - 如果 price_type 为 LAST。
        """
        ...

    def has_bars(self, bar_type: BarType) -> bool:
        """
        Return a value indicating whether the cache has bars for the given bar type.

        返回值指示缓存是否具有给定 bar 类型的 bar。

        Parameters: bar_type (BarType) – The bar type for the bars.
        参数:bar_type (BarType) - bar 的 bar 类型。
        Return type: bool
        """
        ...

    def has_order_book(self, instrument_id: InstrumentId) -> bool:
        """
        Return a value indicating whether the cache has an order book snapshot for the given instrument ID.

        返回值指示缓存是否具有给定金融Instrument ID 的订单簿快照。

        Parameters: instrument_id (InstrumentId) – The instrument ID for the order book snapshot.
        参数:instrument_id (InstrumentId) - 订单簿快照的金融Instrument ID。
        Return type: bool
        """
        ...

    def has_quote_ticks(self, instrument_id: InstrumentId) -> bool:
        """
        Return a value indicating whether the cache has quote ticks for the given instrument ID.

        返回值指示缓存是否具有给定金融Instrument ID 的报价 tick。

        Parameters: instrument_id (InstrumentId) – The instrument ID for the ticks.
        参数:instrument_id (InstrumentId) - tick 的金融Instrument ID。
        Return type: bool
        """
        ...

    def has_trade_ticks(self, instrument_id: InstrumentId) -> bool:
        """
        Return a value indicating whether the cache has trade ticks for the given instrument ID.

        返回值指示缓存是否具有给定金融Instrument ID 的交易 tick。

        Parameters: instrument_id (InstrumentId) – The instrument ID for the ticks.
        参数:instrument_id (InstrumentId) - tick 的金融Instrument ID。
        Return type: bool
        """
        ...

    def heartbeat(self, timestamp: datetime) -> void:
        """
        Add a heartbeat at the given timestamp.

        在给定的时间戳添加心跳。

        Parameters: timestamp (datetime) – The timestamp for the heartbeat.
        参数:timestamp (datetime) - 心跳的时间戳。
        """
        ...

    def instrument(self, instrument_id: InstrumentId):
        """
        Return the instrument corresponding to the given instrument ID.

        返回与给定金融Instrument ID 对应的金融Instrument。

        Parameters: instrument_id (InstrumentId) – The instrument ID of the instrument to return.
        参数:instrument_id (InstrumentId) - 要返回的金融Instrument的金融Instrument ID。
        Return type: Instrument or None
        """
        ...

    def instrument_ids(self, venue: Venue=None) -> list:
        """
        Return all instrument IDs held by the cache.

        返回缓存持有的所有金融Instrument ID。

        Parameters: venue (Venue , optional) – The venue filter for the query.
        参数:venue (Venue,可选) - 查询的平台过滤器。
        Return type: list[InstrumentId]
        """
        ...

    def instruments(self, venue: Venue=None) -> list:
        """
        Return all instruments held by the cache.

        返回缓存持有的所有金融Instrument。

        Parameters: venue (Venue , optional) – The venue filter for the query.
        参数:venue (Venue,可选) - 查询的平台过滤器。
        Return type: list[Instrument]
        """
        ...

    def is_order_closed(self, client_order_id: ClientOrderId) -> bool:
        """
        Return a value indicating whether an order with the given ID is closed.

        返回值指示具有给定 ID 的订单是否已关闭。

        Parameters: client_order_id (ClientOrderId) – The client order ID to check.
        参数:client_order_id (ClientOrderId) - 要检查的客户端订单 ID。
        Return type: bool
        """
        ...

    def is_order_emulated(self, client_order_id: ClientOrderId) -> bool:
        """
        Return a value indicating whether an order with the given ID is emulated.

        返回值指示具有给定 ID 的订单是否为模拟订单。

        Parameters: client_order_id (ClientOrderId) – The client order ID to check.
        参数:client_order_id (ClientOrderId) - 要检查的客户端订单 ID。
        Return type: bool
        """
        ...

    def is_order_inflight(self, client_order_id: ClientOrderId) -> bool:
        """
        Return a value indicating whether an order with the given ID is in-flight.

        返回值指示具有给定 ID 的订单是否正在进行中。

```python
       Parameters: client_order_id (ClientOrderId) – The client order ID to check.
        参数:client_order_id (ClientOrderId) - 要检查的客户端订单 ID。
        Return type: bool
        """
        ...

    def is_order_open(self, client_order_id: ClientOrderId) -> bool:
        """
        Return a value indicating whether an order with the given ID is open.

        返回值指示具有给定 ID 的订单是否未结。

        Parameters: client_order_id (ClientOrderId) – The client order ID to check.
        参数:client_order_id (ClientOrderId) - 要检查的客户端订单 ID。
        Return type: bool
        """
        ...

    def is_order_pending_cancel_local(self, client_order_id: ClientOrderId) -> bool:
        """
        Return a value indicating whether an order with the given ID is pending cancel locally.

        返回值指示具有给定 ID 的订单是否正在本地等待取消。

        Parameters: client_order_id (ClientOrderId) – The client order ID to check.
        参数:client_order_id (ClientOrderId) - 要检查的客户端订单 ID。
        Return type: bool
        """
        ...

    def is_position_closed(self, position_id: PositionId) -> bool:
        """
        Return a value indicating whether a position with the given ID exists and is closed.

        返回值指示具有给定 ID 的持仓是否存在且已关闭。

        Parameters: position_id (PositionId) – The position ID.
        参数:position_id (PositionId) - 持仓 ID。
        Return type: bool
        """
        ...

    def is_position_open(self, position_id: PositionId) -> bool:
        """
        Return a value indicating whether a position with the given ID exists and is open.

        返回值指示具有给定 ID 的持仓是否存在且未结。

        Parameters: position_id (PositionId) – The position ID.
        参数:position_id (PositionId) - 持仓 ID。
        Return type: bool
        """
        ...

    def load_account(self, account_id: AccountId):
        """
        Load the account associated with the given account_id (if found).

        加载与给定 account_id 关联的账户(如果找到)。

        Parameters: account_id (AccountId) – The account ID to load.
        参数:account_id (AccountId) - 要加载的账户 ID。
        Return type: Account or None
        """
        ...

    def load_actor(self, actor: Actor) -> void:
        """
        Load the state dictionary into the given actor.

        将状态字典加载到给定的 actor 中。

        Parameters: actor (Actor) – The actor to load.
        参数:actor (Actor) - 要加载的 actor。
        """
        ...

    def load_instrument(self, instrument_id: InstrumentId):
        """
        Load the instrument associated with the given instrument_id (if found).

        加载与给定 instrument_id 关联的金融Instrument(如果找到)。

        Parameters: instrument_id (InstrumentId) – The instrument ID to load.
        参数:instrument_id (InstrumentId) - 要加载的金融Instrument ID。
        Return type: Instrument or None
        """
        ...

    def load_order(self, client_order_id: ClientOrderId):
        """
        Load the order associated with the given ID (if found).

        加载与给定 ID 关联的订单(如果找到)。

        Parameters: client_order_id (ClientOrderId) – The client order ID to load.
        参数:client_order_id (ClientOrderId) - 要加载的客户端订单 ID。
        Return type: Order or None
        """
        ...

    def load_position(self, position_id: PositionId):
        """
        Load the position associated with the given ID (if found).

        加载与给定 ID 关联的持仓(如果找到)。

        Parameters: position_id (PositionId) – The position ID to load.
        参数:position_id (PositionId) - 要加载的持仓 ID。
        Return type: Position or None
        """
        ...

    def load_strategy(self, strategy: Strategy) -> void:
        """
        Load the state dictionary into the given strategy.

        将状态字典加载到给定的策略中。

        Parameters: strategy (Strategy) – The strategy to load.
        参数:strategy (Strategy) - 要加载的策略。
        """
        ...

    def load_synthetic(self, instrument_id: InstrumentId):
        """
        Load the synthetic instrument associated with the given instrument_id (if found).

        加载与给定 instrument_id 关联的合成金融Instrument(如果找到)。

        Parameters: instrument_id (InstrumentId) – The synthetic instrument ID to load.
        参数:instrument_id (InstrumentId) - 要加载的合成金融Instrument ID。
        Return type: SyntheticInstrument or None
        Raises: ValueError – If instrument_id is not a synthetic instrument ID.
        引发:ValueError - 如果 instrument_id 不是合成金融Instrument ID。
        """
        ...

    def order(self, client_order_id: ClientOrderId):
        """
        Return the order matching the given client order ID (if found).

        返回与给定客户端订单 ID 匹配的订单(如果找到)。

        Return type: Order or None
        """
        ...

    def order_book(self, instrument_id: InstrumentId):
        """
        Return the order book for the given instrument ID.

        返回给定金融Instrument ID 的订单簿。

        Parameters: instrument_id (InstrumentId)
        参数:instrument_id (InstrumentId)
        Return type: OrderBook or None
        """
        ...

    def order_exists(self, client_order_id: ClientOrderId) -> bool:
        """
        Return a value indicating whether an order with the given ID exists.

        返回值指示具有给定 ID 的订单是否存在。

        Parameters: client_order_id (ClientOrderId) – The client order ID to check.
        参数:client_order_id (ClientOrderId) - 要检查的客户端订单 ID。
        Return type: bool
        """
        ...

    def order_list(self, order_list_id: OrderListId):
        """
        Return the order list matching the given order list ID (if found).

        返回与给定订单列表 ID 匹配的订单列表(如果找到)。

        Return type: OrderList or None
        """
        ...

    def order_list_exists(self, order_list_id: OrderListId) -> bool:
        """
        Return a value indicating whether an order list with the given ID exists.

        返回值指示具有给定 ID 的订单列表是否存在。

        Parameters: order_list_id (OrderListId) – The order list ID to check.
        参数:order_list_id (OrderListId) - 要检查的订单列表 ID。
        Return type: bool
        """
        ...

    def order_list_ids(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> set:
        """
        Return all order list IDs.

        返回所有订单列表 ID。

        Return type: set[OrderListId]
        """
        ...

    def order_lists(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> list:
        """
        Return all order lists matching the given query filters.

        返回与给定查询过滤器匹配的所有订单列表。

        No particular order of list elements is guaranteed.

        不保证列表元素的特定顺序。

        Return type: list[OrderList]
        """
        ...

    def orders(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> list:
        """
        Return all orders matching the given query filters.

        返回与给定查询过滤器匹配的所有订单。

        No particular order of list elements is guaranteed.

        不保证列表元素的特定顺序。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
            side (OrderSide, default NO_ORDER_SIDE (no filter)) – The order side query filter.
            side (OrderSide,默认 NO_ORDER_SIDE(无过滤器)) - 订单方向查询过滤器。
        Return type: list[Order]
        """
        ...

    def orders_closed(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> list:
        """
        Return all closed orders with the given query filters.

        返回具有给定查询过滤器的所有已关闭订单。

        No particular order of list elements is guaranteed.

        不保证列表元素的特定顺序。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
            side (OrderSide, default NO_ORDER_SIDE (no filter)) – The order side query filter.
            side (OrderSide,默认 NO_ORDER_SIDE(无过滤器)) - 订单方向查询过滤器。
        Return type: list[Order]
        """
        ...

    def orders_closed_count(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> int:
        """
        Return the count of closed orders with the given query filters.

        返回具有给定查询过滤器的已关闭订单数量。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
            side (OrderSide, default NO_ORDER_SIDE (no filter)) – The order side query filter.
            side (OrderSide,默认 NO_ORDER_SIDE(无过滤器)) - 订单方向查询过滤器。
        Return type: int
        """
        ...

    def orders_emulated(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> list:
        """
        Return all emulated orders with the given query filters.

        返回具有给定查询过滤器的所有模拟订单。

        No particular order of list elements is guaranteed.

        不保证列表元素的特定顺序。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
            side (OrderSide, default NO_ORDER_SIDE (no filter)) – The order side query filter.
            side (OrderSide,默认 NO_ORDER_SIDE(无过滤器)) - 订单方向查询过滤器。
        Return type: list[Order]
        """
        ...

    def orders_emulated_count(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> int:
        """
        Return the count of emulated orders with the given query filters.

        返回具有给定查询过滤器的模拟订单数量。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
            side (OrderSide, default NO_ORDER_SIDE (no filter)) – The order side query filter.
            side (OrderSide,默认 NO_ORDER_SIDE(无过滤器)) - 订单方向查询过滤器。
        Return type: int
        """
        ...

    def orders_for_exec_algorithm(self, exec_algorithm_id: ExecAlgorithmId, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> list:
        """
        Return all execution algorithm orders for the given query filters.

        返回给定查询过滤器的所有执行算法订单。

        Parameters:
        参数:
            exec_algorithm_id (ExecAlgorithmId) – The execution algorithm ID.
            exec_algorithm_id (ExecAlgorithmId) - 执行算法 ID。
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
            side (OrderSide, default NO_ORDER_SIDE (no filter)) – The order side query filter.
            side (OrderSide,默认 NO_ORDER_SIDE(无过滤器)) - 订单方向查询过滤器。
        Return type: list[Order]
        """
        ...

    def orders_for_exec_spawn(self, exec_spawn_id: ClientOrderId) -> list:
        """
        Return all orders for the given execution spawn ID (if found).

        返回给定执行生成 ID 的所有订单(如果找到)。

        Will also include the primary (original) order.

        还将包括原始订单。

        Parameters: exec_spawn_id (ClientOrderId) – The execution algorithm spawning primary (original) client order ID.
        参数:exec_spawn_id (ClientOrderId) - 执行算法生成的原始客户端订单 ID。
        Return type: list[Order]
        """
        ...

    def orders_for_position(self, position_id: PositionId) -> list:
        """
        Return all orders for the given position ID.

        返回给定持仓 ID 的所有订单。

        Parameters: position_id (PositionId) – The position ID for the orders.
        参数:position_id (PositionId) - 订单的持仓 ID。
        Return type: list[Order]
        """
        ...

    def orders_inflight(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> list:
        """
        Return all in-flight orders with the given query filters.

        返回具有给定查询过滤器的所有进行中订单。

        No particular order of list elements is guaranteed.

        不保证列表元素的特定顺序。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
            side (OrderSide, default NO_ORDER_SIDE (no filter)) – The order side query filter.
            side (OrderSide,默认 NO_ORDER_SIDE(无过滤器)) - 订单方向查询过滤器。
        Return type: list[Order]
        """
        ...

    def orders_inflight_count(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> int:
        """
        Return the count of in-flight orders with the given query filters.

        返回具有给定查询过滤器的进行中订单数量。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
            side (OrderSide, default NO_ORDER_SIDE (no filter)) – The order side query filter.
            side (OrderSide,默认 NO_ORDER_SIDE(无过滤器)) - 订单方向查询过滤器。
        Return type: int
        """
        ...

    def orders_open(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> list:
        """
        Return all open orders with the given query filters.

        返回具有给定查询过滤器的所有未结订单。

        No particular order of list elements is guaranteed.

        不保证列表元素的特定顺序。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
            side (OrderSide, default NO_ORDER_SIDE (no filter)) – The order side query filter.
            side (OrderSide,默认 NO_ORDER_SIDE(无过滤器)) - 订单方向查询过滤器。
        Return type: list[Order]
        """
        ...

    def orders_open_count(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> int:
        """
        Return the count of open orders with the given query filters.

        返回具有给定查询过滤器的未结订单数量。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
            side (OrderSide, default NO_ORDER_SIDE (no filter)) – The order side query filter.
            side (OrderSide,默认 NO_ORDER_SIDE(无过滤器)) - 订单方向查询过滤器。
        Return type: int
        """
        ...

    def orders_total_count(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> int:
        """
        Return the total count of orders with the given query filters.

        返回具有给定查询过滤器的订单总数。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
            side (OrderSide, default NO_ORDER_SIDE (no filter)) – The order side query filter.
            side (OrderSide,默认 NO_ORDER_SIDE(无过滤器)) - 订单方向查询过滤器。
        Return type: int
        """
        ...

    def position(self, position_id: PositionId):
        """
        Return the position associated with the given ID (if found).

        返回与给定 ID 关联的持仓(如果找到)。

        Parameters: position_id (PositionId) – The position ID.
        参数:position_id (PositionId) - 持仓 ID。
        Return type: Position or None
        """
        ...

    def position_closed_ids(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> set:
        """
        Return all closed position IDs with the given query filters.

        返回具有给定查询过滤器的所有已关闭持仓 ID。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
        Return type: set[PositionId]
        """
        ...

    def position_exists(self, position_id: PositionId) -> bool:
        """
        Return a value indicating whether a position with the given ID exists.

        返回值指示具有给定 ID 的持仓是否存在。

        Parameters: position_id (PositionId) – The position ID.
        参数:position_id (PositionId) - 持仓 ID。
        Return type: int
        """
        ...

    def position_for_order(self, client_order_id: ClientOrderId):
        """
        Return the position associated with the given client order ID (if found).

        返回与给定客户端订单 ID 关联的持仓(如果找到)。

        Parameters: client_order_id (ClientOrderId) – The client order ID.
        参数:client_order_id (ClientOrderId) - 客户端订单 ID。
        Return type: Position or None
        """
        ...

    def position_id(self, client_order_id: ClientOrderId) -> PositionId:
        """
        Return the position ID associated with the given client order ID (if found).

        返回与给定客户端订单 ID 关联的持仓 ID(如果找到)。

        Parameters: client_order_id (ClientOrderId) – The client order ID associated with the position.
        参数:client_order_id (ClientOrderId) - 与持仓关联的客户端订单 ID。
        Return type: PositionId or None
        """
        ...

    def position_ids(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> set:
        """
        Return all position IDs with the given query filters.

        返回具有给定查询过滤器的所有持仓 ID。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
        Return type: set[PositionId]
        """
        ...

    def position_open_ids(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> set:
        """
        Return all open position IDs with the given query filters.

        返回具有给定查询过滤器的所有未结持仓 ID。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
        Return type: set[PositionId]
        """
        ...

    def position_snapshots(self, position_id: PositionId=None) -> list:
        """
        Return all position snapshots with the given optional identifier filter.

        返回具有给定可选标识符过滤器的所有持仓快照。

        Parameters: position_id (PositionId , optional) – The position ID query filter.
        参数:position_id (PositionId,可选) - 持仓 ID 查询过滤器。
        Return type: list[Position]
        """
        ...

    def positions(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=PositionSide.NO_POSITION_SIDE) -> list:
        """
        Return all positions with the given query filters.

        返回具有给定查询过滤器的所有持仓。

        No particular order of list elements is guaranteed.

        不保证列表元素的特定顺序。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
            side (PositionSide, default NO_POSITION_SIDE (no filter)) – The position side query filter.
            side (PositionSide,默认 NO_POSITION_SIDE(无过滤器)) - 持仓方向查询过滤器。
        Return type: list[Position]
        """
        ...

    def positions_closed(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> list:
        """
        Return all closed positions with the given query filters.

        返回具有给定查询过滤器的所有已关闭持仓。

        No particular order of list elements is guaranteed.

        不保证列表元素的特定顺序。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
        Return type: list[Position]
        """
        ...

    def positions_closed_count(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> int:
        """
        Return the count of closed positions with the given query filters.

        返回具有给定查询过滤器的已关闭持仓数量。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
        Return type: int
        """
        ...

    def positions_open(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=PositionSide.NO_POSITION_SIDE) -> list:
        """
        Return all open positions with the given query filters.

        返回具有给定查询过滤器的所有未结持仓。

        No particular order of list elements is guaranteed.

        不保证列表元素的特定顺序。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
            side (PositionSide, default NO_POSITION_SIDE (no filter)) – The position side query filter.
            side (PositionSide,默认 NO_POSITION_SIDE(无过滤器)) - 持仓方向查询过滤器。
        Return type: list[Position]
        """
        ...

    def positions_open_count(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=PositionSide.NO_POSITION_SIDE) -> int:
        """
        Return the count of open positions with the given query filters.

        返回具有给定查询过滤器的未结持仓数量。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
            side (PositionSide, default NO_POSITION_SIDE (no filter)) – The position side query filter.
            side (PositionSide,默认 NO_POSITION_SIDE(无过滤器)) - 持仓方向查询过滤器。
        Return type: int
        """
        ...

    def positions_total_count(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=PositionSide.NO_POSITION_SIDE) -> int:
        """
        Return the total count of positions with the given query filters.

        返回具有给定查询过滤器的持仓总数。

        Parameters:
        参数:
            venue (Venue , optional) – The venue ID query filter.
            venue (Venue,可选) - 平台 ID 查询过滤器。
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融Instrument ID 查询过滤器。
            strategy_id (StrategyId , optional) – The strategy ID query filter.
            strategy_id (StrategyId,可选) - 策略 ID 查询过滤器。
            side (PositionSide, default NO_POSITION_SIDE (no filter)) – The position side query filter.
            side (PositionSide,默认 NO_POSITION_SIDE(无过滤器)) - 持仓方向查询过滤器。
        Return type: int
        """
        ...

    def price(self, instrument_id: InstrumentId, price_type: PriceType):
        """
        Return the price for the given instrument ID and price type.

        返回给定金融Instrument ID 和价格类型的价格。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The instrument ID for the price.
            instrument_id (InstrumentId) - 价格的金融Instrument ID。
            price_type (PriceType) – The price type for the query.
            price_type (PriceType) - 查询的价格类型。
        Return type: Price or None
        """
        ...

    def quote_tick(self, instrument_id: InstrumentId, index: int=0):
        """
        Return the quote tick for the given instrument ID at the given index.

        返回给定索引处给定金融Instrument ID 的报价 tick。

        Last quote tick if no index specified.

        如果没有指定索引,则返回最后一个报价 tick。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The instrument ID for the tick to get.
            instrument_id (InstrumentId) - 要获取的 tick 的金融Instrument ID。
            index (int , optional) – The index for the tick to get.
            index (int,可选) - 要获取的 tick 的索引。
        Returns: If no ticks or no tick at index then returns None.
        返回值:如果没有 tick 或在索引处没有 tick,则返回 None。
        Return type: QuoteTick or None
        """
        ...

    def quote_tick_count(self, instrument_id: InstrumentId) -> int:
        """
        The count of quote ticks for the given instrument ID.

        给定金融Instrument ID 的报价 tick 计数。

        Parameters: instrument_id (InstrumentId) – The instrument ID for the ticks.
        参数:instrument_id (InstrumentId) - tick 的金融Instrument ID。
        Return type: int
        """
        ...

    def quote_ticks(self, instrument_id: InstrumentId) -> list:
        """
        Return the quote ticks for the given instrument ID.

        返回给定金融Instrument ID 的报价 tick。

        Parameters: instrument_id (InstrumentId) – The instrument ID for the ticks to get.
        参数:instrument_id (InstrumentId) - 要获取的 tick 的金融Instrument ID。
        Return type: list[QuoteTick]
        """
        ...

    def reset(self) -> void:
        """
        Reset the cache.

        重置缓存。

        All stateful fields are reset to their initial value.

        所有有状态字段都重置为其初始值。
        """
        ...

    def snapshot_order_state(self, order: Order) -> void:
        """
        Snapshot the state dictionary for the given order.

        快照给定订单的状态字典。

        This method will persist to the backing cache database.

        此方法将持久化到后备缓存数据库。

```python
        Parameters: order (Order) – The order to snapshot the state for.
        参数:order (Order) - 要为其快照状态的订单。
        """
        ...

    def snapshot_position(self, position: Position) -> void:
        """
        Snapshot the given position in its current state.

        快照给定持仓的当前状态。

        The position ID will be appended with a UUID v4 string.

        持仓 ID 将附加一个 UUID v4 字符串。

        Parameters: position (Position) – The position to snapshot.
        参数:position (Position) - 要快照的持仓。
        """
        ...

    def snapshot_position_state(self, position: Position, ts_snapshot: int, unrealized_pnl=None, open_only: bool=True) -> void:
        """
        Snapshot the state dictionary for the given position.

        快照给定持仓的状态字典。

        This method will persist to the backing cache database.

        此方法将持久化到后备缓存数据库。

        Parameters:
        参数:
            position (Position) – The position to snapshot the state for.
            position (Position) - 要为其快照状态的持仓。
            ts_snapshot (uint64_t) – UNIX timestamp (nanoseconds) when the snapshot was taken.
            ts_snapshot (uint64_t) - 拍摄快照时的 UNIX 时间戳(纳秒)。
            unrealized_pnl (Money , optional) – The current unrealized PnL for the position.
            unrealized_pnl (Money,可选) - 持仓的当前未实现盈亏。
            open_only (bool , default True) – If only open positions should be snapshot, this flag helps to avoid race conditions where a position is snapshot when no longer open.
            open_only (bool,默认 True) - 如果只应快照未结持仓,则此标志有助于避免持仓在不再打开时快照的竞争条件。
        """
        ...

    def strategy_id_for_order(self, client_order_id: ClientOrderId) -> StrategyId:
        """
        Return the strategy ID associated with the given ID (if found).

        返回与给定 ID 关联的策略 ID(如果找到)。

        Parameters: client_order_id (ClientOrderId) – The client order ID associated with the strategy.
        参数:client_order_id (ClientOrderId) - 与策略关联的客户端订单 ID。
        Return type: StrategyId or None
        """
        ...

    def strategy_id_for_position(self, position_id: PositionId) -> StrategyId:
        """
        Return the strategy ID associated with the given ID (if found).

        返回与给定 ID 关联的策略 ID(如果找到)。

        Parameters: position_id (PositionId) – The position ID associated with the strategy.
        参数:position_id (PositionId) - 与策略关联的持仓 ID。
        Return type: StrategyId or None
        """
        ...

    def strategy_ids(self) -> set:
        """
        Return all strategy IDs.

        返回所有策略 ID。

        Return type: set[StrategyId]
        """
        ...

    def synthetic(self, instrument_id: InstrumentId):
        """
        Return the synthetic instrument corresponding to the given instrument ID.

        返回与给定金融Instrument ID 对应的合成金融Instrument。

        Parameters: instrument_id (InstrumentId) – The instrument ID of the synthetic instrument to return.
        参数:instrument_id (InstrumentId) - 要返回的合成金融Instrument的金融Instrument ID。
        Return type: SyntheticInstrument or None
        Raises: ValueError – If instrument_id is not a synthetic instrument ID.
        引发:ValueError - 如果 instrument_id 不是合成金融Instrument ID。
        """
        ...

    def synthetic_ids(self) -> list:
        """
        Return all synthetic instrument IDs held by the cache.

        返回缓存持有的所有合成金融Instrument ID。

        Return type: list[InstrumentId]
        """
        ...

    def synthetics(self) -> list:
        """
        Return all synthetic instruments held by the cache.

        返回缓存持有的所有合成金融Instrument。

        Return type: list[SyntheticInstrument]
        """
        ...

    def trade_tick(self, instrument_id: InstrumentId, index: int=0):
        """
        Return the trade tick for the given instrument ID at the given index

        返回给定索引处给定金融Instrument ID 的交易 tick。

        Last trade tick if no index specified.

        如果没有指定索引,则返回最后一个交易 tick。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The instrument ID for the tick to get.
            instrument_id (InstrumentId) - 要获取的 tick 的金融Instrument ID。
            index (int , optional) – The index for the tick to get.
            index (int,可选) - 要获取的 tick 的索引。
        Returns: If no ticks or no tick at index then returns None.
        返回值:如果没有 tick 或在索引处没有 tick,则返回 None。
        Return type: TradeTick or None
        """
        ...

    def trade_tick_count(self, instrument_id: InstrumentId) -> int:
        """
        The count of trade ticks for the given instrument ID.

        给定金融Instrument ID 的交易 tick 计数。

        Parameters: instrument_id (InstrumentId) – The instrument ID for the ticks.
        参数:instrument_id (InstrumentId) - tick 的金融Instrument ID。
        Return type: int
        """
        ...

    def trade_ticks(self, instrument_id: InstrumentId) -> list:
        """
        Return trade ticks for the given instrument ID.

        返回给定金融Instrument ID 的交易 tick。

        Parameters: instrument_id (InstrumentId) – The instrument ID for the ticks to get.
        参数:instrument_id (InstrumentId) - 要获取的 tick 的金融Instrument ID。
        Return type: list[TradeTick]
        """
        ...

    def update_account(self, account) -> void:
        """
        Update the given account in the cache.

        更新缓存中的给定账户。

        Parameters: account (The account to update *(*from last event ) .)
        参数:account(要更新的账户(来自最后一个事件))。
        """
        ...

    def update_actor(self, actor: Actor) -> void:
        """
        Update the given actor state in the cache.

        更新缓存中的给定 actor 状态。

        Parameters: actor (Actor) – The actor to update.
        参数:actor (Actor) - 要更新的 actor。
        """
        ...

    def update_order(self, order: Order) -> void:
        """
        Update the given order in the cache.

        更新缓存中的给定订单。

        Parameters: order (Order) – The order to update (from last event).
        参数:order (Order) - 要更新的订单(来自最后一个事件)。
        """
        ...

    def update_order_pending_cancel_local(self, order: Order) -> void:
        """
        Update the given order as pending cancel locally.

        将给定的订单更新为本地等待取消。

        Parameters: order (Order) – The order to update.
        参数:order (Order) - 要更新的订单。
        """
        ...

    def update_position(self, position: Position) -> void:
        """
        Update the given position in the cache.

        更新缓存中的给定持仓。

        Parameters: position (Position) – The position to update (from last event).
        参数:position (Position) - 要更新的持仓(来自最后一个事件)。
        """
        ...

    def update_strategy(self, strategy: Strategy) -> void:
        """
        Update the given strategy state in the cache.

        更新缓存中的给定策略状态。

        Parameters: strategy (Strategy) – The strategy to update.
        参数:strategy (Strategy) - 要更新的策略。
        """
        ...

    def venue_order_id(self, client_order_id: ClientOrderId) -> VenueOrderId:
        """
        Return the order ID matching the given client order ID (if found).

        返回与给定客户端订单 ID 匹配的订单 ID(如果找到)。

        Return type: VenueOrderId or None
        """
        ...

class CacheDatabaseAdapter 缓存数据库适配器

class CacheDatabaseAdapter(CacheDatabaseFacade):
    """
    Provides a generic cache database adapter.

    提供通用的缓存数据库适配器。

    Parameters:
    参数:
        trader_id (TraderId) – The trader ID for the adapter.
        trader_id (TraderId) - 适配器的交易者 ID。
        instance_id (UUID4) – The instance ID for the adapter.
        instance_id (UUID4) - 适配器的实例 ID。
        serializer (Serializer) – The serializer for database operations.
        serializer (Serializer) - 数据库操作的序列化器。
        config (CacheConfig , optional) – The configuration for the instance.
        config (CacheConfig,可选) - 实例的配置。
    Raises: TypeError – If config is not of type CacheConfig.
    引发:TypeError - 如果 config 的类型不是 CacheConfig。

    Warning:
        Redis can only accurately store int64 types to 17 digits of precision. Therefore nanosecond timestamp int64’s with 19 digits will lose 2 digits of precision when persisted. One way to solve this is to ensure the serializer converts timestamp int64’s to strings on the way into Redis, and converts timestamp strings back to int64’s on the way out. One way to achieve this is to set the timestamps_as_str flag to true for the MsgSpecSerializer, as per the default implementations for both TradingNode and BacktestEngine.
        Redis 只能准确存储精度为 17 位的 int64 类型。因此,持久化时,具有 19 位数字的纳秒时间戳 int64 将丢失 2 位精度。解决此问题的一种方法是确保序列化器在进入 Redis 时将时间戳 int64 转换为字符串,并在退出 Redis 时将时间戳字符串转换回 int64。实现此目的的一种方法是将 MsgSpecSerializer 的 timestamps_as_str 标志设置为 true,就像 TradingNode 和 BacktestEngine 的默认实现一样。
    """
    def __init__(self, trader_id: TraderId, instance_id: UUID4, serializer: Serializer, config: CacheConfig | None = None) -> None:
        ...

Methods 方法

    def add(self, key: str, value: bytes) -> void:
        """
        Add the given general object value to the database.

        将给定的通用对象值添加到数据库中。

        Parameters:
        参数:
            key (str) – The key to write to.
            key (str) - 要写入的键。
            value (bytes) – The object value.
            value (bytes) - 对象值。
        """
        ...

    def add_account(self, account: Account) -> void:
        """
        Add the given account to the database.

        将给定的账户添加到数据库中。

        Parameters: account (Account) – The account to add.
        参数:account (Account) - 要添加的账户。
        """
        ...

    def add_currency(self, currency: Currency) -> void:
        """
        Add the given currency to the database.

        将给定的货币添加到数据库中。

        Parameters: currency (Currency) – The currency to add.
        参数:currency (Currency) - 要添加的货币。
        """
        ...

    def add_instrument(self, instrument: Instrument) -> void:
        """
        Add the given instrument to the database.

        将给定的金融Instrument添加到数据库中。

        Parameters: instrument (Instrument) – The instrument to add.
        参数:instrument (Instrument) - 要添加的金融Instrument。
        """
        ...

    def add_order(self, order: Order, position_id: PositionId=None, client_id: ClientId=None) -> void:
        """
        Add the given order to the database.

        将给定的订单添加到数据库中。

        Parameters:
        参数:
            order (Order) – The order to add.
            order (Order) - 要添加的订单。
            position_id (PositionId , optional) – The position ID to associate with this order.
            position_id (PositionId,可选) - 与此订单关联的持仓 ID。
            client_id (ClientId , optional) – The execution client ID to associate with this order.
            client_id (ClientId,可选) - 与此订单关联的执行客户端 ID。
        """
        ...

    def add_position(self, position: Position) -> void:
        """
        Add the given position to the database.

        将给定的持仓添加到数据库中。

        Parameters: position (Position) – The position to add.
        参数:position (Position) - 要添加的持仓。
        """
        ...

    def add_synthetic(self, synthetic: SyntheticInstrument) -> void:
        """
        Add the given synthetic instrument to the database.

        将给定的合成金融Instrument添加到数据库中。

        Parameters: synthetic (SyntheticInstrument) – The synthetic instrument to add.
        参数:synthetic (SyntheticInstrument) - 要添加的合成金融Instrument。
        """
        ...

    def close(self) -> void:
        """
        Close the backing database adapter.

        关闭后备数据库适配器。
        """
        ...

    def delete_actor(self, component_id: ComponentId) -> void:
        """
        Delete the given actor from the database.

        从数据库中删除给定的 actor。

        Parameters: component_id (ComponentId) – The ID of the actor state dictionary to delete.
        参数:component_id (ComponentId) - 要删除的 actor 状态字典的 ID。
        """
        ...

    def delete_strategy(self, strategy_id: StrategyId) -> void:
        """
        Delete the given strategy from the database.

        从数据库中删除给定的策略。

        Parameters: strategy_id (StrategyId) – The ID of the strategy state dictionary to delete.
        参数:strategy_id (StrategyId) - 要删除的策略状态字典的 ID。
        """
        ...

    def flush(self) -> void:
        """
        Flush the database which clears all data.

        刷新数据库,清除所有数据。
        """
        ...

    def heartbeat(self, timestamp: datetime) -> void:
        """
        Add a heartbeat at the given timestamp.

        在给定的时间戳添加心跳。

        Parameters: timestamp (datetime) – The timestamp for the heartbeat.
        参数:timestamp (datetime) - 心跳的时间戳。
        """
        ...

    def index_order_position(self, client_order_id: ClientOrderId, position_id: PositionId) -> void:
        """
        Add an index entry for the given client_order_id to position_id.

        为给定的 client_order_id 到 position_id 添加索引条目。

        Parameters:
        参数:
            client_order_id (ClientOrderId) – The client order ID to index.
            client_order_id (ClientOrderId) - 要建立索引的客户端订单 ID。
            position_id (PositionId) – The position ID to index.
            position_id (PositionId) - 要建立索引的持仓 ID。
        """
        ...

    def index_venue_order_id(self, client_order_id: ClientOrderId, venue_order_id: VenueOrderId) -> void:
        """
        Add an index entry for the given venue_order_id to client_order_id.

        为给定的 venue_order_id 到 client_order_id 添加索引条目。

        Parameters:
        参数:
            client_order_id (ClientOrderId) – The client order ID to index.
            client_order_id (ClientOrderId) - 要建立索引的客户端订单 ID。
            venue_order_id (VenueOrderId) – The venue order ID to index.
            venue_order_id (VenueOrderId) - 要建立索引的平台订单 ID。
        """
        ...

    def keys(self, pattern: str='*') -> list:
        """
        Return all keys in the database matching the given pattern.

        返回数据库中与给定模式匹配的所有键。

        Parameters: pattern (str , default '*') – The glob-style pattern to match against the keys in the database.
        参数:pattern (str,默认 '*') - 与数据库中的键匹配的 glob 样式模式。
        Return type: list[str]
        Raises: ValueError – If pattern is not a valid string.
        引发:ValueError - 如果 pattern 不是有效的字符串。
        Warning:
            Using the default ‘*’ pattern string can have serious performance implications and can take a long time to execute if many keys exist in the database. This operation can lead to high memory and CPU usage, and should be used with caution, especially in production environments.
            使用默认的“*”模式字符串可能会对性能产生严重影响,并且如果数据库中存在许多键,则执行时间可能会很长。此操作可能会导致高内存和 CPU 使用率,应谨慎使用,尤其是在生产环境中。
        """
        ...

    def load(self) -> dict:
        """
        Load all general objects from the database.

        从数据库加载所有通用对象。

        Return type: dict[str, bytes]
        """
        ...

    def load_account(self, account_id: AccountId):
        """
        Load the account associated with the given account ID (if found).

        加载与给定账户 ID 关联的账户(如果找到)。

        Parameters: account_id (AccountId) – The account ID to load.
        参数:account_id (AccountId) - 要加载的账户 ID。
        Return type: Account or None
        """
        ...

    def load_accounts(self) -> dict:
        """
        Load all accounts from the database.

        从数据库加载所有账户。

        Return type: dict[AccountId, Account]
        """
        ...

    def load_actor(self, component_id: ComponentId) -> dict:
        """
        Load the state for the given actor.

        加载给定 actor 的状态。

        Parameters: component_id (ComponentId) – The ID of the actor state dictionary to load.
        参数:component_id (ComponentId) - 要加载的 actor 状态字典的 ID。
        Return type: dict[str, Any]
        """
        ...

    def load_currencies(self) -> dict:
        """
        Load all currencies from the database.

        从数据库加载所有货币。

        Return type: dict[str, Currency]
        """
        ...

    def load_currency(self, code: str):
        """
        Load the currency associated with the given currency code (if found).

        加载与给定货币代码关联的货币(如果找到)。

        Parameters: code (str) – The currency code to load.
        参数:code (str) - 要加载的货币代码。
        Return type: Currency or None
        """
        ...

    def load_index_order_client(self) -> dict:
        """
        Load the order to execution client index from the database.

        从数据库加载订单到执行客户端的索引。

        Return type: dict[ClientOrderId, ClientId]
        """
        ...

    def load_index_order_position(self) -> dict:
        """
        Load the order to position index from the database.

        从数据库加载订单到持仓的索引。

        Return type: dict[ClientOrderId, PositionId]
        """
        ...

    def load_instrument(self, instrument_id: InstrumentId):
        """
        Load the instrument associated with the given instrument ID (if found).

        加载与给定金融Instrument ID 关联的金融Instrument(如果找到)。

        Parameters: instrument_id (InstrumentId) – The instrument ID to load.
        参数:instrument_id (InstrumentId) - 要加载的金融Instrument ID。
        Return type: Instrument or None
        """
        ...

    def load_instruments(self) -> dict:
        """
        Load all instruments from the database.

        从数据库加载所有金融Instrument。

        Return type: dict[InstrumentId, Instrument]
        """
        ...

    def load_order(self, client_order_id: ClientOrderId):
        """
        Load the order associated with the given client order ID (if found).

        加载与给定客户端订单 ID 关联的订单(如果找到)。

        Parameters: client_order_id (ClientOrderId) – The client order ID to load.
        参数:client_order_id (ClientOrderId) - 要加载的客户端订单 ID。
        Return type: Order or None
        """
        ...

    def load_orders(self) -> dict:
        """
        Load all orders from the database.

        从数据库加载所有订单。

        Return type: dict[ClientOrderId, Order]
        """
        ...

    def load_position(self, position_id: PositionId):
        """
        Load the position associated with the given ID (if found).

        加载与给定 ID 关联的持仓(如果找到)。

        Parameters: position_id (PositionId) – The position ID to load.
        参数:position_id (PositionId) - 要加载的持仓 ID。
        Return type: Position or None
        """
        ...

    def load_positions(self) -> dict:
        """
        Load all positions from the database.

        从数据库加载所有持仓。

        Return type: dict[PositionId, Position]
        """
        ...

    def load_strategy(self, strategy_id: StrategyId) -> dict:
        """
        Load the state for the given strategy.

        加载给定策略的状态。

        Parameters: strategy_id (StrategyId) – The ID of the strategy state dictionary to load.
        参数:strategy_id (StrategyId) - 要加载的策略状态字典的 ID。
        Return type: dict[str, bytes]
        """
        ...

    def load_synthetic(self, instrument_id: InstrumentId):
        """
        Load the synthetic instrument associated with the given synthetic instrument ID (if found).

        加载与给定合成金融Instrument ID 关联的合成金融Instrument(如果找到)。

        Parameters: instrument_id (InstrumentId) – The synthetic instrument ID to load.
        参数:instrument_id (InstrumentId) - 要加载的合成金融Instrument ID。
        Return type: SyntheticInstrument or None
        Raises: ValueError – If instrument_id is not for a synthetic instrument.
        引发:ValueError - 如果 instrument_id 不是用于合成金融Instrument。
        """
        ...

    def load_synthetics(self) -> dict:
        """
        Load all synthetic instruments from the database.

        从数据库加载所有合成金融Instrument。

        Return type: dict[InstrumentId, SyntheticInstrument]
        """
        ...

    def snapshot_order_state(self, order: Order) -> void:
        """
        Snapshot the state of the given order.

        快照给定订单的状态。

        Parameters: order (Order) – The order for the state snapshot.
        参数:order (Order) - 状态快照的订单。
        """
        ...

    def snapshot_position_state(self, position: Position, ts_snapshot: int, unrealized_pnl=None) -> void:
        """
        Snapshot the state of the given position.

        快照给定持仓的状态。

        Parameters:
        参数:
            position (Position) – The position for the state snapshot.
            position (Position) - 状态快照的持仓。
            ts_snapshot (uint64_t) – UNIX timestamp (nanoseconds) when the snapshot was taken.
            ts_snapshot (uint64_t) - 拍摄快照时的 UNIX 时间戳(纳秒)。
            unrealized_pnl (Money , optional) – The unrealized PnL for the state snapshot.
            unrealized_pnl (Money,可选) - 状态快照的未实现盈亏。
        """
        ...

    def update_account(self, account) -> void:
        """
        Update the given account in the database.

        更新数据库中的给定账户。

        Parameters: account (The account to update *(*from last event ) .)
        参数:account(要更新的账户(来自最后一个事件))。
        """
        ...

    def update_actor(self, actor: Actor) -> void:
        """
        Update the given actor state in the database.

        更新数据库中的给定 actor 状态。

        Parameters: actor (Actor) – The actor to update.
        参数:actor (Actor) - 要更新的 actor。
        """
        ...

    def update_order(self, order: Order) -> void:
        """
        Update the given order in the database.

        更新数据库中的给定订单。

        Parameters: order (Order) – The order to update (from last event).
        参数:order (Order) - 要更新的订单(来自最后一个事件)。
        """
        ...

    def update_position(self, position: Position) -> void:
        """
        Update the given position in the database.

        更新数据库中的给定持仓。

        Parameters: position (Position) – The position to update (from last event).
        参数:position (Position) - 要更新的持仓(来自最后一个事件)。
        """
        ...

    def update_strategy(self, strategy: Strategy) -> void:
        """
        Update the given strategy state in the database.

        更新数据库中的给定策略状态。

        Parameters: strategy (Strategy) – The strategy to update.
        参数:strategy (Strategy) - 要更新的策略。
        """
        ...

class CacheFacade 缓存外观

class CacheFacade(object):
    """
    Provides a read-only facade for the common Cache.

    为通用缓存提供只读外观。
    """
    def __init__(self):
        ...

Methods 方法

    def account(self, account_id: AccountId):
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def account_for_venue(self, venue: Venue):
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def account_id(self, venue: Venue) -> AccountId:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def accounts(self) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def actor_ids(self) -> set:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def add(self, key: str, value: bytes) -> void:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def bar(self, bar_type: BarType, index: int=0):
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def bar_count(self, bar_type: BarType) -> int:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def bars(self, bar_type: BarType) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def book_update_count(self, instrument_id: InstrumentId) -> int:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def client_id(self, client_order_id: ClientOrderId):
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def client_order_id(self, venue_order_id: VenueOrderId) -> ClientOrderId:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def client_order_ids(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> set:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def client_order_ids_closed(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> set:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def client_order_ids_emulated(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> set:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def client_order_ids_inflight(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> set:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def client_order_ids_open(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> set:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def exec_algorithm_ids(self) -> set:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def exec_spawn_total_filled_qty(self, exec_spawn_id: ClientOrderId, active_only: bool=False):
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def exec_spawn_total_leaves_qty(self, exec_spawn_id: ClientOrderId, active_only: bool=False):
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def exec_spawn_total_quantity(self, exec_spawn_id: ClientOrderId, active_only: bool=False):
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def get(self, key: str):
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def get_xrate(self, venue: Venue, from_currency: Currency, to_currency: Currency, price_type: PriceType=PriceType.MID):
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def has_bars(self, bar_type: BarType) -> bool:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def has_order_book(self, instrument_id: InstrumentId) -> bool:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def has_quote_ticks(self, instrument_id: InstrumentId) -> bool:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def has_trade_ticks(self, instrument_id: InstrumentId) -> bool:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def instrument(self, instrument_id: InstrumentId):
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def instrument_ids(self, venue: Venue=None) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def instruments(self, venue: Venue=None) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def is_order_closed(self, client_order_id: ClientOrderId) -> bool:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def is_order_emulated(self, client_order_id: ClientOrderId) -> bool:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def is_order_inflight(self, client_order_id: ClientOrderId) -> bool:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def is_order_open(self, client_order_id: ClientOrderId) -> bool:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def is_order_pending_cancel_local(self, client_order_id: ClientOrderId) -> bool:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def is_position_closed(self, position_id: PositionId) -> bool:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def is_position_open(self, position_id: PositionId) -> bool:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def order(self, client_order_id: ClientOrderId):
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def order_book(self, instrument_id: InstrumentId):
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def order_exists(self, client_order_id: ClientOrderId) -> bool:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def order_list(self, order_list_id: OrderListId):
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def order_list_exists(self, order_list_id: OrderListId) -> bool:
        """
```python
       Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def order_list_ids(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> set:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def order_lists(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def orders(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def orders_closed(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def orders_closed_count(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> int:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def orders_emulated(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def orders_emulated_count(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> int:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def orders_for_exec_algorithm(self, exec_algorithm_id: ExecAlgorithmId, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def orders_for_exec_spawn(self, exec_spawn_id: ClientOrderId) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def orders_for_position(self, position_id: PositionId) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def orders_inflight(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def orders_inflight_count(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> int:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def orders_open(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def orders_open_count(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> int:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def orders_total_count(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=OrderSide.NO_ORDER_SIDE) -> int:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def position(self, position_id: PositionId):
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def position_closed_ids(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> set:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def position_exists(self, position_id: PositionId) -> bool:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def position_for_order(self, client_order_id: ClientOrderId):
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def position_id(self, client_order_id: ClientOrderId) -> PositionId:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def position_ids(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> set:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def position_open_ids(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> set:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def position_snapshots(self, position_id: PositionId=None) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def positions(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=PositionSide.NO_POSITION_SIDE) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def positions_closed(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def positions_closed_count(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None) -> int:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def positions_open(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=PositionSide.NO_POSITION_SIDE) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def positions_open_count(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=PositionSide.NO_POSITION_SIDE) -> int:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def positions_total_count(self, venue: Venue=None, instrument_id: InstrumentId=None, strategy_id: StrategyId=None, side=PositionSide.NO_POSITION_SIDE) -> int:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def price(self, instrument_id: InstrumentId, price_type: PriceType):
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def quote_tick(self, instrument_id: InstrumentId, index: int=0):
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def quote_tick_count(self, instrument_id: InstrumentId) -> int:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def quote_ticks(self, instrument_id: InstrumentId) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def strategy_id_for_order(self, client_order_id: ClientOrderId) -> StrategyId:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def strategy_id_for_position(self, position_id: PositionId) -> StrategyId:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def strategy_ids(self) -> set:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def synthetic(self, instrument_id: InstrumentId):
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def synthetic_ids(self) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def synthetics(self) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def trade_tick(self, instrument_id: InstrumentId, index: int=0):
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def trade_tick_count(self, instrument_id: InstrumentId) -> int:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def trade_ticks(self, instrument_id: InstrumentId) -> list:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...

    def venue_order_id(self, client_order_id: ClientOrderId) -> VenueOrderId:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...