Backtest - Loren1166/NautilusTrader- GitHub Wiki

Backtest 回测

The backtest subpackage groups components relating to backtesting.

回测子包将与回测相关的组件分组。

This module provides a data client for backtesting.

此模块提供用于回测的数据客户端。

class BacktestDataClient 回测数据客户端

class BacktestDataClient(DataClient)

Provides an implementation of DataClient for backtesting.

提供 DataClient 的回测实现。

Parameters:

  • client_id (ClientId): The data client ID. client_id (ClientId):数据客户端 ID。
  • msgbus (MessageBus): The message bus for the client. msgbus (MessageBus):客户端的消息总线。
  • cache (Cache): The cache for the client. cache (Cache):客户端的缓存。
  • clock (Clock): The clock for the client. clock (Clock):客户端的时钟。
  • config (NautilusConfig, optional): The configuration for the instance. config (NautilusConfig,可选):实例的配置。
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.

    Warnings
    --------
    Do not override.

    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.

    Warnings
    --------
    Do not override.

    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.

    Warnings
    --------
    Do not override.

    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.

    Returns
    -------
    str

    """
    ...

@property
def id(self) -> ComponentId:
    """
    The components 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

    """
    ...

def request(self, data_type: DataType, correlation_id: UUID4) -> void:
    ...

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.

    Warnings
    --------
    Do not override.

    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.

    Warnings
    --------
    Do not override.

    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.

    Warnings
    --------
    Do not override.

    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.
    # 返回组件的当前状态。

    Returns
    -------
    ComponentState

    """
    ...

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.

    Warnings
    --------
    Do not override.

    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 subscribe(self, data_type: DataType) -> void:
    ...

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

    Returns
    -------
    list[DataType]

    """
    ...

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

    Returns
    -------
    TraderId

    """
    ...

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

    Returns
    -------
    type

    """
    ...

def unsubscribe(self, data_type: DataType) -> void:
    ...

@property
def venue(self) -> Venue | None:
    """
    The clients venue ID (if applicable).

    Returns
    -------
    Venue or None

    """
    ...

class BacktestMarketDataClient 回测市场数据客户端

class BacktestMarketDataClient(MarketDataClient)

Provides an implementation of MarketDataClient for backtesting.

提供 MarketDataClient 的回测实现。

Parameters:

  • client_id (ClientId): The data client ID. client_id (ClientId):数据客户端 ID。
  • msgbus (MessageBus): The message bus for the client. msgbus (MessageBus):客户端的消息总线。
  • cache (Cache): The cache for the client. cache (Cache):客户端的缓存。
  • clock (Clock): The clock for the client. clock (Clock):客户端的时钟。
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.

    Warnings
    --------
    Do not override.

    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.

    Warnings
    --------
    Do not override.

    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.

    Warnings
    --------
    Do not override.

    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.

    Returns
    -------
    str

    """
    ...

@property
def id(self) -> ComponentId:
    """
    The components 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

    """
    ...

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.
        # 订阅的数据类型。
    correlation_id : UUID4
        The correlation ID for the response.
        # 响应的相关性 ID。

    """
    ...

def request_bars(self, bar_type: BarType, limit: int, correlation_id: UUID4, start: datetime | None = None, end: datetime | None = None) -> void:
    ...

def request_instrument(self, instrument_id: InstrumentId, correlation_id: UUID4, start: datetime | None = None, end: datetime | None = None) -> void:
    ...

def request_instruments(self, venue: Venue, correlation_id: UUID4, start: datetime | None = None, end: datetime | None = None) -> void:
    ...

def request_order_book_snapshot(self, instrument_id: InstrumentId, limit: int, correlation_id: UUID4) -> void:
    ...

def request_quote_ticks(self, instrument_id: InstrumentId, limit: int, correlation_id: UUID4, start: datetime | None = None, end: datetime | None = None) -> void:
    ...

def request_trade_ticks(self, instrument_id: InstrumentId, limit: int, correlation_id: UUID4, start: datetime | None = None, end: datetime | None = None) -> void:
    ...

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.

    Warnings
    --------
    Do not override.

    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.

    Warnings
    --------
    Do not override.

    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.

    Warnings
    --------
    Do not override.

    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.
    # 返回组件的当前状态。

    Returns
    -------
    ComponentState

    """
    ...

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.

    Warnings
    --------
    Do not override.

    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 subscribe(self, data_type: DataType) -> void:
    """
    Subscribe to data for the given data type.

    Parameters
    ----------
    data_type : DataType
        The data type for the subscription.
        # 订阅的数据类型。

    """
    ...

def subscribe_bars(self, bar_type: BarType) -> void:
    ...

def subscribe_instrument(self, instrument_id: InstrumentId) -> void:
    ...

def subscribe_instrument_close(self, instrument_id: InstrumentId) -> void:
    ...

def subscribe_instrument_status(self, instrument_id: InstrumentId) -> void:
    ...

def subscribe_instruments(self) -> void:
    ...

def subscribe_order_book_deltas(self, instrument_id: InstrumentId, book_type: BookType, depth: int = 0, kwargs: dict = None) -> void:
    ...

def subscribe_order_book_snapshots(self, instrument_id: InstrumentId, book_type: BookType, depth: int = 0, kwargs: dict = None) -> void:
    ...

def subscribe_quote_ticks(self, instrument_id: InstrumentId) -> void:
    ...

def subscribe_trade_ticks(self, instrument_id: InstrumentId) -> void:
    ...

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

    Returns
    -------
    list[BarType]

    """
    ...

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

    Returns
    -------
    list[DataType]

    """
    ...

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

    Returns
    -------
    list[InstrumentId]

    """
    ...

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

    Returns
    -------
    list[InstrumentId]

    """
    ...

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

    Returns
    -------
    list[InstrumentId]

    """
    ...

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

    Returns
    -------
    list[InstrumentId]

    """
    ...

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

    Returns
    -------
    list[InstrumentId]

    """
    ...

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

    Returns
    -------
    list[InstrumentId]

    """
    ...

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

    Returns
    -------
    list[InstrumentId]

    """
    ...

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

    Returns
    -------
    TraderId

    """
    ...

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

    Returns
    -------
    type

    """
    ...

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.
        # 订阅的数据类型。

    """
    ...

def unsubscribe_bars(self, bar_type: BarType) -> void:
    ...

def unsubscribe_instrument(self, instrument_id: InstrumentId) -> void:
    ...

def unsubscribe_instrument_close(self, instrument_id: InstrumentId) -> void:
    ...

def unsubscribe_instrument_status(self, instrument_id: InstrumentId) -> void:
    ...

def unsubscribe_instruments(self) -> void:
    ...

def unsubscribe_order_book_deltas(self, instrument_id: InstrumentId) -> void:
    ...

def unsubscribe_order_book_snapshots(self, instrument_id: InstrumentId) -> void:
    ...

def unsubscribe_quote_ticks(self, instrument_id: InstrumentId) -> void:
    ...

def unsubscribe_trade_ticks(self, instrument_id: InstrumentId) -> void:
    ...

@property
def venue(self) -> Venue | None:
    """
    The clients venue ID (if applicable).

    Returns
    -------
    Venue or None

    """
    ...

class BacktestEngine 回测引擎

class BacktestEngine

Provides a backtest engine to run a portfolio of strategies over historical data.

提供回测引擎,用于在历史数据上运行策略组合。

Parameters:

  • config (BacktestEngineConfig, optional): The configuration for the instance. config (BacktestEngineConfig,可选):实例的配置。

Raises:

  • TypeError: If config is not of type BacktestEngineConfig. TypeError:如果 config 的类型不是 BacktestEngineConfig
def __init__(self, config: BacktestEngineConfig | None = None) -> None:
    """
    Provides a backtest engine to run a portfolio of strategies over historical data.

    Parameters
    ----------
    config : BacktestEngineConfig, optional
        The configuration for the instance.
        # 实例的配置。

    Raises
    ------
    TypeError
        If config is not of type BacktestEngineConfig.

    """
    ...

def add_actor(self, actor: Actor) -> None:
    """
    Add the given actor to the backtest engine.

    Parameters
    ----------
    actor : Actor
        The actor to add.
        # 要添加的参与者。

    """
    ...

def add_actors(self, actors: list[Actor]) -> None:
    """
    Add the given list of actors to the backtest engine.

    Parameters
    ----------
    actors : list[Actor]
        The actors to add.
        # 要添加的参与者。

    """
    ...

def add_data(self, data: list, client_id: ClientId = None, validate: bool = True, sort: bool = True) -> None:
    """
    Add the given custom data to the backtest engine.

    Parameters
    ----------
    data : list[*Data]
        The data to add.
        # 要添加的数据。
    client_id : ClientId, optional
        The data client ID to associate with custom data.
        # 与自定义数据关联的数据客户端 ID。
    validate : bool, default True
        If data should be validated (recommended when adding data directly to the engine).
        # 是否应验证数据(建议在将数据直接添加到引擎时)。
    sort : bool, default True
        If data should be sorted by ts_init with the rest of the stream after adding
        (recommended when adding data directly to the engine).
        # 添加后是否应按 ts_init 对数据进行排序(建议在将数据直接添加到引擎时)。

    Raises
    ------
    ValueError
        If data is empty.
    ValueError
        If data contains objects which are not a type of Data.
    ValueError
        If instrument_id for the data is not found in the cache.
    ValueError
        If data elements do not have an instrument_id and client_id is None.
    TypeError
        If data is a type provided by Rust pyo3 (cannot add directly to engine yet).

    Warnings
    --------
    Assumes all data elements are of the same type. Adding lists of varying data types could result in incorrect
    backtest logic.

    Caution if adding data without sort being True, as this could lead to running backtests on a stream which does
    not have monotonically increasing timestamps.
    # 假设所有数据元素都属于同一类型。添加不同数据类型的列表可能会导致不正确的回测逻辑。

    # 如果添加数据时 sort 不为 True,请谨慎,因为这可能会导致在没有单调递增时间戳的流上运行回测。

    """
    ...

def add_exec_algorithm(self, exec_algorithm: ExecAlgorithm) -> None:
    """
    Add the given execution algorithm to the backtest engine.

    Parameters
    ----------
    exec_algorithm : ExecAlgorithm
        The execution algorithm to add.
        # 要添加的执行算法。

    """
    ...

def add_exec_algorithms(self, exec_algorithms: list[ExecAlgorithm]) -> None:
    """
    Add the given list of execution algorithms to the backtest engine.

    Parameters
    ----------
    exec_algorithms : list[ExecAlgorithm]
        The execution algorithms to add.
        # 要添加的执行算法。

    """
    ...

def add_instrument(self, instrument: Instrument) -> None:
    """
    Add the instrument to the backtest engine.

    The instrument must be valid for its associated venue. For instance, derivative instruments which would trade
    on margin cannot be added to a venue with a CASH account.

    Parameters
    ----------
    instrument : Instrument
        The instrument to add.
        # 要添加的Instrument。

    Raises
    ------
    InvalidConfiguration
        If the venue for the instrument has not been added to the engine.
    InvalidConfiguration
        If instrument is not valid for its associated venue.

    """
    ...

def add_strategies(self, strategies: list[Strategy]) -> None:
    """
    Add the given list of strategies to the backtest engine.

    Parameters
    ----------
    strategies : list[Strategy]
        The strategies to add.
        # 要添加的策略。

    """
    ...

def add_strategy(self, strategy: Strategy) -> None:
    """
    Add the given strategy to the backtest engine.

    Parameters
    ----------
    strategy : Strategy
        The strategy to add.
        # 要添加的策略。

    """
    ...

def add_venue(
    self,
    venue: Venue,
    oms_type: OmsType,
    account_type: AccountType,
    starting_balances: list[Money],
    base_currency: Currency | None = None,
    default_leverage: Decimal | None = None,
    leverages: dict[InstrumentId, Decimal] | None = None,
    modules: list[SimulationModule] | None = None,
    fill_model: FillModel | None = None,
    fee_model: FeeModel | None = None,
    latency_model: LatencyModel | None = None,
    book_type: BookType = BookType.L1_MBP,
    routing: bool = False,
    frozen_account: bool = False,
    bar_execution: bool = True,
    reject_stop_orders: bool = True,
    support_gtd_orders: bool = True,
    support_contingent_orders: bool = True,
    use_position_ids: bool = True,
    use_random_ids: bool = False,
    use_reduce_only: bool = True,
) -> None:
    """
    Add a SimulatedExchange with the given parameters to the backtest engine.

    Parameters
    ----------
    venue : Venue
        The venue ID.
        # 交易平台 ID。
    oms_type : OmsType {HEDGING, NETTING}
        The order management system type for the exchange. If HEDGING will generate new position IDs.
        # 交易所的订单管理系统类型。如果为 HEDGING,将生成新的头寸 ID。
    account_type : AccountType
        The account type for the client.
        # 客户端的账户类型。
    starting_balances : list[Money]
        The starting account balances (specify one for a single asset account).
        # 期初账户余额(为单个资产账户指定一个)。
    base_currency : Currency, optional
        The account base currency for the client. Use None for multi-currency accounts.
        # 客户端的账户基础货币。对于多币种账户,请使用 None。
    default_leverage : Decimal, optional
        The account default leverage (for margin accounts).
        # 账户默认杠杆率(适用于保证金账户)。
    leverages : dict[InstrumentId, Decimal], optional
        The instrument specific leverage configuration (for margin accounts).
        # 特定于Instrument的杠杆率配置(适用于保证金账户)。
    modules : list[SimulationModule], optional
        The simulation modules to load into the exchange.
        # 要加载到交易所中的模拟模块。
    fill_model : FillModel, optional
        The fill model for the exchange.
        # 交易所的成交模型。
    fee_model : FeeModel, optional
        The fee model for the venue.
        # 交易平台的费用模型。
    latency_model : LatencyModel, optional
        The latency model for the exchange.
        # 交易所的延迟模型。
    book_type : BookType, default BookType.L1_MBP
        The default order book type for fill modelling.
        # 用于成交建模的默认订单簿类型。
    routing : bool, default False
        If multi-venue routing should be enabled for the execution client.
        # 是否应为执行客户端启用多交易平台路由。
    frozen_account : bool, default False
        If the account for this exchange is frozen (balances will not change).
        # 如果此交易所的账户被冻结(余额将不会改变)。
    bar_execution : bool, default True
        If bars should be processed by the matching engine(s) (and move the market).
        # 是否应由匹配引擎处理K线(并移动市场)。
    reject_stop_orders : bool, default True
        If stop orders are rejected on submission if trigger price is in the market.
        # 如果在提交时触发价在市场中,是否拒绝止损订单。
    support_gtd_orders : bool, default True
        If orders with GTD time in force will be supported by the venue.
        # 交易平台是否支持 GTD 有效期的订单。
    support_contingent_orders : bool, default True
        If contingent orders will be supported/respected by the venue. If False then its expected the strategy will be
        managing any contingent orders.
        # 交易平台是否支持/尊重附带订单。如果为 False,则预计策略将管理任何附带订单。
    use_position_ids : bool, default True
        If venue position IDs will be generated on order fills.
        # 是否将在订单成交时生成交易平台头寸 ID。
    use_random_ids : bool, default False
        If all venue generated identifiers will be random UUID4’s.
        # 如果所有交易平台生成的标识符都将是随机的 UUID4。
    use_reduce_only : bool, default True
        If the reduce_only execution instruction on orders will be honored.
        # 是否将遵守订单上的 `reduce_only` 执行指令。

    Raises
    ------
    ValueError
        If venue is already registered with the engine.

    """
    ...

@property
def backtest_end(self) -> datetime | None:
    """
    datetime | None

    Return the last backtest run time range end (if run).
    # 返回最后一次回测运行的时间范围结束时间(如果已运行)。

    Returns
    -------
    datetime or None

    """
    ...

@property
def backtest_start(self) -> datetime | None:
    """
    datetime | None

    Return the last backtest run time range start (if run).
    # 返回最后一次回测运行的时间范围开始时间(如果已运行)。

    Returns
    -------
    datetime or None

    """
    ...

@property
def cache(self) -> CacheFacade:
    """
    CacheFacade

    Return the engines internal read-only cache.
    # 返回引擎内部的只读缓存。

    Returns
    -------
    CacheFacade

    """
    ...

def change_fill_model(self, venue: Venue, model: FillModel) -> None:
    """
    Change the fill model for the exchange of the given venue.

    Parameters
    ----------
    venue : Venue
        The venue of the simulated exchange.
        # 模拟交易所的交易平台。
    model : FillModel
        The fill model to change to.
        # 要更改的成交模型。

    """
    ...

def clear_actors(self) -> None:
    """
    Clear all actors from the engines internal trader.
    # 从引擎内部的交易者中清除所有参与者。

    """
    ...

def clear_data(self) -> None:
    """
    Clear the engines internal data stream.

    Does not clear added instruments.
    # 不清除已添加的Instrument。

    """
    ...

def clear_exec_algorithms(self) -> None:
    """
    Clear all execution algorithms from the engines internal trader.
    # 从引擎内部的交易者中清除所有执行算法。

    """
    ...

def clear_strategies(self) -> None:
    """
    Clear all trading strategies from the engines internal trader.
    # 从引擎内部的交易者中清除所有交易策略。

    """
    ...

@property
def data(self) -> list[Data]:
    """
    list[Data]

    Return the engines internal data stream.
    # 返回引擎内部的数据流。

    Returns
    -------
    list[Data]

    """
    ...

def dispose(self) -> None:
    """
    Dispose of the backtest engine by disposing the trader and releasing system resources.

    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.
    # 通过处理交易者并释放系统资源来处理回测引擎。

    # 多次调用此方法与调用一次的效果相同(它是幂等的)。调用一次后,它不能被逆转,
    # 并且不应在此实例上调用其他任何方法。

    """
    ...

def dump_pickled_data(self) -> bytes:
    """
    Return the internal data stream pickled.

    Returns
    -------
    bytes

    """
    ...

def end(self):
    """
    Manually end the backtest.
    # 手动结束回测。

    """
    ...

def get_result(self):
    """
    Return the backtest result from the last run.

    Returns
    -------
    BacktestResult

    """
    ...

@property
def instance_id(self) -> UUID4:
    """
    UUID4

    Return the engines instance ID.

    This is a unique identifier per initialized engine.
    # 返回引擎的实例 ID。

    # 这是每个初始化引擎的唯一标识符。

    Returns
    -------
    UUID4

    """
    ...

@property
def iteration(self) -> int:
    """
    int

    Return the backtest engine iteration count.
    # 返回回测引擎迭代计数。

    Returns
    -------
    int

    """
    ...

@property
def kernel(self) -> NautilusKernel:
    """
    NautilusKernel

    Return the internal kernel for the engine.
    # 返回引擎的内部内核。

    Returns
    -------
    NautilusKernel

    """
    ...

def list_venues(self) -> list[Venue]:
    """
    Return the venues contained within the engine.

    Returns
    -------
    list[Venue]

    """
    ...

def load_pickled_data(self, data: bytes) -> None:
    """
    Load the given pickled data directly into the internal data stream.

    It is highly advised to only pass data to this method which was obtained through a call to .dump_pickled_data().

    Warnings
    --------
    This low-level direct access method makes the following assumptions: :
    - The data contains valid Nautilus objects only, which inherit from Data.
    - The data was successfully pickled from a call to pickle.dumps().
    - The data was sorted prior to pickling.
    - All required instruments have been added to the engine.
    # 将给定的腌制数据直接加载到内部数据流中。

    # 强烈建议仅将通过调用 .dump_pickled_data() 获得的数据传递给此方法。

    # 警告
    # 此低级直接访问方法做出以下假设::
    # - 数据仅包含有效的 Nautilus 对象,这些对象继承自 Data。
    # - 数据已通过调用 pickle.dumps() 成功腌制。
    # - 数据在腌制之前已排序。
    # - 所有必需的Instrument都已添加到引擎中。

    """
    ...

@property
def logger(self) -> Logger:
    """
    Logger

    Return the internal logger for the engine.
    # 返回引擎的内部记录器。

    Returns
    -------
    Logger

    """
    ...

@property
def machine_id(self) -> str:
    """
    str

    Return the engines machine ID.
    # 返回引擎的机器 ID。

    Returns
    -------
    str

    """
    ...

@property
def portfolio(self) -> PortfolioFacade:
    """
    PortfolioFacade

    Return the engines internal read-only portfolio.
    # 返回引擎内部的只读投资组合。

    Returns
    -------
    PortfolioFacade

    """
    ...

def reset(self) -> None:
    """
    Reset the backtest engine.

    All stateful fields are reset to their initial value.

    Note: instruments and data are not dropped/reset, this can be done through a separate call to
    .clear_data() if desired.
    # 重置回测引擎。

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

    # 注意:Instrument和数据不会被删除/重置,如果需要,可以通过单独调用 .clear_data() 来完成此操作。

    """
    ...

def run(self, start: datetime | str | int | None = None, end: datetime | str | int | None = None, run_config_id: str | None = None, streaming: bool = False) -> None:
    """
    Run a backtest.

    At the end of the run the trader and strategies will be stopped, then post-run analysis performed.

    If more data than can fit in memory is to be run through the backtest engine, then streaming mode can be utilized.
    The expected sequence is as follows:

    1. Add initial data batch and strategies.
    2. Call run(streaming=True).
    3. Call clear_data().
    4. Add next batch of data stream.
    5. Call either run(streaming=False) or end(). When there is no more data to run on.

    Parameters
    ----------
    start : datetime or str or int, optional
        The start datetime (UTC) for the backtest run. If None engine runs from the start of the data.
        # 回测运行的开始日期时间(UTC)。如果为 None,则引擎从数据开始运行。
    end : datetime or str or int, optional
        The end datetime (UTC) for the backtest run. If None engine runs to the end of the data.
        # 回测运行的结束日期时间(UTC)。如果为 None,则引擎运行到数据结束。
    run_config_id : str, optional
        The tokenized BacktestRunConfig ID.
        # 标记化的 BacktestRunConfig ID。
    streaming : bool, default False
        If running in streaming mode. If False then will end the backtest following the run iterations.
        # 是否以流模式运行。如果为 False,则将在运行迭代后结束回测。

    Raises
    ------
    ValueError
        If no data has been added to the engine.
    ValueError
        If the start is >= the end datetime.

    """
    ...

@property
def run_config_id(self) -> str | None:
    """
    str

    Return the last backtest engine run config ID.
    # 返回最后一次回测引擎运行的配置 ID。

    Returns
    -------
    str or None

    """
    ...

@property
def run_finished(self) -> datetime | None:
    """
    datetime | None

    Return when the last backtest run finished (if run).
    # 返回最后一次回测运行完成的时间(如果已运行)。

    Returns
    -------
    datetime or None

    """
    ...

@property
def run_id(self) -> UUID4 | None:
    """
    UUID4

    Return the last backtest engine run ID (if run).
    # 返回最后一次回测引擎运行的 ID(如果已运行)。

    Returns
    -------
    UUID4 or None

    """
    ...

@property
def run_started(self) -> datetime | None:
    """
    datetime | None

    Return when the last backtest run started (if run).
    # 返回最后一次回测运行开始的时间(如果已运行)。

    Returns
    -------
    datetime or None

    """
    ...

@property
def trader(self) -> Trader:
    """
    Trader

    Return the engines internal trader.
    # 返回引擎内部的交易者。

    Returns
    -------
    Trader

    """
    ...

@property
def trader_id(self) -> TraderId:
    """
    TraderId

    Return the engines trader ID.
    # 返回引擎的交易者 ID。

    Returns
    -------
    TraderId

    """
    ...

class BacktestExecClient 回测执行客户端

class BacktestExecClient(ExecutionClient)

Provides an execution client for the BacktestEngine.

BacktestEngine 提供执行客户端。

Parameters:

  • exchange (SimulatedExchange): The simulated exchange for the backtest. exchange (SimulatedExchange):用于回测的模拟交易所。
  • msgbus (MessageBus): The message bus for the client. msgbus (MessageBus):客户端的消息总线。
  • cache (Cache): The cache for the client. cache (Cache):客户端的缓存。
  • clock (TestClock): The clock for the client. clock (TestClock):客户端的时钟。
  • routing (bool): If multi-venue routing is enabled for the client. routing (bool):是否为客户端启用多交易平台路由。
  • frozen_account (bool): If the backtest run account is frozen. frozen_account (bool):如果回测运行账户被冻结。
@property
def account_id(self) -> AccountId | None:
    """
    The clients account ID.

    Returns
    -------
    AccountId or None

    """
    ...

@property
def account_type(self) -> AccountType:
    """
    The clients account type.

    Returns
    -------
    AccountType

    """
    ...

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

    Returns
    -------
    Currency or None

    """
    ...

def batch_cancel_orders(self, command: BatchCancelOrders) -> void:
    ...

def cancel_all_orders(self, command: CancelAllOrders) -> void:
    ...

def cancel_order(self, command: CancelOrder) -> void:
    ...

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.

    Warnings
    --------
    Do not override.

    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.

    Warnings
    --------
    Do not override.

    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.

    Warnings
    --------
    Do not override.

    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.

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

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

    """
    ...

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.

    Parameters
    ----------
    strategy_id : StrategyId
        The strategy ID associated with the event.
        # 与事件关联的策略 ID。
    instrument_id : InstrumentId
        The instrument ID.
        # Instrument ID。
    client_order_id : ClientOrderId
        The client order ID.
        # 客户端订单 ID。
    venue_order_id : VenueOrderId
        The venue order ID (assigned by the venue).
        # 交易平台订单 ID(由交易平台分配)。
    ts_event : uint64_t
        UNIX timestamp (nanoseconds) when the order accepted event occurred.
        # 订单接受事件发生时的 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.

    Parameters
    ----------
    strategy_id : StrategyId
        The strategy ID associated with the event.
        # 与事件关联的策略 ID。
    instrument_id : InstrumentId
        The instrument ID.
        # Instrument ID。
    client_order_id : ClientOrderId
        The client order ID.
        # 客户端订单 ID。
    venue_order_id : VenueOrderId
        The venue order ID (assigned by the venue).
        # 交易平台订单 ID(由交易平台分配)。
    reason : str
        The order cancel rejected reason.
        # 订单取消被拒绝的原因。
    ts_event : uint64_t
        UNIX timestamp (nanoseconds) when the order cancel rejected event occurred.
        # 订单取消被拒绝事件发生时的 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.

    Parameters
    ----------
    strategy_id : StrategyId
        The strategy ID associated with the event.
        # 与事件关联的策略 ID。
    instrument_id : InstrumentId
        The instrument ID.
        # Instrument ID。
    client_order_id : ClientOrderId
        The client order ID.
        # 客户端订单 ID。
    venue_order_id : VenueOrderId
        The venue order ID (assigned by the venue).
        # 交易平台订单 ID(由交易平台分配)。
    ts_event : uint64_t
        UNIX timestamp (nanoseconds) when order canceled event occurred.
        # 订单取消事件发生时的 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.

    Parameters
    ----------
    strategy_id : StrategyId
        The strategy ID associated with the event.
        # 与事件关联的策略 ID。
    instrument_id : InstrumentId
        The instrument ID.
        # Instrument ID。
    client_order_id : ClientOrderId
        The client order ID.
        # 客户端订单 ID。
    venue_order_id : VenueOrderId
        The venue order ID (assigned by the venue).
        # 交易平台订单 ID(由交易平台分配)。
    ts_event : uint64_t
        UNIX timestamp (nanoseconds) when the order expired event occurred.
        # 订单过期事件发生时的 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.

    Parameters
    ----------
    strategy_id : StrategyId
        The strategy ID associated with the event.
        # 与事件关联的策略 ID。
    instrument_id : InstrumentId
        The instrument ID.
        # Instrument ID。
    client_order_id : ClientOrderId
        The client order ID.
        # 客户端订单 ID。
    venue_order_id : VenueOrderId
        The venue order ID (assigned by the venue).
        # 交易平台订单 ID(由交易平台分配)。
    trade_id : TradeId
        The trade ID.
        # 交易 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.
        # 与订单关联的交易平台头寸 ID。如果交易平台已分配头寸 ID/票证,则在此处传递,
        # 否则传递 None,执行引擎 OMS 将处理头寸 ID 解析。
    order_side : OrderSide {BUY, SELL}
        The execution order side.
        # 执行订单方向。
    order_type : OrderType
        The execution order type.
        # 执行订单类型。
    last_qty : Quantity
        The fill quantity for this execution.
        # 此执行的成交数量。
    last_px : Price
        The fill price for this execution (not average price).
        # 此执行的成交价格(非平均价格)。
    quote_currency : Currency
        The currency of the price.
        # 价格的货币。
    commission : Money
        The fill commission.
        # 成交佣金。
    liquidity_side : LiquiditySide {NO_LIQUIDITY_SIDE, MAKER, TAKER}
        The execution liquidity side.
        # 执行流动性方向。
    ts_event : uint64_t
        UNIX timestamp (nanoseconds) when the order filled event occurred.
        # 订单成交事件发生时的 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.

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

    """
    ...

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

    Parameters
    ----------
    strategy_id : StrategyId
        The strategy ID associated with the event.
        # 与事件关联的策略 ID。
    instrument_id : InstrumentId
        The instrument ID.
        # Instrument ID。
    client_order_id : ClientOrderId
        The client order ID.
        # 客户端订单 ID。
    reason : datetime
        The order rejected reason.
        # 订单被拒绝的原因。
    ts_event : uint64_t
        UNIX timestamp (nanoseconds) when the order rejected event occurred.
        # 订单拒绝事件发生时的 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.

    Parameters
    ----------
    strategy_id : StrategyId
        The strategy ID associated with the event.
        # 与事件关联的策略 ID。
    instrument_id : InstrumentId
        The instrument ID.
        # Instrument ID。
    client_order_id : ClientOrderId
        The client order ID.
        # 客户端订单 ID。
    ts_event : uint64_t
        UNIX timestamp (nanoseconds) when the order submitted event occurred.
        # 订单提交事件发生时的 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.

    Parameters
    ----------
    strategy_id : StrategyId
        The strategy ID associated with the event.
        # 与事件关联的策略 ID。
    instrument_id : InstrumentId
        The instrument ID.
        # Instrument ID。
    client_order_id : ClientOrderId
        The client order ID.
        # 客户端订单 ID。
    venue_order_id : VenueOrderId
        The venue order ID (assigned by the venue).
        # 交易平台订单 ID(由交易平台分配)。
    ts_event : uint64_t
        UNIX timestamp (nanoseconds) when the order triggered event occurred.
        # 订单触发事件发生时的 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.

    Parameters
    ----------
    strategy_id : StrategyId
        The strategy ID associated with the event.
        # 与事件关联的策略 ID。
    instrument_id : InstrumentId
        The instrument ID.
        # Instrument ID。
    client_order_id : ClientOrderId
        The client order ID.
        # 客户端订单 ID。
    venue_order_id : VenueOrderId
        The venue order ID (assigned by the venue).
        # 交易平台订单 ID(由交易平台分配)。
    quantity : Quantity
        The orders current quantity.
        # 订单的当前数量。
    price : Price
        The orders current price.
        # 订单的当前价格。
    trigger_price : Price, optional with no default so None must be passed explicitly
        The orders current trigger price.
        # 订单的当前触发价格。
    ts_event : uint64_t
        UNIX timestamp (nanoseconds) when the order update event occurred.
        # 订单更新事件发生时的 UNIX 时间戳(纳秒)。
    venue_order_id_modified : bool
        If the ID was modified for this event.
        # 如果此事件的 ID 已被修改。

    """
    ...

def get_account(self) -> Account | None:
    """
    Return the account for the client (if registered).

    Returns
    -------
    Account or None

    """
    ...

@property
def id(self) -> ComponentId:
    """
    The components 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

    """
    ...

def modify_order(self, command: ModifyOrder) -> void:
    ...

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

    Returns
    -------
    OmsType

    """
    ...

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

    Parameters
    ----------
    command : QueryOrder
        The command to execute.
        # 要执行的命令。

    """
    ...

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.

    Warnings
    --------
    Do not override.

    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.

    Warnings
    --------
    Do not override.

    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.

    Warnings
    --------
    Do not override.

    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.
    # 返回组件的当前状态。

    Returns
    -------
    ComponentState

    """
    ...

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.

    Warnings
    --------
    Do not override.

    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 submit_order(self, command: SubmitOrder) -> void:
    ...

def submit_order_list(self, command: SubmitOrderList) -> void:
    ...

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

    Returns
    -------
    TraderId

    """
    ...

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

    Returns
    -------
    type

    """
    ...

@property
def venue(self) -> Venue | None:
    """
    The clients venue ID (if not a routing client).

    Returns
    -------
    Venue or None

    """
    ...

class FeeModel 费用模型

class FeeModel

Provides an abstract fee model for trades.

为交易提供抽象费用模型。

def get_commission(self, order: Order, fill_qty: Quantity, fill_px: Price, instrument: Instrument) -> Money:
    """
    Return the commission for a trade.

    Parameters
    ----------
    order : Order
        The order to calculate the commission for.
        # 要计算佣金的订单。
    fill_qty : Quantity
        The fill quantity of the order.
        # 订单的成交数量。
    fill_px : Price
        The fill price of the order.
        # 订单的成交价格。
    instrument : Instrument
        The instrument for the order.
        # 订单的Instrument。

    Returns
    -------
    Money

    """
    ...

class FillModel 成交模型

class FillModel

Provides probabilistic modeling for order fill dynamics including probability of fills and slippage by order type.

为订单成交动态提供概率建模,包括按订单类型划分的成交概率和滑点。

Parameters:

  • prob_fill_on_limit (double): The probability of limit order filling if the market rests on its price. prob_fill_on_limit (double):如果市场停留在其价格上,限价单成交的概率。
  • prob_fill_on_stop (double): The probability of stop orders filling if the market rests on its price. prob_fill_on_stop (double):如果市场停留在其价格上,止损单成交的概率。
  • prob_slippage (double): The probability of order fill prices slipping by one tick. prob_slippage (double):订单成交价格滑点一个刻度的概率。
  • random_seed (int, optional): The random seed (if None then no random seed). random_seed (int,可选):随机种子(如果为 None 则没有随机种子)。

Raises:

  • ValueError: If any probability argument is not within range [0, 1]. ValueError:如果任何概率参数不在 [0, 1] 范围内。
  • TypeError: If random_seed is not None and not of type int. TypeError:如果 random_seed 不是 None 并且不是 int 类型。
def is_limit_filled(self) -> bool:
    """
    Return a value indicating whether a LIMIT order filled.
    # 返回一个值,指示限价单是否已成交。

    Returns
    -------
    bool

    """
    ...

def is_slipped(self) -> bool:
    """
    Return a value indicating whether an order fill slipped.
    # 返回一个值,指示订单成交是否滑点。

    Returns
    -------
    bool

    """
    ...

def is_stop_filled(self) -> bool:
    """
    Return a value indicating whether a STOP-MARKET order filled.
    # 返回一个值,指示市价止损单是否已成交。

    Returns
    -------
    bool

    """
    ...

@property
def prob_fill_on_limit(self) -> bool:
    """
    The probability of limit orders filling on the limit price.
    # 限价单以限价成交的概率。

    Returns
    -------
    bool

    """
    ...

@property
def prob_fill_on_stop(self) -> bool:
    """
    The probability of stop orders filling on the stop price.
    # 止损单以止损价成交的概率。

    Returns
    -------
    bool

    """
    ...

@property
def prob_slippage(self) -> bool:
    """
    The probability of aggressive order execution slipping.
    # 激进订单执行滑点的概率。

    Returns
    -------
    bool

    """
    ...

class FixedFeeModel 固定费用模型

class FixedFeeModel(FeeModel)

Provides a fixed fee model for trades.

为交易提供固定费用模型。

Parameters:

  • commission (Money): The fixed commission amount for trades. commission (Money):交易的固定佣金金额。
  • charge_commission_once (bool, default True): Whether to charge the commission once per order or per fill. charge_commission_once (bool,默认值 True):是否对每个订单或每个成交收取一次佣金。

Raises:

  • ValueError: If commission is not a positive amount. ValueError:如果 commission 不是正数。
def get_commission(self, order: Order, fill_qty: Quantity, fill_px: Price, instrument: Instrument) -> Money:
    ...

class LatencyModel 延迟模型

class LatencyModel

Provides a latency model for simulated exchange message I/O.

为模拟交易所消息 I/O 提供延迟模型。

Parameters:

  • base_latency_nanos (int, default 1_000_000_000): The base latency (nanoseconds) for the model. base_latency_nanos (int,默认值 1_000_000_000):模型的基本延迟(纳秒)。
  • insert_latency_nanos (int, default 0): The order insert latency (nanoseconds) for the model. insert_latency_nanos (int,默认值 0):模型的订单插入延迟(纳秒)。
  • update_latency_nanos (int, default 0): The order update latency (nanoseconds) for the model. update_latency_nanos (int,默认值 0):模型的订单更新延迟(纳秒)。
  • cancel_latency_nanos (int, default 0): The order cancel latency (nanoseconds) for the model. cancel_latency_nanos (int,默认值 0):模型的订单取消延迟(纳秒)。

Raises:

  • ValueError: If base_latency_nanos is negative (< 0). ValueError:如果 base_latency_nanos 为负数(< 0)。
  • ValueError: If insert_latency_nanos is negative (< 0). ValueError:如果 insert_latency_nanos 为负数(< 0)。
  • ValueError: If update_latency_nanos is negative (< 0). ValueError:如果 update_latency_nanos 为负数(< 0)。
  • ValueError: If cancel_latency_nanos is negative (< 0). ValueError:如果 cancel_latency_nanos 为负数(< 0)。
@property
def base_latency_nanos(self) -> int:
    """
    The default latency to the exchange.
    # 与交易所的默认延迟。

    Returns
    -------
    int

    """
    ...

@property
def cancel_latency_nanos(self) -> int:
    """
    The latency (nanoseconds) for order cancel messages to reach the exchange.
    # 订单取消消息到达交易所的延迟(纳秒)。

    Returns
    -------
    int

    """
    ...

@property
def insert_latency_nanos(self) -> int:
    """
    The latency (nanoseconds) for order insert messages to reach the exchange.
    # 订单插入消息到达交易所的延迟(纳秒)。

    Returns
    -------
    int

    """
    ...

@property
def update_latency_nanos(self) -> int:
    """
    The latency (nanoseconds) for order update messages to reach the exchange.
    # 订单更新消息到达交易所的延迟(纳秒)。

    Returns
    -------
    int

    """
    ...

class MakerTakerFeeModel 做市商/吃单者费用模型

class MakerTakerFeeModel(FeeModel)

Provide a fee model for trades based on a maker/taker fee schedule and notional value of the trade.

提供基于做市商/吃单者费用计划和交易名义价值的交易费用模型。

def get_commission(self, order: Order, fill_qty: Quantity, fill_px: Price, instrument: Instrument) -> Money:
    ...

class FXRolloverInterestModule 外汇隔夜利息模块

class FXRolloverInterestModule(SimulationModule)

Provides an FX rollover interest simulation module.

提供外汇隔夜利息模拟模块。

Parameters:

  • config (FXRolloverInterestConfig) config (FXRolloverInterestConfig)
def __init__(self, config: FXRolloverInterestConfig):
    """
    Provides an FX rollover interest simulation module.

    Parameters
    ----------
    config : FXRolloverInterestConfig

    """
    ...

def active_task_ids(self) -> list:
    """
    Return the active task identifiers.

    Returns
    -------
    list[TaskId]

    """
    ...

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

    Parameters
    ----------
    synthetic : SyntheticInstrument
        The synthetic instrument to add to the cache.
        # 要添加到缓存的合成Instrument。

    Raises
    ------
    KeyError
        If synthetic is already in the cache.

    """
    ...

@property
def cache(self) -> CacheFacade:
    """
    The read-only cache for the actor.

    Returns
    -------
    CacheFacade

    """
    ...

def cancel_all_tasks(self) -> void:
    """
    Cancel all queued and active tasks.
    # 取消所有排队的和活动的 tasks。

    """
    ...

def cancel_task(self, task_id: TaskId) -> void:
    """
    Cancel the task with the given task_id (if queued or active).

    If the task is not found then a warning is logged.

    Parameters
    ----------
    task_id : TaskId
        The task identifier.
        # 任务标识符。

    """
    ...

@property
def clock(self) -> Clock:
    """
    The actors clock.

    Returns
    -------
    Clock

    """
    ...

@property
def config(self) -> NautilusConfig:
    """
    The actors configuration.

    Returns
    -------
    NautilusConfig

    """
    ...

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.

    Warnings
    --------
    Do not override.

    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_warning_event(self, event: type) -> void:
    """
    Deregister the given event type from warning log levels.

    Parameters
    ----------
    event : type
        The event class to deregister.
        # 要取消注册的事件类。

    """
    ...

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.

    Warnings
    --------
    Do not override.

    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 exchange(self):
    ...

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.

    Warnings
    --------
    Do not override.

    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.

    Returns
    -------
    str

    """
    ...

def handle_bar(self, bar: Bar) -> void:
    """
    Handle the given bar data.

    If state is RUNNING then passes to on_bar.

    Parameters
    ----------
    bar : Bar
        The bar received.
        # 收到的K线。

    """
    ...

def handle_bars(self, bars: list) -> void:
    """
    Handle the given historical bar data by handling each bar individually.

    Parameters
    ----------
    bars : list[Bar]
        The bars to handle.
        # 要处理的K线。

    """
    ...

def handle_data(self, data: Data) -> void:
    """
    Handle the given data.

    If state is RUNNING then passes to on_data.

    Parameters
    ----------
    data : Data
        The data received.
        # 收到的数据。

    """
    ...

def handle_event(self, event: Event) -> void:
    """
    Handle the given event.

    If state is RUNNING then passes to on_event.

    Parameters
    ----------
    event : Event
        The event received.
        # 收到的事件。

    """
    ...

def handle_historical_data(self, data: Data) -> void:
    """
    Handle the given historical data.

    Parameters
    ----------
    data : Data
        The historical data received.
        # 收到的历史数据。

    """
    ...

def handle_instrument(self, instrument: Instrument) -> void:
    """
    Handle the given instrument.

    Passes to on_instrument if state is RUNNING.

    Parameters
    ----------
    instrument : Instrument
        The instrument received.
        # 收到的Instrument。

    """
    ...

def handle_instrument_close(self, update: InstrumentClose) -> void:
    """
    Handle the given instrument close update.

    If state is RUNNING then passes to on_instrument_close.

    Parameters
    ----------
    update : InstrumentClose
        The update received.
        # 收到的更新。

    """
    ...

def handle_instrument_status(self, data: InstrumentStatus) -> void:
    """
    Handle the given instrument status update.

    If state is RUNNING then passes to on_instrument_status.

    Parameters
    ----------
    data : InstrumentStatus
        The status update received.
        # 收到的状态更新。

    """
    ...

def handle_instruments(self, instruments: list) -> void:
    """
    Handle the given instruments data by handling each instrument individually.

    Parameters
    ----------
    instruments : list[Instrument]
        The instruments received.
        # 收到的Instrument。

    """
    ...

def handle_order_book(self, order_book: OrderBook) -> void:
    """
    Handle the given order book.

    Passes to on_order_book if state is RUNNING.

    Parameters
    ----------
    order_book : OrderBook
        The order book received.
        # 收到的订单簿。

    """
    ...

def handle_order_book_deltas(self, deltas) -> void:
    """
    Handle the given order book deltas.

    Passes to on_order_book_deltas if state is RUNNING. The deltas will be
    nautilus_pyo3.OrderBookDeltas if the pyo3_conversion flag was set for the subscription.

    Parameters
    ----------
    deltas : OrderBookDeltas or nautilus_pyo3.OrderBookDeltas
        The order book deltas received.
        # 收到的订单簿增量。

    """
    ...

def handle_quote_tick(self, tick: QuoteTick) -> void:
    """
    Handle the given quote tick.

    If state is RUNNING then passes to on_quote_tick.

    Parameters
    ----------
    tick : QuoteTick
        The tick received.
        # 收到的报价。

    """
    ...

def handle_quote_ticks(self, ticks: list) -> void:
    """
    Handle the given historical quote tick data by handling each tick individually.

    Parameters
    ----------
    ticks : list[QuoteTick]
        The ticks received.
        # 收到的报价。

    """
    ...

def handle_trade_tick(self, tick: TradeTick) -> void:
    """
    Handle the given trade tick.

    If state is RUNNING then passes to on_trade_tick.

    Parameters
    ----------
    tick : TradeTick
        The tick received.
        # 收到的交易。

    """
    ...

def handle_trade_ticks(self, ticks: list) -> void:
    """
    Handle the given historical trade tick data by handling each tick individually.

    Parameters
    ----------
    ticks : list[TradeTick]
        The ticks received.
        # 收到的交易。

    """
    ...

def has_active_tasks(self) -> bool:
    """
    Return a value indicating whether there are any active tasks.

    Returns
    -------
    bool

    """
    ...

def has_any_tasks(self) -> bool:
    """
    Return a value indicating whether there are any queued or active tasks.

    Returns
    -------
    bool

    """
    ...

def has_pending_requests(self) -> bool:
    """
    Return whether the actor is pending processing for any requests.

    Returns
    -------
    bool
        True if any requests are pending, else False.
        # 如果有任何请求正在等待处理,则为 True,否则为 False。

    """
    ...

def has_queued_tasks(self) -> bool:
    """
    Return a value indicating whether there are any queued tasks.

    Returns
    -------
    bool

    """
    ...

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

    Returns
    -------
    ComponentId

    """
    ...

def indicators_initialized(self) -> bool:
    """
    Return a value indicating whether all indicators are initialized.

    Returns
    -------
    bool
        True if all initialized, else False
        # 如果全部初始化,则为 True,否则为 False

    """
    ...

@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

    """
    ...

def is_pending_request(self, request_id: UUID4) -> bool:
    """
    Return whether the request for the given identifier is pending processing.

    Parameters
    ----------
    request_id : UUID4
        The request ID to check.
        # 要检查的请求 ID。

    Returns
    -------
    bool
        True if request is pending, else False.
        # 如果请求正在等待处理,则为 True,否则为 False。

    """
    ...

@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 load(self, state: dict) -> void:
    """
    Load the actor/strategy state from the give state dictionary.

    Calls on_load and passes the state.

    Parameters
    ----------
    state : dict[*str, object]
        The state dictionary.
        # 状态字典。

    Raises
    ------
    RuntimeError
        If actor/strategy is not registered with a trader.

    """
    ...

@property
def log(self) -> Logger:
    """
    The actors logger.

    Returns
    -------
    Logger

    """
    ...

def log_diagnostics(self, logger: Logger) -> void:
    """
    Log diagnostics out to the BacktestEngine logger.

    Parameters
    ----------
    logger : Logger
        The logger to log to.
        # 要记录到的记录器。

    """
    ...

@property
def msgbus(self) -> MessageBus | None:
    """
    The message bus for the actor (if registered).

    Returns
    -------
    MessageBus or None

    """
    ...

def on_bar(self, bar: Bar) -> void:
    """
    Actions to be performed when running and receives a bar.

    Parameters
    ----------
    bar : Bar
        The bar received.
        # 收到的K线。

    """
    ...

def on_data(self, data) -> void:
    """
    Actions to be performed when running and receives data.

    Parameters
    ----------
    data : Data
        The data received.
        # 收到的数据。

    """
    ...

def on_degrade(self) -> void:
    """
    Actions to be performed on degrade.

    """
    ...

def on_dispose(self) -> void:
    """
    Actions to be performed on dispose.

    Cleanup/release any resources used here.
    # 在此处清理/释放任何使用的资源。

    """
    ...

def on_event(self, event: Event) -> void:
    """
    Actions to be performed running and receives an event.

    Parameters
    ----------
    event : Event
        The event received.
        # 收到的事件。

    """
    ...

def on_fault(self) -> void:
    """
    Actions to be performed on fault.

    Cleanup any resources used by the actor here.
    # 在此处清理参与者使用的任何资源。

    """
    ...

def on_historical_data(self, data) -> void:
    """
    Actions to be performed when running and receives historical data.

    Parameters
    ----------
    data : Data
        The historical data received.
        # 收到的历史数据。

    """
    ...

def on_instrument(self, instrument: Instrument) -> void:
    """
    Actions to be performed when running and receives an instrument.

    Parameters
    ----------
    instrument : Instrument
        The instrument received.
        # 收到的Instrument。

    """
    ...

def on_instrument_close(self, update: InstrumentClose) -> void:
    """
    Actions to be performed when running and receives an instrument close update.

    Parameters
    ----------
    update : InstrumentClose
        The instrument close received.
        # 收到的Instrument收盘价。

    """
    ...

def on_instrument_status(self, data: InstrumentStatus) -> void:
    """
    Actions to be performed when running and receives an instrument status update.

    Parameters
    ----------
    data : InstrumentStatus
        The instrument status update received.
        # 收到的Instrument状态更新。

    """
    ...

def on_load(self, state: dict) -> void:
    """
    Actions to be performed when the actor state is loaded.

    Saved state values will be contained in the give state dictionary.
    # 加载参与者状态时要执行的操作。

    # 保存的状态值将包含在给定的状态字典中。

    """
    ...

def on_order_book(self, order_book: OrderBook) -> void:
    """
    Actions to be performed when running and receives an order book.

    Parameters
    ----------
    order_book : OrderBook
        The order book received.
        # 收到的订单簿。

    """
    ...

def on_order_book_deltas(self, deltas) -> void:
    """
    Actions to be performed when running and receives order book deltas.

    Parameters
    ----------
    deltas : OrderBookDeltas or nautilus_pyo3.OrderBookDeltas
        The order book deltas received.
        # 收到的订单簿增量。

    """
    ...

def on_quote_tick(self, tick: QuoteTick) -> void:
    """
    Actions to be performed when running and receives a quote tick.

    Parameters
    ----------
    tick : QuoteTick
        The tick received.
        # 收到的报价。

    """
    ...

def on_reset(self) -> void:
    """
    Actions to be performed on reset.
    # 重置时要执行的操作。

    """
    ...

def on_resume(self) -> void:
    """
    Actions to be performed on resume.
    # 恢复时要执行的操作。

    """
    ...

def on_save(self) -> dict:
    """
    Actions to be performed when the actor state is saved.

    Create and return a state dictionary of values to be saved.

    Returns
    -------
    dict[str, bytes]
        The strategy state dictionary.
        # 策略状态字典。

    """
    ...

def on_start(self) -> void:
    """
    Actions to be performed on start.

    The intent is that this method is called once per trading ‘run’, when initially starting.

    It is recommended to subscribe/request for data here.
    # 启动时要执行的操作。

    # 目的是在每次交易“运行”开始时调用此方法一次。

    # 建议在此处订阅/请求数据。

    """
    ...

def on_stop(self) -> void:
    """
    Actions to be performed on stop.

    The intent is that this method is called to pause, or when done for day.
    # 停止时要执行的操作。

    # 目的是在暂停或当天完成时调用此方法。

    """
    ...

def on_trade_tick(self, tick: TradeTick) -> void:
    """
    Actions to be performed when running and receives a trade tick.

    Parameters
    ----------
    tick : TradeTick
        The tick received.
        # 收到的交易。

    """
    ...

def pending_requests(self) -> set:
    """
    Return the request IDs which are currently pending processing.

    Returns
    -------
    set[UUID4]

    """
    ...

@property
def portfolio(self) -> PortfolioFacade:
    """
    The read-only portfolio for the actor.

    Returns
    -------
    PortfolioFacade

    """
    ...

def pre_process(self, data: Data) -> void:
    """
    Abstract method pre_process (implement in subclass).
    # 抽象方法 pre_process(在子类中实现)。

    """
    ...

def process(self, ts_now: int) -> void:
    """
    Process the given tick through the module.

    Parameters
    ----------
    ts_now : uint64_t
        The current UNIX time (nanoseconds) in the simulated exchange.
        # 模拟交易所中的当前 UNIX 时间(纳秒)。

    """
    ...

def publish_data(self, data_type: DataType, data: Data) -> void:
    """
    Publish the given data to the message bus.

    Parameters
    ----------
    data_type : DataType
        The data type being published.
        # 正在发布的数据类型。
    data : Data
        The data to publish.
        # 要发布的数据。

    """
    ...

def publish_signal(self, name: str, value, ts_event: int = 0) -> void:
    """
    Publish the given value as a signal to the message bus.

    Parameters
    ----------
    name : str
        The name of the signal being published. The signal name is case-insensitive
        and will be capitalized (e.g., ‘example’ becomes ‘SignalExample’).
        # 正在发布的信号的名称。信号名称不区分大小写,并将大写(例如,“example”变为“SignalExample”)。
    value : object
        The signal data to publish.
        # 要发布的信号数据。
    ts_event : uint64_t, optional
        UNIX timestamp (nanoseconds) when the signal event occurred. If None then will
        timestamp current time.
        # 信号事件发生时的 UNIX 时间戳(纳秒)。如果为 None,则将使用当前时间的时间戳。

    """
    ...

def queue_for_executor(self, func: Callable[..., Any], args: tuple = None, kwargs: dict = None):
    """
    Queues the callable func to be executed as fn(*args, **kwargs) sequentially.

    Parameters
    ----------
    func : Callable
        The function to be executed.
        # 要执行的函数。
    args : positional arguments
        The positional arguments for the call to func.
        # 调用 func 的位置参数。
    kwargs : arbitrary keyword arguments
        The keyword arguments for the call to func.
        # 调用 func 的关键字参数。

    Raises
    ------
    TypeError
        If func is not of type Callable.

    """
    ...

def queued_task_ids(self) -> list:
    """
    Return the queued task identifiers.

    Returns
    -------
    list[TaskId]

    """
    ...

def register_base(self, portfolio: PortfolioFacade, msgbus: MessageBus, cache: CacheFacade, clock: Clock) -> void:
    """
    Register with a trader.

    Parameters
    ----------
    portfolio : PortfolioFacade
        The read-only portfolio for the actor.
        # 参与者的只读投资组合。
    msgbus : MessageBus
        The message bus for the actor.
        # 参与者的消息总线。
    cache : CacheFacade
        The read-only cache for the actor.
        # 参与者的只读缓存。
    clock : Clock
        The clock for the actor.
        # 参与者的时钟。

    """
    ...

def register_executor(self, loop: AbstractEventLoop, executor: Executor) -> void:
    """
    Register the given Executor for the actor.

    Parameters
    ----------
    loop : asyncio.AsbtractEventLoop
        The event loop of the application.
        # 应用程序的事件循环。
    executor : concurrent.futures.Executor
        The executor to register.
        # 要注册的执行器。

    Raises
    ------
    TypeError
        If executor is not of type concurrent.futures.Executor

    """
    ...

def register_indicator_for_bars(self, bar_type: BarType, indicator: Indicator) -> void:
    """
    Register the given indicator with the actor/strategy to receive bar data for the given bar type.

    Parameters
    ----------
    bar_type : BarType
        The bar type for bar updates.
        # K线更新的K线类型。
    indicator : Indicator
        The indicator to register.
        # 要注册的指标。

    """
    ...

def register_indicator_for_quote_ticks(self, instrument_id: InstrumentId, indicator: Indicator) -> void:
    """
    Register the given indicator with the actor/strategy to receive quote tick data for the given instrument ID.

    Parameters
    ----------
    instrument_id : InstrumentId
        The instrument ID for tick updates.
        # 报价更新的Instrument ID。
    indicator : Indicator
        The indicator to register.
        # 要注册的指标。

    """
    ...

def register_indicator_for_trade_ticks(self, instrument_id: InstrumentId, indicator: Indicator) -> void:
    """
    Register the given indicator with the actor/strategy to receive trade tick data for the given instrument ID.

    Parameters
    ----------
    instrument_id : InstrumentId
        The instrument ID for tick updates.
        # 交易更新的Instrument ID。
    indicator : indicator
        The indicator to register.
        # 要注册的指标。

    """
    ...

def register_venue(self, exchange: SimulatedExchange) -> void:
    """
    Register the given simulated exchange with the module.

    Parameters
    ----------
    exchange : SimulatedExchange
        The exchange to register.
        # 要注册的交易所。

    """
    ...

def register_warning_event(self, event: type) -> void:
    """
    Register the given event type for warning log levels.

    Parameters
    ----------
    event : type
        The event class to register.
        # 要注册的事件类。

    """
    ...

@property
def registered_indicators(self) -> list[Indicator]:
    """
    Return the registered indicators for the strategy.

    Returns
    -------
    list[Indicator]

    """
    ...

def request_bars(self, bar_type: BarType, start: datetime = None, end: datetime = None, client_id: ClientId = None, callback: Callable[[UUID4], None] | None = None) -> UUID4:
    """
    Request historical Bar data.

    If end is None then will request up to the most recent data.

    Parameters
    ----------
    bar_type : BarType
        The bar type for the request.
        # 请求的K线类型。
    start : datetime, optional
        The start datetime (UTC) of request time range (inclusive).
        # 请求时间范围的开始日期时间(UTC)(包括)。
    end : datetime, optional
        The end datetime (UTC) of request time range. The inclusiveness depends on
        individual data client implementation.
        # 请求时间范围的结束日期时间(UTC)。包含性取决于各个数据客户端的实现。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from
        the venue in the instrument ID.
        # 命令的特定客户端 ID。如果为 None,则将从Instrument ID 中的交易平台推断。
    callback : Callable[[UUID4], None], optional
        The registered callback, to be called with the request ID when the response
        has completed processing.
        # 已注册的回调,在响应完成处理时将使用请求 ID 调用。

    Returns
    -------
    UUID4
        The request_id for the request.
        # 请求的 request_id。

    Raises
    ------
    ValueError
        If start and end are not None and start is >= end.
    TypeError
        If callback is not None and not of type Callable.

    """
    ...

def request_data(self, data_type: DataType, client_id: ClientId, callback: Callable[[UUID4], None] | None = None) -> UUID4:
    """
    Request custom data for the given data type from the given data client.

    Parameters
    ----------
    data_type : DataType
        The data type for the request.
        # 请求的数据类型。
    client_id : ClientId
        The data client ID.
        # 数据客户端 ID。
    callback : Callable[[UUID4], None], optional
        The registered callback, to be called with the request ID when the response
        has completed processing.
        # 已注册的回调,在响应完成处理时将使用请求 ID 调用。

    Returns
    -------
    UUID4
        The request_id for the request.
        # 请求的 request_id。

    Raises
    ------
    TypeError
        If callback is not None and not of type Callable.

    """
    ...

def request_instrument(self, instrument_id: InstrumentId, start: datetime = None, end: datetime = None, client_id: ClientId = None, callback: Callable[[UUID4], None] | None = None) -> UUID4:
    """
    Request Instrument data for the given instrument ID.

    If end is None then will request up to the most recent data.

    Parameters
    ----------
    instrument_id : InstrumentId
        The instrument ID for the request.
        # 请求的Instrument ID。
    start : datetime, optional
        The start datetime (UTC) of request time range (inclusive).
        # 请求时间范围的开始日期时间(UTC)(包括)。
    end : datetime, optional
        The end datetime (UTC) of request time range. The inclusiveness depends on
        individual data client implementation.
        # 请求时间范围的结束日期时间(UTC)。包含性取决于各个数据客户端的实现。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from
        the venue in the instrument ID.
        # 命令的特定客户端 ID。如果为 None,则将从Instrument ID 中的交易平台推断。
    callback : Callable[[UUID4], None], optional
        The registered callback, to be called with the request ID when the response
        has completed processing.
        # 已注册的回调,在响应完成处理时将使用请求 ID 调用。

    Returns
    -------
    UUID4
        The request_id for the request.
        # 请求的 request_id。

    Raises
    ------
    ValueError
        If start and end are not None and start is >= end.
    TypeError
        If callback is not None and not of type Callable.

    """
    ...

def request_instruments(self, venue: Venue, start: datetime = None, end: datetime = None, client_id: ClientId = None, callback: Callable[[UUID4], None] | None = None) -> UUID4:
    """
    Request all Instrument data for the given venue.

    If end is None then will request up to the most recent data.

    Parameters
    ----------
    venue : Venue
        The venue for the request.
        # 请求的交易平台。
    start : datetime, optional
        The start datetime (UTC) of request time range (inclusive).
        # 请求时间范围的开始日期时间(UTC)(包括)。
    end : datetime, optional
        The end datetime (UTC) of request time range. The inclusiveness depends on
        individual data client implementation.
        # 请求时间范围的结束日期时间(UTC)。包含性取决于各个数据客户端的实现。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from
        the venue in the instrument ID.
        # 命令的特定客户端 ID。如果为 None,则将从Instrument ID 中的交易平台推断。
    callback : Callable[[UUID4], None], optional
        The registered callback, to be called with the request ID when the response
        has completed processing.
        # 已注册的回调,在响应完成处理时将使用请求 ID 调用。

    Returns
    -------
    UUID4
        The request_id for the request.
        # 请求的 request_id。

    Raises
    ------
    ValueError
        If start and end are not None and start is >= end.
    TypeError
        If callback is not None and not of type Callable.

    """
    ...

def request_order_book_snapshot(self, instrument_id: InstrumentId, limit: int, client_id: ClientId = None, callback: Callable[[UUID4], None] | None = None) -> UUID4:
    """
    Request an order book snapshot.

    Parameters
    ----------
    instrument_id : InstrumentId
        The instrument ID for the order book snapshot request.
        # 订单簿快照请求的Instrument ID。
    limit : int, optional
        The limit on the depth of the order book snapshot (default is None).
        # 订单簿快照的深度限制(默认值为 None)。
    client_id : ClientId, optional
        The specific client ID for the command. If None, it will be inferred from the venue in the instrument ID.
        # 命令的特定客户端 ID。如果为 None,则将从Instrument ID 中的交易平台推断。
    callback : Callable[[UUID4], None], optional
        The registered callback, to be called with the request ID when the response
        has completed processing.
        # 已注册的回调,在响应完成处理时将使用请求 ID 调用。

    Returns
    -------
    UUID4
        The request_id for the request.
        # 请求的 request_id。

    Raises
    ------
    ValueError
        If the instrument_id is None.
    TypeError
        If callback is not None and not of type Callable.

    """
    ...

def request_quote_ticks(self, instrument_id: InstrumentId, start: datetime = None, end: datetime = None, client_id: ClientId = None, callback: Callable[[UUID4], None] | None = None) -> UUID4:
    """
    Request historical QuoteTick data.

    If end is None then will request up to the most recent data.

    Parameters
    ----------
    instrument_id : InstrumentId
        The tick instrument ID for the request.
        # 请求的报价Instrument ID。
    start : datetime, optional
        The start datetime (UTC) of request time range (inclusive).
        # 请求时间范围的开始日期时间(UTC)(包括)。
    end : datetime, optional
        The end datetime (UTC) of request time range. The inclusiveness depends on
        individual data client implementation.
        # 请求时间范围的结束日期时间(UTC)。包含性取决于各个数据客户端的实现。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from
        the venue in the instrument ID.
        # 命令的特定客户端 ID。如果为 None,则将从Instrument ID 中的交易平台推断。
    callback : Callable[[UUID4], None], optional
        The registered callback, to be called with the request ID when the response
        has completed processing.
        # 已注册的回调,在响应完成处理时将使用请求 ID 调用。

    Returns
    -------
    UUID4
        The request_id for the request.
        # 请求的 request_id。

    Raises
    ------
    ValueError
        If start and end are not None and start is >= end.
    TypeError
        If callback is not None and not of type Callable.

    """
    ...

```python
def request_trade_ticks(
    self,
    instrument_id: InstrumentId,
    start: datetime = None,
    end: datetime = None,
    client_id: ClientId = None,
    callback: Callable[[UUID4], None] | None = None,
) -> UUID4:
    """
    Request historical TradeTick data.

    If end is None then will request up to the most recent data.

    Parameters
    ----------
    instrument_id : InstrumentId
        The tick instrument ID for the request.
        # 请求的交易Instrument ID。
    start : datetime, optional
        The start datetime (UTC) of request time range (inclusive).
        # 请求时间范围的开始日期时间(UTC)(包括)。
    end : datetime, optional
        The end datetime (UTC) of request time range. The inclusiveness depends on
        individual data client implementation.
        # 请求时间范围的结束日期时间(UTC)。包含性取决于各个数据客户端的实现。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from
        the venue in the instrument ID.
        # 命令的特定客户端 ID。如果为 None,则将从Instrument ID 中的交易平台推断。
    callback : Callable[[UUID4], None], optional
        The registered callback, to be called with the request ID when the response
        has completed processing.
        # 已注册的回调,在响应完成处理时将使用请求 ID 调用。

    Returns
    -------
    UUID4
        The request_id for the request.
        # 请求的 request_id。

    Raises
    ------
    ValueError
        If start and end are not None and start is >= end.
    TypeError
        If callback is not None and not of type Callable.

    """
    ...

def reset(self) -> void:
    ...

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.

    Warnings
    --------
    Do not override.

    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 run_in_executor(self, func: Callable[..., Any], args: tuple = None, kwargs: dict = None) -> TaskId:
    """
    Schedules the callable func to be executed as fn(*args, **kwargs).

    Parameters
    ----------
    func : Callable
        The function to be executed.
        # 要执行的函数。
    args : positional arguments
        The positional arguments for the call to func.
        # 调用 func 的位置参数。
    kwargs : arbitrary keyword arguments
        The keyword arguments for the call to func.
        # 调用 func 的关键字参数。

    Returns
    -------
    TaskId
        The unique task identifier for the execution. This also corresponds to any future objects memory address.
        # 执行的唯一任务标识符。这也对应于任何 future 对象的内存地址。

    Raises
    ------
    TypeError
        If func is not of type Callable.

    """
    ...

def save(self) -> dict:
    """
    Return the actor/strategy state dictionary to be saved.

    Calls on_save.

    Raises
    ------
    RuntimeError
        If actor/strategy is not registered with a trader.

    """
    ...

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.

    Warnings
    --------
    Do not override.

    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.
    # 返回组件的当前状态。

    Returns
    -------
    ComponentState

    """
    ...

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.

    Warnings
    --------
    Do not override.

    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 subscribe_bars(self, bar_type: BarType, client_id: ClientId = None, await_partial: bool = False) -> void:
    """
    Subscribe to streaming Bar data for the given bar type.

    Parameters
    ----------
    bar_type : BarType
        The bar type to subscribe to.
        # 要订阅的K线类型。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from
        the venue in the instrument ID.
        # 命令的特定客户端 ID。如果为 None,则将从Instrument ID 中的交易平台推断。
    await_partial : bool, default False
        If the bar aggregator should await the arrival of a historical partial bar
        prior to actively aggregating new bars.
        # 是否应等待历史部分K线到达,然后再主动聚合新的K线。

    """
    ...

def subscribe_data(self, data_type: DataType, client_id: ClientId = None) -> void:
    """
    Subscribe to data of the given data type.

    Parameters
    ----------
    data_type : DataType
        The data type to subscribe to.
        # 要订阅的数据类型。
    client_id : ClientId, optional
        The data client ID. If supplied then a Subscribe command will be sent to the corresponding data client.
        # 数据客户端 ID。如果提供,则 Subscribe 命令将发送到相应的数据客户端。

    """
    ...

def subscribe_instrument(self, instrument_id: InstrumentId, client_id: ClientId = None) -> void:
    """
    Subscribe to update Instrument data for the given instrument ID.

    Parameters
    ----------
    instrument_id : InstrumentId
        The instrument ID for the subscription.
        # 订阅的Instrument ID。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from
        the venue in the instrument ID.
        # 命令的特定客户端 ID。如果为 None,则将从Instrument ID 中的交易平台推断。

    """
    ...

def subscribe_instrument_close(self, instrument_id: InstrumentId, client_id: ClientId = None) -> void:
    """
    Subscribe to close updates for the given instrument ID.

    Parameters
    ----------
    instrument_id : InstrumentId
        The instrument to subscribe to status updates for.
        # 要订阅状态更新的Instrument。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from
        the venue in the instrument ID.
        # 命令的特定客户端 ID。如果为 None,则将从Instrument ID 中的交易平台推断。

    """
    ...

def subscribe_instrument_status(self, instrument_id: InstrumentId, client_id: ClientId = None) -> void:
    """
    Subscribe to status updates for the given instrument ID.

    Parameters
    ----------
    instrument_id : InstrumentId
        The instrument to subscribe to status updates for.
        # 要订阅状态更新的Instrument。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from
        the venue in the instrument ID.
        # 命令的特定客户端 ID。如果为 None,则将从Instrument ID 中的交易平台推断。

    """
    ...

def subscribe_instruments(self, venue: Venue, client_id: ClientId = None) -> void:
    """
    Subscribe to update Instrument data for the given venue.

    Parameters
    ----------
    venue : Venue
        The venue for the subscription.
        # 订阅的交易平台。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from the venue.
        # 命令的特定客户端 ID。如果为 None,则将从交易平台推断。

    """
    ...

def subscribe_order_book_at_interval(
    self,
    instrument_id: InstrumentId,
    book_type: BookType = BookType.L2_MBP,
    depth: int = 0,
    interval_ms: int = 1000,
    kwargs: dict = None,
    client_id: ClientId = None,
    managed: bool = True,
) -> void:
    """
    Subscribe to an OrderBook at a specified interval for the given instrument ID.

    The DataEngine will only maintain one order book for each instrument. Because of this - the level,
    depth and kwargs for the stream will be set as per the last subscription request (this will also affect
    all subscribers).

    Parameters
    ----------
    instrument_id : InstrumentId
        The order book instrument ID to subscribe to.
        # 要订阅的订单簿Instrument ID。
    book_type : BookType {L1_MBP, L2_MBP, L3_MBO}
        The order book type.
        # 订单簿类型。
    depth : int, optional
        The maximum depth for the order book. A depth of 0 is maximum depth.
        # 订单簿的最大深度。深度为 0 表示最大深度。
    interval_ms : int
        The order book snapshot interval in milliseconds (must be positive).
        # 订单簿快照间隔(以毫秒为单位)(必须为正数)。
    kwargs : dict, optional
        The keyword arguments for exchange specific parameters.
        # 交易所特定参数的关键字参数。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from
        the venue in the instrument ID.
        # 命令的特定客户端 ID。如果为 None,则将从Instrument ID 中的交易平台推断。
    managed : bool, default True
        If an order book should be managed by the data engine based on the subscribed feed.
        # 订单簿是否应由数据引擎根据订阅的馈送进行管理。

    Raises
    ------
    ValueError
        If depth is negative (< 0).
    ValueError
        If interval_ms is not positive (> 0).

    Warnings
    --------
    Consider subscribing to order book deltas if you need intervals less than 100 milliseconds.
    # 如果您需要小于 100 毫秒的间隔,请考虑订阅订单簿增量。

    """
    ...

def subscribe_order_book_deltas(
    self,
    instrument_id: InstrumentId,
    book_type: BookType = BookType.L2_MBP,
    depth: int = 0,
    kwargs: dict = None,
    client_id: ClientId = None,
    managed: bool = True,
    pyo3_conversion: bool = False,
) -> void:
    """
    Subscribe to the order book data stream, being a snapshot then deltas for the given instrument ID.

    Parameters
    ----------
    instrument_id : InstrumentId
        The order book instrument ID to subscribe to.
        # 要订阅的订单簿Instrument ID。
    book_type : BookType {L1_MBP, L2_MBP, L3_MBO}
        The order book type.
        # 订单簿类型。
    depth : int, optional
        The maximum depth for the order book. A depth of 0 is maximum depth.
        # 订单簿的最大深度。深度为 0 表示最大深度。
    kwargs : dict, optional
        The keyword arguments for exchange specific parameters.
        # 交易所特定参数的关键字参数。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from
        the venue in the instrument ID.
        # 命令的特定客户端 ID。如果为 None,则将从Instrument ID 中的交易平台推断。
    managed : bool, default True
        If an order book should be managed by the data engine based on the subscribed feed.
        # 订单簿是否应由数据引擎根据订阅的馈送进行管理。
    pyo3_conversion : bool, default False
        If received deltas should be converted to nautilus_pyo3.OrderBookDeltas prior to being
        passed to the on_order_book_deltas handler.
        # 是否应在传递给 on_order_book_deltas 处理程序之前将接收到的增量转换为
        # nautilus_pyo3.OrderBookDeltas。

    """
    ...

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

    Parameters
    ----------
    instrument_id : InstrumentId
        The tick instrument to subscribe to.
        # 要订阅的报价Instrument。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from
        the venue in the instrument ID.
        # 命令的特定客户端 ID。如果为 None,则将从Instrument ID 中的交易平台推断。

    """
    ...

def subscribe_signal(self, name: str = "") -> void:
    """
    Subscribe to a specific signal by name, or to all signals if no name is provided.

    Parameters
    ----------
    name : str, optional
        The name of the signal to subscribe to. If not provided or an empty string is passed,
        the subscription will include all signals. The signal name is case-insensitive
        and will be capitalized (e.g., ‘example’ becomes ‘SignalExample*’).
        # 要订阅的信号的名称。如果未提供名称或传递空字符串,则订阅将包括所有信号。
        # 信号名称不区分大小写,并将大写(例如,“example”变为“SignalExample*”)。

    """
    ...

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

    Parameters
    ----------
    instrument_id : InstrumentId
        The tick instrument to subscribe to.
        # 要订阅的交易Instrument。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from
        the venue in the instrument ID.
        # 命令的特定客户端 ID。如果为 None,则将从Instrument ID 中的交易平台推断。

    """
    ...

def to_importable_config(self) -> ImportableActorConfig:
    """
    Returns an importable configuration for this actor.

    Returns
    -------
    ImportableActorConfig

    """
    ...

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

    Returns
    -------
    TraderId

    """
    ...

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

    Returns
    -------
    type

    """
    ...

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

    Parameters
    ----------
    bar_type : BarType
        The bar type to unsubscribe from.
        # 要取消订阅的K线类型。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from
        the venue in the instrument ID.
        # 命令的特定客户端 ID。如果为 None,则将从Instrument ID 中的交易平台推断。

    """
    ...

def unsubscribe_data(self, data_type: DataType, client_id: ClientId = None) -> void:
    """
    Unsubscribe from data of the given data type.

    Parameters
    ----------
    data_type : DataType
        The data type to unsubscribe from.
        # 要取消订阅的数据类型。
    client_id : ClientId, optional
        The data client ID. If supplied then an Unsubscribe command will be sent to the data client.
        # 数据客户端 ID。如果提供,则 Unsubscribe 命令将发送到数据客户端。

    """
    ...

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

    Parameters
    ----------
    instrument_id : InstrumentId
        The instrument to unsubscribe from.
        # 要取消订阅的Instrument。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from
        the venue in the instrument ID.
        # 命令的特定客户端 ID。如果为 None,则将从Instrument ID 中的交易平台推断。

    """
    ...

def unsubscribe_instrument_status(self, instrument_id: InstrumentId, client_id: ClientId = None) -> void:
    """
    Unsubscribe to status updates of the given venue.

    Parameters
    ----------
    instrument_id : InstrumentId
        The instrument to unsubscribe to status updates for.
        # 要取消订阅状态更新的Instrument。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from the venue.
        # 命令的特定客户端 ID。如果为 None,则将从交易平台推断。

    """
    ...

def unsubscribe_instruments(self, venue: Venue, client_id: ClientId = None) -> void:
    """
    Unsubscribe from update Instrument data for the given venue.

    Parameters
    ----------
    venue : Venue
        The venue for the subscription.
        # 订阅的交易平台。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from the venue.
        # 命令的特定客户端 ID。如果为 None,则将从交易平台推断。

    """
    ...

def unsubscribe_order_book_at_interval(self, instrument_id: InstrumentId, interval_ms: int = 1000, client_id: ClientId = None) -> void:
    """
    Unsubscribe from an OrderBook at a specified interval for the given instrument ID.

    The interval must match the previously subscribed interval.

    Parameters
    ----------
    instrument_id : InstrumentId
        The order book instrument to subscribe to.
        # 要订阅的订单簿Instrument。
    interval_ms : int
        The order book snapshot interval in milliseconds.
        # 订单簿快照间隔(以毫秒为单位)。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from
        the venue in the instrument ID.
        # 命令的特定客户端 ID。如果为 None,则将从Instrument ID 中的交易平台推断。

    """
    ...

def unsubscribe_order_book_deltas(self, instrument_id: InstrumentId, client_id: ClientId = None) -> void:
    """
    Unsubscribe the order book deltas stream for the given instrument ID.

    Parameters
    ----------
    instrument_id : InstrumentId
        The order book instrument to subscribe to.
        # 要订阅的订单簿Instrument。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from
        the venue in the instrument ID.
        # 命令的特定客户端 ID。如果为 None,则将从Instrument ID 中的交易平台推断。

    """
    ...

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

    Parameters
    ----------
    instrument_id : InstrumentId
        The tick instrument to unsubscribe from.
        # 要取消订阅的报价Instrument。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from
        the venue in the instrument ID.
        # 命令的特定客户端 ID。如果为 None,则将从Instrument ID 中的交易平台推断。

    """
    ...

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

    Parameters
    ----------
    instrument_id : InstrumentId
        The tick instrument ID to unsubscribe from.
        # 要取消订阅的交易Instrument ID。
    client_id : ClientId, optional
        The specific client ID for the command. If None then will be inferred from
        the venue in the instrument ID.
        # 命令的特定客户端 ID。如果为 None,则将从Instrument ID 中的交易平台推断。

    """
    ...

def update_synthetic(self, synthetic: SyntheticInstrument) -> void:
    """
    Update the synthetic instrument in the cache.

    Parameters
    ----------
    synthetic : SyntheticInstrument
        The synthetic instrument to update in the cache.
        # 要在缓存中更新的合成Instrument。

    Raises
    ------
    KeyError
        If synthetic does not already exist in the cache.

    """
    ...

class SimulationModule 模拟模块类

class SimulationModule(Actor):
    """
    The base class for all simulation modules.

    所有模拟模块的基类。

    Warning:
        This class should not be used directly, but through a concrete subclass.
        此类不应直接使用,而应通过具体的子类使用。
    """
    def __init__(self, config: SimulationModuleConfig):
        ...

Properties 属性

    @property
    def cache(self) :
        """
        The read-only cache for the actor.

        actor 的只读缓存。

        Returns:
            CacheFacade
        """
        ...

    @property
    def clock(self):
        """
        The actors clock.

        actor 的时钟。

        Returns:
            Clock
        """
        ...

    @property
    def config(self):
        """
        The actors configuration.

        actor 的配置。

        Returns:
            NautilusConfig
        """
        ...

    @property
    def exchange(self):
        """
        Returns:
        """
        ...

    @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 log(self) :
        """
        The actors logger.

        actor 的日志记录器。

        Returns:
            Logger
        """
        ...

    @property
    def msgbus(self):
        """
        The message bus for the actor (if registered).

        actor 的消息总线(如果已注册)。

        Returns:
            MessageBus or None
        """
        ...

    @property
    def portfolio(self):
        """
        The read-only portfolio for the actor.

        actor 的只读投资组合。

        Returns:
            PortfolioFacade
        """
        ...

    @property
    def registered_indicators(self):
        """
        Return the registered indicators for the strategy.

        返回策略的已注册指标。

        Return type: list[Indicator]
        """
        ...
    
    @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 active_task_ids(self) -> list:
        """
        Return the active task identifiers.

        返回活动的 task 标识符。

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

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

        将创建的合成金融Instrument添加到缓存中。

        Parameters: synthetic (SyntheticInstrument) – The synthetic instrument to add to the cache.
        参数:synthetic (SyntheticInstrument) - 要添加到缓存中的合成金融Instrument。
        Raises: KeyError – If synthetic is already in the cache.
        引发:KeyError - 如果合成金融Instrument已存在于缓存中。
        """
        ...
    
    def cancel_all_tasks(self) -> void:
        """
        Cancel all queued and active tasks.

        取消所有排队和活动的 task。
        """
        ...
    
    def cancel_task(self, task_id: TaskId) -> void:
        """
        Cancel the task with the given task_id (if queued or active).

        取消具有给定 task_id 的任务(如果已排队或活动)。

        If the task is not found then a warning is logged.

        如果未找到任务,则会记录警告。

        Parameters: task_id (TaskId) – The task identifier.
        参数:task_id (TaskId) – 任务标识符。
        """
        ...
    
    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_warning_event(self,  event) -> void:
        """
        Deregister the given event type from warning log levels.

        从警告日志级别取消注册给定的事件类型。

        Parameters: event (type) – The event class to deregister.
        参数:event (type) - 要取消注册的事件类。
        """
        ...
    
    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 handle_bar(self, bar: Bar) -> void:
        """
        Handle the given bar data.

        处理给定的 bar 数据。

        If state is RUNNING then passes to on_bar.

        如果状态为 RUNNING,则传递给 on_bar。

        Parameters: bar (Bar) – The bar received.
        参数:bar (Bar) - 接收到的 bar。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...
    
    def handle_bars(self, bars: list) -> void:
        """
        Handle the given historical bar data by handling each bar individually.

        通过单独处理每个 bar 来处理给定的历史 bar 数据。

        Parameters: bars (list [Bar ]) – The bars to handle.
        参数:bars (list [Bar ]) - 要处理的 bar。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...
    
    def handle_data(self, data: Data) -> void:
        """
        Handle the given data.

        处理给定的数据。

        If state is RUNNING then passes to on_data.

        如果状态为 RUNNING,则传递给 on_data。

        Parameters: data (Data) – The data received.
        参数:data (Data) - 接收到的数据。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def handle_event(self, event: Event) -> void:
        """
        Handle the given event.

        处理给定的事件。

        If state is RUNNING then passes to on_event.

        如果状态为 RUNNING,则传递给 on_event。

        Parameters: event (Event) – The event received.
        参数:event (Event) - 接收到的事件。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def handle_historical_data(self, data) -> void:
        """
        Handle the given historical data.

        处理给定的历史数据。

        Parameters: data (Data) – The historical data received.
        参数:data (Data) - 接收到的历史数据。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def handle_instrument(self, instrument: Instrument) -> void:
        """
        Handle the given instrument.

        处理给定的金融Instrument。

        Passes to on_instrument if state is RUNNING.

        如果状态为 RUNNING,则传递给 on_instrument。

        Parameters: instrument (Instrument) – The instrument received.
        参数:instrument (Instrument) - 接收到的金融Instrument。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def handle_instrument_close(self, update: InstrumentClose) -> void:
        """
        Handle the given instrument close update.

        处理给定的金融Instrument关闭更新。

        If state is RUNNING then passes to on_instrument_close.

        如果状态为 RUNNING,则传递给 on_instrument_close。

        Parameters: update (InstrumentClose) – The update received.
        参数:update (InstrumentClose) - 接收到的更新。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def handle_instrument_status(self, data: InstrumentStatus) -> void:
        """
        Handle the given instrument status update.

        处理给定的金融Instrument状态更新。

        If state is RUNNING then passes to on_instrument_status.

        如果状态为 RUNNING,则传递给 on_instrument_status。

        Parameters: data (InstrumentStatus) – The status update received.
        参数:data (InstrumentStatus) - 接收到的状态更新。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def handle_instruments(self, instruments: list) -> void:
        """
        Handle the given instruments data by handling each instrument individually.

        通过单独处理每个金融Instrument来处理给定的金融Instrument数据。

        Parameters: instruments (list [Instrument ]) – The instruments received.
        参数:instruments (list [Instrument ]) - 接收到的金融Instrument。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def handle_order_book(self, order_book: OrderBook) -> void:
        """
        Handle the given order book.

        处理给定的订单簿。

        Passes to on_order_book if state is RUNNING.

        如果状态为 RUNNING,则传递给 on_order_book。

        Parameters: order_book (OrderBook) – The order book received.
        参数:order_book (OrderBook) - 接收到的订单簿。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def handle_order_book_deltas(self, deltas) -> void:
        """
        Handle the given order book deltas.

        处理给定的订单簿增量。

        Passes to on_order_book_deltas if state is RUNNING. The deltas will be nautilus_pyo3.OrderBookDeltas if the pyo3_conversion flag was set for the subscription.

        如果状态为 RUNNING,则传递给 on_order_book_deltas。如果为订阅设置了 pyo3_conversion 标志,则增量将为 nautilus_pyo3.OrderBookDeltas。

        Parameters: deltas (OrderBookDeltas or nautilus_pyo3.OrderBookDeltas) – The order book deltas received.
        参数:deltas (OrderBookDeltas or nautilus_pyo3.OrderBookDeltas) - 接收到的订单簿增量。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def handle_quote_tick(self, tick: QuoteTick) -> void:
        """
        Handle the given quote tick.

        处理给定的报价 tick。

        If state is RUNNING then passes to on_quote_tick.

        如果状态为 RUNNING,则传递给 on_quote_tick。

        Parameters: tick (QuoteTick) – The tick received.
        参数:tick (QuoteTick) - 接收到的 tick。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def handle_quote_ticks(self, ticks: list) -> void:
        """
        Handle the given historical quote tick data by handling each tick individually.

        通过单独处理每个 tick 来处理给定的历史报价 tick 数据。

        Parameters: ticks (list [QuoteTick ]) – The ticks received.
        参数:ticks (list [QuoteTick ]) - 接收到的 tick。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def handle_trade_tick(self, tick: TradeTick) -> void:
        """
        Handle the given trade tick.

        处理给定的交易 tick。

        If state is RUNNING then passes to on_trade_tick.

        如果状态为 RUNNING,则传递给 on_trade_tick。

        Parameters: tick (TradeTick) – The tick received.
        参数:tick (TradeTick) - 接收到的 tick。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def handle_trade_ticks(self, ticks: list) -> void:
        """
        Handle the given historical trade tick data by handling each tick individually.

        通过单独处理每个 tick 来处理给定的历史交易 tick 数据。

        Parameters: ticks (list [TradeTick ]) – The ticks received.
        参数:ticks (list [TradeTick ]) - 接收到的 tick。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def has_active_tasks(self) -> bool:
        """
        Return a value indicating whether there are any active tasks.

        返回值指示是否有任何活动的 task。

        Return type: bool
        """
        ...

    def has_any_tasks(self) -> bool:
        """
        Return a value indicating whether there are any queued or active tasks.

        返回值指示是否有任何排队或活动的 task。

        Return type: bool
        """
        ...

    def has_pending_requests(self) -> bool:
        """
        Return whether the actor is pending processing for any requests.

        返回 actor 是否正在等待处理任何请求。

        Returns: True if any requests are pending, else False.
        返回值:如果有任何请求正在等待处理,则返回 True,否则返回 False。
        Return type: bool
        """
        ...

    def has_queued_tasks(self) -> bool:
        """
        Return a value indicating whether there are any queued tasks.

        返回值指示是否有任何排队的 task。

        Return type: bool
        """
        ...

    def indicators_initialized(self) -> bool:
        """
        Return a value indicating whether all indicators are initialized.

        返回值指示是否所有指标都已初始化。

        Returns: True if all initialized, else False
        返回值:如果所有指标都已初始化,则返回 True,否则返回 False。
        Return type: bool
        """
        ...

    def is_pending_request(self, request_id: UUID4) -> bool:
        """
        Return whether the request for the given identifier is pending processing.

        返回给定标识符的请求是否正在等待处理。

        Parameters: request_id (UUID4) – The request ID to check.
        参数:request_id (UUID4) - 要检查的请求 ID。

        Returns: True if request is pending, else False.
        返回值:如果请求正在等待处理,则返回 True,否则返回 False。
        Return type: bool
        """
        ...

    def load(self, state: dict) -> void:
        """
        Load the actor/strategy state from the give state dictionary.

        从给定的状态字典加载 actor/strategy 状态。

        Calls on_load and passes the state.

        调用 on_load 并传递状态。

        Parameters: state (dict *[*str , object ]) – The state dictionary.
        参数:state (dict *[*str , object ]) - 状态字典。

        Raises: RuntimeError – If actor/strategy is not registered with a trader.
        引发:RuntimeError - 如果 actor/strategy 未在交易者处注册。

        Warning:
            Exceptions raised will be caught, logged, and reraised.
            引发的异常将被捕获、记录并重新引发。
        """
        ...

    def log_diagnostics(self, logger: Logger) -> void:
        """
        Abstract method (implement in subclass).

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

    def on_bar(self, bar: Bar) -> void:
        """
        Actions to be performed when running and receives a bar.

        运行时执行的操作以及接收到的 bar。

        Parameters: bar (Bar) – The bar received.
        参数:bar (Bar) - 接收到的 bar。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def on_data(self, data: Data) -> void:
        """
        Actions to be performed when running and receives data.

        运行时执行的操作以及接收到的数据。

        Parameters: data (Data) – The data received.
        参数:data (Data) - 接收到的数据。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def on_degrade(self) -> void:
        """
        Actions to be performed on degrade.

        降级时执行的操作。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。

        Should be overridden in the actor implementation.

        应该在 actor 实现中重写。
        """
        ...

    def on_dispose(self) -> void:
        """
        Actions to be performed on dispose.

        释放时执行的操作。

        Cleanup/release any resources used here.

        在此处清理/释放使用的任何资源。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def on_event(self, event: Event) -> void:
        """
        Actions to be performed running and receives an event.

        运行时执行的操作以及接收到的事件。

        Parameters: event (Event) – The event received.
        参数:event (Event) - 接收到的事件。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def on_fault(self) -> void:
        """
        Actions to be performed on fault.

        出现故障时执行的操作。

        Cleanup any resources used by the actor here.

        在此处清理 actor 使用的任何资源。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。

        Should be overridden in the actor implementation.

        应该在 actor 实现中重写。
        """
        ...

    def on_historical_data(self, data) -> void:
        """
        Actions to be performed when running and receives historical data.

        运行时执行的操作以及接收到的历史数据。

        Parameters: data (Data) – The historical data received.
        参数:data (Data) - 接收到的历史数据。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def on_instrument(self, instrument: Instrument) -> void:
        """
        Actions to be performed when running and receives an instrument.

        运行时执行的操作以及接收到的金融Instrument。

        Parameters: instrument (Instrument) – The instrument received.
        参数:instrument (Instrument) - 接收到的金融Instrument。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def on_instrument_close(self, update: InstrumentClose) -> void:
        """
        Actions to be performed when running and receives an instrument close update.

        运行时执行的操作以及接收到的金融Instrument关闭更新。

        Parameters: update (InstrumentClose) – The instrument close received.
        参数:update (InstrumentClose) - 接收到的金融Instrument关闭。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def on_instrument_status(self, data: InstrumentStatus) -> void:
        """
        Actions to be performed when running and receives an instrument status update.

        运行时执行的操作以及接收到的金融Instrument状态更新。

        Parameters: data (InstrumentStatus) – The instrument status update received.
        参数:data (InstrumentStatus) - 接收到的金融Instrument状态更新。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def on_load(self, state: dict) -> void:
        """
        Actions to be performed when the actor state is loaded.

        加载 actor 状态时执行的操作。

        Saved state values will be contained in the give state dictionary.

        保存的状态值将包含在给定的状态字典中。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def on_order_book(self, order_book: OrderBook) -> void:
        """
        Actions to be performed when running and receives an order book.

        运行时执行的操作以及接收到的订单簿。

        Parameters: order_book (OrderBook) – The order book received.
        参数:order_book (OrderBook) - 接收到的订单簿。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def on_order_book_deltas(self, deltas) -> void:
        """
        Actions to be performed when running and receives order book deltas.

        运行时执行的操作以及接收到的订单簿增量。

        Parameters: deltas (OrderBookDeltas or nautilus_pyo3.OrderBookDeltas) – The order book deltas received.
        参数:deltas (OrderBookDeltas or nautilus_pyo3.OrderBookDeltas) - 接收到的订单簿增量。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def on_quote_tick(self, tick: QuoteTick) -> void:
        """
        Actions to be performed when running and receives a quote tick.

        运行时执行的操作以及接收到的报价 tick。

        Parameters: tick (QuoteTick) – The tick received.
        参数:tick (QuoteTick) - 接收到的 tick。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def on_reset(self) -> void:
        """
        Actions to be performed on reset.

        重置时执行的操作。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。

        Should be overridden in a user implementation.

        应该在用户实现中重写。
        """
        ...

    def on_resume(self) -> void:
        """
        Actions to be performed on resume.

        恢复时执行的操作。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def on_save(self) -> dict:
        """
        Actions to be performed when the actor state is saved.

        保存 actor 状态时执行的操作。

        Create and return a state dictionary of values to be saved.

        创建并返回要保存的值的状态字典。

        Returns: The strategy state dictionary.
        返回值:策略状态字典。
        Return type: dict[str, bytes]

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def on_start(self) -> void:
        """
        Actions to be performed on start.

        启动时执行的操作。

        The intent is that this method is called once per trading ‘run’, when initially starting.

        其目的是在每次交易“运行”开始时调用此方法一次。

        It is recommended to subscribe/request for data here.

        建议在此处订阅/请求数据。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。

        Should be overridden in a user implementation.

        应该在用户实现中重写。
        """
        ...

    def on_stop(self) -> void:
        """
        Actions to be performed on stop.

        停止时执行的操作。

        The intent is that this method is called to pause, or when done for day.

        其目的是在暂停时或当天完成后调用此方法。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。

        Should be overridden in a user implementation.

        应该在用户实现中重写。
        """
        ...

    def on_trade_tick(self, tick: TradeTick) -> void:
        """
        Actions to be performed when running and receives a trade tick.

        运行时执行的操作以及接收到的交易 tick。

        Parameters: tick (TradeTick) – The tick received.
        参数:tick (TradeTick) - 接收到的 tick。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def pending_requests(self) -> set:
        """
        Return the request IDs which are currently pending processing.

        返回当前正在等待处理的请求 ID。

        Return type: set[UUID4]
        """
        ...
    
    def pre_process(self, data: Data) -> void:
        """
        Abstract method pre_process (implement in subclass).

        抽象方法 pre_process(在子类中实现)。
        """
        ...
    
    def process(self, ts_now: int) -> void:
        """
        Abstract method (implement in subclass).

        抽象方法(在子类中实现)。
        """
        ...
    
    def publish_data(self, data_type: DataType, data: Data) -> void:
        """
        Publish the given data to the message bus.

        将给定的数据发布到消息总线。

        Parameters:
        参数:
            data_type (DataType) – The data type being published.
            data_type (DataType) - 正在发布的数据类型。
            data (Data) – The data to publish.
            data (Data) - 要发布的数据。
        """
        ...

    def publish_signal(self, name: str, value, ts_event: int=0) -> void:
        """
        Publish the given value as a signal to the message bus.

        将给定的值作为信号发布到消息总线。

        Parameters:
        参数:
            name (str) – The name of the signal being published. The signal name is case-insensitive and will be capitalized (e.g., ‘example’ becomes ‘SignalExample’).
            name (str) - 正在发布的信号的名称。信号名称不区分大小写,并且将大写(例如,“example”变为“SignalExample”)。
            value (object) – The signal data to publish.
            value (object) - 要发布的信号数据。
            ts_event (uint64_t , optional) – UNIX timestamp (nanoseconds) when the signal event occurred. If None then will timestamp current time.
            ts_event (uint64_t,可选) - 信号事件发生时的 UNIX 时间戳(纳秒)。如果为 None,则将使用当前时间作为时间戳。
        """
        ...

    def queue_for_executor(self, func: Callable, args: tuple=None, kwargs: dict=None):
        """
        Queues the callable func to be executed as fn(*args, **kwargs) sequentially.

        将可调用函数 func 排队,以便按顺序执行为 fn(*args, **kwargs)。

        Parameters:
        参数:
            func (Callable) – The function to be executed.
            func (Callable) - 要执行的函数。
            args (positional arguments) – The positional arguments for the call to func.
            args(位置参数) - 对 func 的调用的位置参数。
            kwargs (arbitrary keyword arguments) – The keyword arguments for the call to func.
            kwargs(任意关键字参数) - 对 func 的调用的关键字参数。

        Raises: TypeError – If func is not of type Callable.
        引发:TypeError - 如果 func 的类型不是 Callable。
        """
        ...

    def queued_task_ids(self) -> list:
        """
        Return the queued task identifiers.

        返回排队的 task 标识符。

        Return type: list[TaskId]
        """
        ...
    
    def register_base(self, portfolio: PortfolioFacade, msgbus: MessageBus, cache: CacheFacade, clock: Clock) -> void:
        """
        Register with a trader.

        向交易者注册。

        Parameters:
        参数:
            portfolio (PortfolioFacade) – The read-only portfolio for the actor.
            portfolio (PortfolioFacade) - actor 的只读投资组合。
            msgbus (MessageBus) – The message bus for the actor.
            msgbus (MessageBus) - actor 的消息总线。
            cache (CacheFacade) – The read-only cache for the actor.
            cache (CacheFacade) - actor 的只读缓存。
            clock (Clock) – The clock for the actor.
            clock (Clock) - actor 的时钟。

        Warning:
            System method (not intended to be called by user code).
            系统方法(不打算由用户代码调用)。
        """
        ...

    def register_executor(self, loop, executor: Executor) -> void:
        """
        Register the given Executor for the actor.

        为 actor 注册给定的 Executor。

        Parameters:
        参数:
            loop (asyncio.AsbtractEventLoop) – The event loop of the application.
            loop (asyncio.AsbtractEventLoop) - 应用程序的事件循环。
            executor (concurrent.futures.Executor) – The executor to register.
            executor (concurrent.futures.Executor) - 要注册的执行器。

        Raises: TypeError – If executor is not of type concurrent.futures.Executor
        引发:TypeError - 如果 executor 的类型不是 concurrent.futures.Executor。
        """
        ...

    def register_indicator_for_bars(self, bar_type: BarType, indicator: Indicator) -> void:
        """
        Register the given indicator with the actor/strategy to receive bar data for the given bar type.

        向 actor/strategy 注册给定的指标,以便接收给定 bar 类型的 bar 数据。

        Parameters:
        参数:
            bar_type (BarType) – The bar type for bar updates.
            bar_type (BarType) - bar 更新的 bar 类型。
            indicator (Indicator) – The indicator to register.
            indicator (Indicator) - 要注册的指标。
        """
        ...

    def register_indicator_for_quote_ticks(self, instrument_id: InstrumentId, indicator: Indicator) -> void:
        """
        Register the given indicator with the actor/strategy to receive quote tick data for the given instrument ID.

        向 actor/strategy 注册给定的指标,以便接收给定金融Instrument ID 的报价 tick 数据。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The instrument ID for tick updates.
```python
           instrument_id (InstrumentId) - tick 更新的金融Instrument ID。
            indicator (Indicator) – The indicator to register.
            indicator (Indicator) - 要注册的指标。
        """
        ...

    def register_indicator_for_trade_ticks(self, instrument_id: InstrumentId, indicator) -> void:
        """
        Register the given indicator with the actor/strategy to receive trade tick data for the given instrument ID.

        向 actor/strategy 注册给定的指标,以便接收给定金融Instrument ID 的交易 tick 数据。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The instrument ID for tick updates.
            instrument_id (InstrumentId) - tick 更新的金融Instrument ID。
            indicator (indicator) – The indicator to register.
            indicator (indicator) - 要注册的指标。
        """
        ...

    def register_venue(self, exchange: SimulatedExchange) -> void:
        """
        Register the given simulated exchange with the module.

        向模块注册给定的模拟交易所。

        Parameters: exchange (SimulatedExchange) – The exchange to register.
        参数:exchange (SimulatedExchange) - 要注册的交易所。
        """
        ...
    
    def register_warning_event(self,  event) -> void:
        """
        Register the given event type for warning log levels.

        为警告日志级别注册给定的事件类型。

        Parameters: event (type) – The event class to register.
        参数:event (type) - 要注册的事件类。
        """
        ...

    def request_bars(self, bar_type: BarType, start: datetime=None, end: datetime=None, client_id: ClientId=None, callback=None) -> UUID4:
        """
        Request historical Bar data.

        请求历史 Bar 数据。

        If end is None then will request up to the most recent data.

        如果 end 为 None,则将请求最多到最新数据。

        Parameters:
        参数:
            bar_type (BarType) – The bar type for the request.
            bar_type (BarType) - 请求的 bar 类型。
            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)。包含性取决于各个数据客户端的实现。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue in the instrument ID.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从金融Instrument ID 中的平台推断出来。
            callback (Callable [ [UUID4 ] , None ] , optional) – The registered callback, to be called with the request ID when the response has completed processing.
            callback (Callable [ [UUID4 ] , None ],可选) - 注册的回调函数,当响应完成处理时,将使用请求 ID 调用该回调函数。

        Returns: The request_id for the request.
        返回值:请求的 request_id。
        Return type: UUID4

        Raises:
        引发:
            ValueError – If start and end are not None and start is >= end.
            ValueError - 如果 start 和 end 不为 None 并且 start >= end。
            TypeError – If callback is not None and not of type Callable.
            TypeError - 如果 callback 不为 None 并且类型不是 Callable。
        """
        ...

    def request_data(self, data_type: DataType, client_id: ClientId, callback=None) -> UUID4:
        """
        Request custom data for the given data type from the given data client.

        从给定的数据客户端请求给定数据类型的自定义数据。

        Parameters:
        参数:
            data_type (DataType) – The data type for the request.
            data_type (DataType) - 请求的数据类型。
            client_id (ClientId) – The data client ID.
            client_id (ClientId) - 数据客户端 ID。
            callback (Callable [ [UUID4 ] , None ] , optional) – The registered callback, to be called with the request ID when the response has completed processing.
            callback (Callable [ [UUID4 ] , None ],可选) - 注册的回调函数,当响应完成处理时,将使用请求 ID 调用该回调函数。

        Returns: The request_id for the request.
        返回值:请求的 request_id。
        Return type: UUID4

        Raises: TypeError – If callback is not None and not of type Callable.
        引发:TypeError - 如果 callback 不为 None 并且类型不是 Callable。
        """
        ...

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

        请求给定金融Instrument ID 的金融Instrument数据。

        If end is None then will request up to the most recent data.

        如果 end 为 None,则将请求最多到最新数据。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The instrument ID for the request.
            instrument_id (InstrumentId) - 请求的金融Instrument 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)。包含性取决于各个数据客户端的实现。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue in the instrument ID.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从金融Instrument ID 中的平台推断出来。
            callback (Callable [ [UUID4 ] , None ] , optional) – The registered callback, to be called with the request ID when the response has completed processing.
            callback (Callable [ [UUID4 ] , None ],可选) - 注册的回调函数,当响应完成处理时,将使用请求 ID 调用该回调函数。

        Returns: The request_id for the request.
        返回值:请求的 request_id。
        Return type: UUID4

        Raises:
        引发:
            ValueError – If start and end are not None and start is >= end.
            ValueError - 如果 start 和 end 不为 None 并且 start >= end。
            TypeError – If callback is not None and not of type Callable.
            TypeError - 如果 callback 不为 None 并且类型不是 Callable。
        """
        ...

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

        请求给定平台的所有金融Instrument数据。

        If end is None then will request up to the most recent data.

        如果 end 为 None,则将请求最多到最新数据。

        Parameters:
        参数:
            venue (Venue) – The venue for the request.
            venue (Venue) - 请求的平台。
            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)。包含性取决于各个数据客户端的实现。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue in the instrument ID.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从金融Instrument ID 中的平台推断出来。
            callback (Callable [ [UUID4 ] , None ] , optional) – The registered callback, to be called with the request ID when the response has completed processing.
            callback (Callable [ [UUID4 ] , None ],可选) - 注册的回调函数,当响应完成处理时,将使用请求 ID 调用该回调函数。

        Returns: The request_id for the request.
        返回值:请求的 request_id。
        Return type: UUID4

        Raises:
        引发:
            ValueError – If start and end are not None and start is >= end.
            ValueError - 如果 start 和 end 不为 None 并且 start >= end。
            TypeError – If callback is not None and not of type Callable.
            TypeError - 如果 callback 不为 None 并且类型不是 Callable。
        """
        ...

    def request_order_book_snapshot(self, instrument_id: InstrumentId, limit: int, client_id: ClientId=None, callback=None) -> UUID4:
        """
        Request an order book snapshot.

        请求订单簿快照。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The instrument ID for the order book snapshot request.
            instrument_id (InstrumentId) - 订单簿快照请求的金融Instrument ID。
            limit (int , optional) – The limit on the depth of the order book snapshot (default is None).
            limit (int,可选) - 订单簿快照深度的限制(默认为 None)。
            client_id (ClientId , optional) – The specific client ID for the command. If None, it will be inferred from the venue in the instrument ID.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从金融Instrument ID 中的平台推断出来。
            callback (Callable [ [UUID4 ] , None ] , optional) – The registered callback, to be called with the request ID when the response has completed processing.
            callback (Callable [ [UUID4 ] , None ],可选) - 注册的回调函数,当响应完成处理时,将使用请求 ID 调用该回调函数。

        Returns: The request_id for the request.
        返回值:请求的 request_id。
        Return type: UUID4

        Raises:
        引发:
            ValueError – If the instrument_id is None.
            ValueError - 如果 instrument_id 为 None。
            TypeError – If callback is not None and not of type Callable.
            TypeError - 如果 callback 不为 None 并且类型不是 Callable。
        """
        ...

    def request_quote_ticks(self, instrument_id: InstrumentId, start: datetime=None, end: datetime=None, client_id: ClientId=None, callback=None) -> UUID4:
        """
        Request historical QuoteTick data.

        请求历史报价 Tick 数据。

        If end is None then will request up to the most recent data.

        如果 end 为 None,则将请求最多到最新数据。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The tick instrument ID for the request.
            instrument_id (InstrumentId) - 请求的 tick 金融Instrument 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)。包含性取决于各个数据客户端的实现。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue in the instrument ID.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从金融Instrument ID 中的平台推断出来。
            callback (Callable [ [UUID4 ] , None ] , optional) – The registered callback, to be called with the request ID when the response has completed processing.
            callback (Callable [ [UUID4 ] , None ],可选) - 注册的回调函数,当响应完成处理时,将使用请求 ID 调用该回调函数。

        Returns: The request_id for the request.
        返回值:请求的 request_id。
        Return type: UUID4

        Raises:
        引发:
            ValueError – If start and end are not None and start is >= end.
            ValueError - 如果 start 和 end 不为 None 并且 start >= end。
            TypeError – If callback is not None and not of type Callable.
            TypeError - 如果 callback 不为 None 并且类型不是 Callable。
        """
        ...

    def request_trade_ticks(self, instrument_id: InstrumentId, start: datetime=None, end: datetime=None, client_id: ClientId=None, callback=None) -> UUID4:
        """
        Request historical TradeTick data.

        请求历史交易 Tick 数据。

        If end is None then will request up to the most recent data.

        如果 end 为 None,则将请求最多到最新数据。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The tick instrument ID for the request.
            instrument_id (InstrumentId) - 请求的 tick 金融Instrument 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)。包含性取决于各个数据客户端的实现。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue in the instrument ID.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从金融Instrument ID 中的平台推断出来。
            callback (Callable [ [UUID4 ] , None ] , optional) – The registered callback, to be called with the request ID when the response has completed processing.
            callback (Callable [ [UUID4 ] , None ],可选) - 注册的回调函数,当响应完成处理时,将使用请求 ID 调用该回调函数。

        Returns: The request_id for the request.
        返回值:请求的 request_id。
        Return type: UUID4

        Raises:
        引发:
            ValueError – If start and end are not None and start is >= end.
            ValueError - 如果 start 和 end 不为 None 并且 start >= end。
            TypeError – If callback is not None and not of type Callable.
            TypeError - 如果 callback 不为 None 并且类型不是 Callable。
        """
        ...

    def reset(self) -> void:
        """
        Abstract method (implement in subclass).

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

    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 run_in_executor(self, func: Callable, args: tuple=None, kwargs: dict=None):
        """
        Schedules the callable func to be executed as fn(*args, **kwargs).

        计划可调用函数 func 以 fn(*args, **kwargs) 的形式执行。

        Parameters:
        参数:
            func (Callable) – The function to be executed.
            func (Callable) - 要执行的函数。
            args (positional arguments) – The positional arguments for the call to func.
            args(位置参数) - 对 func 的调用的位置参数。
            kwargs (arbitrary keyword arguments) – The keyword arguments for the call to func.
            kwargs(任意关键字参数) - 对 func 的调用的关键字参数。

        Returns: The unique task identifier for the execution. This also corresponds to any future objects memory address.
        返回值:执行的唯一 task 标识符。这也对应于任何 future 对象的内存地址。
        Return type: TaskId

        Raises: TypeError – If func is not of type Callable.
        引发:TypeError - 如果 func 的类型不是 Callable。
        """
        ...

    def save(self) -> dict:
        """
        Return the actor/strategy state dictionary to be saved.

        返回要保存的 actor/strategy 状态字典。

        Calls on_save.

        调用 on_save。

        Raises: RuntimeError – If actor/strategy is not registered with a trader.
        引发:RuntimeError - 如果 actor/strategy 未在交易者处注册。

        Warning:
            Exceptions raised will be caught, logged, and reraised.
            引发的异常将被捕获、记录并重新引发。
        """
        ...

    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 subscribe_bars(self, bar_type: BarType, client_id: ClientId=None, await_partial: bool=False) -> void:
        """
        Subscribe to streaming Bar data for the given bar type.

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

        Parameters:
        参数:
            bar_type (BarType) – The bar type to subscribe to.
            bar_type (BarType) - 要订阅的 bar 类型。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue in the instrument ID.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从金融Instrument ID 中的平台推断出来。
            await_partial (bool , default False) – If the bar aggregator should await the arrival of a historical partial bar prior to actively aggregating new bars.
            await_partial (bool,默认 False) - bar 聚合器是否应在主动聚合新 bar 之前等待历史部分 bar 的到来。
        """
        ...

    def subscribe_data(self, data_type: DataType, client_id: ClientId=None) -> void:
        """
        Subscribe to data of the given data type.

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

        Parameters:
        参数:
            data_type (DataType) – The data type to subscribe to.
            data_type (DataType) - 要订阅的数据类型。
            client_id (ClientId , optional) – The data client ID. If supplied then a Subscribe command will be sent to the corresponding data client.
            client_id (ClientId,可选) - 数据客户端 ID。如果提供,则将向相应的数据客户端发送 Subscribe 命令。
        """
        ...

    def subscribe_instrument(self, instrument_id: InstrumentId, client_id: ClientId=None) -> void:
        """
        Subscribe to update Instrument data for the given instrument ID.

        订阅给定金融Instrument ID 的更新金融Instrument数据。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The instrument ID for the subscription.
            instrument_id (InstrumentId) - 订阅的金融Instrument ID。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue in the instrument ID.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从金融Instrument ID 中的平台推断出来。
        """
        ...

    def subscribe_instrument_close(self, instrument_id: InstrumentId, client_id: ClientId=None) -> void:
        """
        Subscribe to close updates for the given instrument ID.

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

        Parameters:
        参数:
            instrument_id (InstrumentId) – The instrument to subscribe to status updates for.
            instrument_id (InstrumentId) - 要订阅状态更新的金融Instrument。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue in the instrument ID.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从金融Instrument ID 中的平台推断出来。
        """
        ...

    def subscribe_instrument_status(self, instrument_id: InstrumentId, client_id: ClientId=None) -> void:
        """
        Subscribe to status updates for the given instrument ID.

        订阅给定金融Instrument ID 的状态更新。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The instrument to subscribe to status updates for.
            instrument_id (InstrumentId) - 要订阅状态更新的金融Instrument。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue in the instrument ID.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从金融Instrument ID 中的平台推断出来。
        """
        ...

    def subscribe_instruments(self, venue: Venue, client_id: ClientId=None) -> void:
        """
        Subscribe to update Instrument data for the given venue.

        订阅给定平台的更新金融Instrument数据。

        Parameters:
        参数:
            venue (Venue) – The venue for the subscription.
            venue (Venue) - 订阅的平台。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从平台推断出来。
        """
        ...

    def subscribe_order_book_at_interval(self, instrument_id: InstrumentId, book_type=BookType.L2_MBP, depth: int=0, interval_ms: int=1000, kwargs: dict=None, client_id: ClientId=None, managed: bool=True) -> void:
        """
        Subscribe to an OrderBook at a specified interval for the given instrument ID.

        以指定的间隔订阅给定金融Instrument ID 的订单簿。

        The DataEngine will only maintain one order book for each instrument. Because of this - the level, depth and kwargs for the stream will be set as per the last subscription request (this will also affect all subscribers).

        数据引擎将只为每个金融Instrument维护一个订单簿。因此,流的级别、深度和 kwargs 将根据最后一个订阅请求进行设置(这也会影响所有订阅者)。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The order book instrument ID to subscribe to.
            instrument_id (InstrumentId) - 要订阅的订单簿金融Instrument ID。
            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) – The maximum depth for the order book. A depth of 0 is maximum depth.
            depth (int,可选) - 订单簿的最大深度。深度为 0 表示最大深度。
            interval_ms (int) – The order book snapshot interval in milliseconds (must be positive).
            interval_ms (int) - 订单簿快照间隔(以毫秒为单位)(必须为正数)。
            kwargs (dict , optional) – The keyword arguments for exchange specific parameters.
            kwargs (dict,可选) - 交换特定参数的关键字参数。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue in the instrument ID.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从金融Instrument ID 中的平台推断出来。
            managed (bool , default True) – If an order book should be managed by the data engine based on the subscribed feed.
            managed (bool,默认 True) - 是否应根据订阅的源由数据引擎管理订单簿。

        Raises:
        引发:
            ValueError – If depth is negative (< 0).
            ValueError - 如果 depth 为负数(< 0)。
            ValueError – If interval_ms is not positive (> 0).
            ValueError - 如果 interval_ms 不是正数(> 0)。

        Warning:
            Consider subscribing to order book deltas if you need intervals less than 100 milliseconds.
            如果需要小于 100 毫秒的间隔,请考虑订阅订单簿增量。
        """
        ...

    def subscribe_order_book_deltas(self, instrument_id: InstrumentId, book_type=BookType.L2_MBP, depth: int=0, kwargs: dict=None, client_id: ClientId=None, managed: bool=True, pyo3_conversion: bool=False) -> void:
        """
        Subscribe to the order book data stream, being a snapshot then deltas for the given instrument ID.

        订阅订单簿数据流,即给定金融Instrument ID 的快照,然后是增量。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The order book instrument ID to subscribe to.
            instrument_id (InstrumentId) - 要订阅的订单簿金融Instrument ID。
            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) – 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,可选) - 交换特定参数的关键字参数。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue in the instrument ID.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从金融Instrument ID 中的平台推断出来。
            managed (bool , default True) – If an order book should be managed by the data engine based on the subscribed feed.
            managed (bool,默认 True) - 是否应根据订阅的源由数据引擎管理订单簿。
            pyo3_conversion (bool , default False) – If received deltas should be converted to nautilus_pyo3.OrderBookDeltas prior to being passed to the on_order_book_deltas handler.
            pyo3_conversion (bool,默认 False) - 在传递给 on_order_book_deltas 处理程序之前,是否应将接收到的增量转换为 nautilus_pyo3.OrderBookDeltas。
        """
        ...

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

        订阅给定金融Instrument ID 的流式报价 Tick 数据。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The tick instrument to subscribe to.
            instrument_id (InstrumentId) - 要订阅的 tick 金融Instrument。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue in the instrument ID.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从金融Instrument ID 中的平台推断出来。
        """
        ...

    def subscribe_signal(self, name: str='') -> void:
        """
        Subscribe to a specific signal by name, or to all signals if no name is provided.

        按名称订阅特定信号,或者如果没有提供名称,则订阅所有信号。

        Parameters: name (str , optional) – The name of the signal to subscribe to. If not provided or an empty string is passed, the subscription will include all signals. The signal name is case-insensitive and will be capitalized (e.g., ‘example’ becomes ‘SignalExample*’).
        参数:name (str,可选) - 要订阅的信号的名称。如果没有提供或传递空字符串,则订阅将包含所有信号。信号名称不区分大小写,并且将大写(例如,“example”变为“SignalExample*”)。
        """
        ...

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

        订阅给定金融Instrument ID 的流式交易 Tick 数据。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The tick instrument to subscribe to.
            instrument_id (InstrumentId) - 要订阅的 tick 金融Instrument。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue in the instrument ID.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从金融Instrument ID 中的平台推断出来。
        """
        ...

    def to_importable_config(self) -> ImportableActorConfig:
        """
        Returns an importable configuration for this actor.

        返回此 actor 的可导入配置。

        Return type: ImportableActorConfig
        """
        ...

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

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

        Parameters:
        参数:
            bar_type (BarType) – The bar type to unsubscribe from.
            bar_type (BarType) - 要取消订阅的 bar 类型。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue in the instrument ID.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从金融Instrument ID 中的平台推断出来。
        """
        ...

    def unsubscribe_data(self, data_type: DataType, client_id: ClientId=None) -> void:
        """
        Unsubscribe from data of the given data type.

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

        Parameters:
        参数:
            data_type (DataType) – The data type to unsubscribe from.
            data_type (DataType) - 要取消订阅的数据类型。
            client_id (ClientId , optional) – The data client ID. If supplied then an Unsubscribe command will be sent to the data client.
            client_id (ClientId,可选) - 数据客户端 ID。如果提供,则将向数据客户端发送 Unsubscribe 命令。
        """
        ...

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

        取消订阅给定金融Instrument ID 的更新金融Instrument数据。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The instrument to unsubscribe from.
            instrument_id (InstrumentId) - 要取消订阅的金融Instrument。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue in the instrument ID.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从金融Instrument ID 中的平台推断出来。
        """
        ...

    def unsubscribe_instrument_status(self, instrument_id: InstrumentId, client_id: ClientId=None) -> void:
        """
        Unsubscribe to status updates of the given venue.

        取消订阅给定平台的状态更新。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The instrument to unsubscribe to status updates for.
            instrument_id (InstrumentId) - 要取消订阅状态更新的金融Instrument。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从平台推断出来。
        """
        ...

    def unsubscribe_instruments(self, venue: Venue, client_id: ClientId=None) -> void:
        """
        Unsubscribe from update Instrument data for the given venue.

        取消订阅给定平台的更新金融Instrument数据。

        Parameters:
        参数:
            venue (Venue) – The venue for the subscription.
            venue (Venue) - 订阅的平台。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从平台推断出来。
        """
        ...

    def unsubscribe_order_book_at_interval(self, instrument_id: InstrumentId, interval_ms: int=1000, client_id: ClientId=None) -> void:
        """
        Unsubscribe from an OrderBook at a specified interval for the given instrument ID.

        以指定的间隔取消订阅给定金融Instrument ID 的订单簿。

        The interval must match the previously subscribed interval.

        间隔必须与之前订阅的间隔匹配。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The order book instrument to subscribe to.
            instrument_id (InstrumentId) - 要订阅的订单簿金融Instrument。
            interval_ms (int) – The order book snapshot interval in milliseconds.
            interval_ms (int) - 订单簿快照间隔(以毫秒为单位)。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue in the instrument ID.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从金融Instrument ID 中的平台推断出来。
        """
        ...


```python
   def unsubscribe_order_book_deltas(self, instrument_id: InstrumentId, client_id: ClientId=None) -> void:
        """
        Unsubscribe the order book deltas stream for the given instrument ID.

        取消订阅给定金融Instrument ID 的订单簿增量流。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The order book instrument to subscribe to.
            instrument_id (InstrumentId) - 要订阅的订单簿金融Instrument。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue in the instrument ID.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从金融Instrument ID 中的平台推断出来。
        """
        ...

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

        取消订阅给定金融Instrument ID 的流式报价 Tick 数据。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The tick instrument to unsubscribe from.
            instrument_id (InstrumentId) - 要取消订阅的 tick 金融Instrument。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue in the instrument ID.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从金融Instrument ID 中的平台推断出来。
        """
        ...

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

        取消订阅给定金融Instrument ID 的流式交易 Tick 数据。

        Parameters:
        参数:
            instrument_id (InstrumentId) – The tick instrument ID to unsubscribe from.
            instrument_id (InstrumentId) - 要取消订阅的 tick 金融Instrument ID。
            client_id (ClientId , optional) – The specific client ID for the command. If None then will be inferred from the venue in the instrument ID.
            client_id (ClientId,可选) - 命令的特定客户端 ID。如果为 None,则将从金融Instrument ID 中的平台推断出来。
        """
        ...

    def update_synthetic(self, synthetic: SyntheticInstrument) -> void:
        """
        Update the synthetic instrument in the cache.

        更新缓存中的合成金融Instrument。

        Parameters: synthetic (SyntheticInstrument) – The synthetic instrument to update in the cache.
        参数:synthetic (SyntheticInstrument) - 要在缓存中更新的合成金融Instrument。
        Raises: KeyError – If synthetic does not already exist in the cache.
        引发:KeyError - 如果合成金融Instrument在缓存中不存在。
        """
        ...

class BacktestNode 回测节点

class BacktestNode(object):
    """
    Provides a node for orchestrating groups of backtest runs.

    提供一个节点来协调多组回测运行。

    Parameters: configs (list [BacktestRunConfig ]) – The backtest run configurations.
    参数:configs (list [BacktestRunConfig ]) - 回测运行配置。
    Raises:
    引发:
        ValueError – If configs is None or empty.
        ValueError - 如果 configs 为 None 或为空。
        ValueError – If configs contains a type other than BacktestRunConfig.
        ValueError - 如果 configs 包含 BacktestRunConfig 以外的类型。
    """
    def __init__(self, configs: list[BacktestRunConfig]):
        ...

Properties 属性

    @property
    def configs(self) -> list[BacktestRunConfig]:
        """
        Return the loaded backtest run configs for the node.

        返回节点已加载的回测运行配置。

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

Methods 方法

    def get_log_guard(self):
        """
        Return the global logging systems log guard.

        返回全局日志记录系统的日志保护。

        May return None if no internal engines are initialized yet.

        如果尚未初始化内部引擎,则可能返回 None。

        Return type: nautilus_pyo3.LogGuard | LogGuard | None
        """
        ...

    def get_engine(self, run_config_id: str):
        """
        Return the backtest engine associated with the given run config ID (if found).

        返回与给定运行配置 ID 关联的回测引擎(如果找到)。

        Parameters: run_config_id (str) – The run configuration ID for the created engine.
        参数:run_config_id (str) - 已创建引擎的运行配置 ID。

        Return type: BacktestEngine or None
        """
        ...

    def get_engines(self) -> list:
        """
        Return all backtest engines created by the node.

        返回节点创建的所有回测引擎。

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

    def run(self) -> list:
        """
        Run the backtest node which will synchronously execute the list of loaded backtest run configs.

        运行回测节点,该节点将同步执行已加载的回测运行配置列表。

        Any exceptions raised from a backtest will be printed to stdout and the next backtest run will commence (if any).

        从回测中引发的任何异常都将打印到标准输出,并且下一个回测运行将开始(如果有)。

        Returns: The results of the backtest runs.
        返回值:回测运行的结果。
        Return type: list[BacktestResult]
        """
        ...

    @classmethod
    def load_catalog(cls, config: BacktestDataConfig):
        """
        """
        ...

    @classmethod
    def load_data_config(cls, config: BacktestDataConfig):
        """
        """
        ...
    
    def dispose(self):
        """
        """
        ...

class BacktestResult 回测结果

class BacktestResult(object):
    """
    Represents the results of a single complete backtest run.

    表示单个完整回测运行的结果。
    """
    def __init__(self):
        ...

Properties 属性

    trader_id: str
    machine_id: str
    run_config_id: str | None
    instance_id: str
    run_id: str
    run_started: int | None
    run_finished: int | None
    backtest_start: int | None
    backtest_end: int | None
    elapsed_time: float
    iterations: int
    total_events: int
    total_orders: int
    total_positions: int
    stats_pnls: dict[str, dict[str, float]]
    stats_returns: dict[str, float]

Methods 方法

    def ensure_plotting(func):
        """
        Decorate a function that require a plotting library.

        装饰需要绘图库的函数。

        Ensures library is installed and providers a better error about how to install if not found.

        确保安装了库,并在找不到库时提供更好的错误信息。
        """
        ...