Skip to content
Loren1166 edited this page Sep 24, 2024 · 1 revision

Live 实时

The live subpackage groups all engine and client implementations for live trading. # 实时子包将所有引擎和客户端实现分组以进行实时交易。

Generally a common event loop is passed into each live engine to support the overarching design of a single efficient event loop, by default uvloop. # 通常,一个通用的事件循环被传递到每个实时引擎,以支持单个高效事件循环的总体设计,默认情况下是 uvloop。

The LiveDataClient class is responsible for interfacing with a particular API which may be presented directly by a venue, or through a broker intermediary.

LiveDataClient 类负责与特定 API 交互,该 API 可以由场所直接提供,也可以通过经纪商中介提供。

It could also be possible to write clients for specialized data providers.

也可以为专门的数据提供商编写客户端。

class LiveDataClient 实时数据客户端

Bases: DataClient

class LiveDataClient(DataClient):
    """
    The base class for all live data clients.

    所有实时数据客户端的基类。

    Parameters:
    参数:
        loop (asyncio.AbstractEventLoop) – The event loop for the client.
        loop (asyncio.AbstractEventLoop) - 客户端的事件循环。
        client_id (ClientId) – The client ID.
        client_id (ClientId) - 客户端 ID。
        venue (Venue, optional with no default so None must be passed explicitly) – The client venue. If multi-venue then can be None.
        venue (Venue,可选,没有默认值,因此必须显式传递 None) - 客户端场所。如果是多场所,则可以为 None。
        msgbus (MessageBus) – The message bus for the client.
        msgbus (MessageBus) - 客户端的消息总线。
        cache (Cache) – The cache for the client.
        cache (Cache) - 客户端的缓存。
        clock (LiveClock) – The clock for the client.
        clock (LiveClock) - 客户端的时钟。
        config (NautilusConfig , optional) – The configuration for the instance.
        config (NautilusConfig,可选) - 实例的配置。

    Warning:
        This class should not be used directly, but through a concrete subclass.
        此类不应直接使用,而应通过具体的子类使用。
    """
    def __init__(self, loop: asyncio.AbstractEventLoop, client_id: ClientId, venue: Venue | None, msgbus: MessageBus, cache: Cache, clock: LiveClock, config: NautilusConfig | None = None):
        ...

Properties 属性

    @property
    def is_connected(self) -> bool:
        """
        If the client is connected.

        如果客户端已连接。

        Returns:
            bool
        """
        ...
    
    @property
    def id(self) -> ComponentId:
        """
        The components ID.

        组件 ID。

        Returns:
            ComponentId
        """
        ...

    @property
    def is_degraded(self) -> bool:
        """
        bool

        Return whether the current component state is DEGRADED.

        返回当前组件状态是否为 DEGRADED。

        Returns:
            bool
        """
        ...

    @property
    def is_disposed(self) -> bool:
        """
        bool

        Return whether the current component state is DISPOSED.

        返回当前组件状态是否为 DISPOSED。

        Returns:
            bool
        """
        ...

    @property
    def is_faulted(self) -> bool:
        """
        bool

        Return whether the current component state is FAULTED.

        返回当前组件状态是否为 FAULTED。

        Returns:
            bool
        """
        ...

    @property
    def is_initialized(self) -> bool:
        """
        bool

        Return whether the component has been initialized (component.state >= INITIALIZED).

        返回组件是否已初始化 (component.state >= INITIALIZED)。

        Returns:
            bool
        """
        ...

    @property
    def is_running(self) -> bool:
        """
        bool

        Return whether the current component state is RUNNING.

        返回当前组件状态是否为 RUNNING。

        Returns:
            bool
        """
        ...

    @property
    def is_stopped(self) -> bool:
        """
        bool

        Return whether the current component state is STOPPED.

        返回当前组件状态是否为 STOPPED。

        Returns:
            bool
        """
        ...
    
    @property
    def state(self) -> ComponentState:
        """
        ComponentState

        Return the components current state.

        返回组件的当前状态。

        Return type: ComponentState
        Type: Component.state
        """
        ...

    @property
    def trader_id(self):
        """
        The trader ID associated with the component.

        与组件关联的交易者 ID。

        Returns:
            TraderId
        """
        ...

    @property
    def type(self):
        """
        The components type.

        组件类型。

        Returns:
            type
        """
        ...

    @property
    def venue(self):
        """
        The clients venue ID (if applicable).

        客户端的场所 ID(如果适用)。

        Returns:
            Venue or None
        """
        ...

Methods 方法

    @staticmethod
    async def run_after_delay(delay: float, coro: Coroutine) -> None:
        """
        Run the given coroutine after a delay.

        延迟后运行给定的协程。

        Parameters:
        参数:
            delay (float) – The delay (seconds) before running the coroutine.
            delay (float) - 运行协程之前的延迟(以秒为单位)。
            coro (Coroutine) – The coroutine to run after the initial delay.
            coro (Coroutine) - 初始延迟后要运行的协程。
        """
        ...

    def create_task(self, coro: Coroutine, log_msg: str | None = None, actions=None, success_msg: str | None = None, success_color=LogColor.NORMAL):
        """
        Run the given coroutine with error handling and optional callback actions when done.

        运行给定的协程,并在完成后使用错误处理和可选的回调操作。

        Parameters:
        参数:
            coro (Coroutine) – The coroutine to run.
            coro (Coroutine) - 要运行的协程。
            log_msg (str , optional) – The log message for the task.
            log_msg (str,可选) - 任务的日志消息。
            actions (Callable , optional) – The actions callback to run when the coroutine is done.
            actions (Callable,可选) - 协程完成后要运行的操作回调。
            success_msg (str , optional) – The log message to write on actions success.
            success_msg (str,可选) - 操作成功时要写入的日志消息。
            success_color (LogColor, default NORMAL) – The log message color for actions success.
            success_color (LogColor,默认 NORMAL) - 操作成功时要使用的日志消息颜色。

        Return type: asyncio.Task
        """
        ...

    def connect(self) -> None:
        """
        Connect the client.

        连接客户端。
        """
        ...
    
    def disconnect(self) -> None:
        """
        Disconnect the client.

        断开客户端连接。
        """
        ...

    def subscribe(self, data_type: DataType) -> void:
        """
        Subscribe to data for the given data type.

        订阅给定数据类型的数据。

        Parameters: data_type (DataType) – The data type for the subscription.
        参数:data_type (DataType) - 订阅的数据类型。
        """
        ...

    def unsubscribe(self, data_type: DataType) -> void:
        """
        Unsubscribe from data for the given data type.

        取消订阅给定数据类型的数据。

        Parameters: data_type (DataType) – The data type for the subscription.
        参数:data_type (DataType) - 订阅的数据类型。
        """
        ...

    def request(self, data_type: DataType, correlation_id: UUID4) -> void:
        """
        Request data for the given data type.

        请求给定数据类型的数据。

        Parameters:
        参数:
            data_type (DataType) – The data type for the subscription.
            data_type (DataType) - 订阅的数据类型。
            correlation_id (UUID4) – The correlation ID for the response.
            correlation_id (UUID4) - 响应的相关 ID。
        """
        ...
    
    def degrade(self) -> void:
        """
        Degrade the component.

        While executing on_degrade() any exception will be logged and reraised, then the component will remain in a DEGRADING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...
    
    def dispose(self) -> void:
        """
        Dispose of the component.

        While executing on_dispose() any exception will be logged and reraised, then the component will remain in a DISPOSING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...
    
    def fault(self) -> void:
        """
        Fault the component.

        Calling this method multiple times has the same effect as calling it once (it is idempotent). Once called, it cannot be reversed, and no other methods should be called on this instance.

        While executing on_fault() any exception will be logged and reraised, then the component will remain in a FAULTING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    @classmethod
    def fully_qualified_name(cls) -> str:
        """
        Return the fully qualified name for the components class.

        返回组件类的完全限定名称。

        Return type: str
        """
        ...

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

        重置组件。

        All stateful fields are reset to their initial value.

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

        While executing on_reset() any exception will be logged and reraised, then the component will remain in a RESETTING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    def resume(self) -> void:
        """
        Resume the component.

        While executing on_resume() any exception will be logged and reraised, then the component will remain in a RESUMING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    def start(self) -> void:
        """
        Start the component.

        While executing on_start() any exception will be logged and reraised, then the component will remain in a STARTING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    def stop(self) -> void:
        """
        Stop the component.

        While executing on_stop() any exception will be logged and reraised, then the component will remain in a STOPPING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    def subscribed_custom_data(self) -> list:
        """
        Return the custom data types subscribed to.

        返回订阅的自定义数据类型。

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

class LiveMarketDataClient 实时市场数据客户端

Bases: MarketDataClient

class LiveMarketDataClient(MarketDataClient):
    """
    The base class for all live data clients.

    所有实时数据客户端的基类。

    Parameters:
    参数:
        loop (asyncio.AbstractEventLoop) – The event loop for the client.
        loop (asyncio.AbstractEventLoop) - 客户端的事件循环。
        client_id (ClientId) – The client ID.
        client_id (ClientId) - 客户端 ID。
        venue (Venue, optional with no default so None must be passed explicitly) – The client venue. If multi-venue then can be None.
        venue (Venue,可选,没有默认值,因此必须显式传递 None) - 客户端场所。如果是多场所,则可以为 None。
        msgbus (MessageBus) – The message bus for the client.
        msgbus (MessageBus) - 客户端的消息总线。
        cache (Cache) – The cache for the client.
        cache (Cache) - 客户端的缓存。
        clock (LiveClock) – The clock for the client.
        clock (LiveClock) - 客户端的时钟。
        instrument_provider (InstrumentProvider) – The instrument provider for the client.
        instrument_provider (InstrumentProvider) - 客户端的金融工具提供器。
        config (NautilusConfig , optional) – The configuration for the instance.
        config (NautilusConfig,可选) - 实例的配置。
    Warning:
        This class should not be used directly, but through a concrete subclass.
        此类不应直接使用,而应通过具体的子类使用。
    """
    def __init__(self, loop: asyncio.AbstractEventLoop, client_id: ClientId, venue: Venue | None, msgbus: MessageBus, cache: Cache, clock: LiveClock, instrument_provider: InstrumentProvider, config: NautilusConfig | None = None):
        ...

Methods 方法

    @staticmethod
    async def run_after_delay(delay: float, coro: Coroutine) -> None:
        """
        Run the given coroutine after a delay.

        延迟后运行给定的协程。

        Parameters:
        参数:
            delay (float) – The delay (seconds) before running the coroutine.
            delay (float) - 运行协程之前的延迟(以秒为单位)。
            coro (Coroutine) – The coroutine to run after the initial delay.
            coro (Coroutine) - 初始延迟后要运行的协程。
        """
        ...

    def create_task(self, coro: Coroutine, log_msg: str | None = None, actions=None, success_msg: str | None = None, success_color=LogColor.NORMAL):
        """
        Run the given coroutine with error handling and optional callback actions when done.

        运行给定的协程,并在完成后使用错误处理和可选的回调操作。

        Parameters:
        参数:
            coro (Coroutine) – The coroutine to run.
            coro (Coroutine) - 要运行的协程。
            log_msg (str , optional) – The log message for the task.
            log_msg (str,可选) - 任务的日志消息。
            actions (Callable , optional) – The actions callback to run when the coroutine is done.
            actions (Callable,可选) - 协程完成后要运行的操作回调。
            success_msg (str , optional) – The log message to write on actions success.
            success_msg (str,可选) - 操作成功时要写入的日志消息。
            success_color (LogColor, default NORMAL) – The log message color for actions success.
            success_color (LogColor,默认 NORMAL) - 操作成功时要使用的日志消息颜色。

        Return type: asyncio.Task
        """
        ...

    def connect(self) -> None:
        """
        Connect the client.

        连接客户端。
        """
        ...

    def disconnect(self) -> None:
        """
        Disconnect the client.

        断开客户端连接。
        """
        ...

    def subscribe(self, data_type: DataType) -> void:
        """
        Subscribe to data for the given data type.

        订阅给定数据类型的数据。

        Parameters: data_type (DataType) – The data type for the subscription.
        参数:data_type (DataType) - 订阅的数据类型。
        """
        ...

    def subscribe_instruments(self) -> void:
        """
        Subscribe to all Instrument data.

        订阅所有金融工具数据。
        """
        ...

    def subscribe_instrument(self, instrument_id: InstrumentId) -> void:
        """
        Subscribe to the Instrument with the given instrument ID.

        订阅具有给定金融工具 ID 的金融工具。
        """
        ...

    def subscribe_order_book_deltas(self, instrument_id: InstrumentId, book_type: BookType, depth: int = 0, kwargs: dict = None) -> void:
        """
        Subscribe to OrderBookDeltas data for the given instrument ID.

        订阅给定金融工具 ID 的 OrderBookDeltas 数据。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The order book instrument to subscribe to.
            instrument_id (InstrumentId) - 要订阅的订单簿金融工具。
            book_type (BookType {L1_MBP, L2_MBP, L3_MBO}) – The order book type.
            book_type (BookType {L1_MBP, L2_MBP, L3_MBO}) - 订单簿类型。
            depth (int , optional , default None) – The maximum depth for the subscription.
            depth (int,可选,默认 None) - 订阅的最大深度。
            kwargs (dict , optional) – The keyword arguments for exchange specific parameters.
            kwargs (dict,可选) - 交换特定参数的关键字参数。
        """
        ...

    def subscribe_order_book_snapshots(self, instrument_id: InstrumentId, book_type: BookType, depth: int = 0, kwargs: dict = None) -> void:
        """
        Subscribe to OrderBook snapshots data for the given instrument ID.

        订阅给定金融工具 ID 的 OrderBook 快照数据。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The order book instrument to subscribe to.
            instrument_id (InstrumentId) - 要订阅的订单簿金融工具。
            book_type (BookType {L1_MBP, L2_MBP, L3_MBO}) – The order book level.
            book_type (BookType {L1_MBP, L2_MBP, L3_MBO}) - 订单簿级别。
            depth (int , optional) – The maximum depth for the order book. A depth of 0 is maximum depth.
            depth (int,可选) - 订单簿的最大深度。深度为 0 表示最大深度。
            kwargs (dict , optional) – The keyword arguments for exchange specific parameters.
            kwargs (dict,可选) - 交换特定参数的关键字参数。
        """
        ...

    def subscribe_quote_ticks(self, instrument_id: InstrumentId) -> void:
        """
        Subscribe to QuoteTick data for the given instrument ID.

        订阅给定金融工具 ID 的报价行情数据。

        Parameters: instrument_id (InstrumentId) – The tick instrument to subscribe to.
        参数:instrument_id (InstrumentId) - 要订阅的行情金融工具。
        """
        ...

    def subscribe_trade_ticks(self, instrument_id: InstrumentId) -> void:
        """
        Subscribe to TradeTick data for the given instrument ID.

        订阅给定金融工具 ID 的交易行情数据。

        Parameters: instrument_id (InstrumentId) – The tick instrument to subscribe to.
        参数:instrument_id (InstrumentId) - 要订阅的行情金融工具。
        """
        ...

    def subscribe_bars(self, bar_type: BarType) -> void:
        """
        Subscribe to Bar data for the given bar type.

        订阅给定 bar 类型的 Bar 数据。

        Parameters: bar_type (BarType) – The bar type to subscribe to.
        参数:bar_type (BarType) - 要订阅的 bar 类型。
        """
        ...

    def subscribe_instrument_status(self, instrument_id: InstrumentId) -> void:
        """
        Subscribe to InstrumentStatus data for the given instrument ID.

        订阅给定金融工具 ID 的金融工具状态数据。

        Parameters: instrument_id (InstrumentId) – The tick instrument to subscribe to.
        参数:instrument_id (InstrumentId) - 要订阅的行情金融工具。
        """
        ...

    def subscribe_instrument_close(self, instrument_id: InstrumentId) -> void:
        """
        Subscribe to InstrumentClose updates for the given instrument ID.

        订阅给定金融工具 ID 的金融工具收盘价更新。

        Parameters: instrument_id (InstrumentId) – The tick instrument to subscribe to.
        参数:instrument_id (InstrumentId) - 要订阅的行情金融工具。
        """
        ...

    def unsubscribe(self, data_type: DataType) -> void:
        """
        Unsubscribe from data for the given data type.

        取消订阅给定数据类型的数据。

        Parameters: data_type (DataType) – The data type for the subscription.
        参数:data_type (DataType) - 订阅的数据类型。
        """
        ...

    def unsubscribe_instruments(self) -> void:
        """
        Unsubscribe from all Instrument data.

        取消订阅所有金融工具数据。
        """
        ...

    def unsubscribe_instrument(self, instrument_id: InstrumentId) -> void:
        """
        Unsubscribe from Instrument data for the given instrument ID.

        取消订阅给定金融工具 ID 的金融工具数据。

        Parameters: instrument_id (InstrumentId) – The instrument to unsubscribe from.
        参数:instrument_id (InstrumentId) - 要取消订阅的金融工具。
        """
        ...

    def unsubscribe_order_book_deltas(self, instrument_id: InstrumentId) -> void:
        """
        Unsubscribe from OrderBookDeltas data for the given instrument ID.

        取消订阅给定金融工具 ID 的 OrderBookDeltas 数据。

        Parameters: instrument_id (InstrumentId) – The order book instrument to unsubscribe from.
        参数:instrument_id (InstrumentId) - 要取消订阅的订单簿金融工具。
        """
        ...

    def unsubscribe_order_book_snapshots(self, instrument_id: InstrumentId) -> void:
        """
        Unsubscribe from OrderBook snapshots data for the given instrument ID.

        取消订阅给定金融工具 ID 的 OrderBook 快照数据。

        Parameters: instrument_id (InstrumentId) – The order book instrument to unsubscribe from.
        参数:instrument_id (InstrumentId) - 要取消订阅的订单簿金融工具。
        """
        ...

    def unsubscribe_quote_ticks(self, instrument_id: InstrumentId) -> void:
        """
        Unsubscribe from QuoteTick data for the given instrument ID.

        取消订阅给定金融工具 ID 的报价行情数据。

        Parameters: instrument_id (InstrumentId) – The tick instrument to unsubscribe from.
        参数:instrument_id (InstrumentId) - 要取消订阅的行情金融工具。
        """
        ...

    def unsubscribe_trade_ticks(self, instrument_id: InstrumentId) -> void:
        """
        Unsubscribe from TradeTick data for the given instrument ID.

        取消订阅给定金融工具 ID 的交易行情数据。

        Parameters: instrument_id (InstrumentId) – The tick instrument to unsubscribe from.
        参数:instrument_id (InstrumentId) - 要取消订阅的行情金融工具。
        """
        ...

    def unsubscribe_bars(self, bar_type: BarType) -> void:
        """
        Unsubscribe from Bar data for the given bar type.

        取消订阅给定 bar 类型的 Bar 数据。

        Parameters: bar_type (BarType) – The bar type to unsubscribe from.
        参数:bar_type (BarType) - 要取消订阅的 bar 类型。
        """
        ...

    def unsubscribe_instrument_status(self, instrument_id: InstrumentId) -> void:
        """
        Unsubscribe from InstrumentStatus data for the given instrument ID.

        取消订阅给定金融工具 ID 的金融工具状态数据。

        Parameters: instrument_id (InstrumentId) – The instrument status updates to unsubscribe from.
        参数:instrument_id (InstrumentId) - 要取消订阅状态更新的金融工具。
        """
        ...

    def unsubscribe_instrument_close(self, instrument_id: InstrumentId) -> void:
        """
        Unsubscribe from InstrumentClose data for the given instrument ID.

        取消订阅给定金融工具 ID 的金融工具收盘价数据。

        Parameters: instrument_id (InstrumentId) – The tick instrument to unsubscribe from.
        参数:instrument_id (InstrumentId) - 要取消订阅的行情金融工具。
        """
        ...

    def request(self, data_type: DataType, correlation_id: UUID4) -> void:
        """
        Request data for the given data type.

        请求给定数据类型的数据。

        Parameters:
        参数:
            data_type (DataType) – The data type for the subscription.
            data_type (DataType) - 订阅的数据类型。
            correlation_id (UUID4) – The correlation ID for the response.
            correlation_id (UUID4) - 响应的相关 ID。
        """
        ...

    def request_instrument(self, instrument_id: InstrumentId, correlation_id: UUID4, start: datetime = None, end: datetime = None) -> void:
        """
        Request Instrument data for the given instrument ID.

        请求给定金融工具 ID 的金融工具数据。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The instrument ID for the request.
            instrument_id (InstrumentId) - 请求的金融工具 ID。
            correlation_id (UUID4) – The correlation ID for the request.
            correlation_id (UUID4) - 请求的相关 ID。
            start (datetime , optional) – The start datetime (UTC) of request time range (inclusive).
            start (datetime,可选) - 请求时间范围的开始日期时间(UTC)(含)。
            end (datetime , optional) – The end datetime (UTC) of request time range. The inclusiveness depends on individual data client implementation.
            end (datetime,可选) - 请求时间范围的结束日期时间(UTC)。包含性取决于各个数据客户端的实现。
        """
        ...

    def request_instruments(self, venue: Venue, correlation_id: UUID4, start: datetime = None, end: datetime = None) -> void:
        """
        Request all Instrument data for the given venue.

        请求给定场所的所有金融工具数据。

        Parameters:
        参数:
            venue (Venue) – The venue for the request.
            venue (Venue) - 请求的场所。
            correlation_id (UUID4) – The correlation ID for the request.
            correlation_id (UUID4) - 请求的相关 ID。
            start (datetime , optional) – The start datetime (UTC) of request time range (inclusive).
            start (datetime,可选) - 请求时间范围的开始日期时间(UTC)(含)。
            end (datetime , optional) – The end datetime (UTC) of request time range. The inclusiveness depends on individual data client implementation.
            end (datetime,可选) - 请求时间范围的结束日期时间(UTC)。包含性取决于各个数据客户端的实现。
        """
        ...

    def request_quote_ticks(self, instrument_id: InstrumentId, limit: int, correlation_id: UUID4, start: datetime = None, end: datetime = None) -> void:
        """
        Request historical QuoteTick data.

        请求历史报价行情数据。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The tick instrument ID for the request.
            instrument_id (InstrumentId) - 请求的行情金融工具 ID。
            limit (int) – The limit for the number of returned ticks.
            limit (int) - 返回的行情数量限制。
            correlation_id (UUID4) – The correlation ID for the request.
            correlation_id (UUID4) - 请求的相关 ID。
            start (datetime , optional) – The start datetime (UTC) of request time range (inclusive).
            start (datetime,可选) - 请求时间范围的开始日期时间(UTC)(含)。
            end (datetime , optional) – The end datetime (UTC) of request time range. The inclusiveness depends on individual data client implementation.
            end (datetime,可选) - 请求时间范围的结束日期时间(UTC)。包含性取决于各个数据客户端的实现。
        """
        ...

    def request_trade_ticks(self, instrument_id: InstrumentId, limit: int, correlation_id: UUID4, start: datetime = None, end: datetime = None) -> void:
        """
        Request historical TradeTick data.

        请求历史交易行情数据。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The tick instrument ID for the request.
            instrument_id (InstrumentId) - 请求的行情金融工具 ID。
            limit (int) – The limit for the number of returned ticks.
            limit (int) - 返回的行情数量限制。
            correlation_id (UUID4) – The correlation ID for the request.
            correlation_id (UUID4) - 请求的相关 ID。
            start (datetime , optional) – The start datetime (UTC) of request time range (inclusive).
            start (datetime,可选) - 请求时间范围的开始日期时间(UTC)(含)。
            end (datetime , optional) – The end datetime (UTC) of request time range. The inclusiveness depends on individual data client implementation.
            end (datetime,可选) - 请求时间范围的结束日期时间(UTC)。包含性取决于各个数据客户端的实现。
        """
        ...

    def request_bars(self, bar_type: BarType, limit: int, correlation_id: UUID4, start: datetime = None, end: datetime = None) -> void:
        """
        Request historical Bar data.

        请求历史 Bar 数据。

        Parameters:
        参数:
            bar_type (BarType) – The bar type for the request.
            bar_type (BarType) - 请求的 bar 类型。
            limit (int) – The limit for the number of returned bars.
            limit (int) - 返回的 bar 数量限制。
            correlation_id (UUID4) – The correlation ID for the request.
            correlation_id (UUID4) - 请求的相关 ID。
            start (datetime , optional) – The start datetime (UTC) of request time range (inclusive).
            start (datetime,可选) - 请求时间范围的开始日期时间(UTC)(含)。
            end (datetime , optional) – The end datetime (UTC) of request time range. The inclusiveness depends on individual data client implementation.
            end (datetime,可选) - 请求时间范围的结束日期时间(UTC)。包含性取决于各个数据客户端的实现。
        """
        ...

    def request_order_book_snapshot(self, instrument_id: InstrumentId, limit: int, correlation_id: UUID4) -> void:
        """
        Request order book snapshot data.

        请求订单簿快照数据。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The instrument ID for the order book snapshot request.
            instrument_id (InstrumentId) - 订单簿快照请求的金融工具 ID。
            limit (int) – The limit on the depth of the order book snapshot.
            limit (int) - 订单簿快照深度的限制。
            correction_id (UUID4) – The correlation ID for the request.
            correction_id (UUID4) - 请求的相关 ID。
        """
        ...

    def degrade(self) -> void:
        """
        Degrade the component.

        While executing on_degrade() any exception will be logged and reraised, then the component will remain in a DEGRADING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...
    
    def dispose(self) -> void:
        """
        Dispose of the component.

        While executing on_dispose() any exception will be logged and reraised, then the component will remain in a DISPOSING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...
    
    def fault(self) -> void:
        """
        Fault the component.

        Calling this method multiple times has the same effect as calling it once (it is idempotent). Once called, it cannot be reversed, and no other methods should be called on this instance.

        While executing on_fault() any exception will be logged and reraised, then the component will remain in a FAULTING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    @classmethod
    def fully_qualified_name(cls) -> str:
        """
        Return the fully qualified name for the components class.

        返回组件类的完全限定名称。

        Return type: str
        """
        ...

    @property
    def id(self) -> ComponentId:
        """
        The components ID.

        组件 ID。

        Returns:
            ComponentId
        """
        ...

    @property
    def is_connected(self) -> bool:
        """
        ```python
       If the client is connected.

        如果客户端已连接。

        Returns:
            bool
        """
        ...

    @property
    def is_degraded(self) -> bool:
        """
        bool

        Return whether the current component state is DEGRADED.

        返回当前组件状态是否为 DEGRADED。

        Returns:
            bool
        """
        ...

    @property
    def is_disposed(self) -> bool:
        """
        bool

        Return whether the current component state is DISPOSED.

        返回当前组件状态是否为 DISPOSED。

        Returns:
            bool
        """
        ...

    @property
    def is_faulted(self) -> bool:
        """
        bool

        Return whether the current component state is FAULTED.

        返回当前组件状态是否为 FAULTED。

        Returns:
            bool
        """
        ...

    @property
    def is_initialized(self) -> bool:
        """
        bool

        Return whether the component has been initialized (component.state >= INITIALIZED).

        返回组件是否已初始化 (component.state >= INITIALIZED)。

        Returns:
            bool
        """
        ...

    @property
    def is_running(self) -> bool:
        """
        bool

        Return whether the current component state is RUNNING.

        返回当前组件状态是否为 RUNNING。

        Returns:
            bool
        """
        ...

    @property
    def is_stopped(self) -> bool:
        """
        bool

        Return whether the current component state is STOPPED.

        返回当前组件状态是否为 STOPPED。

        Returns:
            bool
        """
        ...

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

        重置组件。

        All stateful fields are reset to their initial value.

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

        While executing on_reset() any exception will be logged and reraised, then the component will remain in a RESETTING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    def resume(self) -> void:
        """
        Resume the component.

        While executing on_resume() any exception will be logged and reraised, then the component will remain in a RESUMING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    def start(self) -> void:
        """
        Start the component.

        While executing on_start() any exception will be logged and reraised, then the component will remain in a STARTING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    @property
    def state(self) -> ComponentState:
        """
        ComponentState

        Return the components current state.

        返回组件的当前状态。

        Return type: ComponentState
        Type: Component.state
        """
        ...

    def stop(self) -> void:
        """
        Stop the component.

        While executing on_stop() any exception will be logged and reraised, then the component will remain in a STOPPING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    def subscribed_bars(self) -> list:
        """
        Return the bar types subscribed to.

        返回订阅的 bar 类型。

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

    def subscribed_custom_data(self) -> list:
        """
        Return the custom data types subscribed to.

        返回订阅的自定义数据类型。

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

    def subscribed_instrument_close(self) -> list:
        """
        Return the instrument closes subscribed to.

        返回订阅的金融工具收盘价。

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

    def subscribed_instrument_status(self) -> list:
        """
        Return the status update instruments subscribed to.

        返回订阅的状态更新金融工具。

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

    def subscribed_instruments(self) -> list:
        """
        Return the instruments subscribed to.

        返回订阅的金融工具。

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

    def subscribed_order_book_deltas(self) -> list:
        """
        Return the order book delta instruments subscribed to.

        返回订阅的订单簿增量金融工具。

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

    def subscribed_order_book_snapshots(self) -> list:
        """
        Return the order book snapshot instruments subscribed to.

        返回订阅的订单簿快照金融工具。

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

    def subscribed_quote_ticks(self) -> list:
        """
        Return the quote tick instruments subscribed to.

        返回订阅的报价行情金融工具。

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

    def subscribed_trade_ticks(self) -> list:
        """
        Return the trade tick instruments subscribed to.

        返回订阅的交易行情金融工具。

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

    @property
    def trader_id(self):
        """
        The trader ID associated with the component.

        与组件关联的交易者 ID。

        Returns:
            TraderId
        """
        ...

    @property
    def type(self):
        """
        The components type.

        组件类型。

        Returns:
            type
        """
        ...

    @property
    def venue(self):
        """
        The clients venue ID (if applicable).

        客户端的场所 ID(如果适用)。

        Returns:
            Venue or None
        """
        ...

class LiveDataEngine 实时数据引擎

Bases: DataEngine

class LiveDataEngine(DataEngine):
    """
    Provides a high-performance asynchronous live data engine.

    提供高性能异步实时数据引擎。

    Parameters:
    参数:
        loop (asyncio.AbstractEventLoop) – The event loop for the engine.
        loop (asyncio.AbstractEventLoop) - 引擎的事件循环。
        msgbus (MessageBus) – The message bus for the engine.
        msgbus (MessageBus) - 引擎的消息总线。
        cache (Cache) – The cache for the engine.
        cache (Cache) - 引擎的缓存。
        clock (LiveClock) – The clock for the engine.
        clock (LiveClock) - 引擎的时钟。
        config (LiveDataEngineConfig , optional) – The configuration for the instance.
        config (LiveDataEngineConfig,可选) - 实例的配置。

    Raises: TypeError – If config is not of type LiveDataEngineConfig.
    引发:TypeError - 如果 config 的类型不是 LiveDataEngineConfig。
    """
    def __init__(self, loop: asyncio.AbstractEventLoop, msgbus: MessageBus, cache: Cache, clock: LiveClock, config: LiveDataEngineConfig | None = None):
        ...

Properties 属性

    @property
    def command_count(self) -> int:
        """
        The total count of data commands received by the engine.

        引擎接收到的数据命令总数。

        Returns:
            int
        """
        ...

    @property
    def data_count(self) -> int:
        """
        The total count of data stream objects received by the engine.

        引擎接收到的数据流对象总数。

        Returns:
            int
        """
        ...

    @property
    def debug(self):
        """
        If debug mode is active (will provide extra debug logging).

        是否激活调试模式(将提供额外的调试日志)。

        Returns:
            bool
        """
        ...

    @property
    def default_client(self):
        """
        ClientId | None

        Return the default data client registered with the engine.

        返回在引擎中注册的默认数据客户端。

        Return type: ClientId or None
        Type: DataEngine.default_client
        """
        ...
    
    @property
    def id(self) -> ComponentId:
        """
        The components ID.

        组件 ID。

        Returns:
            ComponentId
        """
        ...

    @property
    def is_degraded(self) -> bool:
        """
        bool

        Return whether the current component state is DEGRADED.

        返回当前组件状态是否为 DEGRADED。

        Returns:
            bool
        """
        ...

    @property
    def is_disposed(self) -> bool:
        """
        bool

        Return whether the current component state is DISPOSED.

        返回当前组件状态是否为 DISPOSED。

        Returns:
            bool
        """
        ...

    @property
    def is_faulted(self) -> bool:
        """
        bool

        Return whether the current component state is FAULTED.

        返回当前组件状态是否为 FAULTED。

        Returns:
            bool
        """
        ...

    @property
    def is_initialized(self) -> bool:
        """
        bool

        Return whether the component has been initialized (component.state >= INITIALIZED).

        返回组件是否已初始化 (component.state >= INITIALIZED)。

        Returns:
            bool
        """
        ...

    @property
    def is_running(self) -> bool:
        """
        bool

        Return whether the current component state is RUNNING.

        返回当前组件状态是否为 RUNNING。

        Returns:
            bool
        """
        ...

    @property
    def is_stopped(self) -> bool:
        """
        bool

        Return whether the current component state is STOPPED.

        返回当前组件状态是否为 STOPPED。

        Returns:
            bool
        """
        ...
    
    @property
    def registered_clients(self) -> list[ClientId]:
        """
        list[ClientId]

        Return the execution clients registered with the engine.

        返回在引擎中注册的执行客户端。

        Return type: list[ClientId]
        Type: DataEngine.registered_clients
        """
        ...

    @property
    def request_count(self) -> int:
        """
        The total count of data requests received by the engine.

        引擎接收到的数据请求总数。

        Returns:
            int
        """
        ...
    
    @property
    def reconciliation(self) -> bool:
        """
        Return whether the reconciliation process will be run on start.

        返回是否将在启动时运行对账过程。

        Return type: bool
        """
        ...
    
    @property
    def response_count(self) -> int:
        """
        The total count of data responses received by the engine.

        引擎接收到的数据响应总数。

        Returns:
            int
        """
        ...
    
    @property
    def state(self) -> ComponentState:
        """
        ComponentState

        Return the components current state.

        返回组件的当前状态。

        Return type: ComponentState
        Type: Component.state
        """
        ...

    @property
    def trader_id(self):
        """
        The trader ID associated with the component.

        与组件关联的交易者 ID。

        Returns:
            TraderId
        """
        ...

    @property
    def type(self):
        """
        The components type.

        组件类型。

        Returns:
            type
        """
        ...

Methods 方法

    def connect(self) -> None:
        """
        Connect the engine by calling connect on all registered clients.

        通过在所有注册的客户端上调用 connect 来连接引擎。
        """
        ...

    def disconnect(self) -> None:
        """
        Disconnect the engine by calling disconnect on all registered clients.

        通过在所有注册的客户端上调用 disconnect 来断开引擎连接。
        """
        ...

    def get_cmd_queue_task(self):
        """
        Return the internal command queue task for the engine.

        返回引擎的内部命令队列任务。

        Return type: asyncio.Task or None
        """
        ...

    def get_req_queue_task(self):
        """
        Return the internal request queue task for the engine.

        返回引擎的内部请求队列任务。

        Return type: asyncio.Task or None
        """
        ...

    def get_res_queue_task(self):
        """
        Return the internal response queue task for the engine.

        返回引擎的内部响应队列任务。

        Return type: asyncio.Task or None
        """
        ...

    def get_data_queue_task(self):
        """
        Return the internal data queue task for the engine.

        返回引擎的内部数据队列任务。

        Return type: asyncio.Task or None
        """
        ...

    def cmd_qsize(self) -> int:
        """
        Return the number of DataCommand objects buffered on the internal queue.

        返回内部队列中缓冲的 DataCommand 对象的数量。

        Return type: int
        """
        ...

    def req_qsize(self) -> int:
        """
        Return the number of DataRequest objects buffered on the internal queue.

        返回内部队列中缓冲的 DataRequest 对象的数量。

        Return type: int
        """
        ...

    def res_qsize(self) -> int:
        """
        Return the number of DataResponse objects buffered on the internal queue.

        返回内部队列中缓冲的 DataResponse 对象的数量。

        Return type: int
        """
        ...

    def data_qsize(self) -> int:
        """
        Return the number of Data objects buffered on the internal queue.

        返回内部队列中缓冲的 Data 对象的数量。

        Return type: int
        """
        ...

    def kill(self) -> None:
        """
        Kill the engine by abruptly canceling the queue tasks and calling stop.

        通过突然取消队列任务并调用 stop 来终止引擎。
        """
        ...

    def execute(self, command: DataCommand) -> None:
        """
        Execute the given data command.

        执行给定的数据命令。

        If the internal queue is already full then will log a warning and block until queue size reduces.

        如果内部队列已满,则会记录警告并阻塞,直到队列大小减少。

        Parameters: command (DataCommand) – The command to execute.
        参数:command (DataCommand) - 要执行的命令。

        Warning:
            This method is not thread-safe and should only be called from the same thread the event loop is running on. Calling it from a different thread may lead to unexpected behavior.
            此方法不是线程安全的,只能从事件循环运行的同一线程调用。从不同的线程调用它可能会导致意外行为。
        """
        ...

    def request(self, request: DataRequest) -> None:
        """
        Handle the given request.

        处理给定的请求。

        If the internal queue is already full then will log a warning and block until queue size reduces.

        如果内部队列已满,则会记录警告并阻塞,直到队列大小减少。

        Parameters: request (DataRequest) – The request to handle.
        参数:request (DataRequest) - 要处理的请求。

        Warning:
            This method is not thread-safe and should only be called from the same thread the event loop is running on. Calling it from a different thread may lead to unexpected behavior.
            此方法不是线程安全的,只能从事件循环运行的同一线程调用。从不同的线程调用它可能会导致意外行为。
        """
        ...

    def response(self, response: DataResponse) -> None:
        """
        Handle the given response.

        处理给定的响应。

        If the internal queue is already full then will log a warning and block until queue size reduces.

        如果内部队列已满,则会记录警告并阻塞,直到队列大小减少。

        Parameters: response (DataResponse) – The response to handle.
        参数:response (DataResponse) - 要处理的响应。

        Warning:
            This method is not thread-safe and should only be called from the same thread the event loop is running on. Calling it from a different thread may lead to unexpected behavior.
            此方法不是线程安全的,只能从事件循环运行的同一线程调用。从不同的线程调用它可能会导致意外行为。
        """
        ...

    def process(self, data: Data) -> None:
        """
        Process the given data.

        处理给定的数据。

        If the internal queue is already full then will log a warning and block until queue size reduces.

        如果内部队列已满,则会记录警告并阻塞,直到队列大小减少。

        Parameters: data (Data) – The data to process.
        参数:data (Data) - 要处理的数据。

        Warning:
            This method is not thread-safe and should only be called from the same thread the event loop is running on. Calling it from a different thread may lead to unexpected behavior.
            此方法不是线程安全的,只能从事件循环运行的同一线程调用。从不同的线程调用它可能会导致意外行为。
        """
        ...

    def check_connected(self) -> bool:
        """
        Check all of the engines clients are connected.

        检查引擎的所有客户端是否都已连接。

        Returns: True if all clients connected, else False.
        返回值:如果所有客户端都已连接,则返回 True,否则返回 False。
        Return type: bool
        """
        ...

    def check_disconnected(self) -> bool:
        """
        Check all of the engines clients are disconnected.

        检查引擎的所有客户端是否都已断开连接。

        Returns: True if all clients disconnected, else False.
        返回值:如果所有客户端都已断开连接,则返回 True,否则返回 False。
        Return type: bool
        """
        ...

    def degrade(self) -> void:
        """
        Degrade the component.

        While executing on_degrade() any exception will be logged and reraised, then the component will remain in a DEGRADING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...
    
    def deregister_client(self, client: DataClient) -> void:
        """
        Deregister the given data client from the data engine.

        从数据引擎中取消注册给定的数据客户端。

        Parameters: client (DataClient) – The data client to deregister.
        参数:client (DataClient) - 要取消注册的数据客户端。
        """
        ...
    
    def dispose(self) -> void:
        """
        Dispose of the component.

        While executing on_dispose() any exception will be logged and reraised, then the component will remain in a DISPOSING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...
    
    def fault(self) -> void:
        """
        Fault the component.

        Calling this method multiple times has the same effect as calling it once (it is idempotent). Once called, it cannot be reversed, and no other methods should be called on this instance.

        While executing on_fault() any exception will be logged and reraised, then the component will remain in a FAULTING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    @classmethod
    def fully_qualified_name(cls) -> str:
        """
        Return the fully qualified name for the components class.

        返回组件类的完全限定名称。

        Return type: str
        """
        ...
    
    def register_catalog(self, catalog: ParquetDataCatalog) -> None:
        """
        Register the given data catalog with the engine.

        向引擎注册给定的数据目录。

        Parameters: catalog (ParquetDataCatalog) – The data catalog to register.
        参数:catalog (ParquetDataCatalog) - 要注册的数据目录。
        """
        ...
    
    def register_client(self, client: DataClient) -> void:
        """
        Register the given data client with the data engine.

        向数据引擎注册给定的数据客户端。

        Parameters: client (DataClient) – The client to register.
        参数:client (DataClient) - 要注册的客户端。

        Raises: ValueError – If client is already registered.
        引发:ValueError - 如果客户端已注册。
        """
        ...

    def register_default_client(self, client: DataClient) -> void:
        """
        Register the given client as the default routing client (when a specific venue routing cannot be found).

        注册给定的客户端作为默认路由客户端(当找不到特定的场所路由时)。

        Any existing default routing client will be overwritten.

        任何现有的默认路由客户端都将被覆盖。

        Parameters: client (DataClient) – The client to register.
        参数:client (DataClient) - 要注册的客户端。
        """
        ...

    def register_venue_routing(self, client: DataClient, venue: Venue) -> void:
        """
        Register the given client to route messages to the given venue.

        注册给定的客户端以将消息路由到给定的场所。

        Any existing client in the routing map for the given venue will be overwritten.

        给定场所的路由映射中任何现有的客户端都将被覆盖。

        Parameters:
        参数:
            venue (Venue) – The venue to route messages to.
            venue (Venue) - 要将消息路由到的场所。
            client (DataClient) – The client for the venue routing.
            client (DataClient) - 场所路由的客户端。
        """
        ...

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

        重置组件。

        All stateful fields are reset to their initial value.

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

        While executing on_reset() any exception will be logged and reraised, then the component will remain in a RESETTING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    def resume(self) -> void:
        """
        Resume the component.

        While executing on_resume() any exception will be logged and reraised, then the component will remain in a RESUMING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    def start(self) -> void:
        """
        Start the component.

        While executing on_start() any exception will be logged and reraised, then the component will remain in a STARTING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    @property
    def state(self) -> ComponentState:
        """
        ComponentState

        Return the components current state.

        返回组件的当前状态。

        Return type: ComponentState
        Type: Component.state
        """
        ...

    def stop(self) -> void:
        """
        Stop the component.

        While executing on_stop() any exception will be logged and reraised, then the component will remain in a STOPPING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    def stop_clients(self) -> void:
        """
        Stop the registered clients.

        停止注册的客户端。
        """
        ...

    def subscribed_bars(self) -> list:
        """
        Return the bar types subscribed to.

        返回订阅的 bar 类型。

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

    def subscribed_custom_data(self) -> list:
        """
        Return the custom data types subscribed to.

        返回订阅的自定义数据类型。

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

    def subscribed_instrument_close(self) -> list:
        """
        Return the close price instruments subscribed to.

        返回订阅的收盘价金融工具。

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

    def subscribed_instrument_status(self) -> list:
        """
        Return the status update instruments subscribed to.

        返回订阅的状态更新金融工具。

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

    def subscribed_instruments(self) -> list:
        """
        Return the instruments subscribed to.

        返回订阅的金融工具。

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

    def subscribed_order_book_deltas(self) -> list:
        """
        Return the order book delta instruments subscribed to.

        返回订阅的订单簿增量金融工具。

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

    def subscribed_order_book_snapshots(self) -> list:
        """
        Return the order book snapshot instruments subscribed to.

        返回订阅的订单簿快照金融工具。

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

    def subscribed_quote_ticks(self) -> list:
        """
        Return the quote tick instruments subscribed to.

        返回订阅的报价行情金融工具。

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

    def subscribed_synthetic_quotes(self) -> list:
        """
        Return the synthetic instrument quote ticks subscribed to.

        返回订阅的合成金融工具报价行情。

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

    def subscribed_synthetic_trades(self) -> list:
        """
        Return the synthetic instrument trade ticks subscribed to.

        返回订阅的合成金融工具交易行情。

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

    def subscribed_trade_ticks(self) -> list:
        """
        Return the trade tick instruments subscribed to.

        返回订阅的交易行情金融工具。

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

The LiveExecutionClient class is responsible for interfacing with a particular API which may be presented directly by a venue, or through a broker intermediary.

LiveExecutionClient 类负责与特定 API 交互,该 API 可以由场所直接提供,也可以通过经纪商中介提供。

class LiveExecutionClient 实时执行客户端

Bases: ExecutionClient

class LiveExecutionClient(ExecutionClient):
    """
    The base class for all live execution clients.

    所有实时执行客户端的基类。

    Parameters:
    参数:
        loop (asyncio.AbstractEventLoop) – The event loop for the client.
        loop (asyncio.AbstractEventLoop) - 客户端的事件循环。
        client_id (ClientId) – The client ID.
        client_id (ClientId) - 客户端 ID。
        venue (Venue, optional with no default so None must be passed explicitly) – The client venue. If multi-venue then can be None.
        venue (Venue,可选,没有默认值,因此必须显式传递 None) - 客户端场所。如果是多场所,则可以为 None。
        instrument_provider (InstrumentProvider) – The instrument provider for the client.
        instrument_provider (InstrumentProvider) - 客户端的金融工具提供器。
        account_type (AccountType) – The account type for the client.
        account_type (AccountType) - 客户端的账户类型。
        base_currency (Currency , optional) – The account base currency for the client. Use None for multi-currency accounts.
        base_currency (Currency,可选) - 客户端的账户基础货币。对于多币种账户,请使用 None。
        msgbus (MessageBus) – The message bus for the client.
        msgbus (MessageBus) - 客户端的消息总线。
        cache (Cache) – The cache for the client.
        cache (Cache) - 客户端的缓存。
        clock (LiveClock) – The clock for the client.
        clock (LiveClock) - 客户端的时钟。
        config (NautilusConfig , optional) – The configuration for the instance.
        config (NautilusConfig,可选) - 实例的配置。
    Raises: ValueError – If oms_type is UNSPECIFIED (must be specified).
    引发:ValueError - 如果 oms_type 为 UNSPECIFIED(必须指定)。

    Warning:
        This class should not be used directly, but through a concrete subclass.
        此类不应直接使用,而应通过具体的子类使用。
    """
    def __init__(self, loop: asyncio.AbstractEventLoop, client_id: ClientId, venue: Venue | None, instrument_provider: InstrumentProvider, account_type: AccountType, base_currency: Currency | None, msgbus: MessageBus, cache: Cache, clock: LiveClock, config: NautilusConfig | None = None):
        ...

Properties 属性

    @property
    def account_id(self):
        """
        The clients account ID.

        客户端的账户 ID。

        Returns:
            AccountId or None
        """
        ...
    
    @property
    def account_type(self):
        """
        The clients account type.

        客户端的账户类型。

        Returns:
            AccountType
        """
        ...

    @property
    def base_currency(self):
        """
        The clients account base currency (None for multi-currency accounts).

        客户端的账户基础货币(对于多币种账户为 None)。

        Returns:
            Currency or None
        """
        ...
    
    @property
    def id(self) -> ComponentId:
        """
        The components ID.

        组件 ID。

        Returns:
            ComponentId
        """
        ...

    @property
    def is_connected(self) -> bool:
        """
        If the client is connected.

        如果客户端已连接。

        Returns:
            bool
        """
        ...
    
    @property
    def is_degraded(self) -> bool:
        """
        bool

        Return whether the current component state is DEGRADED.

        返回当前组件状态是否为 DEGRADED。

        Returns:
            bool
        """
        ...

    @property
    def is_disposed(self) -> bool:
        """
        bool

        Return whether the current component state is DISPOSED.

        返回当前组件状态是否为 DISPOSED。

        Returns:
            bool
        """
        ...

    @property
    def is_faulted(self) -> bool:
        """
        bool

        Return whether the current component state is FAULTED.

        返回当前组件状态是否为 FAULTED。

        Returns:
            bool
        """
        ...

    @property
    def is_initialized(self) -> bool:
        """
        bool

        Return whether the component has been initialized (component.state >= INITIALIZED).

        返回组件是否已初始化 (component.state >= INITIALIZED)。

        Returns:
            bool
        """
        ...

    @property
    def is_running(self) -> bool:
        """
        bool

        Return whether the current component state is RUNNING.

        返回当前组件状态是否为 RUNNING。

        Returns:
            bool
        """
        ...

    @property
    def is_stopped(self) -> bool:
        """
        bool

        Return whether the current component state is STOPPED.

        返回当前组件状态是否为 STOPPED。

        Returns:
            bool
        """
        ...

    @property
    def oms_type(self):
        """
        The venues order management system type.

        场所的订单管理系统类型。

        Returns:
            OmsType
        """
        ...

    @property
    def state(self) -> ComponentState:
        """
        ComponentState

        Return the components current state.

        返回组件的当前状态。

        Return type: ComponentState
        Type: Component.state
        """
        ...

    @property
    def trader_id(self):
        """
        The trader ID associated with the component.

        与组件关联的交易者 ID。

        Returns:
            TraderId
        """
        ...

    @property
    def type(self):
        """
        The components type.

        组件类型。

        Returns:
            type
        """
        ...

    @property
    def venue(self):
        """
        The clients venue ID (if not a routing client).

        客户端的场所 ID(如果不是路由客户端)。

        Returns:
            Venue or None
        """
        ...

Methods 方法

    @staticmethod
    async def run_after_delay(delay: float, coro: Coroutine) -> None:
        """
        Run the given coroutine after a delay.

        延迟后运行给定的协程。

        Parameters:
        参数:
            ```python
           delay (float) – The delay (seconds) before running the coroutine.
            delay (float) - 运行协程之前的延迟(以秒为单位)。
            coro (Coroutine) – The coroutine to run after the initial delay.
            coro (Coroutine) - 初始延迟后要运行的协程。
        """
        ...

    def create_task(self, coro: Coroutine, log_msg: str | None = None, actions=None, success_msg: str | None = None, success_color=LogColor.NORMAL):
        """
        Run the given coroutine with error handling and optional callback actions when done.

        运行给定的协程,并在完成后使用错误处理和可选的回调操作。

        Parameters:
        参数:
            coro (Coroutine) – The coroutine to run.
            coro (Coroutine) - 要运行的协程。
            log_msg (str , optional) – The log message for the task.
            log_msg (str,可选) - 任务的日志消息。
            actions (Callable , optional) – The actions callback to run when the coroutine is done.
            actions (Callable,可选) - 协程完成后要运行的操作回调。
            success_msg (str , optional) – The log message to write on actions success.
            success_msg (str,可选) - 操作成功时要写入的日志消息。
            success_color (str, default NORMAL) – The log message color for actions success.
            success_color (str,默认 NORMAL) - 操作成功时要使用的日志消息颜色。

        Return type: asyncio.Task
        """
        ...

    def connect(self) -> None:
        """
        Connect the client.

        连接客户端。
        """
        ...

    def disconnect(self) -> None:
        """
        Disconnect the client.

        断开客户端连接。
        """
        ...

    def submit_order(self, command: SubmitOrder) -> void:
        """
        Submit the order contained in the given command for execution.

        提交给定命令中包含的订单以执行。

        Parameters: command (SubmitOrder) – The command to execute.
        参数:command (SubmitOrder) - 要执行的命令。
        """
        ...

    def submit_order_list(self, command: SubmitOrderList) -> void:
        """
        Submit the order list contained in the given command for execution.

        提交给定命令中包含的订单列表以执行。

        Parameters: command (SubmitOrderList) – The command to execute.
        参数:command (SubmitOrderList) - 要执行的命令。
        """
        ...

    def modify_order(self, command: ModifyOrder) -> void:
        """
        Modify the order with parameters contained in the command.

        使用命令中包含的参数修改订单。

        Parameters: command (ModifyOrder) – The command to execute.
        参数:command (ModifyOrder) - 要执行的命令。
        """
        ...

    def cancel_order(self, command: CancelOrder) -> void:
        """
        Cancel the order with the client order ID contained in the given command.

        使用给定命令中包含的客户端订单 ID 取消订单。

        Parameters: command (CancelOrder) – The command to execute.
        参数:command (CancelOrder) - 要执行的命令。
        """
        ...

    def cancel_all_orders(self, command: CancelAllOrders) -> void:
        """
        Cancel all orders for the instrument ID contained in the given command.

        取消给定命令中包含的金融工具 ID 的所有订单。

        Parameters: command (CancelAllOrders) – The command to execute.
        参数:command (CancelAllOrders) - 要执行的命令。
        """
        ...

    def batch_cancel_orders(self, command: BatchCancelOrders) -> void:
        """
        Batch cancel orders for the instrument ID contained in the given command.

        批量取消给定命令中包含的金融工具 ID 的订单。

        Parameters: command (BatchCancelOrders) – The command to execute.
        参数:command (BatchCancelOrders) - 要执行的命令。
        """
        ...

    def query_order(self, command: QueryOrder) -> void:
        """
        Initiate a reconciliation for the queried order which will generate an OrderStatusReport.

        启动对查询订单的对账,这将生成 OrderStatusReport。

        Parameters: command (QueryOrder) – The command to execute.
        参数:command (QueryOrder) - 要执行的命令。
        """
        ...

    async def generate_order_status_report(self, instrument_id: InstrumentId, client_order_id: ClientOrderId | None = None, venue_order_id: VenueOrderId | None = None):
        """
        Generate an OrderStatusReport for the given order identifier parameter(s).

        为给定的订单标识符参数生成 OrderStatusReport。

        If the order is not found, or an error occurs, then logs and returns None.

        如果未找到订单或发生错误,则记录并返回 None。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The instrument ID for the report.
            instrument_id (InstrumentId) - 报告的金融工具 ID。
            client_order_id (ClientOrderId , optional) – The client order ID for the report.
            client_order_id (ClientOrderId,可选) - 报告的客户端订单 ID。
            venue_order_id (VenueOrderId , optional) – The venue order ID for the report.
            venue_order_id (VenueOrderId,可选) - 报告的场所订单 ID。
        Return type: OrderStatusReport or None
        Raises: ValueError – If both the client_order_id and venue_order_id are None.
        引发:ValueError - 如果 client_order_id 和 venue_order_id 均为 None。
        """
        ...

    async def generate_order_status_reports(self, instrument_id: InstrumentId | None = None, start=None, end=None, open_only: bool = False) -> list:
        """
        Generate a list of `OrderStatusReport`s with optional query filters.

        生成 `OrderStatusReport` 列表,并使用可选的查询过滤器。

        The returned list may be empty if no orders match the given parameters.

        如果没有任何订单与给定的参数匹配,则返回的列表可能为空。

        Parameters:
        参数:
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融工具 ID 查询过滤器。
            start (pd.Timestamp , optional) – The start datetime (UTC) query filter.
            start (pd.Timestamp,可选) - 开始日期时间 (UTC) 查询过滤器。
            end (pd.Timestamp , optional) – The end datetime (UTC) query filter.
            end (pd.Timestamp,可选) - 结束日期时间 (UTC) 查询过滤器。
            open_only (bool , default False) – If the query is for open orders only.
            open_only (bool,默认 False) - 查询是否仅针对未结订单。

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

    async def generate_fill_reports(self, instrument_id: InstrumentId | None = None, venue_order_id: VenueOrderId | None = None, start=None, end=None) -> list:
        """
        Generate a list of `FillReport`s with optional query filters.

        生成 `FillReport` 列表,并使用可选的查询过滤器。

        The returned list may be empty if no trades match the given parameters.

        如果没有任何交易与给定的参数匹配,则返回的列表可能为空。

        Parameters:
        参数:
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融工具 ID 查询过滤器。
            venue_order_id (VenueOrderId , optional) – The venue order ID (assigned by the venue) query filter.
            venue_order_id (VenueOrderId,可选) - 场所订单 ID(由场所分配)查询过滤器。
            start (pd.Timestamp , optional) – The start datetime (UTC) query filter.
            start (pd.Timestamp,可选) - 开始日期时间 (UTC) 查询过滤器。
            end (pd.Timestamp , optional) – The end datetime (UTC) query filter.
            end (pd.Timestamp,可选) - 结束日期时间 (UTC) 查询过滤器。

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

    async def generate_position_status_reports(self, instrument_id: InstrumentId | None = None, start=None, end=None) -> list:
        """
        Generate a list of `PositionStatusReport`s with optional query filters.

        生成 `PositionStatusReport` 列表,并使用可选的查询过滤器。

        The returned list may be empty if no positions match the given parameters.

        如果没有任何持仓与给定的参数匹配,则返回的列表可能为空。

        Parameters:
        参数:
            instrument_id (InstrumentId , optional) – The instrument ID query filter.
            instrument_id (InstrumentId,可选) - 金融工具 ID 查询过滤器。
            start (pd.Timestamp , optional) – The start datetime (UTC) query filter.
            start (pd.Timestamp,可选) - 开始日期时间 (UTC) 查询过滤器。
            end (pd.Timestamp , optional) – The end datetime (UTC) query filter.
            end (pd.Timestamp,可选) - 结束日期时间 (UTC) 查询过滤器。

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

    async def generate_mass_status(self, lookback_mins: int | None = None):
        """
        Generate an ExecutionMassStatus report.

        生成 ExecutionMassStatus 报告。

        Parameters: lookback_mins (int , optional) – The maximum lookback for querying closed orders, trades and positions.
        参数:lookback_mins (int,可选) - 查询已关闭订单、交易和持仓的最大回溯时间。

        Return type: ExecutionMassStatus or None
        """
        ...
    
    def degrade(self) -> void:
        """
        Degrade the component.

        While executing on_degrade() any exception will be logged and reraised, then the component will remain in a DEGRADING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...
    
    def dispose(self) -> void:
        """
        Dispose of the component.

        While executing on_dispose() any exception will be logged and reraised, then the component will remain in a DISPOSING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...
    
    def fault(self) -> void:
        """
        Fault the component.

        Calling this method multiple times has the same effect as calling it once (it is idempotent). Once called, it cannot be reversed, and no other methods should be called on this instance.

        While executing on_fault() any exception will be logged and reraised, then the component will remain in a FAULTING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    @classmethod
    def fully_qualified_name(cls) -> str:
        """
        Return the fully qualified name for the components class.

        返回组件类的完全限定名称。

        Return type: str
        """
        ...

    def generate_account_state(self, balances: list, margins: list, reported: bool, ts_event: int, info: dict = None) -> void:
        """
        Generate an AccountState event and publish on the message bus.

        生成 AccountState 事件并在消息总线上发布。

        Parameters:
        参数:
            balances (list [AccountBalance ]) – The account balances.
            balances (list [AccountBalance ]) - 账户余额。
            margins (list [MarginBalance ]) – The margin balances.
            margins (list [MarginBalance ]) - 保证金余额。
            reported (bool) – If the balances are reported directly from the exchange.
            reported (bool) - 余额是否直接从交易所报告。
            ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the account state event occurred.
            ts_event (uint64_t) - 账户状态事件发生的 UNIX 时间戳(纳秒)。
            info (dict *[*str , object ]) – The additional implementation specific account information.
            info (dict *[*str,object]) - 额外的特定于实现的账户信息。
        """
        ...

    def generate_order_accepted(self, strategy_id: StrategyId, instrument_id: InstrumentId, client_order_id: ClientOrderId, venue_order_id: VenueOrderId, ts_event: int) -> void:
        """
        Generate an OrderAccepted event and send it to the ExecutionEngine.

        生成 OrderAccepted 事件并将其发送到 ExecutionEngine。

        Parameters:
        参数:
            strategy_id (StrategyId) – The strategy ID associated with the event.
            strategy_id (StrategyId) - 与事件关联的策略 ID。
            instrument_id (InstrumentId) – The instrument ID.
            instrument_id (InstrumentId) - 金融工具 ID。
            client_order_id (ClientOrderId) – The client order ID.
            client_order_id (ClientOrderId) - 客户端订单 ID。
            venue_order_id (VenueOrderId) – The venue order ID (assigned by the venue).
            venue_order_id (VenueOrderId) - 场所订单 ID(由场所分配)。
            ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order accepted event occurred.
            ts_event (uint64_t) - 订单接受事件发生的 UNIX 时间戳(纳秒)。
        """
        ...

    def generate_order_cancel_rejected(self, strategy_id: StrategyId, instrument_id: InstrumentId, client_order_id: ClientOrderId, venue_order_id: VenueOrderId, reason: str, ts_event: int) -> void:
        """
        Generate an OrderCancelRejected event and send it to the ExecutionEngine.

        生成 OrderCancelRejected 事件并将其发送到 ExecutionEngine。

        Parameters:
        参数:
            strategy_id (StrategyId) – The strategy ID associated with the event.
            strategy_id (StrategyId) - 与事件关联的策略 ID。
            instrument_id (InstrumentId) – The instrument ID.
            instrument_id (InstrumentId) - 金融工具 ID。
            client_order_id (ClientOrderId) – The client order ID.
            client_order_id (ClientOrderId) - 客户端订单 ID。
            venue_order_id (VenueOrderId) – The venue order ID (assigned by the venue).
            venue_order_id (VenueOrderId) - 场所订单 ID(由场所分配)。
            reason (str) – The order cancel rejected reason.
            reason (str) - 订单取消被拒绝的原因。
            ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order cancel rejected event occurred.
            ts_event (uint64_t) - 订单取消被拒绝事件发生的 UNIX 时间戳(纳秒)。
        """
        ...

    def generate_order_canceled(self, strategy_id: StrategyId, instrument_id: InstrumentId, client_order_id: ClientOrderId, venue_order_id: VenueOrderId, ts_event: int) -> void:
        """
        Generate an OrderCanceled event and send it to the ExecutionEngine.

        生成 OrderCanceled 事件并将其发送到 ExecutionEngine。

        Parameters:
        参数:
            strategy_id (StrategyId) – The strategy ID associated with the event.
            strategy_id (StrategyId) - 与事件关联的策略 ID。
            instrument_id (InstrumentId) – The instrument ID.
            instrument_id (InstrumentId) - 金融工具 ID。
            client_order_id (ClientOrderId) – The client order ID.
            client_order_id (ClientOrderId) - 客户端订单 ID。
            venue_order_id (VenueOrderId) – The venue order ID (assigned by the venue).
            venue_order_id (VenueOrderId) - 场所订单 ID(由场所分配)。
            ts_event (uint64_t) – UNIX timestamp (nanoseconds) when order canceled event occurred.
            ts_event (uint64_t) - 订单取消事件发生的 UNIX 时间戳(纳秒)。
        """
        ...

    def generate_order_expired(self, strategy_id: StrategyId, instrument_id: InstrumentId, client_order_id: ClientOrderId, venue_order_id: VenueOrderId, ts_event: int) -> void:
        """
        Generate an OrderExpired event and send it to the ExecutionEngine.

        生成 OrderExpired 事件并将其发送到 ExecutionEngine。

        Parameters:
        参数:
            strategy_id (StrategyId) – The strategy ID associated with the event.
            strategy_id (StrategyId) - 与事件关联的策略 ID。
            instrument_id (InstrumentId) – The instrument ID.
            instrument_id (InstrumentId) - 金融工具 ID。
            client_order_id (ClientOrderId) – The client order ID.
            client_order_id (ClientOrderId) - 客户端订单 ID。
            venue_order_id (VenueOrderId) – The venue order ID (assigned by the venue).
            venue_order_id (VenueOrderId) - 场所订单 ID(由场所分配)。
            ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order expired event occurred.
            ts_event (uint64_t) - 订单到期事件发生的 UNIX 时间戳(纳秒)。
        """
        ...

    def generate_order_filled(self, strategy_id: StrategyId, instrument_id: InstrumentId, client_order_id: ClientOrderId, venue_order_id: VenueOrderId, venue_position_id: PositionId | None, trade_id: TradeId, order_side: OrderSide, order_type: OrderType, last_qty: Quantity, last_px: Price, quote_currency: Currency, commission: Money, liquidity_side: LiquiditySide, ts_event: int) -> void:
        """
        Generate an OrderFilled event and send it to the ExecutionEngine.

        生成 OrderFilled 事件并将其发送到 ExecutionEngine。

        Parameters:
        参数:
            strategy_id (StrategyId) – The strategy ID associated with the event.
            strategy_id (StrategyId) - 与事件关联的策略 ID。
            instrument_id (InstrumentId) – The instrument ID.
            instrument_id (InstrumentId) - 金融工具 ID。
            client_order_id (ClientOrderId) – The client order ID.
            client_order_id (ClientOrderId) - 客户端订单 ID。
            venue_order_id (VenueOrderId) – The venue order ID (assigned by the venue).
            venue_order_id (VenueOrderId) - 场所订单 ID(由场所分配)。
            trade_id (TradeId) – The trade ID.
            trade_id (TradeId) - 交易 ID。
            venue_position_id (PositionId, optional with no default so None must be passed explicitly) – The venue position ID associated with the order. If the trading venue has assigned a position ID / ticket then pass that here, otherwise pass None and the execution engine OMS will handle position ID resolution.
            venue_position_id (PositionId,可选,没有默认值,因此必须显式传递 None) - 与订单关联的场所持仓 ID。如果交易场所已分配持仓 ID / 票据,则在此处传递该 ID,否则传递 None,执行引擎 OMS 将处理持仓 ID 解析。
            order_side (OrderSide {BUY, SELL}) – The execution order side.
            order_side (OrderSide {BUY, SELL}) - 执行订单方向。
            order_type (OrderType) – The execution order type.
            order_type (OrderType) - 执行订单类型。
            last_qty (Quantity) – The fill quantity for this execution.
            last_qty (Quantity) - 此执行的成交数量。
            last_px (Price) – The fill price for this execution (not average price).
            last_px (Price) - 此执行的成交价格(非平均价格)。
            quote_currency (Currency) – The currency of the price.
            quote_currency (Currency) - 价格的货币。
            commission (Money) – The fill commission.
            commission (Money) - 成交佣金。
            liquidity_side (LiquiditySide {NO_LIQUIDITY_SIDE, MAKER, TAKER}) – The execution liquidity side.
            liquidity_side (LiquiditySide {NO_LIQUIDITY_SIDE, MAKER, TAKER}) - 执行流动性方向。
            ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order filled event occurred.
            ts_event (uint64_t) - 订单成交事件发生的 UNIX 时间戳(纳秒)。
        """
        ...

    def generate_order_modify_rejected(self, strategy_id: StrategyId, instrument_id: InstrumentId, client_order_id: ClientOrderId, venue_order_id: VenueOrderId, reason: str, ts_event: int) -> void:
        """
        Generate an OrderModifyRejected event and send it to the ExecutionEngine.

        生成 OrderModifyRejected 事件并将其发送到 ExecutionEngine。

        Parameters:
        参数:
            strategy_id (StrategyId) – The strategy ID associated with the event.
            strategy_id (StrategyId) - 与事件关联的策略 ID。
            instrument_id (InstrumentId) – The instrument ID.
            instrument_id (InstrumentId) - 金融工具 ID。
            client_order_id (ClientOrderId) – The client order ID.
            client_order_id (ClientOrderId) - 客户端订单 ID。
            venue_order_id (VenueOrderId) – The venue order ID (assigned by the venue).
            venue_order_id (VenueOrderId) - 场所订单 ID(由场所分配)。
            reason (str) – The order update rejected reason.
            reason (str) - 订单更新被拒绝的原因。
            ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order update rejection event occurred.
            ts_event (uint64_t) - 订单更新拒绝事件发生的 UNIX 时间戳(纳秒)。
        """
        ...

    def generate_order_rejected(self, strategy_id: StrategyId, instrument_id: InstrumentId, client_order_id: ClientOrderId, reason: datetime, ts_event: int) -> void:
        """
        Generate an OrderRejected event and send it to the ExecutionEngine.

        生成 OrderRejected 事件并将其发送到 ExecutionEngine。

        Parameters:
        参数:
            strategy_id (StrategyId) – The strategy ID associated with the event.
            strategy_id (StrategyId) - 与事件关联的策略 ID。
            instrument_id (InstrumentId) – The instrument ID.
            instrument_id (InstrumentId) - 金融工具 ID。
            client_order_id (ClientOrderId) – The client order ID.
            client_order_id (ClientOrderId) - 客户端订单 ID。
            reason (datetime) – The order rejected reason.
            reason (datetime) - 订单被拒绝的原因。
            ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order rejected event occurred.
            ts_event (uint64_t) - 订单被拒绝事件发生的 UNIX 时间戳(纳秒)。
        """
        ...

    def generate_order_submitted(self, strategy_id: StrategyId, instrument_id: InstrumentId, client_order_id: ClientOrderId, ts_event: int) -> void:
        """
        Generate an OrderSubmitted event and send it to the ExecutionEngine.

        生成 OrderSubmitted 事件并将其发送到 ExecutionEngine。

        Parameters:
        参数:
            strategy_id (StrategyId) – The strategy ID associated with the event.
            strategy_id (StrategyId) - 与事件关联的策略 ID。
            instrument_id (InstrumentId) – The instrument ID.
            instrument_id (InstrumentId) - 金融工具 ID。
            client_order_id (ClientOrderId) – The client order ID.
            client_order_id (ClientOrderId) - 客户端订单 ID。
            ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order submitted event occurred.
            ts_event (uint64_t) - 订单提交事件发生的 UNIX 时间戳(纳秒)。
        """
        ...

    def generate_order_triggered(self, strategy_id: StrategyId, instrument_id: InstrumentId, client_order_id: ClientOrderId, venue_order_id: VenueOrderId, ts_event: int) -> void:
        """
        Generate an OrderTriggered event and send it to the ExecutionEngine.

        生成 OrderTriggered 事件并将其发送到 ExecutionEngine。

        Parameters:
        参数:
            strategy_id (StrategyId) – The strategy ID associated with the event.
            strategy_id (StrategyId) - 与事件关联的策略 ID。
            instrument_id (InstrumentId) – The instrument ID.
            instrument_id (InstrumentId) - 金融工具 ID。
            client_order_id (ClientOrderId) – The client order ID.
            client_order_id (ClientOrderId) - 客户端订单 ID。
            venue_order_id (VenueOrderId) – The venue order ID (assigned by the venue).
            venue_order_id (VenueOrderId) - 场所订单 ID(由场所分配)。
            ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order triggered event occurred.
            ts_event (uint64_t) - 订单触发事件发生的 UNIX 时间戳(纳秒)。
        """
        ...

    def generate_order_updated(self, strategy_id: StrategyId, instrument_id: InstrumentId, client_order_id: ClientOrderId, venue_order_id: VenueOrderId, quantity: Quantity, price: Price, trigger_price: Price, ts_event: int, venue_order_id_modified: bool=False) -> void:
        """
        Generate an OrderUpdated event and send it to the ExecutionEngine.

        生成 OrderUpdated 事件并将其发送到 ExecutionEngine。

        Parameters:
        参数:
            strategy_id (StrategyId) – The strategy ID associated with the event.
            strategy_id (StrategyId) - 与事件关联的策略 ID。
            instrument_id (InstrumentId) – The instrument ID.
            instrument_id (InstrumentId) - 金融工具 ID。
            client_order_id (ClientOrderId) – The client order ID.
            client_order_id (ClientOrderId) - 客户端订单 ID。
            venue_order_id (VenueOrderId) – The venue order ID (assigned by the venue).
            venue_order_id (VenueOrderId) - 场所订单 ID(由场所分配)。
            quantity (Quantity) – The orders current quantity.
            quantity (Quantity) - 订单的当前数量。
            price (Price) – The orders current price.
            price (Price) - 订单的当前价格。
            trigger_price (Price, optional with no default so None must be passed explicitly) – The orders current trigger price.
            trigger_price (Price,可选,没有默认值,因此必须显式传递 None) - 订单的当前触发价格。
            ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order update event occurred.
            ts_event (uint64_t) - 订单更新事件发生的 UNIX 时间戳(纳秒)。
            venue_order_id_modified (bool) – If the ID was modified for this event.
            venue_order_id_modified (bool) - 此事件的 ID 是否已修改。
        """
        ...

    def get_account(self):
        """
        Return the account for the client (if registered).

        返回客户端的账户(如果已注册)。

        Return type: Account or None
        """
        ...
    
    def reset(self) -> void:
        """
        Reset the component.

        重置组件。

        All stateful fields are reset to their initial value.

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

        While executing on_reset() any exception will be logged and reraised, then the component will remain in a RESETTING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    def resume(self) -> void:
        """
        Resume the component.

        While executing on_resume() any exception will be logged and reraised, then the component will remain in a RESUMING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    def start(self) -> void:
        """
        Start the component.

        While executing on_start() any exception will be logged and reraised, then the component will remain in a STARTING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    @property
    def state(self) -> ComponentState:
        """
        ComponentState

        Return the components current state.

        返回组件的当前状态。

        Return type: ComponentState
        Type: Component.state
        """
        ...

    def stop(self) -> void:
        """
        Stop the component.

        While executing on_stop() any exception will be logged and reraised, then the component will remain in a STOPPING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

class LiveExecutionEngine 实时执行引擎

Bases: ExecutionEngine

class LiveExecutionEngine(ExecutionEngine):
    """
    Provides a high-performance asynchronous live execution engine.

    提供高性能异步实时执行引擎。

    Parameters:
    参数:
        loop (asyncio.AbstractEventLoop) – The event loop for the engine.
        loop (asyncio.AbstractEventLoop) - 引擎的事件循环。
        msgbus (MessageBus) – The message bus for the engine.
        msgbus (MessageBus) - 引擎的消息总线。
        cache (Cache) – The cache for the engine.
        cache (Cache) - 引擎的缓存。
        clock (LiveClock) – The clock for the engine.
        clock (LiveClock) - 引擎的时钟。
        config (LiveExecEngineConfig , optional) – The configuration for the instance.
        config (LiveExecEngineConfig,可选) - 实例的配置。
    Raises: TypeError – If config is not of type LiveExecEngineConfig.
    引发:TypeError - 如果 config 的类型不是 LiveExecEngineConfig。
    """
    def __init__(self, loop: asyncio.AbstractEventLoop, msgbus: MessageBus, cache: Cache, clock: LiveClock, config: LiveExecEngineConfig | None = None):
        ...

Properties 属性

    @property
    def command_count(self) -> int:
        """
        The total count of commands received by the engine.

        引擎接收到的命令总数。

        Returns:
            int
        """
        ...

    @property
    def debug(self):
        """
        If debug mode is active (will provide extra debug logging).

        是否激活调试模式(将提供额外的调试日志)。

        Returns:
            bool
        """
        ...

    @property
    def default_client(self):
        """
        ClientId | None

        Return the default execution client registered with the engine.

        返回在引擎中注册的默认执行客户端。

        Return type: ClientId or None
        Type: ExecutionEngine.default_client
        """
        ...
    
    @property
    def event_count(self) -> int:
        """
        The total count of events received by the engine.

        引擎接收到的事件总数。

        Returns:
            int
        """
        ...

    @property
    def id(self) -> ComponentId:
        """
        The components ID.

        组件 ID。

        Returns:
            ComponentId
        """
        ...

    @property
    def is_degraded(self) -> bool:
        """
        bool

        Return whether the current component state is DEGRADED.

        返回当前组件状态是否为 DEGRADED。

        Returns:
            bool
        """
        ...

    @property
    def is_disposed(self) -> bool:
        """
        bool

        Return whether the current component state is DISPOSED.

        返回当前组件状态是否为 DISPOSED。

        Returns:
            bool
        """
        ...

    @property
    def is_faulted(self) -> bool:
        """
        bool

        Return whether the current component state is FAULTED.

        返回当前组件状态是否为 FAULTED。

        Returns:
            bool
        """
        ...

    @property
    def is_initialized(self) -> bool:
        """
        bool

        Return whether the component has been initialized (component.state >= INITIALIZED).

        返回组件是否已初始化 (component.state >= INITIALIZED)。

        Returns:
            bool
        """
        ...

    @property
    def is_running(self) -> bool:
        """
        bool

        Return whether the current component state is RUNNING.

        返回当前组件状态是否为 RUNNING。

        Returns:
            bool
        """
        ...

    @property
    def is_stopped(self) -> bool:
        """
        bool

        Return whether the current component state is STOPPED.

        返回当前组件状态是否为 STOPPED。

        Returns:
            bool
        """
        ...

    @property
    def reconciliation(self) -> bool:
        """
        Return whether the reconciliation process will be run on start.

        返回是否将在启动时运行对账过程。

        Return type: bool
        """
        ...

    ```python
   @property
    def report_count(self):
        """
        ‘int’ The total count of reports received by the engine.

        'int' 引擎接收到的报告总数。

        Returns:
            int

        Type:
            report_count
        """
        ...
    
    @property
    def registered_clients(self) -> list[ClientId]:
        """
        list[ClientId]

        Return the execution clients registered with the engine.

        返回在引擎中注册的执行客户端。

        Return type: list[ClientId]
        Type: DataEngine.registered_clients
        """
        ...
    
    @property
    def snapshot_orders(self):
        """
        If order state snapshots should be persisted.

        是否应持久化订单状态快照。

        Returns:
            bool
        """
        ...
    
    @property
    def snapshot_positions(self):
        """
        If position state snapshots should be persisted.

        是否应持久化持仓状态快照。

        Returns:
            bool
        """
        ...
    
    @property
    def snapshot_positions_interval_secs(self):
        """
        The interval (seconds) at which additional position state snapshots are persisted.

        持久化额外的持仓状态快照的时间间隔(以秒为单位)。

        Returns:
            double
        """
        ...
    
    @property
    def snapshot_positions_timer_name(self):
        """
        """
        ...
    
    @property
    def state(self) -> ComponentState:
        """
        ComponentState

        Return the components current state.

        返回组件的当前状态。

        Return type: ComponentState
        Type: Component.state
        """
        ...

    @property
    def trader_id(self):
        """
        The trader ID associated with the component.

        与组件关联的交易者 ID。

        Returns:
            TraderId
        """
        ...

    @property
    def type(self):
        """
        The components type.

        组件类型。

        Returns:
            type
        """
        ...

Methods 方法

    def connect(self) -> None:
        """
        Connect the engine by calling connect on all registered clients.

        通过在所有注册的客户端上调用 connect 来连接引擎。
        """
        ...

    def disconnect(self) -> None:
        """
        Disconnect the engine by calling disconnect on all registered clients.

        通过在所有注册的客户端上调用 disconnect 来断开引擎连接。
        """
        ...

    def get_cmd_queue_task(self):
        """
        Return the internal command queue task for the engine.

        返回引擎的内部命令队列任务。

        Return type: asyncio.Task or None
        """
        ...

    def get_evt_queue_task(self):
        """
        Return the internal event queue task for the engine.

        返回引擎的内部事件队列任务。

        Return type: asyncio.Task or None
        """
        ...

    def get_inflight_check_task(self):
        """
        Return the internal in-flight check task for the engine.

        返回引擎的内部进行中检查任务。

        Return type: asyncio.Task or None
        """
        ...

    def cmd_qsize(self) -> int:
        """
        Return the number of Command messages buffered on the internal queue.

        返回内部队列中缓冲的 Command 消息的数量。

        Return type: int
        """
        ...

    def evt_qsize(self) -> int:
        """
        Return the number of Event messages buffered on the internal queue.

        返回内部队列中缓冲的 Event 消息的数量。

        Return type: int
        """
        ...

    def kill(self) -> None:
        """
        Kill the engine by abruptly canceling the queue task and calling stop.

        通过突然取消队列任务并调用 stop 来终止引擎。
        """
        ...

    def execute(self, command: TradingCommand) -> None:
        """
        Execute the given command.

        执行给定的命令。

        If the internal queue is already full then will log a warning and block until queue size reduces.

        如果内部队列已满,则会记录警告并阻塞,直到队列大小减少。

        Parameters: command (TradingCommand) – The command to execute.
        参数:command (TradingCommand) - 要执行的命令。

        Warning:
            This method is not thread-safe and should only be called from the same thread the event loop is running on. Calling it from a different thread may lead to unexpected behavior.
            此方法不是线程安全的,只能从事件循环运行的同一线程调用。从不同的线程调用它可能会导致意外行为。
        """
        ...

    def process(self, event: OrderEvent) -> None:
        """
        Process the given event.

        处理给定的事件。

        If the internal queue is already full then will log a warning and block until queue size reduces.

        如果内部队列已满,则会记录警告并阻塞,直到队列大小减少。

        Parameters: event (OrderEvent) – The event to process.
        参数:event (OrderEvent) - 要处理的事件。

        Warning:
            This method is not thread-safe and should only be called from the same thread the event loop is running on. Calling it from a different thread may lead to unexpected behavior.
            此方法不是线程安全的,只能从事件循环运行的同一线程调用。从不同的线程调用它可能会导致意外行为。
        """
        ...

    async def reconcile_state(self, timeout_secs: float = 10.0) -> bool:
        """
        Reconcile the internal execution state with all execution clients (external state).

        将内部执行状态与所有执行客户端(外部状态)对账。

        Parameters: timeout_secs (double , default 10.0) – The timeout (seconds) for reconciliation to complete.
        参数:timeout_secs (double,默认 10.0) - 对账完成的超时时间(以秒为单位)。

        Returns: True if states reconcile within timeout, else False.
        返回值:如果状态在超时时间内对账,则返回 True,否则返回 False。
        Return type: bool

        Raises: ValueError – If timeout_secs is not positive (> 0).
        引发:ValueError - 如果 timeout_secs 不是正数 (> 0)。
        """
        ...

    def reconcile_report(self, report: ExecutionReport) -> bool:
        """
        Reconcile the given execution report.

        对账给定的执行报告。

        Parameters: report (ExecutionReport) – The execution report to check.
        参数:report (ExecutionReport) - 要检查的执行报告。

        Returns: True if reconciliation successful, else False.
        返回值:如果对账成功,则返回 True,否则返回 False。
        Return type: bool
        """
        ...

    def reconcile_mass_status(self, report: ExecutionMassStatus) -> None:
        """
        Reconcile the given execution mass status report.

        对账给定的执行批量状态报告。

        Parameters: report (ExecutionMassStatus) – The execution mass status report to reconcile.
        参数:report (ExecutionMassStatus) - 要对账的执行批量状态报告。
        """
        ...

    def check_connected(self) -> bool:
        """
        Check all of the engines clients are connected.

        检查引擎的所有客户端是否都已连接。

        Returns: True if all clients connected, else False.
        返回值:如果所有客户端都已连接,则返回 True,否则返回 False。
        Return type: bool
        """
        ...

    def check_disconnected(self) -> bool:
        """
        Check all of the engines clients are disconnected.

        检查引擎的所有客户端是否都已断开连接。

        Returns: True if all clients disconnected, else False.
        返回值:如果所有客户端都已断开连接,则返回 True,否则返回 False。
        Return type: bool
        """
        ...

    def check_integrity(self) -> bool:
        """
        Check integrity of data within the cache and clients.

        检查缓存和客户端中数据的完整性。

        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 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 degrade(self) -> void:
        """
        Degrade the component.

        While executing on_degrade() any exception will be logged and reraised, then the component will remain in a DEGRADING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...
    
    def deregister_client(self, client: ExecutionClient) -> void:
        """
        Deregister the given execution client from the execution engine.

        从执行引擎中取消注册给定的执行客户端。

        Parameters: client (ExecutionClient) – The execution client to deregister.
        参数:client (ExecutionClient) - 要取消注册的执行客户端。
        Raises: ValueError – If client is not registered with the execution engine.
        引发:ValueError - 如果客户端未在执行引擎中注册。
        """
        ...
    
    def dispose(self) -> void:
        """
        Dispose of the component.

        While executing on_dispose() any exception will be logged and reraised, then the component will remain in a DISPOSING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...
    
    def fault(self) -> void:
        """
        Fault the component.

        Calling this method multiple times has the same effect as calling it once (it is idempotent). Once called, it cannot be reversed, and no other methods should be called on this instance.

        While executing on_fault() any exception will be logged and reraised, then the component will remain in a FAULTING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

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

        刷新执行数据库,永久删除所有持久化数据。

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

    @classmethod
    def fully_qualified_name(cls) -> str:
        """
        Return the fully qualified name for the components class.

        返回组件类的完全限定名称。

        Return type: str
        """
        ...

    def get_external_order_claim(self, instrument_id: InstrumentId):
        """
        Get any external order claim for the given instrument ID.

        获取给定金融工具 ID 的任何外部订单声明。

        Parameters: instrument_id (InstrumentId) – The instrument ID for the claim.
        参数:instrument_id (InstrumentId) - 声明的金融工具 ID。

        Return type: StrategyId or None
        """
        ...

    def get_external_order_claims_instruments(self) -> set:
        """
        Get all external order claims instrument IDs.

        获取所有外部订单声明的金融工具 ID。

        Return type: set[InstrumentId]
        """
        ...
    
    def load_cache(self) -> void:
        """
        Load the cache up from the execution database.

        从执行数据库加载缓存。
        """
        ...

    def position_id_count(self, strategy_id: StrategyId) -> int:
        """
        The position ID count for the given strategy ID.

        给定策略 ID 的持仓 ID 计数。

        Parameters: strategy_id (StrategyId) – The strategy ID for the position count.
        参数:strategy_id (StrategyId) - 持仓计数的策略 ID。
        Return type: int
        """
        ...
    
    def register_client(self, client: ExecutionClient) -> void:
        """
        Register the given execution client with the execution engine.

        向执行引擎注册给定的执行客户端。

        If the client.venue is None and a default routing client has not been previously registered then will be registered as such.

        如果 client.venue 为 None 并且之前没有注册默认路由客户端,则将注册为默认路由客户端。

        Parameters: client (ExecutionClient) – The execution client to register.
        参数:client (ExecutionClient) - 要注册的执行客户端。
        Raises: ValueError – If client is already registered with the execution engine.
        引发:ValueError - 如果客户端已在执行引擎中注册。
        """
        ...

    def register_default_client(self, client: ExecutionClient) -> void:
        """
        Register the given client as the default routing client (when a specific venue routing cannot be found).

        注册给定的客户端作为默认路由客户端(当找不到特定的场所路由时)。

        Any existing default routing client will be overwritten.

        任何现有的默认路由客户端都将被覆盖。

        Parameters: client (ExecutionClient) – The client to register.
        参数:client (ExecutionClient) - 要注册的客户端。
        """
        ...

    def register_external_order_claims(self, strategy: Strategy) -> void:
        """
        Register the given strategies external order claim instrument IDs (if any)

        注册给定策略的外部订单声明金融工具 ID(如果有)。

        Parameters: strategy (Strategy) – The strategy for the registration.
        参数:strategy (Strategy) - 注册的策略。
        Raises: InvalidConfiguration – If a strategy is already registered to claim external orders for an instrument ID.
        引发:InvalidConfiguration - 如果策略已注册以声明金融工具 ID 的外部订单。
        """
        ...

    def register_oms_type(self, strategy: Strategy) -> void:
        """
        Register the given trading strategies OMS (Order Management System) type.

        注册给定的交易策略 OMS(订单管理系统)类型。

        Parameters: strategy (Strategy) – The strategy for the registration.
        参数:strategy (Strategy) - 注册的策略。
        """
        ...

    def register_venue_routing(self, client: ExecutionClient, venue: Venue) -> void:
        """
        Register the given client to route orders to the given venue.

        注册给定的客户端以将订单路由到给定的场所。

        Any existing client in the routing map for the given venue will be overwritten.

        给定场所的路由映射中任何现有的客户端都将被覆盖。

        Parameters:
        参数:
            venue (Venue) – The venue to route orders to.
            venue (Venue) - 要将订单路由到的场所。
            client (ExecutionClient) – The client for the venue routing.
            client (ExecutionClient) - 场所路由的客户端。
        """
        ...

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

        重置组件。

        All stateful fields are reset to their initial value.

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

        While executing on_reset() any exception will be logged and reraised, then the component will remain in a RESETTING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    def resume(self) -> void:
        """
        Resume the component.

        While executing on_resume() any exception will be logged and reraised, then the component will remain in a RESUMING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    def start(self) -> void:
        """
        Start the component.

        While executing on_start() any exception will be logged and reraised, then the component will remain in a STARTING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    @property
    def state(self) -> ComponentState:
        """
        ComponentState

        Return the components current state.

        返回组件的当前状态。

        Return type: ComponentState
        Type: Component.state
        """
        ...

    def stop(self) -> void:
        """
        Stop the component.

        While executing on_stop() any exception will be logged and reraised, then the component will remain in a STOPPING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    def stop_clients(self) -> void:
        """
        Stop the registered clients.

        停止注册的客户端。
        """
        ...

class LiveRiskEngine 实时风险引擎

Bases: RiskEngine

class LiveRiskEngine(RiskEngine):
    """
    Provides a high-performance asynchronous live risk engine.

    提供高性能异步实时风险引擎。

    Parameters:
    参数:
        loop (asyncio.AbstractEventLoop) – The event loop for the engine.
        loop (asyncio.AbstractEventLoop) - 引擎的事件循环。
        portfolio (PortfolioFacade) – The portfolio for the engine.
        portfolio (PortfolioFacade) - 引擎的投资组合。
        msgbus (MessageBus) – The message bus for the engine.
        msgbus (MessageBus) - 引擎的消息总线。
        cache (CacheFacade) – The read-only cache for the engine.
        cache (CacheFacade) - 引擎的只读缓存。
        clock (LiveClock) – The clock for the engine.
        clock (LiveClock) - 引擎的时钟。
        config (LiveRiskEngineConfig) – The configuration for the instance.
        config (LiveRiskEngineConfig) - 实例的配置。

    Raises: TypeError – If config is not of type LiveRiskEngineConfig.
    引发:TypeError - 如果 config 的类型不是 LiveRiskEngineConfig。
    """
    def __init__(self, loop: asyncio.AbstractEventLoop, portfolio: PortfolioFacade, msgbus: MessageBus, cache: CacheFacade, clock: LiveClock, config: LiveRiskEngineConfig):
        ...

Properties 属性

    @property
    def command_count(self) -> int:
        """
        The total count of commands received by the engine.

        引擎接收到的命令总数。

        Returns:
            int
        """
        ...

    @property
    def debug(self):
        """
        If debug mode is active (will provide extra debug logging).

        是否激活调试模式(将提供额外的调试日志)。

        Returns:
            bool
        """
        ...

    @property
    def event_count(self) -> int:
        """
        The total count of events received by the engine.

        引擎接收到的事件总数。

        Returns:
            int
        """
        ...
    
    @property
    def id(self) -> ComponentId:
        """
        The components ID.

        组件 ID。

        Returns:
            ComponentId
        """
        ...

    @property
    def is_bypassed(self):
        """
        If the risk engine is completely bypassed.

        风险引擎是否完全绕过。

        Returns:
            bool
        """
        ...

    @property
    def is_degraded(self) -> bool:
        """
        bool

        Return whether the current component state is DEGRADED.

        返回当前组件状态是否为 DEGRADED。

        Returns:
            bool
        """
        ...

    @property
    def is_disposed(self) -> bool:
        """
        bool

        Return whether the current component state is DISPOSED.

        返回当前组件状态是否为 DISPOSED。

        Returns:
            bool
        """
        ...

    @property
    def is_faulted(self) -> bool:
        """
        bool

        Return whether the current component state is FAULTED.

        返回当前组件状态是否为 FAULTED。

        Returns:
            bool
        """
        ...

    @property
    def is_initialized(self) -> bool:
        """
        bool

        Return whether the component has been initialized (component.state >= INITIALIZED).

        返回组件是否已初始化 (component.state >= INITIALIZED)。

        Returns:
            bool
        """
        ...

    @property
    def is_running(self) -> bool:
        """
        bool

        Return whether the current component state is RUNNING.

        返回当前组件状态是否为 RUNNING。

        Returns:
            bool
        """
        ...

    @property
    def is_stopped(self) -> bool:
        """
        bool

        Return whether the current component state is STOPPED.

        返回当前组件状态是否为 STOPPED。

        Returns:
            bool
        """
        ...

    @property
    def state(self) -> ComponentState:
        """
        ComponentState

        Return the components current state.

        返回组件的当前状态。

        Return type: ComponentState
        Type: Component.state
        """
        ...

    @property
    def trader_id(self):
        """
        The trader ID associated with the component.

        与组件关联的交易者 ID。

        Returns:
            TraderId
        """
        ...
    
    @property
    def trading_state(self):
        """
        The current trading state for the engine.

        引擎的当前交易状态。

        Returns:
            TradingState
        """
        ...

    @property
    def type(self):
        """
        The components type.

        组件类型。

        Returns:
            type
        """
        ...

Methods 方法

    def get_cmd_queue_task(self):
        """
        Return the internal command queue task for the engine.

        返回引擎的内部命令队列任务。

        Return type: asyncio.Task or None
        """
        ...

    def get_evt_queue_task(self):
        """
        Return the internal event queue task for the engine.

        返回引擎的内部事件队列任务。

        Return type: asyncio.Task or None
        """
        ...

    def cmd_qsize(self) -> int:
        """
        Return the number of Command messages buffered on the internal queue.

        返回内部队列中缓冲的 Command 消息的数量。

        Return type: int
        """
        ...

    def evt_qsize(self) -> int:
        """
        Return the number of Event messages buffered on the internal queue.

        返回内部队列中缓冲的 Event 消息的数量。

        Return type: int
        """
        ...

    def kill(self) -> None:
        """
        Kill the engine by abruptly canceling the queue task and calling stop.

        通过突然取消队列任务并调用 stop 来终止引擎。
        """
        ...

    def execute(self, command: Command) -> None:
        """
        Execute the given command.

        执行给定的命令。

        If the internal queue is already full then will log a warning and block until queue size reduces.

        如果内部队列已满,则会记录警告并阻塞,直到队列大小减少。

        Parameters: command (Command) – The command to execute.
        参数:command (Command) - 要执行的命令。

        Warning:
            This method is not thread-safe and should only be called from the same thread the event loop is running on. Calling it from a different thread may lead to unexpected behavior.
            此方法不是线程安全的,只能从事件循环运行的同一线程调用。从不同的线程调用它可能会导致意外行为。
        """
        ...

    def process(self, event: Event) -> None:
        """
        Process the given event.

        处理给定的事件。

        If the internal queue is already full then will log a warning and block until queue size reduces.

        如果内部队列已满,则会记录警告并阻塞,直到队列大小减少。

        Parameters: event (Event) – The event to process.
        参数:event (Event) - 要处理的事件。

        Warning:
            This method is not thread-safe and should only be called from the same thread the event loop is running on. Calling it from a different thread may lead to unexpected behavior.
            此方法不是线程安全的,只能从事件循环运行的同一线程调用。从不同的线程调用它可能会导致意外行为。
        """
        ...

    def max_notional_per_order(self, instrument_id: InstrumentId):
        """
        Return the current maximum notional per order for the given instrument ID.

        返回给定金融工具 ID 的当前每笔订单的最大名义价值。

        Return type: Decimal or None
        """
        ...

    def max_notionals_per_order(self) -> dict:
        """
        Return the current maximum notionals per order settings.

        返回当前每笔订单的最大名义价值设置。

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

    def max_order_modify_rate(self) -> tuple:
        """
        Return the current maximum order modify rate limit setting.

        返回当前的最大订单修改速率限制设置。

        Returns: The limit per timedelta interval.
        返回值:每个 timedelta 间隔的限制。
        Return type: (int, timedelta)
        """
        ...

    def max_order_submit_rate(self) -> tuple:
        """
        Return the current maximum order submit rate limit setting.

        返回当前的最大订单提交速率限制设置。

        Returns: The limit per timedelta interval.
        返回值:每个 timedelta 间隔的限制。
        Return type: (int, timedelta)
        """
        ...

    def degrade(self) -> void:
        """
        Degrade the component.

        While executing on_degrade() any exception will be logged and reraised, then the component will remain in a DEGRADING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...
    
    def dispose(self) -> void:
        """
        Dispose of the component.

        While executing on_dispose() any exception will be logged and reraised, then the component will remain in a DISPOSING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...
    
    def fault(self) -> void:
        """
        Fault the component.

        Calling this method multiple times has the same effect as calling it once (it is idempotent). Once called, it cannot be reversed, and no other methods should be called on this instance.

        While executing on_fault() any exception will be logged and reraised, then the component will remain in a FAULTING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    @classmethod
    def fully_qualified_name(cls) -> str:
        """
        Return the fully qualified name for the components class.

        返回组件类的完全限定名称。

        Return type: str
        """
        ...

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

        重置组件。

        All stateful fields are reset to their initial value.

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

        While executing on_reset() any exception will be logged and reraised, then the component will remain in a RESETTING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    def resume(self) -> void:
        """
        Resume the component.

        While executing on_resume() any exception will be logged and reraised, then the component will remain in a RESUMING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    def set_max_notional_per_order(self, instrument_id: InstrumentId, new_value) -> void:
        """
        Set the maximum notional value per order for the given instrument ID.

        为给定金融工具 ID 设置每笔订单的最大名义价值。

        Passing a new_value of None will disable the pre-trade risk max notional check.

        传递 new_value 为 None 将禁用交易前风险最大名义价值检查。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The instrument ID for the max notional.
            instrument_id (InstrumentId) - 最大名义价值的金融工具 ID。
            new_value (integer , float , string or Decimal) – The max notional value to set.
            new_value(整数、浮点数、字符串或 Decimal) - 要设置的最大名义价值。

        Raises:
        引发:
            decimal.InvalidOperation – If new_value not a valid input for decimal.Decimal.
            decimal.InvalidOperation - 如果 new_value 不是 decimal.Decimal 的有效输入。
            ValueError – If new_value is not None and not positive.
            ValueError - 如果 new_value 不为 None 并且不是正数。
        """
        ...

    def set_trading_state(self, state: TradingState) -> void:
        """
        Set the trading state for the engine.

        设置引擎的交易状态。

        Parameters: state (TradingState) – The state to set.
        参数:state (TradingState) - 要设置的状态。
        """
        ...

    def start(self) -> void:
        """
        Start the component.

        While executing on_start() any exception will be logged and reraised, then the component will remain in a STARTING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

    @property
    def state(self) -> ComponentState:
        """
        ComponentState

        Return the components current state.

        返回组件的当前状态。

        Return type: ComponentState
        Type: Component.state
        """
        ...

    def stop(self) -> void:
        """
        Stop the component.

        While executing on_stop() any exception will be logged and reraised, then the component will remain in a STOPPING state.

        警告:
            不要覆盖。

        If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.

        如果组件未处于可执行此方法的有效状态,则组件状态将不会更改,并且将记录错误。
        """
        ...

class TradingNode 交易节点

Bases: object

class TradingNode(object):
    """
    Provides an asynchronous network node for live trading.

    为实时交易提供异步网络节点。

    Parameters:
    参数:
        config (TradingNodeConfig , optional) – The configuration for the instance.
        config (TradingNodeConfig,可选) - 实例的配置。
        loop (asyncio.AbstractEventLoop , optional) – The event loop for the node. If None then will get the running event loop internally.
        loop (asyncio.AbstractEventLoop,可选) - 节点的事件循环。如果为 None,则将在内部获取正在运行的事件循环。
    """
    def __init__(self, config: TradingNodeConfig | None = None, loop: asyncio.AbstractEventLoop | None = None):
        ...

Properties 属性

    @property
    def trader_id(self) -> TraderId:
        """
        Return the nodes trader ID.

        返回节点的交易者 ID。

        Return type: TraderId
        """
        ...

    @property
    def machine_id(self) -> str:
        """
        Return the nodes machine ID.

        返回节点的机器 ID。

        Return type: str
        """
        ...

    @property
    def instance_id(self) -> UUID4:
        """
        Return the nodes instance ID.

        返回节点的实例 ID。

        Return type: UUID4
        """
        ...

    @property
    def trader(self):
        """
        Return the nodes internal trader.

        返回节点的内部交易者。

        Return type: Trader
        """
        ...

    @property
    def cache(self):
        """
        Return the nodes internal read-only cache.

        返回节点的内部只读缓存。

        Return type: CacheFacade
        """
        ...

    @property
    def portfolio(self):
        ```python
       """
        Return the nodes internal read-only portfolio.

        返回节点的内部只读投资组合。

        Return type: PortfolioFacade
        """
        ...

    @property
    def is_running(self) -> bool:
        """
        Return whether the trading node is running.

        返回交易节点是否正在运行。

        Return type: bool
        """
        ...
    
    @property
    def is_built(self) -> bool:
        """
        Return whether the trading node clients are built.

        返回交易节点客户端是否已构建。

        Return type: bool
        """
        ...

Methods 方法

    def get_event_loop(self) -> AbstractEventLoop | None:
        """
        Return the event loop of the trading node.

        返回交易节点的事件循环。

        Return type: asyncio.AbstractEventLoop or None
        """
        ...

    def get_logger(self) -> Logger:
        """
        Return the logger for the trading node.

        返回交易节点的日志记录器。

        Return type: Logger
        """
        ...
    
    def add_data_client_factory(self, name: str, factory) -> None:
        """
        Add the given data client factory to the node.

        将给定的数据客户端工厂添加到节点。

        Parameters:
        参数:
            name (str) – The name of the client factory.
            name (str) - 客户端工厂的名称。
            factory (type *[*LiveDataClientFactory ]) – The factory class to add.
            factory (type *[*LiveDataClientFactory]) - 要添加的工厂类。

        Raises:
        引发:
            ValueError – If name is not a valid string.
            ValueError - 如果 name 不是有效的字符串。
            KeyError – If name has already been added.
            KeyError - 如果 name 已经添加。
        """
        ...

    def add_exec_client_factory(self, name: str, factory) -> None:
        """
        Add the given execution client factory to the node.

        将给定的执行客户端工厂添加到节点。

        Parameters:
        参数:
            name (str) – The name of the client factory.
            name (str) - 客户端工厂的名称。
            factory (type *[*LiveExecutionClientFactory ]) – The factory class to add.
            factory (type *[*LiveExecutionClientFactory]) - 要添加的工厂类。

        Raises:
        引发:
            ValueError – If name is not a valid string.
            ValueError - 如果 name 不是有效的字符串。
            KeyError – If name has already been added.
            KeyError - 如果 name 已经添加。
        """
        ...

    def build(self) -> None:
        """
        Build the nodes clients.

        构建节点客户端。
        """
        ...

    def run(self) -> None:
        """
        Start and run the trading node.

        启动并运行交易节点。
        """
        ...

    def publish_bus_message(self, bus_msg) -> None:
        """
        Publish bus message on the internal message bus.

        在内部消息总线上发布总线消息。

        Note the message will not be published externally.

        注意,消息不会在外部发布。

        Parameters: bus_msg (nautilus_pyo3.BusMessage) – The bus message to publish.
        参数:bus_msg (nautilus_pyo3.BusMessage) - 要发布的总线消息。
        """
        ...

    async def run_async(self) -> None:
        """
        Start and run the trading node asynchronously.

        异步启动并运行交易节点。
        """
        ...

    async def maintain_heartbeat(self, interval: float) -> None:
        """
        Maintain heartbeats at the given interval while the node is running.

        在节点运行时以给定的间隔维护心跳。

        Parameters: interval (float) – The interval (seconds) between heartbeats.
        参数:interval (float) - 心跳之间的时间间隔(以秒为单位)。
        """
        ...

    def stop(self) -> None:
        """
        Stop the trading node gracefully.

        优雅地停止交易节点。

        After a specified delay the internal Trader residual state will be checked.

        在指定的延迟之后,将检查内部交易者的剩余状态。

        If save strategy is configured, then strategy states will be saved.

        如果配置了保存策略,则将保存策略状态。
        """
        ...

    async def stop_async(self) -> None:
        """
        Stop the trading node gracefully, asynchronously.

        异步优雅地停止交易节点。

        After a specified delay the internal Trader residual state will be checked.

        在指定的延迟之后,将检查内部交易者的剩余状态。

        If save strategy is configured, then strategy states will be saved.

        如果配置了保存策略,则将保存策略状态。
        """
        ...

    def dispose(self) -> None:
        """
        Dispose of the trading node.

        释放交易节点。

        Gracefully shuts down the executor and event loop.

        优雅地关闭执行器和事件循环。
        """
        ...

class TradingNodeBuilder 交易节点构建器

Bases: object

class TradingNodeBuilder(object):
    """
    Provides building services for a trading node.

    为交易节点提供构建服务。

    Parameters:
    参数:
        loop (asyncio.AbstractEventLoop) – The event loop for the clients.
        loop (asyncio.AbstractEventLoop) - 客户端的事件循环。
        data_engine (LiveDataEngine) – The data engine for the trading node.
        data_engine (LiveDataEngine) - 交易节点的数据引擎。
        exec_engine (LiveExecutionEngine) – The execution engine for the trading node.
        exec_engine (LiveExecutionEngine) - 交易节点的执行引擎。
        portfolio (Portfolio) – The portfolio for the trading node.
        portfolio (Portfolio) - 交易节点的投资组合。
        msgbus (MessageBus) – The message bus for the trading node.
        msgbus (MessageBus) - 交易节点的消息总线。
        cache (Cache) – The cache for building clients.
        cache (Cache) - 用于构建客户端的缓存。
        clock (LiveClock) – The clock for building clients.
        clock (LiveClock) - 用于构建客户端的时钟。
        logger (Logger) – The logger for building clients.
        logger (Logger) - 用于构建客户端的日志记录器。
    """
    def __init__(self, loop: asyncio.AbstractEventLoop, data_engine: LiveDataEngine, exec_engine: LiveExecutionEngine, portfolio: Portfolio, msgbus: MessageBus, cache: Cache, clock: LiveClock, logger: Logger):
        ...

Methods 方法

    def add_data_client_factory(self, name: str, factory) -> None:
        """
        Add the given data client factory to the builder.

        将给定的数据客户端工厂添加到构建器。

        Parameters:
        参数:
            name (str) – The name of the client.
            name (str) - 客户端的名称。
            factory (type *[*LiveDataClientFactory ]) – The factory to add.
            factory (type *[*LiveDataClientFactory]) - 要添加的工厂。

        Raises:
        引发:
            ValueError – If name is not a valid string.
            ValueError - 如果 name 不是有效的字符串。
            KeyError – If name has already been added.
            KeyError - 如果 name 已经添加。
        """
        ...

    def add_exec_client_factory(self, name: str, factory) -> None:
        """
        Add the given client factory to the builder.

        将给定的客户端工厂添加到构建器。

        Parameters:
        参数:
            name (str) – The name of the client.
            name (str) - 客户端的名称。
            factory (type *[*LiveExecutionClientFactory ]) – The factory to add.
            factory (type *[*LiveExecutionClientFactory]) - 要添加的工厂。

        Raises:
        引发:
            ValueError – If name is not a valid string.
            ValueError - 如果 name 不是有效的字符串。
            KeyError – If name has already been added.
            KeyError - 如果 name 已经添加。
        """
        ...

    def build_data_clients(self, config: dict[str, LiveDataClientConfig]) -> None:
        """
        Build the data clients with the given configuration.

        使用给定的配置构建数据客户端。

        Parameters: config (dict *[*str , ImportableConfig | LiveDataClientConfig ]) – The data clients configuration.
        参数:config (dict *[*str,ImportableConfig | LiveDataClientConfig]) - 数据客户端配置。
        """
        ...

    def build_exec_clients(self, config: dict[str, LiveExecClientConfig]) -> None:
        """
        Build the execution clients with the given configuration.

        使用给定的配置构建执行客户端。

        Parameters: config (dict *[*str , ImportableConfig | LiveExecClientConfig ]) – The execution clients configuration.
        参数:config (dict *[*str,ImportableConfig | LiveExecClientConfig]) - 执行客户端配置。
        """
        ...
文档 (Documentation)
入门 (Getting Started)
概念 (Concepts)
教程 (Tutorials)
集成 (Integrations)
Python API
Rust API[未翻译]
开发者指南 (Developer Guide)
Clone this wiki locally