Orders 订单 - Loren1166/NautilusTrader- GitHub Wiki
Orders 订单
Provides a full range of standard order types, as well as more advanced types and order lists.
提供全面的标准订单类型,以及更高级的类型和订单列表。
class Order 订单
class Order(object):
"""
Order(OrderInitialized init)
The base class for all orders.
所有订单的基类。
Parameters:
init (OrderInitialized) – The order initialized event.
init (OrderInitialized) - 订单初始化事件。
WARNING
This class should not be used directly, but through a concrete subclass.
此类不应直接使用,而应通过具体的子类使用。
"""
def __init__(self, init: "OrderInitialized") -> None:
...
@property
def account_id(self) -> "AccountId" or None:
"""
The account ID associated with the order.
与订单关联的账户 ID。
Returns:
AccountId or None
"""
...
def apply(self, event: "OrderEvent") -> None:
"""
Apply the given order event to the order.
将给定的订单事件应用于订单。
Parameters:
event (OrderEvent) – The order event to apply.
event (OrderEvent) - 要应用的订单事件。
Raises:
ValueError – If self.client_order_id is not equal to event.client_order_id.
ValueError - 如果 self.client_order_id 不等于 event.client_order_id。
ValueError – If self.venue_order_id and event.venue_order_id are both not None, and are not equal.
ValueError - 如果 self.venue_order_id 和 event.venue_order_id 都不为 None,并且不相等。
InvalidStateTrigger – If event is not a valid trigger from the current order.status.
InvalidStateTrigger - 如果事件不是当前 order.status 的有效触发器。
KeyError – If event is OrderFilled and event.trade_id already applied to the order.
KeyError - 如果 event 是 OrderFilled 并且 event.trade_id 已经应用于订单。
"""
...
@property
def avg_px(self) -> float:
"""
The order average fill price.
订单平均成交价格。
Returns:
double
"""
...
@property
def client_order_id(self) -> "ClientOrderId":
"""
The client order ID.
客户端订单 ID。
Returns:
ClientOrderId
"""
...
@staticmethod
def closing_side(position_side: "PositionSide") -> "OrderSide":
"""
Return the order side needed to close a position with the given side.
返回平仓给定方向头寸所需的订单方向。
Parameters:
position_side (PositionSide {LONG, SHORT}) – The side of the position to close.
position_side (PositionSide {LONG, SHORT}) - 要平仓头寸的方向。
Return type:
OrderSide
Raises:
ValueError – If position_side is FLAT or invalid.
ValueError - 如果 position_side 为 FLAT 或无效。
"""
...
def commissions(self) -> list:
"""
Return the total commissions generated by the order.
返回订单产生的总佣金。
Return type:
list[Money]
"""
...
@property
def contingency_type(self) -> "ContingencyType":
"""
The orders contingency type.
订单的意外事件类型。
Returns:
ContingencyType
"""
...
@property
def emulation_trigger(self) -> "TriggerType":
"""
The order emulation trigger type.
订单模拟触发器类型。
Returns:
TriggerType
"""
...
@property
def event_count(self) -> int:
"""
Return the count of events applied to the order.
返回应用于订单的事件计数。
Return type:
int
"""
...
@property
def events(self) -> list["OrderEvent"]:
"""
Return the order events.
返回订单事件。
Return type:
list[OrderEvent]
"""
...
@property
def exec_algorithm_id(self) -> "ExecAlgorithmId" or None:
"""
The execution algorithm ID for the order.
订单的执行算法 ID。
Returns:
ExecAlgorithmId or None
"""
...
@property
def exec_algorithm_params(self) -> dict[str, Any] or None:
"""
The execution algorithm parameters for the order.
订单的执行算法参数。
Returns:
dict[str, Any] or None
"""
...
@property
def exec_spawn_id(self) -> "ClientOrderId" or None:
"""
The execution algorithm spawning client order ID.
执行算法生成的客户端订单 ID。
Returns:
ClientOrderId or None
"""
...
@property
def filled_qty(self) -> "Quantity":
"""
The order total filled quantity.
订单总成交数量。
Returns:
Quantity
"""
...
@property
def has_price(self) -> bool:
"""
Return whether the order has a price property.
返回订单是否具有 price 属性。
Return type:
bool
"""
...
@property
def has_trigger_price(self) -> bool:
"""
Return whether the order has a trigger_price property.
返回订单是否具有 trigger_price 属性。
Return type:
bool
"""
...
def info(self) -> str:
"""
Return a summary description of the order.
返回订单的摘要描述。
Return type:
str
"""
...
@property
def init_event(self) -> "OrderInitialized":
"""
Return the initialization event for the order.
返回订单的初始化事件。
Return type:
OrderInitialized
"""
...
@property
def init_id(self) -> "UUID4":
"""
The event ID of the OrderInitialized event.
OrderInitialized 事件的事件 ID。
Returns:
UUID4
"""
...
@property
def instrument_id(self) -> "InstrumentId":
"""
The order instrument ID.
订单金融工具 ID。
Returns:
InstrumentId
"""
...
@property
def is_active_local(self) -> bool:
"""
Return whether the order is active and held in the local system.
返回订单是否处于活动状态并在本地系统中持有。
An order is considered active local when its status is any of;
当订单的状态为以下任何一种时,该订单被视为本地活动订单:
INITIALIZED
EMULATED
RELEASED
Return type:
bool
"""
...
@property
def is_aggressive(self) -> bool:
"""
Return whether the order is aggressive (order_type is MARKET).
返回订单是否为激进订单(order_type 为 MARKET)。
Return type:
bool
"""
...
@property
def is_buy(self) -> bool:
"""
Return whether the order side is BUY.
返回订单方向是否为 BUY。
Return type:
bool
"""
...
@property
def is_canceled(self) -> bool:
"""
Return whether current status is CANCELED.
返回当前状态是否为 CANCELED。
Return type:
bool
"""
...
@property
def is_child_order(self) -> bool:
"""
Return whether the order has a parent order.
返回订单是否具有父订单。
Return type:
bool
"""
...
@property
def is_closed(self) -> bool:
"""
Return whether the order is closed.
返回订单是否已平仓。
An order is considered closed when its status can no longer change. The possible statuses of closed orders include;
当订单的状态不再可以更改时,该订单被视为已平仓。已平仓订单的可能状态包括:
DENIED
REJECTED
CANCELED
EXPIRED
FILLED
Return type:
bool
"""
...
@property
def is_contingency(self) -> bool:
"""
Return whether the order has a contingency (contingency_type is not NO_CONTINGENCY).
返回订单是否具有意外事件(contingency_type 不为 NO_CONTINGENCY)。
Return type:
bool
"""
...
@property
def is_emulated(self) -> bool:
"""
Return whether the order is emulated and held in the local system.
返回订单是否被模拟并在本地系统中持有。
Return type:
bool
"""
...
@property
def is_inflight(self) -> bool:
"""
Return whether the order is in-flight (order request sent to the trading venue).
返回订单是否正在进行中(订单请求已发送到交易场所)。
An order is considered in-flight when its status is any of;
当订单的状态为以下任何一种时,该订单被视为正在进行中:
SUBMITTED
PENDING_UPDATE
PENDING_CANCEL
Return type:
bool
WARNING
An emulated order is never considered in-flight.
模拟订单永远不会被视为正在进行中。
"""
...
@property
def is_open(self) -> bool:
"""
Return whether the order is open at the trading venue.
返回订单是否在交易场所开仓。
An order is considered open when its status is any of;
当订单的状态为以下任何一种时,该订单被视为开仓:
ACCEPTED
TRIGGERED
PENDING_UPDATE
PENDING_CANCEL
PARTIALLY_FILLED
Return type:
bool
WARNING
An emulated order is never considered open.
模拟订单永远不会被视为开仓。
"""
...
@property
def is_parent_order(self) -> bool:
"""
Return whether the order has at least one child order.
返回订单是否至少有一个子订单。
Return type:
bool
"""
...
@property
def is_passive(self) -> bool:
"""
Return whether the order is passive (order_type not MARKET).
返回订单是否为被动订单(order_type 不为 MARKET)。
Return type:
bool
"""
...
@property
def is_pending_cancel(self) -> bool:
"""
Return whether the current status is PENDING_CANCEL.
返回当前状态是否为 PENDING_CANCEL。
Return type:
bool
"""
...
@property
def is_pending_update(self) -> bool:
"""
Return whether the current status is PENDING_UPDATE.
返回当前状态是否为 PENDING_UPDATE。
Return type:
bool
"""
...
@property
def is_post_only(self) -> bool:
"""
If the order will only provide liquidity (make a market).
如果订单只提供流动性(做市商)。
Returns:
bool
"""
...
@property
def is_primary(self) -> bool:
"""
Return whether the order is the primary for an execution algorithm sequence.
返回订单是否是执行算法序列的主订单。
Return type:
bool
"""
...
@property
def is_quote_quantity(self) -> bool:
"""
If the order quantity is denominated in the quote currency.
如果订单数量以报价货币计价。
Returns:
bool
"""
...
@property
def is_reduce_only(self) -> bool:
"""
If the order carries the ‘reduce-only’ execution instruction.
如果订单带有“仅减少”执行指令。
Returns:
bool
"""
...
@property
def is_sell(self) -> bool:
"""
Return whether the order side is SELL.
返回订单方向是否为 SELL。
Return type:
bool
"""
...
@property
def is_spawned(self) -> bool:
"""
Return whether the order was spawned as part of an execution algorithm sequence.
返回订单是否作为执行算法序列的一部分生成。
Return type:
bool
"""
...
@property
def last_event(self) -> "OrderEvent":
"""
Return the last event applied to the order.
返回应用于订单的最后一个事件。
Return type:
OrderEvent
"""
...
@property
def last_trade_id(self) -> "TradeId" or None:
"""
The orders last trade match ID.
订单的最后交易匹配 ID。
Returns:
TradeId or None
"""
...
@property
def leaves_qty(self) -> "Quantity":
"""
The order total leaves quantity.
订单总剩余数量。
Returns:
Quantity
"""
...
@property
def linked_order_ids(self) -> list["ClientOrderId"] or None:
"""
The orders linked client order ID(s).
订单链接的客户端订单 ID。
Returns:
list[ClientOrderId] or None
"""
...
@property
def liquidity_side(self) -> "LiquiditySide":
"""
The order liquidity side.
订单流动性方向。
Returns:
LiquiditySide
"""
...
@staticmethod
def opposite_side(side: "OrderSide") -> "OrderSide":
"""
Return the opposite order side from the given side.
从给定的方向返回相反的订单方向。
Parameters:
side (OrderSide {BUY, SELL}) – The original order side.
side (OrderSide {BUY, SELL}) - 原始订单方向。
Return type:
OrderSide
Raises:
ValueError – If side is invalid.
ValueError - 如果方向无效。
"""
...
@property
def order_list_id(self) -> "OrderListId" or None:
"""
The order list ID associated with the order.
与订单关联的订单列表 ID。
Returns:
OrderListId or None
"""
...
@property
def order_type(self) -> "OrderType":
"""
The order type.
订单类型。
Returns:
OrderType
"""
...
@property
def parent_order_id(self) -> "ClientOrderId" or None:
"""
The parent client order ID.
父客户端订单 ID。
Returns:
ClientOrderId or None
"""
...
@property
def position_id(self) -> "PositionId" or None:
"""
The position ID associated with the order.
与订单关联的头寸 ID。
Returns:
PositionId or None
"""
...
@property
def quantity(self) -> "Quantity":
"""
The order quantity.
订单数量。
Returns:
Quantity
"""
...
@property
def side(self) -> "OrderSide":
"""
The order side.
订单方向。
Returns:
OrderSide
"""
...
def side_string(self) -> str:
"""
Return the orders side as a string.
将订单方向作为字符串返回。
Return type:
str
"""
...
def signed_decimal_qty(self):
"""
Return a signed decimal representation of the remaining quantity.
返回剩余数量的带符号十进制表示形式。
If the order is a BUY, the value is positive (e.g. Decimal(‘10.25’))
如果订单是买入,则值为正数(例如Decimal('10.25'))
If the order is a SELL, the value is negative (e.g. Decimal(‘-10.25’))
如果订单是卖出,则值为负数(例如Decimal('-10.25'))
Return type:
Decimal
"""
return
@property
def slippage(self) -> float:
"""
The order total price slippage.
订单总价格滑点。
Returns:
double
"""
...
@property
def status(self) -> "OrderStatus":
"""
Return the orders current status.
返回订单的当前状态。
Return type:
OrderStatus
"""
...
def status_string(self) -> str:
"""
Return the orders current status as a string.
将订单的当前状态作为字符串返回。
Return type:
str
"""
...
@property
def strategy_id(self) -> "StrategyId":
"""
The strategy ID associated with the order.
与订单关联的策略 ID。
Returns:
StrategyId
"""
...
@property
def symbol(self) -> "Symbol":
"""
Return the orders ticker symbol.
返回订单的代码。
Return type:
Symbol
"""
...
@property
def tags(self) -> list[str] or None:
"""
The order custom user tags.
订单自定义用户标签。
Returns:
list[str] or None
"""
...
@property
def time_in_force(self) -> "TimeInForce":
"""
The order time in force.
订单有效时间。
Returns:
TimeInForce
"""
...
def to_dict(self) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def trade_ids(self) -> list["TradeId"]:
"""
Return the trade match IDs.
返回交易匹配 ID。
Return type:
list[TradeId]
"""
...
@property
def trader_id(self) -> "TraderId":
"""
The trader ID associated with the position.
与头寸关联的交易者 ID。
Returns:
TraderId
"""
...
@property
def trigger_instrument_id(self) -> "InstrumentId" or None:
"""
The order emulation trigger instrument ID (will be instrument_id if None).
订单模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
Returns:
InstrumentId or None
"""
...
@property
def ts_init(self) -> int:
"""
UNIX timestamp (nanoseconds) when the object was initialized.
对象初始化时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
@property
def ts_last(self) -> int:
"""
UNIX timestamp (nanoseconds) when the last event occurred.
上次事件发生时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
def type_string(self) -> str:
"""
Return the orders type as a string.
将订单类型作为字符串返回。
Return type:
str
"""
...
@property
def venue(self) -> "Venue":
"""
Return the orders trading venue.
返回订单的交易场所。
Return type:
Venue
"""
...
@property
def venue_order_id(self) -> "VenueOrderId" or None:
"""
The venue assigned order ID.
交易场所分配的订单 ID。
Returns:
VenueOrderId or None
"""
...
@property
def venue_order_ids(self) -> list["VenueOrderId"]:
"""
Return the venue order IDs.
返回交易场所订单 ID。
Return type:
list[VenueOrderId]
"""
...
def would_reduce_only(self, position_side: "PositionSide", position_qty: "Quantity") -> bool:
"""
Whether the current order would only reduce the given position if applied in full.
如果当前订单完全应用,是否只会减少给定的头寸。
Parameters:
position_side (PositionSide {FLAT, LONG, SHORT}) – The side of the position to check against.
position_side (PositionSide {FLAT, LONG, SHORT}) - 要检查的头寸方向。
position_qty (Quantity) – The quantity of the position to check against.
position_qty (Quantity) - 要检查的头寸数量。
Return type:
bool
"""
...
class LimitOrder 限价单
class LimitOrder(Order):
"""
LimitOrder(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, Quantity quantity, Price price, UUID4 init_id, uint64_t ts_init, TimeInForce time_in_force=TimeInForce.GTC, uint64_t expire_time_ns=0, bool post_only=False, bool reduce_only=False, bool quote_quantity=False, Quantity display_qty=None, TriggerType emulation_trigger=TriggerType.NO_TRIGGER, InstrumentId trigger_instrument_id=None, ContingencyType contingency_type=ContingencyType.NO_CONTINGENCY, OrderListId order_list_id=None, list linked_order_ids=None, ClientOrderId parent_order_id=None, ExecAlgorithmId exec_algorithm_id=None, dict exec_algorithm_params=None, ClientOrderId exec_spawn_id=None, list tags=None)
Represents a Limit order.
表示一个限价单。
A Limit order is an order to BUY (or SELL) at a specified price or better. The Limit order ensures that if the order fills, it will not fill at a price less favorable than your limit price, but it does not guarantee a fill.
限价单是指以指定价格或更好的价格买入(或卖出)的订单。限价单确保如果订单成交,它不会以比您的限价更不利的价格成交,但它不保证成交。
A Limit-On-Open (LOO) order can be represented using a time in force of AT_THE_OPEN.
限价开仓单 (LOO) 可以使用 AT_THE_OPEN 的有效时间来表示。
A Limit-On-Close (LOC) order can be represented using a time in force of AT_THE_CLOSE.
限价平仓单 (LOC) 可以使用 AT_THE_CLOSE 的有效时间来表示。
Parameters:
trader_id (TraderId) – The trader ID associated with the order.
trader_id (TraderId) - 与订单关联的交易者 ID。
strategy_id (StrategyId) – The strategy ID associated with the order.
strategy_id (StrategyId) - 与订单关联的策略 ID。
instrument_id (InstrumentId) – The order instrument ID.
instrument_id (InstrumentId) - 订单金融工具 ID。
client_order_id (ClientOrderId) – The client order ID.
client_order_id (ClientOrderId) - 客户端订单 ID。
order_side (OrderSide {BUY, SELL}) – The order side.
order_side (OrderSide {BUY, SELL}) - 订单方向。
quantity (Quantity) – The order quantity (> 0).
quantity (Quantity) - 订单数量 (> 0)。
price (Price) – The order limit price.
price (Price) - 订单限价。
init_id (UUID4) – The order initialization event ID.
init_id (UUID4) - 订单初始化事件 ID。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.
ts_init (uint64_t) - 对象初始化时的 UNIX 时间戳(纳秒)。
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY, AT_THE_OPEN, AT_THE_CLOSE}, default GTC) – The order time in force.
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY, AT_THE_OPEN, AT_THE_CLOSE},默认 GTC) - 订单有效时间。
expire_time_ns (uint64_t , default 0 *(*no expiry )) – UNIX timestamp (nanoseconds) when the order will expire.
expire_time_ns (uint64_t,默认 0 *(*无到期*)) - 订单到期的 UNIX 时间戳(纳秒)。
post_only (bool , default False) – If the order will only provide liquidity (make a market).
post_only (bool,默认 False) - 如果订单只提供流动性(做市商)。
reduce_only (bool , default False) – If the order carries the ‘reduce-only’ execution instruction.
reduce_only (bool,默认 False) - 如果订单带有“仅减少”执行指令。
quote_quantity (bool , default False) – If the order quantity is denominated in the quote currency.
quote_quantity (bool,默认 False) - 如果订单数量以报价货币计价。
display_qty (Quantity , optional) – The quantity of the order to display on the public book (iceberg).
display_qty (Quantity,可选) - 要在公开订单簿上显示的订单数量(冰山订单)。
emulation_trigger (EmulationTrigger, default NO_TRIGGER) – The emulation trigger for the order.
emulation_trigger (EmulationTrigger,默认 NO_TRIGGER) - 订单的模拟触发器。
trigger_instrument_id (InstrumentId , optional) – The emulation trigger instrument ID for the order (if None then will be the instrument_id).
trigger_instrument_id (InstrumentId,可选) - 订单的模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
contingency_type (ContingencyType, default NO_CONTINGENCY) – The order contingency type.
contingency_type (ContingencyType,默认 NO_CONTINGENCY) - 订单意外事件类型。
order_list_id (OrderListId , optional) – The order list ID associated with the order.
order_list_id (OrderListId,可选) - 与订单关联的订单列表 ID。
linked_order_ids (list [ClientOrderId ] , optional) – The order linked client order ID(s).
linked_order_ids (list [ClientOrderId ],可选) - 订单链接的客户端订单 ID。
parent_order_id (ClientOrderId , optional) – The order parent client order ID.
parent_order_id (ClientOrderId,可选) - 订单父客户端订单 ID。
exec_algorithm_id (ExecAlgorithmId , optional) – The execution algorithm ID for the order.
exec_algorithm_id (ExecAlgorithmId,可选) - 订单的执行算法 ID。
exec_algorithm_params (dict *[*str , Any ] , optional) – The execution algorithm parameters for the order.
exec_algorithm_params (dict *[*str , Any ],可选) - 订单的执行算法参数。
exec_spawn_id (ClientOrderId , optional) – The execution algorithm spawning primary client order ID.
exec_spawn_id (ClientOrderId,可选) - 执行算法生成的原始客户端订单 ID。
tags (list *[*str ] , optional) – The custom user tags for the order.
tags (list *[*str ],可选) - 订单的自定义用户标签。
Raises:
ValueError – If order_side is NO_ORDER_SIDE.
ValueError - 如果 order_side 为 NO_ORDER_SIDE。
ValueError – If quantity is not positive (> 0).
ValueError - 如果 quantity 不为正数 (> 0)。
ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.
ValueError - 如果 time_in_force 为 GTD 并且 expire_time_ns <= UNIX epoch。
ValueError – If display_qty is negative (< 0) or greater than quantity.
ValueError - 如果 display_qty 为负数 (< 0) 或大于 quantity。
"""
@staticmethod
def create(init: "OrderInitialized"):
...
@property
def display_qty(self) -> "Quantity" or None:
"""
The quantity of the order to display on the public book (iceberg).
要在公开订单簿上显示的订单数量(冰山订单)。
Returns:
Quantity or None
"""
...
@property
def expire_time(self) -> "datetime" or None:
"""
Return the expire time for the order (UTC).
返回订单的到期时间 (UTC)。
Return type:
datetime or None
"""
...
@property
def expire_time_ns(self) -> int:
"""
The order expiration (UNIX epoch nanoseconds), zero for no expiration.
订单到期时间(UNIX 纪元纳秒),0 表示无到期时间。
Returns:
uint64_t
"""
...
@staticmethod
def from_pyo3(pyo3_order):
...
def info(self) -> str:
"""
Return a summary description of the order.
返回订单的摘要描述。
Return type:
str
"""
...
@property
def price(self) -> "Price":
"""
The order price (LIMIT).
订单价格 (LIMIT)。
Returns:
Price
"""
...
def to_dict(self) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@staticmethod
def transform_py(order: "Order", ts_init: int, price: "Price" = None) -> "LimitOrder":
...
class LimitIfTouchedOrder 触碰限价单
class LimitIfTouchedOrder(Order):
"""
LimitIfTouchedOrder(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, Quantity quantity, Price price, Price trigger_price, TriggerType trigger_type, UUID4 init_id, uint64_t ts_init, TimeInForce time_in_force=TimeInForce.GTC, uint64_t expire_time_ns=0, bool post_only=False, bool reduce_only=False, bool quote_quantity=False, Quantity display_qty=None, TriggerType emulation_trigger=TriggerType.NO_TRIGGER, InstrumentId trigger_instrument_id=None, ContingencyType contingency_type=ContingencyType.NO_CONTINGENCY, OrderListId order_list_id=None, list linked_order_ids=None, ClientOrderId parent_order_id=None, ExecAlgorithmId exec_algorithm_id=None, dict exec_algorithm_params=None, ClientOrderId exec_spawn_id=None, list tags=None)
Represents a Limit-If-Touched (LIT) conditional order.
表示一个触碰限价单 (LIT) 条件订单。
A Limit-If-Touched (LIT) is an order to BUY (or SELL) an instrument at a specified price or better, below (or above) the market. This order is held in the system until the trigger price is touched. A LIT order is similar to a Stop-Limit order, except that a LIT SELL order is placed above the current market price, and a Stop-Limit SELL order is placed below.
触碰限价单 (LIT) 是指以指定价格或更好的价格买入(或卖出)金融工具的订单,该价格低于(或高于)市场价格。此订单在系统中持有,直到触及触发价格。LIT 订单类似于止损限价单,不同之处在于 LIT 卖出订单放置在当前市场价格之上,而止损限价卖出订单放置在当前市场价格之下。
Using a LIT order helps to ensure that, if the order does execute, the order will not execute at a price less favorable than the limit price.
使用 LIT 订单有助于确保,如果订单确实执行,订单将不会以比限价更不利的价格执行。
Parameters:
trader_id (TraderId) – The trader ID associated with the order.
trader_id (TraderId) - 与订单关联的交易者 ID。
strategy_id (StrategyId) – The strategy ID associated with the order.
strategy_id (StrategyId) - 与订单关联的策略 ID。
instrument_id (InstrumentId) – The order instrument ID.
instrument_id (InstrumentId) - 订单金融工具 ID。
client_order_id (ClientOrderId) – The client order ID.
client_order_id (ClientOrderId) - 客户端订单 ID。
order_side (OrderSide {BUY, SELL}) – The order side.
order_side (OrderSide {BUY, SELL}) - 订单方向。
quantity (Quantity) – The order quantity (> 0).
quantity (Quantity) - 订单数量 (> 0)。
price (Price) – The order price (LIMIT).
price (Price) - 订单价格 (LIMIT)。
trigger_price (Price) – The order trigger price (STOP).
trigger_price (Price) - 订单触发价格 (STOP)。
trigger_type (TriggerType) – The order trigger type.
trigger_type (TriggerType) - 订单触发器类型。
init_id (UUID4) – The order initialization event ID.
init_id (UUID4) - 订单初始化事件 ID。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.
ts_init (uint64_t) - 对象初始化时的 UNIX 时间戳(纳秒)。
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY}, default GTC) – The order time in force.
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY},默认 GTC) - 订单有效时间。
expire_time_ns (uint64_t , default 0 *(*no expiry )) – UNIX timestamp (nanoseconds) when the order will expire.
expire_time_ns (uint64_t,默认 0 *(*无到期*)) - 订单到期的 UNIX 时间戳(纳秒)。
post_only (bool , default False) – If the LIMIT order will only provide liquidity (once triggered).
post_only (bool,默认 False) - 如果限价单仅提供流动性(一旦触发)。
reduce_only (bool , default False) – If the LIMIT order carries the ‘reduce-only’ execution instruction.
reduce_only (bool,默认 False) - 如果限价单带有“仅减少”执行指令。
quote_quantity (bool , default False) – If the order quantity is denominated in the quote currency.
quote_quantity (bool,默认 False) - 如果订单数量以报价货币计价。
display_qty (Quantity , optional) – The quantity of the LIMIT order to display on the public book (iceberg).
display_qty (Quantity,可选) - 要在公开订单簿上显示的限价单数量(冰山订单)。
emulation_trigger (EmulationTrigger, default NO_TRIGGER) – The emulation trigger for the order.
emulation_trigger (EmulationTrigger,默认 NO_TRIGGER) - 订单的模拟触发器。
trigger_instrument_id (InstrumentId , optional) – The emulation trigger instrument ID for the order (if None then will be the instrument_id).
trigger_instrument_id (InstrumentId,可选) - 订单的模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
contingency_type (ContingencyType, default NO_CONTINGENCY) – The order contingency type.
contingency_type (ContingencyType,默认 NO_CONTINGENCY) - 订单意外事件类型。
order_list_id (OrderListId , optional) – The order list ID associated with the order.
order_list_id (OrderListId,可选) - 与订单关联的订单列表 ID。
linked_order_ids (list [ClientOrderId ] , optional) – The order linked client order ID(s).
linked_order_ids (list [ClientOrderId ],可选) - 订单链接的客户端订单 ID。
parent_order_id (ClientOrderId , optional) – The order parent client order ID.
parent_order_id (ClientOrderId,可选) - 订单父客户端订单 ID。
exec_algorithm_id (ExecAlgorithmId , optional) – The execution algorithm ID for the order.
exec_algorithm_id (ExecAlgorithmId,可选) - 订单的执行算法 ID。
exec_algorithm_params (dict *[*str , Any ] , optional) – The execution algorithm parameters for the order.
exec_algorithm_params (dict *[*str , Any ],可选) - 订单的执行算法参数。
exec_spawn_id (ClientOrderId , optional) – The execution algorithm spawning primary client order ID.
exec_spawn_id (ClientOrderId,可选) - 执行算法生成的原始客户端订单 ID。
tags (list *[*str ] , optional) – The custom user tags for the order.
tags (list *[*str ],可选) - 订单的自定义用户标签。
Raises:
ValueError – If order_side is NO_ORDER_SIDE.
ValueError - 如果 order_side 为 NO_ORDER_SIDE。
ValueError – If quantity is not positive (> 0).
ValueError - 如果 quantity 不为正数 (> 0)。
ValueError – If trigger_type is NO_TRIGGER.
ValueError - 如果 trigger_type 为 NO_TRIGGER。
ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE.
ValueError - 如果 time_in_force 为 AT_THE_OPEN 或 AT_THE_CLOSE。
ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.
ValueError - 如果 time_in_force 为 GTD 并且 expire_time_ns <= UNIX epoch。
ValueError – If display_qty is negative (< 0) or greater than quantity.
ValueError - 如果 display_qty 为负数 (< 0) 或大于 quantity。
"""
@staticmethod
def create(init):
...
@property
def display_qty(self) -> "Quantity" or None:
"""
The quantity of the LIMIT order to display on the public book (iceberg).
要在公开订单簿上显示的限价单数量(冰山订单)。
Returns:
Quantity or None
"""
...
@property
def expire_time(self) -> "datetime" or None:
"""
Return the expire time for the order (UTC).
返回订单的到期时间 (UTC)。
Return type:
datetime or None
"""
...
@property
def expire_time_ns(self) -> int:
"""
The order expiration (UNIX epoch nanoseconds), zero for no expiration.
订单到期时间(UNIX 纪元纳秒),0 表示无到期时间。
Returns:
uint64_t
"""
...
def info(self) -> str:
"""
Return a summary description of the order.
返回订单的摘要描述。
Return type:
str
"""
...
@property
def is_triggered(self) -> bool:
"""
If the order has been triggered.
如果订单已触发。
Returns:
bool
"""
...
@property
def price(self) -> "Price":
"""
The order price (LIMIT).
订单价格 (LIMIT)。
Returns:
Price
"""
...
def to_dict(self) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def trigger_price(self) -> "Price":
"""
The order trigger price (STOP).
订单触发价格 (STOP)。
Returns:
Price
"""
...
@property
def trigger_type(self) -> "TriggerType":
"""
The trigger type for the order.
订单的触发器类型。
Returns:
TriggerType
"""
...
@property
def ts_triggered(self) -> int:
"""
UNIX timestamp (nanoseconds) when the order was triggered (0 if not triggered).
订单触发时的 UNIX 时间戳(纳秒)(如果未触发,则为 0)。
Returns:
uint64_t
"""
...
class OrderList 订单列表
class OrderList(object):
"""
OrderList(OrderListId order_list_id, list orders)
Represents a list of bulk or related contingent orders.
表示批量或相关联的条件订单列表。
Parameters:
order_list_id (OrderListId) – The order list ID.
order_list_id (OrderListId) - 订单列表 ID。
orders (list [Order ]) – The contained orders list.
orders (list [Order ]) - 包含的订单列表。
Raises:
ValueError – If orders is empty.
ValueError - 如果 orders 为空。
ValueError – If orders contains a type other than Order.
ValueError - 如果 orders 包含 Order 以外的类型。
"""
def __init__(self, order_list_id: "OrderListId", orders: list["Order"]) -> None:
...
@property
def first(self) -> list["Order"]:
"""
The first order in the list (typically the parent).
列表中的第一个订单(通常是父订单)。
Returns:
list[Order]
"""
...
@property
def id(self) -> "OrderListId":
"""
The order list ID.
订单列表 ID。
Returns:
OrderListId
"""
...
@property
def instrument_id(self) -> "InstrumentId":
"""
The instrument ID associated with the list.
与列表关联的金融工具 ID。
Returns:
InstrumentId
"""
...
@property
def orders(self) -> list["Order"]:
"""
The contained orders list.
包含的订单列表。
Returns:
list[Order]
"""
...
@property
def strategy_id(self) -> "StrategyId":
"""
The strategy ID associated with the list.
与列表关联的策略 ID。
Returns:
StrategyId
"""
...
@property
def ts_init(self) -> int:
"""
UNIX timestamp (nanoseconds) when the object was initialized.
对象初始化时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
class MarketOrder 市价单
class MarketOrder(Order):
"""
MarketOrder(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, Quantity quantity, UUID4 init_id, uint64_t ts_init, TimeInForce time_in_force=TimeInForce.GTC, bool reduce_only=False, bool quote_quantity=False, ContingencyType contingency_type=ContingencyType.NO_CONTINGENCY, OrderListId order_list_id=None, list linked_order_ids=None, ClientOrderId parent_order_id=None, ExecAlgorithmId exec_algorithm_id=None, dict exec_algorithm_params=None, ClientOrderId exec_spawn_id=None, list tags=None)
Represents a Market order.
表示一个市价单。
A Market order is an order to BUY (or SELL) at the market bid or offer price. A market order may increase the likelihood of a fill and the speed of execution, but unlike the Limit order - a Market order provides no price protection and may fill at a price far lower/higher than the top-of-book bid/ask.
市价单是指以市场买入价或卖出价买入(或卖出)的订单。市价单可能会增加成交的可能性和执行速度,但与限价单不同的是,市价单不提供价格保护,并且可能会以远低于/高于最佳买入/卖出价的价格成交。
A Market-On-Open (MOO) order can be represented using a time in force of AT_THE_OPEN.
市价开仓单 (MOO) 可以使用 AT_THE_OPEN 的有效时间来表示。
A Market-On-Close (MOC) order can be represented using a time in force of AT_THE_CLOSE.
市价平仓单 (MOC) 可以使用 AT_THE_CLOSE 的有效时间来表示。
Parameters:
trader_id (TraderId) – The trader ID associated with the order.
trader_id (TraderId) - 与订单关联的交易者 ID。
strategy_id (StrategyId) – The strategy ID associated with the order.
strategy_id (StrategyId) - 与订单关联的策略 ID。
instrument_id (InstrumentId) – The order instrument ID.
instrument_id (InstrumentId) - 订单金融工具 ID。
client_order_id (ClientOrderId) – The client order ID.
client_order_id (ClientOrderId) - 客户端订单 ID。
order_side (OrderSide {BUY, SELL}) – The order side.
order_side (OrderSide {BUY, SELL}) - 订单方向。
quantity (Quantity) – The order quantity (> 0).
quantity (Quantity) - 订单数量 (> 0)。
init_id (UUID4) – The order initialization event ID.
init_id (UUID4) - 订单初始化事件 ID。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.
ts_init (uint64_t) - 对象初始化时的 UNIX 时间戳(纳秒)。
time_in_force (TimeInForce {GTC, IOC, FOK, DAY, AT_THE_OPEN, AT_THE_CLOSE}, default GTC) – The order time in force.
time_in_force (TimeInForce {GTC, IOC, FOK, DAY, AT_THE_OPEN, AT_THE_CLOSE},默认 GTC) - 订单有效时间。
reduce_only (bool , default False) – If the order carries the ‘reduce-only’ execution instruction.
reduce_only (bool,默认 False) - 如果订单带有“仅减少”执行指令。
quote_quantity (bool , default False) – If the order quantity is denominated in the quote currency.
quote_quantity (bool,默认 False) - 如果订单数量以报价货币计价。
contingency_type (ContingencyType, default NO_CONTINGENCY) – The order contingency type.
contingency_type (ContingencyType,默认 NO_CONTINGENCY) - 订单意外事件类型。
order_list_id (OrderListId , optional) – The order list ID associated with the order.
order_list_id (OrderListId,可选) - 与订单关联的订单列表 ID。
linked_order_ids (list [ClientOrderId ] , optional) – The order linked client order ID(s).
linked_order_ids (list [ClientOrderId ],可选) - 订单链接的客户端订单 ID。
parent_order_id (ClientOrderId , optional) – The order parent client order ID.
parent_order_id (ClientOrderId,可选) - 订单父客户端订单 ID。
exec_algorithm_id (ExecAlgorithmId , optional) – The execution algorithm ID for the order.
exec_algorithm_id (ExecAlgorithmId,可选) - 订单的执行算法 ID。
exec_algorithm_params (dict *[*str , Any ] , optional) – The execution algorithm parameters for the order.
exec_algorithm_params (dict *[*str , Any ],可选) - 订单的执行算法参数。
exec_spawn_id (ClientOrderId , optional) – The execution algorithm spawning primary client order ID.
exec_spawn_id (ClientOrderId,可选) - 执行算法生成的原始客户端订单 ID。
tags (list *[*str ] , optional) – The custom user tags for the order.
tags (list *[*str ],可选) - 订单的自定义用户标签。
Raises:
ValueError – If order_side is NO_ORDER_SIDE.
ValueError - 如果 order_side 为 NO_ORDER_SIDE。
ValueError – If quantity is not positive (> 0).
ValueError - 如果 quantity 不为正数 (> 0)。
ValueError – If time_in_force is GTD.
ValueError - 如果 time_in_force 为 GTD。
"""
@staticmethod
def create(init):
...
@staticmethod
def from_pyo3(pyo3_order):
...
def info(self) -> str:
"""
Return a summary description of the order.
返回订单的摘要描述。
Return type:
str
"""
...
def to_dict(self) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@staticmethod
def transform_py(order: "Order", ts_init: int) -> "MarketOrder":
...
class MarketIfTouchedOrder 触碰市价单
class MarketIfTouchedOrder(Order):
"""
MarketIfTouchedOrder(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, Quantity quantity, Price trigger_price, TriggerType trigger_type, UUID4 init_id, uint64_t ts_init, TimeInForce time_in_force=TimeInForce.GTC, uint64_t expire_time_ns=0, bool reduce_only=False, bool quote_quantity=False, TriggerType emulation_trigger=TriggerType.NO_TRIGGER, InstrumentId trigger_instrument_id=None, ContingencyType contingency_type=ContingencyType.NO_CONTINGENCY, OrderListId order_list_id=None, list linked_order_ids=None, ClientOrderId parent_order_id=None, ExecAlgorithmId exec_algorithm_id=None, dict exec_algorithm_params=None, ClientOrderId exec_spawn_id=None, list tags=None)
Represents a Market-If-Touched (MIT) conditional order.
表示一个触碰市价单 (MIT) 条件订单。
A Market-If-Touched (MIT) is an order to BUY (or SELL) an instrument below (or above) the market. This order is held in the system until the trigger price is touched, and is then submitted as a market order. An MIT order is similar to a Stop-Order, except that an MIT SELL order is placed above the current market price, and a stop SELL order is placed below.
触碰市价单 (MIT) 是指以低于(或高于)市场价格买入(或卖出)金融工具的订单。此订单在系统中持有,直到触及触发价格,然后作为市价单提交。MIT 订单类似于止损单,不同之处在于 MIT 卖出订单放置在当前市场价格之上,而止损卖出订单放置在当前市场价格之下。
Parameters:
trader_id (TraderId) – The trader ID associated with the order.
trader_id (TraderId) - 与订单关联的交易者 ID。
strategy_id (StrategyId) – The strategy ID associated with the order.
strategy_id (StrategyId) - 与订单关联的策略 ID。
instrument_id (InstrumentId) – The order instrument ID.
instrument_id (InstrumentId) - 订单金融工具 ID。
client_order_id (ClientOrderId) – The client order ID.
client_order_id (ClientOrderId) - 客户端订单 ID。
order_side (OrderSide {BUY, SELL}) – The order side.
order_side (OrderSide {BUY, SELL}) - 订单方向。
quantity (Quantity) – The order quantity (> 0).
quantity (Quantity) - 订单数量 (> 0)。
trigger_price (Price) – The order trigger price (STOP).
trigger_price (Price) - 订单触发价格 (STOP)。
trigger_type (TriggerType) – The order trigger type.
trigger_type (TriggerType) - 订单触发器类型。
init_id (UUID4) – The order initialization event ID.
init_id (UUID4) - 订单初始化事件 ID。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.
ts_init (uint64_t) - 对象初始化时的 UNIX 时间戳(纳秒)。
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY}, default GTC) – The order time in force.
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY},默认 GTC) - 订单有效时间。
expire_time_ns (uint64_t , default 0 *(*no expiry )) – UNIX timestamp (nanoseconds) when the order will expire.
expire_time_ns (uint64_t,默认 0 *(*无到期*)) - 订单到期的 UNIX 时间戳(纳秒)。
reduce_only (bool , default False) – If the order carries the ‘reduce-only’ execution instruction.
reduce_only (bool,默认 False) - 如果订单带有“仅减少”执行指令。
quote_quantity (bool , default False) – If the order quantity is denominated in the quote currency.
quote_quantity (bool,默认 False) - 如果订单数量以报价货币计价。
emulation_trigger (EmulationTrigger, default NO_TRIGGER) – The emulation trigger for the order.
emulation_trigger (EmulationTrigger,默认 NO_TRIGGER) - 订单的模拟触发器。
trigger_instrument_id (InstrumentId , optional) – The emulation trigger instrument ID for the order (if None then will be the instrument_id).
trigger_instrument_id (InstrumentId,可选) - 订单的模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
contingency_type (ContingencyType, default NO_CONTINGENCY) – The order contingency type.
contingency_type (ContingencyType,默认 NO_CONTINGENCY) - 订单意外事件类型。
order_list_id (OrderListId , optional) – The order list ID associated with the order.
order_list_id (OrderListId,可选) - 与订单关联的订单列表 ID。
linked_order_ids (list [ClientOrderId ] , optional) – The order linked client order ID(s).
linked_order_ids (list [ClientOrderId ],可选) - 订单链接的客户端订单 ID。
parent_order_id (ClientOrderId , optional) – The order parent client order ID.
parent_order_id (ClientOrderId,可选) - 订单父客户端订单 ID。
exec_algorithm_id (ExecAlgorithmId , optional) – The execution algorithm ID for the order.
exec_algorithm_id (ExecAlgorithmId,可选) - 订单的执行算法 ID。
exec_algorithm_params (dict *[*str , Any ] , optional) – The execution algorithm parameters for the order.
exec_algorithm_params (dict *[*str , Any ],可选) - 订单的执行算法参数。
exec_spawn_id (ClientOrderId , optional) – The execution algorithm spawning primary client order ID.
exec_spawn_id (ClientOrderId,可选) - 执行算法生成的原始客户端订单 ID。
tags (list *[*str ] , optional) – The custom user tags for the order.
tags (list *[*str ],可选) - 订单的自定义用户标签。
Raises:
ValueError – If order_side is NO_ORDER_SIDE.
ValueError - 如果 order_side 为 NO_ORDER_SIDE。
ValueError – If quantity is not positive (> 0).
ValueError - 如果 quantity 不为正数 (> 0)。
ValueError – If trigger_type is NO_TRIGGER.
ValueError - 如果 trigger_type 为 NO_TRIGGER。
ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE.
ValueError - 如果 time_in_force 为 AT_THE_OPEN 或 AT_THE_CLOSE。
ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.
ValueError - 如果 time_in_force 为 GTD 并且 expire_time_ns <= UNIX epoch。
"""
@staticmethod
def create(init):
...
@property
def expire_time(self) -> "datetime" or None:
"""
Return the expire time for the order (UTC).
返回订单的到期时间 (UTC)。
Return type:
datetime or None
"""
...
@property
def expire_time_ns(self) -> int:
"""
The order expiration (UNIX epoch nanoseconds), zero for no expiration.
订单到期时间(UNIX 纪元纳秒),0 表示无到期时间。
Returns:
uint64_t
"""
...
def info(self) -> str:
"""
Return a summary description of the order.
返回订单的摘要描述。
Return type:
str
"""
...
def to_dict(self) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def trigger_price(self) -> "Price":
"""
The order trigger price (STOP).
订单触发价格 (STOP)。
Returns:
Price
"""
...
@property
def trigger_type(self) -> "TriggerType":
"""
The trigger type for the order.
订单的触发器类型。
Returns:
TriggerType
"""
...
class MarketToLimitOrder 市价转限价单
class MarketToLimitOrder(Order):
"""
MarketToLimitOrder(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, Quantity quantity, UUID4 init_id, uint64_t ts_init, TimeInForce time_in_force=TimeInForce.GTC, uint64_t expire_time_ns=0, bool reduce_only=False, bool quote_quantity=False, Quantity display_qty=None, ContingencyType contingency_type=ContingencyType.NO_CONTINGENCY, OrderListId order_list_id=None, list linked_order_ids=None, ClientOrderId parent_order_id=None, ExecAlgorithmId exec_algorithm_id=None, dict exec_algorithm_params=None, ClientOrderId exec_spawn_id=None, list tags=None)
Represents a Market-To-Limit (MTL) order.
表示一个市价转限价单 (MTL) 订单。
A Market-to-Limit (MTL) order is submitted as a market order to execute at the current best market price. If the order is only partially filled, the remainder of the order is canceled and re-submitted as a Limit order with the limit price equal to the price at which the filled portion of the order executed.
市价转限价单 (MTL) 订单作为市价单提交,以当前最佳市场价格执行。如果订单仅部分成交,则订单的剩余部分将被取消并重新提交为限价单,限价等于订单成交部分的执行价格。
Parameters:
trader_id (TraderId) – The trader ID associated with the order.
trader_id (TraderId) - 与订单关联的交易者 ID。
strategy_id (StrategyId) – The strategy ID associated with the order.
strategy_id (StrategyId) - 与订单关联的策略 ID。
instrument_id (InstrumentId) – The order instrument ID.
instrument_id (InstrumentId) - 订单金融工具 ID。
client_order_id (ClientOrderId) – The client order ID.
client_order_id (ClientOrderId) - 客户端订单 ID。
order_side (OrderSide {BUY, SELL}) – The order side.
order_side (OrderSide {BUY, SELL}) - 订单方向。
quantity (Quantity) – The order quantity (> 0).
quantity (Quantity) - 订单数量 (> 0)。
init_id (UUID4) – The order initialization event ID.
init_id (UUID4) - 订单初始化事件 ID。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.
ts_init (uint64_t) - 对象初始化时的 UNIX 时间戳(纳秒)。
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY}, default GTC) – The order time in force.
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY},默认 GTC) - 订单有效时间。
expire_time_ns (uint64_t , default 0 *(*no expiry )) – UNIX timestamp (nanoseconds) when the order will expire.
expire_time_ns (uint64_t,默认 0 *(*无到期*)) - 订单到期的 UNIX 时间戳(纳秒)。
reduce_only (bool , default False) – If the order carries the ‘reduce-only’ execution instruction.
reduce_only (bool,默认 False) - 如果订单带有“仅减少”执行指令。
quote_quantity (bool , default False) – If the order quantity is denominated in the quote currency.
quote_quantity (bool,默认 False) - 如果订单数量以报价货币计价。
display_qty (Quantity , optional) – The quantity of the limit order to display on the public book (iceberg).
display_qty (Quantity,可选) - 要在公开订单簿上显示的限价单数量(冰山订单)。
contingency_type (ContingencyType, default NO_CONTINGENCY) – The order contingency type.
contingency_type (ContingencyType,默认 NO_CONTINGENCY) - 订单意外事件类型。
order_list_id (OrderListId , optional) – The order list ID associated with the order.
order_list_id (OrderListId,可选) - 与订单关联的订单列表 ID。
linked_order_ids (list [ClientOrderId ] , optional) – The order linked client order ID(s).
linked_order_ids (list [ClientOrderId ],可选) - 订单链接的客户端订单 ID。
parent_order_id (ClientOrderId , optional) – The order parent client order ID.
parent_order_id (ClientOrderId,可选) - 订单父客户端订单 ID。
exec_algorithm_id (ExecAlgorithmId , optional) – The execution algorithm ID for the order.
exec_algorithm_id (ExecAlgorithmId,可选) - 订单的执行算法 ID。
exec_algorithm_params (dict *[*str , Any ] , optional) – The execution algorithm parameters for the order.
exec_algorithm_params (dict *[*str , Any ],可选) - 订单的执行算法参数。
exec_spawn_id (ClientOrderId , optional) – The execution algorithm spawning primary client order ID.
exec_spawn_id (ClientOrderId,可选) - 执行算法生成的原始客户端订单 ID。
tags (list *[*str ] , optional) – The custom user tags for the order.
tags (list *[*str ],可选) - 订单的自定义用户标签。
Raises:
ValueError – If order_side is NO_ORDER_SIDE.
ValueError - 如果 order_side 为 NO_ORDER_SIDE。
ValueError – If quantity is not positive (> 0).
ValueError - 如果 quantity 不为正数 (> 0)。
ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE.
ValueError - 如果 time_in_force 为 AT_THE_OPEN 或 AT_THE_CLOSE。
"""
@staticmethod
def create(init):
...
@property
def display_qty(self) -> "Quantity" or None:
"""
The quantity of the limit order to display on the public book (iceberg).
要在公开订单簿上显示的限价单数量(冰山订单)。
Returns:
Quantity or None
"""
...
@property
def expire_time(self) -> "datetime" or None:
"""
Return the expire time for the order (UTC).
返回订单的到期时间 (UTC)。
Return type:
datetime or None
"""
...
@property
def expire_time_ns(self) -> int:
"""
The order expiration (UNIX epoch nanoseconds), zero for no expiration.
订单到期时间(UNIX 纪元纳秒),0 表示无到期时间。
Returns:
uint64_t
"""
...
def info(self) -> str:
"""
Return a summary description of the order.
返回订单的摘要描述。
Return type:
str
"""
...
@property
def price(self) -> "Price" or None:
"""
The order price (LIMIT).
订单价格 (LIMIT)。
Returns:
Price or None
"""
...
def to_dict(self) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
class StopLimitOrder 止损限价单
class StopLimitOrder(Order):
"""
StopLimitOrder(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, Quantity quantity, Price price, Price trigger_price, TriggerType trigger_type, UUID4 init_id, uint64_t ts_init, TimeInForce time_in_force=TimeInForce.GTC, uint64_t expire_time_ns=0, bool post_only=False, bool reduce_only=False, bool quote_quantity=False, Quantity display_qty=None, TriggerType emulation_trigger=TriggerType.NO_TRIGGER, InstrumentId trigger_instrument_id=None, ContingencyType contingency_type=ContingencyType.NO_CONTINGENCY, OrderListId order_list_id=None, list linked_order_ids=None, ClientOrderId parent_order_id=None, ExecAlgorithmId exec_algorithm_id=None, dict exec_algorithm_params=None, ClientOrderId exec_spawn_id=None, list tags=None)
Represents a Stop-Limit conditional order.
表示一个止损限价条件订单。
A Stop-Limit order is an instruction to submit a BUY (or SELL) limit order when the specified stop trigger price is attained or penetrated. The order has two basic components: the stop price and the limit price. When a trade has occurred at or through the stop price, the order becomes executable and enters the market as a limit order, which is an order to BUY (or SELL) at a specified price or better.
止损限价单是指当达到或突破指定的止损触发价格时提交买入(或卖出)限价单的指令。该订单有两个基本组成部分:止损价和限价。当以止损价或通过止损价进行交易时,订单变为可执行订单,并作为限价单进入市场,限价单是指以指定价格或更好的价格买入(或卖出)的订单。
A Stop-Limit eliminates the price risk associated with a stop order where the execution price cannot be guaranteed, but exposes the trader to the risk that the order may never fill, even if the stop price is reached.
止损限价单消除了止损单中无法保证执行价格的价格风险,但使交易者面临即使达到止损价也可能永远无法成交的风险。
Parameters:
trader_id (TraderId) – The trader ID associated with the order.
trader_id (TraderId) - 与订单关联的交易者 ID。
strategy_id (StrategyId) – The strategy ID associated with the order.
strategy_id (StrategyId) - 与订单关联的策略 ID。
instrument_id (InstrumentId) – The order instrument ID.
instrument_id (InstrumentId) - 订单金融工具 ID。
client_order_id (ClientOrderId) – The client order ID.
client_order_id (ClientOrderId) - 客户端订单 ID。
order_side (OrderSide {BUY, SELL}) – The order side.
order_side (OrderSide {BUY, SELL}) - 订单方向。
quantity (Quantity) – The order quantity (> 0).
quantity (Quantity) - 订单数量 (> 0)。
price (Price) – The order price (LIMIT).
price (Price) - 订单价格 (LIMIT)。
trigger_price (Price) – The order trigger price (STOP).
trigger_price (Price) - 订单触发价格 (STOP)。
trigger_type (TriggerType) – The order trigger type.
trigger_type (TriggerType) - 订单触发器类型。
init_id (UUID4) – The order initialization event ID.
init_id (UUID4) - 订单初始化事件 ID。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.
ts_init (uint64_t) - 对象初始化时的 UNIX 时间戳(纳秒)。
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY}, default GTC) – The order time in force.
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY},默认 GTC) - 订单有效时间。
expire_time_ns (uint64_t , default 0 *(*no expiry )) – UNIX timestamp (nanoseconds) when the order will expire.
expire_time_ns (uint64_t,默认 0 *(*无到期*)) - 订单到期的 UNIX 时间戳(纳秒)。
post_only (bool , default False) – If the LIMIT order will only provide liquidity (once triggered).
post_only (bool,默认 False) - 如果限价单仅提供流动性(一旦触发)。
reduce_only (bool , default False) – If the LIMIT order carries the ‘reduce-only’ execution instruction.
reduce_only (bool,默认 False) - 如果限价单带有“仅减少”执行指令。
quote_quantity (bool , default False) – If the order quantity is denominated in the quote currency.
quote_quantity (bool,默认 False) - 如果订单数量以报价货币计价。
display_qty (Quantity , optional) – The quantity of the LIMIT order to display on the public book (iceberg).
display_qty (Quantity,可选) - 要在公开订单簿上显示的限价单数量(冰山订单)。
emulation_trigger (EmulationTrigger, default NO_TRIGGER) – The emulation trigger for the order.
emulation_trigger (EmulationTrigger,默认 NO_TRIGGER) - 订单的模拟触发器。
trigger_instrument_id (InstrumentId , optional) – The emulation trigger instrument ID for the order (if None then will be the instrument_id).
trigger_instrument_id (InstrumentId,可选) - 订单的模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
contingency_type (ContingencyType, default NO_CONTINGENCY) – The order contingency type.
contingency_type (ContingencyType,默认 NO_CONTINGENCY) - 订单意外事件类型。
order_list_id (OrderListId , optional) – The order list ID associated with the order.
order_list_id (OrderListId,可选) - 与订单关联的订单列表 ID。
linked_order_ids (list [ClientOrderId ] , optional) – The order linked client order ID(s).
linked_order_ids (list [ClientOrderId ],可选) - 订单链接的客户端订单 ID。
parent_order_id (ClientOrderId , optional) – The order parent client order ID.
parent_order_id (ClientOrderId,可选) - 订单父客户端订单 ID。
exec_algorithm_id (ExecAlgorithmId , optional) – The execution algorithm ID for the order.
exec_algorithm_id (ExecAlgorithmId,可选) - 订单的执行算法 ID。
exec_algorithm_params (dict *[*str , Any ] , optional) – The execution algorithm parameters for the order.
exec_algorithm_params (dict *[*str , Any ],可选) - 订单的执行算法参数。
exec_spawn_id (ClientOrderId , optional) – The execution algorithm spawning primary client order ID.
exec_spawn_id (ClientOrderId,可选) - 执行算法生成的原始客户端订单 ID。
tags (list *[*str ] , optional) – The custom user tags for the order.
tags (list *[*str ],可选) - 订单的自定义用户标签。
Raises:
ValueError – If order_side is NO_ORDER_SIDE.
ValueError - 如果 order_side 为 NO_ORDER_SIDE。
ValueError – If quantity is not positive (> 0).
ValueError - 如果 quantity 不为正数 (> 0)。
ValueError – If trigger_type is NO_TRIGGER.
ValueError - 如果 trigger_type 为 NO_TRIGGER。
ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE.
ValueError - 如果 time_in_force 为 AT_THE_OPEN 或 AT_THE_CLOSE。
ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.
ValueError - 如果 time_in_force 为 GTD 并且 expire_time_ns <= UNIX epoch。
ValueError – If display_qty is negative (< 0) or greater than quantity.
ValueError - 如果 display_qty 为负数 (< 0) 或大于 quantity。
"""
@staticmethod
def create(init):
...
@property
def display_qty(self) -> "Quantity" or None:
"""
The quantity of the LIMIT order to display on the public book (iceberg).
要在公开订单簿上显示的限价单数量(冰山订单)。
Returns:
Quantity or None
"""
...
@property
def expire_time(self) -> "datetime" or None:
"""
Return the expire time for the order (UTC).
返回订单的到期时间 (UTC)。
Return type:
datetime or None
"""
...
@property
def expire_time_ns(self) -> int:
"""
The order expiration (UNIX epoch nanoseconds), zero for no expiration.
订单到期时间(UNIX 纪元纳秒),0 表示无到期时间。
Returns:
uint64_t
"""
...
@staticmethod
def from_pyo3(pyo3_order):
...
def info(self) -> str:
"""
Return a summary description of the order.
返回订单的摘要描述。
Return type:
str
"""
...
@property
def is_triggered(self) -> bool:
"""
If the order has been triggered.
如果订单已触发。
Returns:
bool
"""
...
@property
def price(self) -> "Price":
"""
The order price (LIMIT).
订单价格 (LIMIT)。
Returns:
Price
"""
...
def to_dict(self) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def trigger_price(self) -> "Price":
"""
The order trigger price (STOP).
订单触发价格 (STOP)。
Returns:
Price
"""
...
@property
def trigger_type(self) -> "TriggerType":
"""
The trigger type for the order.
订单的触发器类型。
Returns:
TriggerType
"""
...
@property
def ts_triggered(self) -> int:
"""
UNIX timestamp (nanoseconds) when the order was triggered (0 if not triggered).
订单触发时的 UNIX 时间戳(纳秒)(如果未触发,则为 0)。
Returns:
uint64_t
"""
...
class StopMarketOrder 止损市价单
class StopMarketOrder(Order):
"""
StopMarketOrder(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, Quantity quantity, Price trigger_price, TriggerType trigger_type, UUID4 init_id, uint64_t ts_init, TimeInForce time_in_force=TimeInForce.GTC, uint64_t expire_time_ns=0, bool reduce_only=False, bool quote_quantity=False, TriggerType emulation_trigger=TriggerType.NO_TRIGGER, InstrumentId trigger_instrument_id=None, ContingencyType contingency_type=ContingencyType.NO_CONTINGENCY, OrderListId order_list_id=None, list linked_order_ids=None, ClientOrderId parent_order_id=None, ExecAlgorithmId exec_algorithm_id=None, dict exec_algorithm_params=None, ClientOrderId exec_spawn_id=None, list tags=None)
Represents a Stop-Market conditional order.
表示一个止损市价条件订单。
A Stop-Market order is an instruction to submit a BUY (or SELL) market order if and when the specified stop trigger price is attained or penetrated. A Stop-Market order is not guaranteed a specific execution price and may execute significantly away from its stop price.
止损市价单是指当达到或突破指定的止损触发价格时提交买入(或卖出)市价单的指令。止损市价单不保证特定的执行价格,并且可能以与其止损价相差很大的价格执行。
A SELL Stop-Market order is always placed below the current market price, and is typically used to limit a loss or protect a profit on a long position.
卖出止损市价单始终放置在当前市场价格之下,通常用于限制多头头寸的损失或保护利润。
A BUY Stop-Market order is always placed above the current market price, and is typically used to limit a loss or protect a profit on a short position.
买入止损市价单始终放置在当前市场价格之上,通常用于限制空头头寸的损失或保护利润。
Parameters:
trader_id (TraderId) – The trader ID associated with the order.
trader_id (TraderId) - 与订单关联的交易者 ID。
strategy_id (StrategyId) – The strategy ID associated with the order.
strategy_id (StrategyId) - 与订单关联的策略 ID。
instrument_id (InstrumentId) – The order instrument ID.
instrument_id (InstrumentId) - 订单金融工具 ID。
client_order_id (ClientOrderId) – The client order ID.
client_order_id (ClientOrderId) - 客户端订单 ID。
order_side (OrderSide {BUY, SELL}) – The order side.
order_side (OrderSide {BUY, SELL}) - 订单方向。
quantity (Quantity) – The order quantity (> 0).
quantity (Quantity) - 订单数量 (> 0)。
trigger_price (Price) – The order trigger price (STOP).
trigger_price (Price) - 订单触发价格 (STOP)。
trigger_type (TriggerType) – The order trigger type.
trigger_type (TriggerType) - 订单触发器类型。
init_id (UUID4) – The order initialization event ID.
init_id (UUID4) - 订单初始化事件 ID。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.
ts_init (uint64_t) - 对象初始化时的 UNIX 时间戳(纳秒)。
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY}, default GTC) – The order time in force.
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY},默认 GTC) - 订单有效时间。
expire_time_ns (uint64_t , default 0 *(*no expiry )) – UNIX timestamp (nanoseconds) when the order will expire.
expire_time_ns (uint64_t,默认 0 *(*无到期*)) - 订单到期的 UNIX 时间戳(纳秒)。
reduce_only (bool , default False) – If the order carries the ‘reduce-only’ execution instruction.
reduce_only (bool,默认 False) - 如果订单带有“仅减少”执行指令。
quote_quantity (bool , default False) – If the order quantity is denominated in the quote currency.
quote_quantity (bool,默认 False) - 如果订单数量以报价货币计价。
emulation_trigger (TriggerType, default NO_TRIGGER) – The order emulation trigger.
emulation_trigger (TriggerType,默认 NO_TRIGGER) - 订单模拟触发器。
trigger_instrument_id (InstrumentId , optional) – The emulation trigger instrument ID for the order (if None then will be the instrument_id).
trigger_instrument_id (InstrumentId,可选) - 订单的模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
contingency_type (ContingencyType, default NO_CONTINGENCY) – The order contingency type.
contingency_type (ContingencyType,默认 NO_CONTINGENCY) - 订单意外事件类型。
order_list_id (OrderListId , optional) – The order list ID associated with the order.
order_list_id (OrderListId,可选) - 与订单关联的订单列表 ID。
linked_order_ids (list [ClientOrderId ] , optional) – The order linked client order ID(s).
linked_order_ids (list [ClientOrderId ],可选) - 订单链接的客户端订单 ID。
parent_order_id (ClientOrderId , optional) – The order parent client order ID.
parent_order_id (ClientOrderId,可选) - 订单父客户端订单 ID。
exec_algorithm_id (ExecAlgorithmId , optional) – The execution algorithm ID for the order.
exec_algorithm_id (ExecAlgorithmId,可选) - 订单的执行算法 ID。
exec_algorithm_params (dict *[*str , Any ] , optional) – The execution algorithm parameters for the order.
exec_algorithm_params (dict *[*str , Any ],可选) - 订单的执行算法参数。
exec_spawn_id (ClientOrderId , optional) – The execution algorithm spawning primary client order ID.
exec_spawn_id (ClientOrderId,可选) - 执行算法生成的原始客户端订单 ID。
tags (list *[*str ] , optional) – The custom user tags for the order.
tags (list *[*str ],可选) - 订单的自定义用户标签。
Raises:
ValueError – If order_side is NO_ORDER_SIDE.
ValueError - 如果 order_side 为 NO_ORDER_SIDE。
ValueError – If quantity is not positive (> 0).
ValueError - 如果 quantity 不为正数 (> 0)。
ValueError – If trigger_type is NO_TRIGGER.
ValueError - 如果 trigger_type 为 NO_TRIGGER。
ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE.
ValueError - 如果 time_in_force 为 AT_THE_OPEN 或 AT_THE_CLOSE。
ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.
ValueError - 如果 time_in_force 为 GTD 并且 expire_time_ns <= UNIX epoch。
"""
@staticmethod
def create(init):
...
@property
def expire_time(self) -> "datetime" or None:
"""
Return the expire time for the order (UTC).
返回订单的到期时间 (UTC)。
Return type:
datetime or None
"""
...
@property
def expire_time_ns(self) -> int:
"""
The order expiration (UNIX epoch nanoseconds), zero for no expiration.
订单到期时间(UNIX 纪元纳秒),0 表示无到期时间。
Returns:
uint64_t
"""
...
def info(self) -> str:
"""
Return a summary description of the order.
返回订单的摘要描述。
Return type:
str
"""
...
def to_dict(self) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def trigger_price(self) -> "Price":
"""
The order trigger price (STOP).
订单触发价格 (STOP)。
Returns:
Price
"""
...
@property
def trigger_type(self) -> "TriggerType":
"""
The trigger type for the order.
订单的触发器类型。
Returns:
TriggerType
"""
...
class TrailingStopLimitOrder 追踪止损限价单
class TrailingStopLimitOrder(Order):
"""
TrailingStopLimitOrder(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, Quantity quantity, Price price: Price | None, Price trigger_price: Price | None, TriggerType trigger_type, limit_offset: Decimal, trailing_offset: Decimal, TrailingOffsetType trailing_offset_type, UUID4 init_id, uint64_t ts_init, TimeInForce time_in_force=TimeInForce.GTC, uint64_t expire_time_ns=0, bool post_only=False, bool reduce_only=False, bool quote_quantity=False, Quantity display_qty=None, TriggerType emulation_trigger=TriggerType.NO_TRIGGER, InstrumentId trigger_instrument_id=None, ContingencyType contingency_type=ContingencyType.NO_CONTINGENCY, OrderListId order_list_id=None, list linked_order_ids=None, ClientOrderId parent_order_id=None, ExecAlgorithmId exec_algorithm_id=None, dict exec_algorithm_params=None, ClientOrderId exec_spawn_id=None, list tags=None)
Represents a Trailing-Stop-Limit conditional order.
表示一个追踪止损限价条件订单。
Parameters:
trader_id (TraderId) – The trader ID associated with the order.
trader_id (TraderId) - 与订单关联的交易者 ID。
strategy_id (StrategyId) – The strategy ID associated with the order.
strategy_id (StrategyId) - 与订单关联的策略 ID。
instrument_id (InstrumentId) – The order instrument ID.
instrument_id (InstrumentId) - 订单金融工具 ID。
client_order_id (ClientOrderId) – The client order ID.
client_order_id (ClientOrderId) - 客户端订单 ID。
order_side (OrderSide {BUY, SELL}) – The order side.
order_side (OrderSide {BUY, SELL}) - 订单方向。
quantity (Quantity) – The order quantity (> 0).
quantity (Quantity) - 订单数量 (> 0)。
price (Price, optional with no default so None must be passed explicitly) – The order price (LIMIT). If None then will typically default to the delta of market price and limit_offset.
price (Price,可选,无默认值,因此必须显式传递 None) - 订单价格 (LIMIT)。如果为 None,则通常默认为市场价格和 limit_offset 的差值。
trigger_price (Price, optional with no default so None must be passed explicitly) – The order trigger price (STOP). If None then will typically default to the delta of market price and trailing_offset.
trigger_price (Price,可选,无默认值,因此必须显式传递 None) - 订单触发价格 (STOP)。如果为 None,则通常默认为市场价格和 trailing_offset 的差值。
trigger_type (TriggerType) – The order trigger type.
trigger_type (TriggerType) - 订单触发器类型。
limit_offset (Decimal) – The trailing offset for the order price (LIMIT).
limit_offset (Decimal) - 订单价格 (LIMIT) 的追踪偏移量。
trailing_offset (Decimal) – The trailing offset for the order trigger price (STOP).
trailing_offset (Decimal) - 订单触发价格 (STOP) 的追踪偏移量。
trailing_offset_type (TrailingOffsetType) – The order trailing offset type.
trailing_offset_type (TrailingOffsetType) - 订单追踪偏移量类型。
init_id (UUID4) – The order initialization event ID.
init_id (UUID4) - 订单初始化事件 ID。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.
ts_init (uint64_t) - 对象初始化时的 UNIX 时间戳(纳秒)。
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY}, default GTC) – The order time in force.
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY},默认 GTC) - 订单有效时间。
expire_time_ns (uint64_t , default 0 *(*no expiry )) – UNIX timestamp (nanoseconds) when the order will expire.
expire_time_ns (uint64_t,默认 0 *(*无到期*)) - 订单到期的 UNIX 时间戳(纳秒)。
post_only (bool , default False) – If the LIMIT order will only provide liquidity (once triggered).
post_only (bool,默认 False) - 如果限价单仅提供流动性(一旦触发)。
reduce_only (bool , default False) – If the LIMIT order carries the ‘reduce-only’ execution instruction.
reduce_only (bool,默认 False) - 如果限价单带有“仅减少”执行指令。
quote_quantity (bool , default False) – If the order quantity is denominated in the quote currency.
quote_quantity (bool,默认 False) - 如果订单数量以报价货币计价。
display_qty (Quantity , optional) – The quantity of the LIMIT order to display on the public book (iceberg).
display_qty (Quantity,可选) - 要在公开订单簿上显示的限价单数量(冰山订单)。
emulation_trigger (TriggerType, default NO_TRIGGER) – The order emulation trigger.
emulation_trigger (TriggerType,默认 NO_TRIGGER) - 订单模拟触发器。
trigger_instrument_id (InstrumentId , optional) – The emulation trigger instrument ID for the order (if None then will be the instrument_id).
trigger_instrument_id (InstrumentId,可选) - 订单的模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
contingency_type (ContingencyType, default NO_CONTINGENCY) – The order contingency type.
contingency_type (ContingencyType,默认 NO_CONTINGENCY) - 订单意外事件类型。
order_list_id (OrderListId , optional) – The order list ID associated with the order.
order_list_id (OrderListId,可选) - 与订单关联的订单列表 ID。
linked_order_ids (list [ClientOrderId ] , optional) – The order linked client order ID(s).
linked_order_ids (list [ClientOrderId ],可选) - 订单链接的客户端订单 ID。
parent_order_id (ClientOrderId , optional) – The order parent client order ID.
parent_order_id (ClientOrderId,可选) - 订单父客户端订单 ID。
exec_algorithm_id (ExecAlgorithmId , optional) – The execution algorithm ID for the order.
exec_algorithm_id (ExecAlgorithmId,可选) - 订单的执行算法 ID。
exec_algorithm_params (dict *[*str , Any ] , optional) – The execution algorithm parameters for the order.
exec_algorithm_params (dict *[*str , Any ],可选) - 订单的执行算法参数。
exec_spawn_id (ClientOrderId , optional) – The execution algorithm spawning primary client order ID.
exec_spawn_id (ClientOrderId,可选) - 执行算法生成的原始客户端订单 ID。
tags (list *[*str ] , optional) – The custom user tags for the order.
tags (list *[*str ],可选) - 订单的自定义用户标签。
Raises:
ValueError – If order_side is NO_ORDER_SIDE.
ValueError - 如果 order_side 为 NO_ORDER_SIDE。
ValueError – If quantity is not positive (> 0).
ValueError - 如果 quantity 不为正数 (> 0)。
ValueError – If trigger_type is NO_TRIGGER.
ValueError - 如果 trigger_type 为 NO_TRIGGER。
ValueError – If trailing_offset_type is NO_TRAILING_OFFSET.
ValueError - 如果 trailing_offset_type 为 NO_TRAILING_OFFSET。
ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE.
ValueError - 如果 time_in_force 为 AT_THE_OPEN 或 AT_THE_CLOSE。
ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.
ValueError - 如果 time_in_force 为 GTD 并且 expire_time_ns <= UNIX epoch。
ValueError – If display_qty is negative (< 0) or greater than quantity.
ValueError - 如果 display_qty 为负数 (< 0) 或大于 quantity。
"""
@staticmethod
def create(init):
...
@property
def display_qty(self) -> "Quantity" or None:
"""
The quantity of the LIMIT order to display on the public book (iceberg).
要在公开订单簿上显示的限价单数量(冰山订单)。
Returns:
Quantity or None
"""
...
@property
def expire_time(self) -> "datetime" or None:
"""
Return the expire time for the order (UTC).
返回订单的到期时间 (UTC)。
Return type:
datetime or None
"""
...
@property
def expire_time_ns(self) -> int:
"""
The order expiration (UNIX epoch nanoseconds), zero for no expiration.
订单到期时间(UNIX 纪元纳秒),0 表示无到期时间。
Returns:
uint64_t
"""
...
def info(self) -> str:
"""
Return a summary description of the order.
返回订单的摘要描述。
Return type:
str
"""
...
@property
def is_triggered(self) -> bool:
"""
If the order has been triggered.
如果订单已触发。
Returns:
bool
"""
...
@property
def limit_offset(self) -> "Decimal":
"""
The trailing offset for the orders limit price.
订单限价的追踪偏移量。
Returns:
Decimal
"""
...
@property
def price(self) -> "Price" or None:
"""
The order price (LIMIT).
订单价格 (LIMIT)。
Returns:
Price or None
"""
...
def to_dict(self) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def trailing_offset(self) -> "Decimal":
"""
The trailing offset for the orders trigger price (STOP).
订单触发价格 (STOP) 的追踪偏移量。
Returns:
Decimal
"""
...
@property
def trailing_offset_type(self) -> "TrailingOffsetType":
"""
The trailing offset type.
追踪偏移量类型。
Returns:
TrailingOffsetType
"""
...
@property
def trigger_price(self) -> "Price" or None:
"""
The order trigger price (STOP).
订单触发价格 (STOP)。
Returns:
Price or None
"""
...
@property
def trigger_type(self) -> "TriggerType":
"""
The trigger type for the order.
订单的触发器类型。
Returns:
TriggerType
"""
...
@property
def ts_triggered(self) -> int:
"""
UNIX timestamp (nanoseconds) when the order was triggered (0 if not triggered).
订单触发时的 UNIX 时间戳(纳秒)(如果未触发,则为 0)。
Returns:
uint64_t
"""
...
class TrailingStopMarketOrder 追踪止损市价单
class TrailingStopMarketOrder(Order):
"""
TrailingStopMarketOrder(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, Quantity quantity, Price trigger_price: Price | None, TriggerType trigger_type, trailing_offset: Decimal, TrailingOffsetType trailing_offset_type, UUID4 init_id, uint64_t ts_init, TimeInForce time_in_force=TimeInForce.GTC, uint64_t expire_time_ns=0, bool reduce_only=False, bool quote_quantity=False, TriggerType emulation_trigger=TriggerType.NO_TRIGGER, InstrumentId trigger_instrument_id=None, ContingencyType contingency_type=ContingencyType.NO_CONTINGENCY, OrderListId order_list_id=None, list linked_order_ids=None, ClientOrderId parent_order_id=None, ExecAlgorithmId exec_algorithm_id=None, dict exec_algorithm_params=None, ClientOrderId exec_spawn_id=None, list tags=None)
Represents a Trailing-Stop-Market conditional order.
表示一个追踪止损市价条件订单。
Parameters:
trader_id (TraderId) – The trader ID associated with the order.
trader_id (TraderId) - 与订单关联的交易者 ID。
strategy_id (StrategyId) – The strategy ID associated with the order.
strategy_id (StrategyId) - 与订单关联的策略 ID。
instrument_id (InstrumentId) – The order instrument ID.
instrument_id (InstrumentId) - 订单金融工具 ID。
client_order_id (ClientOrderId) – The client order ID.
client_order_id (ClientOrderId) - 客户端订单 ID。
order_side (OrderSide {BUY, SELL}) – The order side.
order_side (OrderSide {BUY, SELL}) - 订单方向。
quantity (Quantity) – The order quantity (> 0).
quantity (Quantity) - 订单数量 (> 0)。
trigger_price (Price, optional with no default so None must be passed explicitly) – The order trigger price (STOP). If None then will typically default to the delta of market price and trailing_offset.
trigger_price (Price,可选,无默认值,因此必须显式传递 None) - 订单触发价格 (STOP)。如果为 None,则通常默认为市场价格和 trailing_offset 的差值。
trigger_type (TriggerType) – The order trigger type.
trigger_type (TriggerType) - 订单触发器类型。
trailing_offset (Decimal) – The trailing offset for the trigger price (STOP).
trailing_offset (Decimal) - 触发价格 (STOP) 的追踪偏移量。
trailing_offset_type (TrailingOffsetType) – The order trailing offset type.
trailing_offset_type (TrailingOffsetType) - 订单追踪偏移量类型。
init_id (UUID4) – The order initialization event ID.
init_id (UUID4) - 订单初始化事件 ID。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.
ts_init (uint64_t) - 对象初始化时的 UNIX 时间戳(纳秒)。
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY}, default GTC) – The order time in force.
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY},默认 GTC) - 订单有效时间。
expire_time_ns (uint64_t , default 0 *(*no expiry )) – UNIX timestamp (nanoseconds) when the order will expire.
expire_time_ns (uint64_t,默认 0 *(*无到期*)) - 订单到期的 UNIX 时间戳(纳秒)。
reduce_only (bool , default False) – If the order carries the ‘reduce-only’ execution instruction.
reduce_only (bool,默认 False) - 如果订单带有“仅减少”执行指令。
quote_quantity (bool , default False) – If the order quantity is denominated in the quote currency.
quote_quantity (bool,默认 False) - 如果订单数量以报价货币计价。
emulation_trigger (TriggerType, default NO_TRIGGER) – The order emulation trigger.
emulation_trigger (TriggerType,默认 NO_TRIGGER) - 订单模拟触发器。
trigger_instrument_id (InstrumentId , optional) – The emulation trigger instrument ID for the order (if None then will be the instrument_id).
trigger_instrument_id (InstrumentId,可选) - 订单的模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
contingency_type (ContingencyType, default NO_CONTINGENCY) – The order contingency type.
contingency_type (ContingencyType,默认 NO_CONTINGENCY) - 订单意外事件类型。
order_list_id (OrderListId , optional) – The order list ID associated with the order.
order_list_id (OrderListId,可选) - 与订单关联的订单列表 ID。
linked_order_ids (list [ClientOrderId ] , optional) – The order linked client order ID(s).
linked_order_ids (list [ClientOrderId ],可选) - 订单链接的客户端订单 ID。
parent_order_id (ClientOrderId , optional) – The order parent client order ID.
parent_order_id (ClientOrderId,可选) - 订单父客户端订单 ID。
exec_algorithm_id (ExecAlgorithmId , optional) – The execution algorithm ID for the order.
exec_algorithm_id (ExecAlgorithmId,可选) - 订单的执行算法 ID。
exec_algorithm_params (dict *[*str , Any ] , optional) – The execution algorithm parameters for the order.
exec_algorithm_params (dict *[*str , Any ],可选) - 订单的执行算法参数。
exec_spawn_id (ClientOrderId , optional) – The execution algorithm spawning primary client order ID.
exec_spawn_id (ClientOrderId,可选) - 执行算法生成的原始客户端订单 ID。
tags (list *[*str ] , optional) – The custom user tags for the order.
tags (list *[*str ],可选) - 订单的自定义用户标签。
Raises:
ValueError – If order_side is NO_ORDER_SIDE.
ValueError - 如果 order_side 为 NO_ORDER_SIDE。
ValueError – If quantity is not positive (> 0).
ValueError - 如果 quantity 不为正数 (> 0)。
ValueError – If trigger_type is NO_TRIGGER.
ValueError - 如果 trigger_type 为 NO_TRIGGER。
ValueError – If trailing_offset_type is NO_TRAILING_OFFSET.
ValueError - 如果 trailing_offset_type 为 NO_TRAILING_OFFSET。
ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE.
ValueError - 如果 time_in_force 为 AT_THE_OPEN 或 AT_THE_CLOSE。
ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.
ValueError - 如果 time_in_force 为 GTD 并且 expire_time_ns <= UNIX epoch。
"""
@staticmethod
def create(init):
...
@property
def expire_time(self) -> "datetime" or None:
"""
Return the expire time for the order (UTC).
返回订单的到期时间 (UTC)。
Return type:
datetime or None
"""
...
@property
def expire_time_ns(self) -> int:
"""
The order expiration (UNIX epoch nanoseconds), zero for no expiration.
订单到期时间(UNIX 纪元纳秒),0 表示无到期时间。
Returns:
uint64_t
"""
...
def info(self) -> str:
"""
Return a summary description of the order.
返回订单的摘要描述。
Return type:
str
"""
...
def to_dict(self) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def trailing_offset(self) -> "Decimal":
"""
The trailing offset for the orders trigger price (STOP).
订单触发价格 (STOP) 的追踪偏移量。
Returns:
Decimal
"""
...
@property
def trailing_offset_type(self) -> "TrailingOffsetType":
"""
The trailing offset type.
追踪偏移量类型。
Returns:
TrailingOffsetType
"""
...
@property
def trigger_price(self) -> "Price" or None:
"""
The order trigger price (STOP).
订单触发价格 (STOP)。
Returns:
Price or None
"""
...
@property
def trigger_type(self) -> "TriggerType":
"""
The trigger type for the order.
订单的触发器类型。
Returns:
TriggerType
"""
...
class OrderUnpacker 订单解包器
Provides a means of unpacking orders from value dictionaries.
提供从值字典中解包订单的方法。
class OrderUnpacker(object):
"""
Provides a means of unpacking orders from value dictionaries.
提供从值字典中解包订单的方法。
"""
@staticmethod
def from_init(init: "OrderInitialized") -> "Order":
"""
Return an order initialized from the given event.
从给定的事件返回一个初始化的订单。
Parameters:
init (OrderInitialized) – The event to initialize with.
init (OrderInitialized) - 用于初始化的事件。
Return type:
Order
"""
...
@staticmethod
def unpack(values: dict) -> "Order":
"""
Return an order unpacked from the given values.
从给定的值中解包一个订单。
Parameters:
values (dict *[*str , object ])
values (dict *[*str , object ])
Return type:
Order
"""
...
class MarketOrder 市价单
class MarketOrder(Order):
"""
MarketOrder(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, Quantity quantity, UUID4 init_id, uint64_t ts_init, TimeInForce time_in_force=TimeInForce.GTC, bool reduce_only=False, bool quote_quantity=False, ContingencyType contingency_type=ContingencyType.NO_CONTINGENCY, OrderListId order_list_id=None, list linked_order_ids=None, ClientOrderId parent_order_id=None, ExecAlgorithmId exec_algorithm_id=None, dict exec_algorithm_params=None, ClientOrderId exec_spawn_id=None, list tags=None)
Represents a Market order.
表示一个市价单。
A Market order is an order to BUY (or SELL) at the market bid or offer price. A market order may increase the likelihood of a fill and the speed of execution, but unlike the Limit order - a Market order provides no price protection and may fill at a price far lower/higher than the top-of-book bid/ask.
市价单是指以市场买入价或卖出价买入(或卖出)的订单。市价单可能会增加成交的可能性和执行速度,但与限价单不同的是,市价单不提供价格保护,并且可能会以远低于/高于最佳买入/卖出价的价格成交。
A Market-On-Open (MOO) order can be represented using a time in force of AT_THE_OPEN.
市价开仓单 (MOO) 可以使用 AT_THE_OPEN 的有效时间来表示。
A Market-On-Close (MOC) order can be represented using a time in force of AT_THE_CLOSE.
市价平仓单 (MOC) 可以使用 AT_THE_CLOSE 的有效时间来表示。
Parameters:
trader_id (TraderId) – The trader ID associated with the order.
trader_id (TraderId) - 与订单关联的交易者 ID。
strategy_id (StrategyId) – The strategy ID associated with the order.
strategy_id (StrategyId) - 与订单关联的策略 ID。
instrument_id (InstrumentId) – The order instrument ID.
instrument_id (InstrumentId) - 订单金融工具 ID。
client_order_id (ClientOrderId) – The client order ID.
client_order_id (ClientOrderId) - 客户端订单 ID。
order_side (OrderSide {BUY, SELL}) – The order side.
order_side (OrderSide {BUY, SELL}) - 订单方向。
quantity (Quantity) – The order quantity (> 0).
quantity (Quantity) - 订单数量 (> 0)。
init_id (UUID4) – The order initialization event ID.
init_id (UUID4) - 订单初始化事件 ID。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.
ts_init (uint64_t) - 对象初始化时的 UNIX 时间戳(纳秒)。
time_in_force (TimeInForce {GTC, IOC, FOK, DAY, AT_THE_OPEN, AT_THE_CLOSE}, default GTC) – The order time in force.
time_in_force (TimeInForce {GTC, IOC, FOK, DAY, AT_THE_OPEN, AT_THE_CLOSE},默认 GTC) - 订单有效时间。
reduce_only (bool , default False) – If the order carries the ‘reduce-only’ execution instruction.
reduce_only (bool,默认 False) - 如果订单带有“仅减少”执行指令。
quote_quantity (bool , default False) – If the order quantity is denominated in the quote currency.
quote_quantity (bool,默认 False) - 如果订单数量以报价货币计价。
contingency_type (ContingencyType, default NO_CONTINGENCY) – The order contingency type.
contingency_type (ContingencyType,默认 NO_CONTINGENCY) - 订单意外事件类型。
order_list_id (OrderListId , optional) – The order list ID associated with the order.
order_list_id (OrderListId,可选) - 与订单关联的订单列表 ID。
linked_order_ids (list [ClientOrderId ] , optional) – The order linked client order ID(s).
linked_order_ids (list [ClientOrderId ],可选) - 订单链接的客户端订单 ID。
parent_order_id (ClientOrderId , optional) – The order parent client order ID.
parent_order_id (ClientOrderId,可选) - 订单父客户端订单 ID。
exec_algorithm_id (ExecAlgorithmId , optional) – The execution algorithm ID for the order.
exec_algorithm_id (ExecAlgorithmId,可选) - 订单的执行算法 ID。
exec_algorithm_params (dict *[*str , Any ] , optional) – The execution algorithm parameters for the order.
exec_algorithm_params (dict *[*str , Any ],可选) - 订单的执行算法参数。
exec_spawn_id (ClientOrderId , optional) – The execution algorithm spawning primary client order ID.
exec_spawn_id (ClientOrderId,可选) - 执行算法生成的原始客户端订单 ID。
tags (list *[*str ] , optional) – The custom user tags for the order.
tags (list *[*str ],可选) - 订单的自定义用户标签。
Raises:
ValueError – If order_side is NO_ORDER_SIDE.
ValueError - 如果 order_side 为 NO_ORDER_SIDE。
ValueError – If quantity is not positive (> 0).
ValueError - 如果 quantity 不为正数 (> 0)。
ValueError – If time_in_force is GTD.
ValueError - 如果 time_in_force 为 GTD。
"""
@property
def account_id(self) -> "AccountId" or None:
"""
The account ID associated with the order.
与订单关联的账户 ID。
Returns:
AccountId or None
"""
...
def apply(self, event: "OrderEvent") -> None:
"""
Apply the given order event to the order.
将给定的订单事件应用于订单。
Parameters:
event (OrderEvent) – The order event to apply.
event (OrderEvent) - 要应用的订单事件。
Raises:
ValueError – If self.client_order_id is not equal to event.client_order_id.
ValueError - 如果 self.client_order_id 不等于 event.client_order_id。
ValueError – If self.venue_order_id and event.venue_order_id are both not None, and are not equal.
ValueError - 如果 self.venue_order_id 和 event.venue_order_id 都不为 None,并且不相等。
InvalidStateTrigger – If event is not a valid trigger from the current order.status.
InvalidStateTrigger - 如果事件不是当前 order.status 的有效触发器。
KeyError – If event is OrderFilled and event.trade_id already applied to the order.
KeyError - 如果 event 是 OrderFilled 并且 event.trade_id 已经应用于订单。
"""
...
@property
def avg_px(self) -> float:
"""
The order average fill price.
订单平均成交价格。
Returns:
double
"""
...
@property
def client_order_id(self) -> "ClientOrderId":
"""
The client order ID.
客户端订单 ID。
Returns:
ClientOrderId
"""
...
@staticmethod
def closing_side(position_side: "PositionSide") -> "OrderSide":
"""
Return the order side needed to close a position with the given side.
返回平仓给定方向头寸所需的订单方向。
Parameters:
position_side (PositionSide {LONG, SHORT}) – The side of the position to close.
position_side (PositionSide {LONG, SHORT}) - 要平仓头寸的方向。
Return type:
OrderSide
Raises:
ValueError – If position_side is FLAT or invalid.
ValueError - 如果 position_side 为 FLAT 或无效。
"""
...
def commissions(self) -> list:
"""
Return the total commissions generated by the order.
返回订单产生的总佣金。
Return type:
list[Money]
"""
...
@property
def contingency_type(self) -> "ContingencyType":
"""
The orders contingency type.
订单的意外事件类型。
Returns:
ContingencyType
"""
...
@staticmethod
def create(init):
...
@property
def emulation_trigger(self) -> "TriggerType":
"""
The order emulation trigger type.
订单模拟触发器类型。
Returns:
TriggerType
"""
...
@property
def event_count(self) -> int:
"""
Return the count of events applied to the order.
返回应用于订单的事件计数。
Return type:
int
"""
...
@property
def events(self) -> list["OrderEvent"]:
"""
Return the order events.
返回订单事件。
Return type:
list[OrderEvent]
"""
...
@property
def exec_algorithm_id(self) -> "ExecAlgorithmId" or None:
"""
The execution algorithm ID for the order.
订单的执行算法 ID。
Returns:
ExecAlgorithmId or None
"""
...
@property
def exec_algorithm_params(self) -> dict[str, Any] or None:
"""
The execution algorithm parameters for the order.
订单的执行算法参数。
Returns:
dict[str, Any] or None
"""
...
@property
def exec_spawn_id(self) -> "ClientOrderId" or None:
"""
The execution algorithm spawning client order ID.
执行算法生成的客户端订单 ID。
Returns:
ClientOrderId or None
"""
...
@property
def filled_qty(self) -> "Quantity":
"""
The order total filled quantity.
订单总成交数量。
Returns:
Quantity
"""
...
@staticmethod
def from_pyo3(pyo3_order):
...
@property
def has_price(self) -> bool:
"""
Return whether the order has a price property.
返回订单是否具有 price 属性。
Return type:
bool
"""
...
@property
def has_trigger_price(self) -> bool:
"""
Return whether the order has a trigger_price property.
返回订单是否具有 trigger_price 属性。
Return type:
bool
"""
...
def info(self) -> str:
"""
Return a summary description of the order.
返回订单的摘要描述。
Return type:
str
"""
...
@property
def init_event(self) -> "OrderInitialized":
"""
Return the initialization event for the order.
返回订单的初始化事件。
Return type:
OrderInitialized
"""
...
@property
def init_id(self) -> "UUID4":
"""
The event ID of the OrderInitialized event.
OrderInitialized 事件的事件 ID。
Returns:
UUID4
"""
...
@property
def instrument_id(self) -> "InstrumentId":
"""
The order instrument ID.
订单金融工具 ID。
Returns:
InstrumentId
"""
...
@property
def is_active_local(self) -> bool:
"""
Return whether the order is active and held in the local system.
返回订单是否处于活动状态并在本地系统中持有。
An order is considered active local when its status is any of;
当订单的状态为以下任何一种时,该订单被视为本地活动订单:
INITIALIZED
EMULATED
RELEASED
Return type:
bool
"""
...
@property
def is_aggressive(self) -> bool:
"""
Return whether the order is aggressive (order_type is MARKET).
返回订单是否为激进订单(order_type 为 MARKET)。
Return type:
bool
"""
...
@property
def is_buy(self) -> bool:
"""
Return whether the order side is BUY.
返回订单方向是否为 BUY。
Return type:
bool
"""
...
@property
def is_canceled(self) -> bool:
"""
Return whether current status is CANCELED.
返回当前状态是否为 CANCELED。
Return type:
bool
"""
...
@property
def is_child_order(self) -> bool:
"""
Return whether the order has a parent order.
返回订单是否具有父订单。
Return type:
bool
"""
...
@property
def is_closed(self) -> bool:
"""
Return whether the order is closed.
返回订单是否已平仓。
An order is considered closed when its status can no longer change. The possible statuses of closed orders include;
当订单的状态不再可以更改时,该订单被视为已平仓。已平仓订单的可能状态包括:
DENIED
REJECTED
CANCELED
EXPIRED
FILLED
Return type:
bool
"""
...
@property
def is_contingency(self) -> bool:
"""
Return whether the order has a contingency (contingency_type is not NO_CONTINGENCY).
返回订单是否具有意外事件(contingency_type 不为 NO_CONTINGENCY)。
Return type:
bool
"""
...
@property
def is_emulated(self) -> bool:
"""
Return whether the order is emulated and held in the local system.
返回订单是否被模拟并在本地系统中持有。
Return type:
bool
"""
...
@property
def is_inflight(self) -> bool:
"""
Return whether the order is in-flight (order request sent to the trading venue).
返回订单是否正在进行中(订单请求已发送到交易场所)。
An order is considered in-flight when its status is any of;
当订单的状态为以下任何一种时,该订单被视为正在进行中:
SUBMITTED
PENDING_UPDATE
PENDING_CANCEL
Return type:
bool
WARNING
An emulated order is never considered in-flight.
模拟订单永远不会被视为正在进行中。
"""
...
@property
def is_open(self) -> bool:
"""
Return whether the order is open at the trading venue.
返回订单是否在交易场所开仓。
An order is considered open when its status is any of;
当订单的状态为以下任何一种时,该订单被视为开仓:
ACCEPTED
TRIGGERED
PENDING_UPDATE
PENDING_CANCEL
PARTIALLY_FILLED
Return type:
bool
WARNING
An emulated order is never considered open.
模拟订单永远不会被视为开仓。
"""
...
@property
def is_parent_order(self) -> bool:
"""
Return whether the order has at least one child order.
返回订单是否至少有一个子订单。
Return type:
bool
"""
...
@property
def is_passive(self) -> bool:
"""
Return whether the order is passive (order_type not MARKET).
返回订单是否为被动订单(order_type 不为 MARKET)。
Return type:
bool
"""
...
@property
def is_pending_cancel(self) -> bool:
"""
Return whether the current status is PENDING_CANCEL.
返回当前状态是否为 PENDING_CANCEL。
Return type:
bool
"""
...
@property
def is_pending_update(self) -> bool:
"""
Return whether the current status is PENDING_UPDATE.
返回当前状态是否为 PENDING_UPDATE。
Return type:
bool
"""
...
@property
def is_post_only(self) -> bool:
"""
If the order will only provide liquidity (make a market).
如果订单只提供流动性(做市商)。
Returns:
bool
"""
...
@property
def is_primary(self) -> bool:
"""
Return whether the order is the primary for an execution algorithm sequence.
返回订单是否是执行算法序列的主订单。
Return type:
bool
"""
...
@property
def is_quote_quantity(self) -> bool:
"""
If the order quantity is denominated in the quote currency.
如果订单数量以报价货币计价。
Returns:
bool
"""
...
@property
def is_reduce_only(self) -> bool:
"""
If the order carries the ‘reduce-only’ execution instruction.
如果订单带有“仅减少”执行指令。
Returns:
bool
"""
...
@property
def is_sell(self) -> bool:
"""
Return whether the order side is SELL.
返回订单方向是否为 SELL。
Return type:
bool
"""
...
@property
def is_spawned(self) -> bool:
"""
Return whether the order was spawned as part of an execution algorithm sequence.
返回订单是否作为执行算法序列的一部分生成。
Return type:
bool
"""
...
@property
def last_event(self) -> "OrderEvent":
"""
Return the last event applied to the order.
返回应用于订单的最后一个事件。
Return type:
OrderEvent
"""
...
@property
def last_trade_id(self) -> "TradeId" or None:
"""
The orders last trade match ID.
订单的最后交易匹配 ID。
Returns:
TradeId or None
"""
...
@property
def leaves_qty(self) -> "Quantity":
"""
The order total leaves quantity.
订单总剩余数量。
Returns:
Quantity
"""
...
@property
def linked_order_ids(self) -> list["ClientOrderId"] or None:
"""
The orders linked client order ID(s).
订单链接的客户端订单 ID。
Returns:
list[ClientOrderId] or None
"""
...
@property
def liquidity_side(self) -> "LiquiditySide":
"""
The order liquidity side.
订单流动性方向。
Returns:
LiquiditySide
"""
...
@staticmethod
def opposite_side(side: "OrderSide") -> "OrderSide":
"""
Return the opposite order side from the given side.
从给定的方向返回相反的订单方向。
Parameters:
side (OrderSide {BUY, SELL}) – The original order side.
side (OrderSide {BUY, SELL}) - 原始订单方向。
Return type:
OrderSide
Raises:
ValueError – If side is invalid.
ValueError - 如果方向无效。
"""
...
@property
def order_list_id(self) -> "OrderListId" or None:
"""
The order list ID associated with the order.
与订单关联的订单列表 ID。
Returns:
OrderListId or None
"""
...
@property
def order_type(self) -> "OrderType":
"""
The order type.
订单类型。
Returns:
OrderType
"""
...
@property
def parent_order_id(self) -> "ClientOrderId" or None:
"""
The parent client order ID.
父客户端订单 ID。
Returns:
ClientOrderId or None
"""
...
@property
def position_id(self) -> "PositionId" or None:
"""
The position ID associated with the order.
与订单关联的头寸 ID。
Returns:
PositionId or None
"""
...
@property
def quantity(self) -> "Quantity":
"""
The order quantity.
订单数量。
Returns:
Quantity
"""
...
@property
def side(self) -> "OrderSide":
"""
The order side.
订单方向。
Returns:
OrderSide
"""
...
def side_string(self) -> str:
"""
Return the orders side as a string.
将订单方向作为字符串返回。
Return type:
str
"""
...
def signed_decimal_qty(self):
"""
Return a signed decimal representation of the remaining quantity.
返回剩余数量的带符号十进制表示形式。
If the order is a BUY, the value is positive (e.g. Decimal(‘10.25’))
如果订单是买入,则值为正数(例如 Decimal('10.25'))
If the order is a SELL, the value is negative (e.g. Decimal(‘-10.25’))
如果订单是卖出,则值为负数(例如 Decimal('-10.25'))
Return type:
Decimal
"""
return
@property
def slippage(self) -> float:
"""
The order total price slippage.
订单总价格滑点。
Returns:
double
"""
...
@property
def status(self) -> "OrderStatus":
"""
Return the orders current status.
返回订单的当前状态。
Return type:
OrderStatus
"""
...
def status_string(self) -> str:
"""
Return the orders current status as a string.
将订单的当前状态作为字符串返回。
Return type:
str
"""
...
@property
def strategy_id(self) -> "StrategyId":
"""
The strategy ID associated with the order.
与订单关联的策略 ID。
Returns:
StrategyId
"""
...
@property
def symbol(self) -> "Symbol":
"""
Return the orders ticker symbol.
返回订单的代码。
Return type:
Symbol
"""
...
@property
def tags(self) -> list[str] or None:
"""
The order custom user tags.
订单自定义用户标签。
Returns:
list[str] or None
"""
...
@property
def time_in_force(self) -> "TimeInForce":
"""
The order time in force.
订单有效时间。
Returns:
TimeInForce
"""
...
def to_dict(self) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def trade_ids(self) -> list["TradeId"]:
"""
Return the trade match IDs.
返回交易匹配 ID。
Return type:
list[TradeId]
"""
...
@property
def trader_id(self) -> "TraderId":
"""
The trader ID associated with the position.
与头寸关联的交易者 ID。
Returns:
TraderId
"""
...
@staticmethod
def transform_py(order: "Order", ts_init: int) -> "MarketOrder":
...
@property
def trigger_instrument_id(self) -> "InstrumentId" or None:
"""
The order emulation trigger instrument ID (will be instrument_id if None).
订单模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
Returns:
InstrumentId or None
"""
...
@property
def ts_init(self) -> int:
"""
UNIX timestamp (nanoseconds) when the object was initialized.
对象初始化时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
@property
def ts_last(self) -> int:
"""
UNIX timestamp (nanoseconds) when the last event occurred.
上次事件发生时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
def type_string(self) -> str:
"""
Return the orders type as a string.
将订单类型作为字符串返回。
Return type:
str
"""
...
@property
def venue(self) -> "Venue":
"""
Return the orders trading venue.
返回订单的交易场所。
Return type:
Venue
"""
...
@property
def venue_order_id(self) -> "VenueOrderId" or None:
"""
The venue assigned order ID.
交易场所分配的订单 ID。
Returns:
VenueOrderId or None
"""
...
@property
def venue_order_ids(self) -> list["VenueOrderId"]:
"""
Return the venue order IDs.
返回交易场所订单 ID。
Return type:
list[VenueOrderId]
"""
...
def would_reduce_only(self, position_side: "PositionSide", position_qty: "Quantity") -> bool:
"""
Whether the current order would only reduce the given position if applied in full.
如果当前订单完全应用,是否只会减少给定的头寸。
Parameters:
position_side (PositionSide {FLAT, LONG, SHORT}) – The side of the position to check against.
position_side (PositionSide {FLAT, LONG, SHORT}) - 要检查的头寸方向。
position_qty (Quantity) – The quantity of the position to check against.
position_qty (Quantity) - 要检查的头寸数量。
Return type:
bool
"""
...
class LimitOrder 限价订单
class LimitOrder(Order):
"""
LimitOrder(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, Quantity quantity, Price price, UUID4 init_id, uint64_t ts_init, TimeInForce time_in_force=TimeInForce.GTC, uint64_t expire_time_ns=0, bool post_only=False, bool reduce_only=False, bool quote_quantity=False, Quantity display_qty=None, TriggerType emulation_trigger=TriggerType.NO_TRIGGER, InstrumentId trigger_instrument_id=None, ContingencyType contingency_type=ContingencyType.NO_CONTINGENCY, OrderListId order_list_id=None, list linked_order_ids=None, ClientOrderId parent_order_id=None, ExecAlgorithmId exec_algorithm_id=None, dict exec_algorithm_params=None, ClientOrderId exec_spawn_id=None, list tags=None)
Represents a Limit order.
表示限价订单。
A Limit order is an order to BUY (or SELL) at a specified price or better. The Limit order ensures that if the order fills, it will not fill at a price less favorable than your limit price, but it does not guarantee a fill.
限价订单是以指定价格或更优价格买入(或卖出)的订单。限价订单确保如果订单成交,它不会以比您的限价更不利的价格成交,但它不保证成交。
A Limit-On-Open (LOO) order can be represented using a time in force of AT_THE_OPEN.
限价开仓单 (LOO) 可以使用 AT_THE_OPEN 的有效时间来表示。
A Limit-On-Close (LOC) order can be represented using a time in force of AT_THE_CLOSE.
限价平仓单 (LOC) 可以使用 AT_THE_CLOSE 的有效时间来表示。
Parameters:
trader_id (TraderId) – The trader ID associated with the order.
trader_id (TraderId) - 与订单关联的交易者ID。
strategy_id (StrategyId) – The strategy ID associated with the order.
strategy_id (StrategyId) - 与订单关联的策略ID。
instrument_id (InstrumentId) – The order instrument ID.
instrument_id (InstrumentId) - 订单金融工具ID。
client_order_id (ClientOrderId) – The client order ID.
client_order_id (ClientOrderId) - 客户端订单ID。
order_side (OrderSide {BUY, SELL}) – The order side.
order_side (OrderSide {BUY, SELL}) - 订单方向。
quantity (Quantity) – The order quantity (> 0).
quantity (Quantity) - 订单数量 (> 0)。
price (Price) – The order limit price.
price (Price) - 订单限价。
init_id (UUID4) – The order initialization event ID.
init_id (UUID4) - 订单初始化事件ID。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.
ts_init (uint64_t) - 对象初始化时的UNIX时间戳(纳秒)。
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY, AT_THE_OPEN, AT_THE_CLOSE}, default GTC) – The order time in force.
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY, AT_THE_OPEN, AT_THE_CLOSE}, 默认 GTC) - 订单有效时间。
expire_time_ns (uint64_t , default 0 *(*no expiry )) – UNIX timestamp (nanoseconds) when the order will expire.
expire_time_ns (uint64_t , 默认 0 *(*无到期*)) - 订单到期的UNIX时间戳(纳秒)。
post_only (bool , default False) – If the order will only provide liquidity (make a market).
post_only (bool , 默认 False) - 如果订单只提供流动性(做市商)。
reduce_only (bool , default False) – If the order carries the ‘reduce-only’ execution instruction.
reduce_only (bool , 默认 False) - 如果订单带有“仅减少”执行指令。
quote_quantity (bool , default False) – If the order quantity is denominated in the quote currency.
quote_quantity (bool , 默认 False) - 如果订单数量以报价货币计价。
display_qty (Quantity , optional) – The quantity of the order to display on the public book (iceberg).
display_qty (Quantity , 可选) - 要在公开订单簿上显示的订单数量(冰山订单)。
emulation_trigger (EmulationTrigger, default NO_TRIGGER) – The emulation trigger for the order.
emulation_trigger (EmulationTrigger, 默认 NO_TRIGGER) - 订单的模拟触发器。
trigger_instrument_id (InstrumentId , optional) – The emulation trigger instrument ID for the order (if None then will be the instrument_id).
trigger_instrument_id (InstrumentId , 可选) - 订单的模拟触发器金融工具ID(如果为None,则将为instrument_id)。
contingency_type (ContingencyType, default NO_CONTINGENCY) – The order contingency type.
contingency_type (ContingencyType, 默认 NO_CONTINGENCY) - 订单意外事件类型。
order_list_id (OrderListId , optional) – The order list ID associated with the order.
order_list_id (OrderListId , 可选) - 与订单关联的订单列表ID。
linked_order_ids (list [ClientOrderId ] , optional) – The order linked client order ID(s).
linked_order_ids (list [ClientOrderId ] , 可选) - 订单链接的客户端订单ID。
parent_order_id (ClientOrderId , optional) – The order parent client order ID.
parent_order_id (ClientOrderId , 可选) - 订单父客户端订单ID。
exec_algorithm_id (ExecAlgorithmId , optional) – The execution algorithm ID for the order.
exec_algorithm_id (ExecAlgorithmId , 可选) - 订单的执行算法ID。
exec_algorithm_params (dict *[*str , Any ] , optional) – The execution algorithm parameters for the order.
exec_algorithm_params (dict *[*str , Any ] , 可选) - 订单的执行算法参数。
exec_spawn_id (ClientOrderId , optional) – The execution algorithm spawning primary client order ID.
exec_spawn_id (ClientOrderId , 可选) - 执行算法生成的原始客户端订单ID。
tags (list *[*str ] , optional) – The custom user tags for the order.
tags (list *[*str ] , 可选) - 订单的自定义用户标签。
Raises:
ValueError – If order_side is NO_ORDER_SIDE.
ValueError - 如果 order_side 为 NO_ORDER_SIDE。
ValueError – If quantity is not positive (> 0).
ValueError - 如果 quantity 不为正数 (> 0)。
ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.
ValueError - 如果 time_in_force 为 GTD 并且 expire_time_ns <= UNIX epoch。
ValueError – If display_qty is negative (< 0) or greater than quantity.
ValueError - 如果 display_qty 为负数 (< 0) 或大于 quantity。
"""
@property
def account_id(self) -> "AccountId" or None:
"""
The account ID associated with the order.
与订单关联的账户ID。
Returns:
AccountId or None
"""
...
def apply(self, event: "OrderEvent") -> None:
"""
Apply the given order event to the order.
将给定的订单事件应用于订单。
Parameters:
event (OrderEvent) – The order event to apply.
event (OrderEvent) - 要应用的订单事件。
Raises:
ValueError – If self.client_order_id is not equal to event.client_order_id.
ValueError - 如果 self.client_order_id 不等于 event.client_order_id。
ValueError – If self.venue_order_id and event.venue_order_id are both not None, and are not equal.
ValueError - 如果 self.venue_order_id 和 event.venue_order_id 都不为 None,并且不相等。
InvalidStateTrigger – If event is not a valid trigger from the current order.status.
InvalidStateTrigger - 如果事件不是当前 order.status 的有效触发器。
KeyError – If event is OrderFilled and event.trade_id already applied to the order.
KeyError - 如果 event 是 OrderFilled 并且 event.trade_id 已经应用于订单。
"""
...
@property
def avg_px(self) -> float:
"""
The order average fill price.
订单平均成交价格。
Returns:
double
"""
...
@property
def client_order_id(self) -> "ClientOrderId":
"""
The client order ID.
客户端订单ID。
Returns:
ClientOrderId
"""
...
@staticmethod
def closing_side(position_side: "PositionSide") -> "OrderSide":
"""
Return the order side needed to close a position with the given side.
返回平仓给定方向头寸所需的订单方向。
Parameters:
position_side (PositionSide {LONG, SHORT}) – The side of the position to close.
position_side (PositionSide {LONG, SHORT}) - 要平仓头寸的方向。
Return type:
OrderSide
Raises:
ValueError – If position_side is FLAT or invalid.
ValueError - 如果 position_side 为 FLAT 或无效。
"""
...
def commissions(self) -> list:
"""
Return the total commissions generated by the order.
返回订单产生的总佣金。
Return type:
list[Money]
"""
...
@property
def contingency_type(self) -> "ContingencyType":
"""
The orders contingency type.
订单的意外事件类型。
Returns:
ContingencyType
"""
...
@staticmethod
def create(init: "OrderInitialized"):
...
@property
def display_qty(self) -> "Quantity" or None:
"""
The quantity of the order to display on the public book (iceberg).
要在公开订单簿上显示的订单数量(冰山订单)。
Returns:
Quantity or None
"""
...
@property
def emulation_trigger(self) -> "TriggerType":
"""
The order emulation trigger type.
订单模拟触发器类型。
Returns:
TriggerType
"""
...
@property
def event_count(self) -> int:
"""
Return the count of events applied to the order.
返回应用于订单的事件计数。
Return type:
int
"""
...
@property
def events(self) -> list["OrderEvent"]:
"""
Return the order events.
返回订单事件。
Return type:
list[OrderEvent]
"""
...
@property
def exec_algorithm_id(self) -> "ExecAlgorithmId" or None:
"""
The execution algorithm ID for the order.
订单的执行算法ID。
Returns:
ExecAlgorithmId or None
"""
...
@property
def exec_algorithm_params(self) -> dict[str, Any] or None:
"""
The execution algorithm parameters for the order.
订单的执行算法参数。
Returns:
dict[str, Any] or None
"""
...
@property
def exec_spawn_id(self) -> "ClientOrderId" or None:
"""
The execution algorithm spawning client order ID.
执行算法生成的客户端订单ID。
Returns:
ClientOrderId or None
"""
...
@property
def expire_time(self) -> "datetime" or None:
"""
Return the expire time for the order (UTC).
返回订单的到期时间(UTC)。
Return type:
datetime or None
"""
...
@property
def expire_time_ns(self) -> int:
"""
The order expiration (UNIX epoch nanoseconds), zero for no expiration.
订单到期时间(UNIX纪元纳秒),0表示无到期时间。
Returns:
uint64_t
"""
...
@property
def filled_qty(self) -> "Quantity":
"""
The order total filled quantity.
订单总成交数量。
Returns:
Quantity
"""
...
@staticmethod
def from_pyo3(pyo3_order):
...
@property
def has_price(self) -> bool:
"""
Return whether the order has a price property.
返回订单是否具有价格属性。
Return type:
bool
"""
...
@property
def has_trigger_price(self) -> bool:
"""
Return whether the order has a trigger_price property.
返回订单是否具有触发价格属性。
Return type:
bool
"""
...
def info(self) -> str:
"""
Return a summary description of the order.
返回订单的摘要描述。
Return type:
str
"""
...
@property
def init_event(self) -> "OrderInitialized":
"""
Return the initialization event for the order.
返回订单的初始化事件。
Return type:
OrderInitialized
"""
...
@property
def init_id(self) -> "UUID4":
"""
The event ID of the OrderInitialized event.
OrderInitialized 事件的事件 ID。
Returns:
UUID4
"""
...
@property
def instrument_id(self) -> "InstrumentId":
"""
The order instrument ID.
订单金融工具ID。
Returns:
InstrumentId
"""
...
@property
def is_active_local(self) -> bool:
"""
Return whether the order is active and held in the local system.
返回订单是否处于活动状态并在本地系统中持有。
An order is considered active local when its status is any of;
当订单的状态为以下任何一种时,该订单被视为本地活动订单:
INITIALIZED
EMULATED
RELEASED
Return type:
bool
"""
...
@property
def is_aggressive(self) -> bool:
"""
Return whether the order is aggressive (order_type is MARKET).
返回订单是否为激进订单(order_type 为 MARKET)。
Return type:
bool
"""
...
@property
def is_buy(self) -> bool:
"""
Return whether the order side is BUY.
返回订单方向是否为BUY。
Return type:
bool
"""
...
@property
def is_canceled(self) -> bool:
"""
Return whether current status is CANCELED.
返回当前状态是否为CANCELED。
Return type:
bool
"""
...
@property
def is_child_order(self) -> bool:
"""
Return whether the order has a parent order.
返回订单是否具有父订单。
Return type:
bool
"""
...
@property
def is_closed(self) -> bool:
"""
Return whether the order is closed.
返回订单是否已平仓。
An order is considered closed when its status can no longer change. The possible statuses of closed orders include;
当订单的状态不再可以更改时,该订单被视为已平仓。已平仓订单的可能状态包括:
DENIED
REJECTED
CANCELED
EXPIRED
FILLED
Return type:
bool
"""
...
@property
def is_contingency(self) -> bool:
"""
Return whether the order has a contingency (contingency_type is not NO_CONTINGENCY).
返回订单是否具有意外事件(contingency_type不为NO_CONTINGENCY)。
Return type:
bool
"""
...
@property
def is_emulated(self) -> bool:
"""
Return whether the order is emulated and held in the local system.
返回订单是否被模拟并在本地系统中持有。
Return type:
bool
"""
...
@property
def is_inflight(self) -> bool:
"""
Return whether the order is in-flight (order request sent to the trading venue).
返回订单是否正在进行中(订单请求已发送到交易场所)。
An order is considered in-flight when its status is any of;
当订单的状态为以下任何一种时,该订单被视为正在进行中:
SUBMITTED
PENDING_UPDATE
PENDING_CANCEL
Return type:
bool
WARNING
An emulated order is never considered in-flight.
模拟订单永远不会被视为正在进行中。
"""
...
@property
def is_open(self) -> bool:
"""
Return whether the order is open at the trading venue.
返回订单是否在交易场所开仓。
An order is considered open when its status is any of;
当订单的状态为以下任何一种时,该订单被视为开仓:
ACCEPTED
TRIGGERED
PENDING_UPDATE
PENDING_CANCEL
PARTIALLY_FILLED
Return type:
bool
WARNING
An emulated order is never considered open.
模拟订单永远不会被视为开仓。
"""
...
@property
def is_parent_order(self) -> bool:
"""
Return whether the order has at least one child order.
返回订单是否至少有一个子订单。
Return type:
bool
"""
...
@property
def is_passive(self) -> bool:
"""
Return whether the order is passive (order_type not MARKET).
返回订单是否为被动订单(order_type不为MARKET)。
Return type:
bool
"""
...
@property
def is_pending_cancel(self) -> bool:
"""
Return whether the current status is PENDING_CANCEL.
返回当前状态是否为PENDING_CANCEL。
Return type:
bool
"""
...
@property
def is_pending_update(self) -> bool:
"""
Return whether the current status is PENDING_UPDATE.
返回当前状态是否为PENDING_UPDATE。
Return type:
bool
"""
...
@property
def is_post_only(self) -> bool:
"""
If the order will only provide liquidity (make a market).
如果订单只提供流动性(做市商)。
Returns:
bool
"""
...
@property
def is_primary(self) -> bool:
"""
Return whether the order is the primary for an execution algorithm sequence.
返回订单是否是执行算法序列的主订单。
Return type:
bool
"""
...
@property
def is_quote_quantity(self) -> bool:
"""
If the order quantity is denominated in the quote currency.
如果订单数量以报价货币计价。
Returns:
bool
"""
...
@property
def is_reduce_only(self) -> bool:
"""
If the order carries the ‘reduce-only’ execution instruction.
如果订单带有“仅减少”执行指令。
Returns:
bool
"""
...
@property
def is_sell(self) -> bool:
"""
Return whether the order side is SELL.
返回订单方向是否为SELL。
Return type:
bool
"""
...
@property
def is_spawned(self) -> bool:
"""
Return whether the order was spawned as part of an execution algorithm sequence.
返回订单是否作为执行算法序列的一部分生成。
Return type:
bool
"""
...
@property
def last_event(self) -> "OrderEvent":
"""
Return the last event applied to the order.
返回应用于订单的最后一个事件。
Return type:
OrderEvent
"""
...
@property
def last_trade_id(self) -> "TradeId" or None:
"""
The orders last trade match ID.
订单的最后交易匹配ID。
Returns:
TradeId or None
"""
...
@property
def leaves_qty(self) -> "Quantity":
"""
The order total leaves quantity.
订单总剩余数量。
Returns:
Quantity
"""
...
@property
def linked_order_ids(self) -> list["ClientOrderId"] or None:
"""
The orders linked client order ID(s).
订单链接的客户端订单ID。
Returns:
list[ClientOrderId] or None
"""
...
@property
def liquidity_side(self) -> "LiquiditySide":
"""
The order liquidity side.
订单流动性方向。
Returns:
LiquiditySide
"""
...
@staticmethod
def opposite_side(side: "OrderSide") -> "OrderSide":
"""
Return the opposite order side from the given side.
从给定的方向返回相反的订单方向。
Parameters:
side (OrderSide {BUY, SELL}) – The original order side.
side (OrderSide {BUY, SELL}) - 原始订单方向。
Return type:
OrderSide
Raises:
ValueError – If side is invalid.
ValueError - 如果方向无效。
"""
...
@property
def order_list_id(self) -> "OrderListId" or None:
"""
The order list ID associated with the order.
与订单关联的订单列表ID。
Returns:
OrderListId or None
"""
...
@property
def order_type(self) -> "OrderType":
"""
The order type.
订单类型。
Returns:
OrderType
"""
...
@property
def parent_order_id(self) -> "ClientOrderId" or None:
"""
The parent client order ID.
父客户端订单ID。
Returns:
ClientOrderId or None
"""
...
@property
def position_id(self) -> "PositionId" or None:
"""
The position ID associated with the order.
与订单关联的头寸ID。
Returns:
PositionId or None
"""
...
@property
def price(self) -> "Price":
"""
The order price (LIMIT).
订单价格(LIMIT)。
Returns:
Price
"""
...
@property
def quantity(self) -> "Quantity":
"""
The order quantity.
订单数量。
Returns:
Quantity
"""
...
@property
def side(self) -> "OrderSide":
"""
The order side.
订单方向。
Returns:
OrderSide
"""
...
def side_string(self) -> str:
"""
Return the orders side as a string.
将订单方向作为字符串返回。
Return type:
str
"""
...
def signed_decimal_qty(self):
"""
Return a signed decimal representation of the remaining quantity.
返回剩余数量的带符号十进制表示形式。
If the order is a BUY, the value is positive (e.g. Decimal(‘10.25’))
如果订单是买入,则值为正数(例如 Decimal('10.25'))
If the order is a SELL, the value is negative (e.g. Decimal(‘-10.25’))
如果订单是卖出,则值为负数(例如 Decimal('-10.25'))
Return type:
Decimal
"""
return
@property
def slippage(self) -> float:
"""
The order total price slippage.
订单总价格滑点。
Returns:
double
"""
...
@property
def status(self) -> "OrderStatus":
"""
Return the orders current status.
返回订单的当前状态。
Return type:
OrderStatus
"""
...
def status_string(self) -> str:
"""
Return the orders current status as a string.
将订单的当前状态作为字符串返回。
Return type:
str
"""
...
@property
def strategy_id(self) -> "StrategyId":
"""
The strategy ID associated with the order.
与订单关联的策略ID。
Returns:
StrategyId
"""
...
@property
def symbol(self) -> "Symbol":
"""
Return the orders ticker symbol.
返回订单的代码。
Return type:
Symbol
"""
...
@property
def tags(self) -> list[str] or None:
"""
The order custom user tags.
订单自定义用户标签。
Returns:
list[str] or None
"""
...
@property
def time_in_force(self) -> "TimeInForce":
"""
The order time in force.
订单有效时间。
Returns:
TimeInForce
"""
...
def to_dict(self) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def trade_ids(self) -> list["TradeId"]:
"""
Return the trade match IDs.
返回交易匹配ID。
Return type:
list[TradeId]
"""
...
@property
def trader_id(self) -> "TraderId":
"""
The trader ID associated with the position.
与头寸关联的交易者ID。
Returns:
TraderId
"""
...
@staticmethod
def transform_py(
order: "Order", ts_init: int, price: "Price" = None
) -> "LimitOrder":
...
@property
def trigger_instrument_id(self) -> "InstrumentId" or None:
"""
The order emulation trigger instrument ID (will be instrument_id if None).
订单模拟触发器金融工具ID(如果为None,则将为instrument_id)。
Returns:
InstrumentId or None
"""
...
@property
def ts_init(self) -> int:
"""
UNIX timestamp (nanoseconds) when the object was initialized.
对象初始化时的UNIX时间戳(纳秒)。
Returns:
uint64_t
"""
...
@property
def ts_last(self) -> int:
"""
UNIX timestamp (nanoseconds) when the last event occurred.
上次事件发生时的UNIX时间戳(纳秒)。
Returns:
uint64_t
"""
...
def type_string(self) -> str:
"""
Return the orders type as a string.
将订单类型作为字符串返回。
Return type:
str
"""
...
@property
def venue(self) -> "Venue":
"""
Return the orders trading venue.
返回订单的交易场所。
Return type:
Venue
"""
...
@property
def venue_order_id(self) -> "VenueOrderId" or None:
"""
The venue assigned order ID.
交易场所分配的订单ID。
Returns:
VenueOrderId or None
"""
...
@property
def venue_order_ids(self) -> list["VenueOrderId"]:
"""
Return the venue order IDs.
返回交易场所订单ID。
Return type:
list[VenueOrderId]
"""
...
def would_reduce_only(
self, position_side: "PositionSide", position_qty: "Quantity"
) -> bool:
"""
Whether the current order would only reduce the given position if applied in full.
如果当前订单完全应用,是否只会减少给定的头寸。
Parameters:
position_side (PositionSide {FLAT, LONG, SHORT}) – The side of the position to check against.
position_side (PositionSide {FLAT, LONG, SHORT}) - 要检查的头寸方向。
position_qty (Quantity) – The quantity of the position to check against.
position_qty (Quantity) - 要检查的头寸数量。
Return type:
bool
"""
...
class StopMarketOrder 止损市价单
class StopMarketOrder(Order):
"""
StopMarketOrder(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, Quantity quantity, Price trigger_price, TriggerType trigger_type, UUID4 init_id, uint64_t ts_init, TimeInForce time_in_force=TimeInForce.GTC, uint64_t expire_time_ns=0, bool reduce_only=False, bool quote_quantity=False, TriggerType emulation_trigger=TriggerType.NO_TRIGGER, InstrumentId trigger_instrument_id=None, ContingencyType contingency_type=ContingencyType.NO_CONTINGENCY, OrderListId order_list_id=None, list linked_order_ids=None, ClientOrderId parent_order_id=None, ExecAlgorithmId exec_algorithm_id=None, dict exec_algorithm_params=None, ClientOrderId exec_spawn_id=None, list tags=None)
Represents a Stop-Market conditional order.
表示一个止损市价条件订单。
A Stop-Market order is an instruction to submit a BUY (or SELL) market order if and when the specified stop trigger price is attained or penetrated. A Stop-Market order is not guaranteed a specific execution price and may execute significantly away from its stop price.
止损市价单是指当达到或突破指定的止损触发价格时提交买入(或卖出)市价单的指令。止损市价单不保证特定的执行价格,并且可能以与其止损价相差很大的价格执行。
A SELL Stop-Market order is always placed below the current market price, and is typically used to limit a loss or protect a profit on a long position.
卖出止损市价单始终放置在当前市场价格之下,通常用于限制多头头寸的损失或保护利润。
A BUY Stop-Market order is always placed above the current market price, and is typically used to limit a loss or protect a profit on a short position.
买入止损市价单始终放置在当前市场价格之上,通常用于限制空头头寸的损失或保护利润。
Parameters:
trader_id (TraderId) – The trader ID associated with the order.
trader_id (TraderId) - 与订单关联的交易者 ID。
strategy_id (StrategyId) – The strategy ID associated with the order.
strategy_id (StrategyId) - 与订单关联的策略 ID。
instrument_id (InstrumentId) – The order instrument ID.
instrument_id (InstrumentId) - 订单金融工具 ID。
client_order_id (ClientOrderId) – The client order ID.
client_order_id (ClientOrderId) - 客户端订单 ID。
order_side (OrderSide {BUY, SELL}) – The order side.
order_side (OrderSide {BUY, SELL}) - 订单方向。
quantity (Quantity) – The order quantity (> 0).
quantity (Quantity) - 订单数量 (> 0)。
trigger_price (Price) – The order trigger price (STOP).
trigger_price (Price) - 订单触发价格 (STOP)。
trigger_type (TriggerType) – The order trigger type.
trigger_type (TriggerType) - 订单触发器类型。
init_id (UUID4) – The order initialization event ID.
init_id (UUID4) - 订单初始化事件 ID。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.
ts_init (uint64_t) - 对象初始化时的 UNIX 时间戳(纳秒)。
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY}, default GTC) – The order time in force.
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY}, 默认 GTC) - 订单有效时间。
expire_time_ns (uint64_t , default 0 *(*no expiry )) – UNIX timestamp (nanoseconds) when the order will expire.
expire_time_ns (uint64_t, 默认 0 *(*无到期*)) - 订单到期的 UNIX 时间戳(纳秒)。
reduce_only (bool , default False) – If the order carries the ‘reduce-only’ execution instruction.
reduce_only (bool, 默认 False) - 如果订单带有“仅减少”执行指令。
quote_quantity (bool , default False) – If the order quantity is denominated in the quote currency.
quote_quantity (bool, 默认 False) - 如果订单数量以报价货币计价。
emulation_trigger (TriggerType, default NO_TRIGGER) – The order emulation trigger.
emulation_trigger (TriggerType, 默认 NO_TRIGGER) - 订单模拟触发器。
trigger_instrument_id (InstrumentId , optional) – The emulation trigger instrument ID for the order (if None then will be the instrument_id).
trigger_instrument_id (InstrumentId, 可选) - 订单的模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
contingency_type (ContingencyType, default NO_CONTINGENCY) – The order contingency type.
contingency_type (ContingencyType, 默认 NO_CONTINGENCY) - 订单意外事件类型。
order_list_id (OrderListId , optional) – The order list ID associated with the order.
order_list_id (OrderListId, 可选) - 与订单关联的订单列表 ID。
linked_order_ids (list [ClientOrderId ] , optional) – The order linked client order ID(s).
linked_order_ids (list [ClientOrderId ], 可选) - 订单链接的客户端订单 ID。
parent_order_id (ClientOrderId , optional) – The order parent client order ID.
parent_order_id (ClientOrderId, 可选) - 订单父客户端订单 ID。
exec_algorithm_id (ExecAlgorithmId , optional) – The execution algorithm ID for the order.
exec_algorithm_id (ExecAlgorithmId, 可选) - 订单的执行算法 ID。
exec_algorithm_params (dict *[*str , Any ] , optional) – The execution algorithm parameters for the order.
exec_algorithm_params (dict *[*str , Any ], 可选) - 订单的执行算法参数。
exec_spawn_id (ClientOrderId , optional) – The execution algorithm spawning primary client order ID.
exec_spawn_id (ClientOrderId, 可选) - 执行算法生成的原始客户端订单 ID。
tags (list *[*str ] , optional) – The custom user tags for the order.
tags (list *[*str ], 可选) - 订单的自定义用户标签。
Raises:
ValueError – If order_side is NO_ORDER_SIDE.
ValueError - 如果 order_side 为 NO_ORDER_SIDE。
ValueError – If quantity is not positive (> 0).
ValueError - 如果 quantity 不为正数 (> 0)。
ValueError – If trigger_type is NO_TRIGGER.
ValueError - 如果 trigger_type 为 NO_TRIGGER。
ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE.
ValueError - 如果 time_in_force 为 AT_THE_OPEN 或 AT_THE_CLOSE。
ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.
ValueError - 如果 time_in_force 为 GTD 并且 expire_time_ns <= UNIX epoch。
"""
@property
def account_id(self) -> "AccountId" or None:
"""
The account ID associated with the order.
与订单关联的账户ID。
Returns:
AccountId or None
"""
...
def apply(self, event: "OrderEvent") -> None:
"""
Apply the given order event to the order.
将给定的订单事件应用于订单。
Parameters:
event (OrderEvent) – The order event to apply.
event (OrderEvent) - 要应用的订单事件。
Raises:
ValueError – If self.client_order_id is not equal to event.client_order_id.
ValueError - 如果 self.client_order_id 不等于 event.client_order_id。
ValueError – If self.venue_order_id and event.venue_order_id are both not None, and are not equal.
ValueError - 如果 self.venue_order_id 和 event.venue_order_id 都不为 None,并且不相等。
InvalidStateTrigger – If event is not a valid trigger from the current order.status.
InvalidStateTrigger - 如果事件不是当前 order.status 的有效触发器。
KeyError – If event is OrderFilled and event.trade_id already applied to the order.
KeyError - 如果 event 是 OrderFilled 并且 event.trade_id 已经应用于订单。
"""
...
@property
def avg_px(self) -> float:
"""
The order average fill price.
订单平均成交价格。
Returns:
double
"""
...
@property
def client_order_id(self) -> "ClientOrderId":
"""
The client order ID.
客户端订单 ID。
Returns:
ClientOrderId
"""
...
@staticmethod
def closing_side(position_side: "PositionSide") -> "OrderSide":
"""
Return the order side needed to close a position with the given side.
返回平仓给定方向头寸所需的订单方向。
Parameters:
position_side (PositionSide {LONG, SHORT}) – The side of the position to close.
position_side (PositionSide {LONG, SHORT}) - 要平仓头寸的方向。
Return type:
OrderSide
Raises:
ValueError – If position_side is FLAT or invalid.
ValueError - 如果 position_side 为 FLAT 或无效。
"""
...
def commissions(self) -> list:
"""
Return the total commissions generated by the order.
返回订单产生的总佣金。
Return type:
list[Money]
"""
...
@property
def contingency_type(self) -> "ContingencyType":
"""
The orders contingency type.
订单的意外事件类型。
Returns:
ContingencyType
"""
...
@staticmethod
def create(init):
...
@property
def emulation_trigger(self) -> "TriggerType":
"""
The order emulation trigger type.
订单模拟触发器类型。
Returns:
TriggerType
"""
...
@property
def event_count(self) -> int:
"""
Return the count of events applied to the order.
返回应用于订单的事件计数。
Return type:
int
"""
...
@property
def events(self) -> list["OrderEvent"]:
"""
Return the order events.
返回订单事件。
Return type:
list[OrderEvent]
"""
...
@property
def exec_algorithm_id(self) -> "ExecAlgorithmId" or None:
"""
The execution algorithm ID for the order.
订单的执行算法 ID。
Returns:
ExecAlgorithmId or None
"""
...
@property
def exec_algorithm_params(self) -> dict[str, Any] or None:
"""
The execution algorithm parameters for the order.
订单的执行算法参数。
Returns:
dict[str, Any] or None
"""
...
@property
def exec_spawn_id(self) -> "ClientOrderId" or None:
"""
The execution algorithm spawning client order ID.
执行算法生成的客户端订单 ID。
Returns:
ClientOrderId or None
"""
...
@property
def expire_time(self) -> "datetime" or None:
"""
Return the expire time for the order (UTC).
返回订单的到期时间 (UTC)。
Return type:
datetime or None
"""
...
@property
def expire_time_ns(self) -> int:
"""
The order expiration (UNIX epoch nanoseconds), zero for no expiration.
订单到期时间(UNIX 纪元纳秒),0 表示无到期时间。
Returns:
uint64_t
"""
...
@property
def filled_qty(self) -> "Quantity":
"""
The order total filled quantity.
订单总成交数量。
Returns:
Quantity
"""
...
@property
def has_price(self) -> bool:
"""
Return whether the order has a price property.
返回订单是否具有 price 属性。
Return type:
bool
"""
...
@property
def has_trigger_price(self) -> bool:
"""
Return whether the order has a trigger_price property.
返回订单是否具有 trigger_price 属性。
Return type:
bool
"""
...
def info(self) -> str:
"""
Return a summary description of the order.
返回订单的摘要描述。
Return type:
str
"""
...
@property
def init_event(self) -> "OrderInitialized":
"""
Return the initialization event for the order.
返回订单的初始化事件。
Return type:
OrderInitialized
"""
...
@property
def init_id(self) -> "UUID4":
"""
The event ID of the OrderInitialized event.
OrderInitialized 事件的事件 ID。
Returns:
UUID4
"""
...
@property
def instrument_id(self) -> "InstrumentId":
"""
The order instrument ID.
订单金融工具 ID。
Returns:
InstrumentId
"""
...
@property
def is_active_local(self) -> bool:
"""
Return whether the order is active and held in the local system.
返回订单是否处于活动状态并在本地系统中持有。
An order is considered active local when its status is any of;
当订单的状态为以下任何一种时,该订单被视为本地活动订单:
INITIALIZED
EMULATED
RELEASED
Return type:
bool
"""
...
@property
def is_aggressive(self) -> bool:
"""
Return whether the order is aggressive (order_type is MARKET).
返回订单是否为激进订单(order_type 为 MARKET)。
Return type:
bool
"""
...
@property
def is_buy(self) -> bool:
"""
Return whether the order side is BUY.
返回订单方向是否为 BUY。
Return type:
bool
"""
...
@property
def is_canceled(self) -> bool:
"""
Return whether current status is CANCELED.
返回当前状态是否为 CANCELED。
Return type:
bool
"""
...
@property
def is_child_order(self) -> bool:
"""
Return whether the order has a parent order.
返回订单是否具有父订单。
Return type:
bool
"""
...
@property
def is_closed(self) -> bool:
"""
Return whether the order is closed.
返回订单是否已平仓。
An order is considered closed when its status can no longer change. The possible statuses of closed orders include;
当订单的状态不再可以更改时,该订单被视为已平仓。已平仓订单的可能状态包括:
DENIED
REJECTED
CANCELED
EXPIRED
FILLED
Return type:
bool
"""
...
@property
def is_contingency(self) -> bool:
"""
Return whether the order has a contingency (contingency_type is not NO_CONTINGENCY).
返回订单是否具有意外事件(contingency_type 不为 NO_CONTINGENCY)。
Return type:
bool
"""
...
@property
def is_emulated(self) -> bool:
"""
Return whether the order is emulated and held in the local system.
返回订单是否被模拟并在本地系统中持有。
Return type:
bool
"""
...
@property
def is_inflight(self) -> bool:
"""
Return whether the order is in-flight (order request sent to the trading venue).
返回订单是否正在进行中(订单请求已发送到交易场所)。
An order is considered in-flight when its status is any of;
当订单的状态为以下任何一种时,该订单被视为正在进行中:
SUBMITTED
PENDING_UPDATE
PENDING_CANCEL
Return type:
bool
WARNING
An emulated order is never considered in-flight.
模拟订单永远不会被视为正在进行中。
"""
...
@property
def is_open(self) -> bool:
"""
Return whether the order is open at the trading venue.
返回订单是否在交易场所开仓。
An order is considered open when its status is any of;
当订单的状态为以下任何一种时,该订单被视为开仓:
ACCEPTED
TRIGGERED
PENDING_UPDATE
PENDING_CANCEL
PARTIALLY_FILLED
Return type:
bool
WARNING
An emulated order is never considered open.
模拟订单永远不会被视为开仓。
"""
...
@property
def is_parent_order(self) -> bool:
"""
Return whether the order has at least one child order.
返回订单是否至少有一个子订单。
Return type:
bool
"""
...
@property
def is_passive(self) -> bool:
"""
Return whether the order is passive (order_type not MARKET).
返回订单是否为被动订单(order_type 不为 MARKET)。
Return type:
bool
"""
...
@property
def is_pending_cancel(self) -> bool:
"""
Return whether the current status is PENDING_CANCEL.
返回当前状态是否为 PENDING_CANCEL。
Return type:
bool
"""
...
@property
def is_pending_update(self) -> bool:
"""
Return whether the current status is PENDING_UPDATE.
返回当前状态是否为 PENDING_UPDATE。
Return type:
bool
"""
...
@property
def is_post_only(self) -> bool:
"""
If the order will only provide liquidity (make a market).
如果订单只提供流动性(做市商)。
Returns:
bool
"""
...
@property
def is_primary(self) -> bool:
"""
Return whether the order is the primary for an execution algorithm sequence.
返回订单是否是执行算法序列的主订单。
Return type:
bool
"""
...
@property
def is_quote_quantity(self) -> bool:
"""
If the order quantity is denominated in the quote currency.
如果订单数量以报价货币计价。
Returns:
bool
"""
...
@property
def is_reduce_only(self) -> bool:
"""
If the order carries the ‘reduce-only’ execution instruction.
如果订单带有“仅减少”执行指令。
Returns:
bool
"""
...
@property
def is_sell(self) -> bool:
"""
Return whether the order side is SELL.
返回订单方向是否为 SELL。
Return type:
bool
"""
...
@property
def is_spawned(self) -> bool:
"""
Return whether the order was spawned as part of an execution algorithm sequence.
返回订单是否作为执行算法序列的一部分生成。
Return type:
bool
"""
...
@property
def is_triggered(self) -> bool:
"""
If the order has been triggered.
如果订单已触发。
Returns:
bool
"""
...
@property
def last_event(self) -> "OrderEvent":
"""
Return the last event applied to the order.
返回应用于订单的最后一个事件。
Return type:
OrderEvent
"""
...
@property
def last_trade_id(self) -> "TradeId" or None:
"""
The orders last trade match ID.
订单的最后交易匹配 ID。
Returns:
TradeId or None
"""
...
@property
def leaves_qty(self) -> "Quantity":
"""
The order total leaves quantity.
订单总剩余数量。
Returns:
Quantity
"""
...
@property
def linked_order_ids(self) -> list["ClientOrderId"] or None:
"""
The orders linked client order ID(s).
订单链接的客户端订单 ID。
Returns:
list[ClientOrderId] or None
"""
...
@property
def liquidity_side(self) -> "LiquiditySide":
"""
The order liquidity side.
订单流动性方向。
Returns:
LiquiditySide
"""
...
@staticmethod
def opposite_side(side: "OrderSide") -> "OrderSide":
"""
Return the opposite order side from the given side.
从给定的方向返回相反的订单方向。
Parameters:
side (OrderSide {BUY, SELL}) – The original order side.
side (OrderSide {BUY, SELL}) - 原始订单方向。
Return type:
OrderSide
Raises:
ValueError – If side is invalid.
ValueError - 如果方向无效。
"""
...
@property
def order_list_id(self) -> "OrderListId" or None:
"""
The order list ID associated with the order.
与订单关联的订单列表 ID。
Returns:
OrderListId or None
"""
...
@property
def order_type(self) -> "OrderType":
"""
The order type.
订单类型。
Returns:
OrderType
"""
...
@property
def parent_order_id(self) -> "ClientOrderId" or None:
"""
The parent client order ID.
父客户端订单 ID。
Returns:
ClientOrderId or None
"""
...
@property
def position_id(self) -> "PositionId" or None:
"""
The position ID associated with the order.
与订单关联的头寸 ID。
Returns:
PositionId or None
"""
...
@property
def quantity(self) -> "Quantity":
"""
The order quantity.
订单数量。
Returns:
Quantity
"""
...
@property
def side(self) -> "OrderSide":
"""
The order side.
订单方向。
Returns:
OrderSide
"""
...
def side_string(self) -> str:
"""
Return the orders side as a string.
将订单方向作为字符串返回。
Return type:
str
"""
...
def signed_decimal_qty(self):
"""
Return a signed decimal representation of the remaining quantity.
返回剩余数量的带符号十进制表示形式。
If the order is a BUY, the value is positive (e.g. Decimal(‘10.25’))
如果订单是买入,则值为正数(例如Decimal('10.25'))
If the order is a SELL, the value is negative (e.g. Decimal(‘-10.25’))
如果订单是卖出,则值为负数(例如Decimal('-10.25'))
Return type:
Decimal
"""
return
@property
def slippage(self) -> float:
"""
The order total price slippage.
订单总价格滑点。
Returns:
double
"""
...
@property
def status(self) -> "OrderStatus":
"""
Return the orders current status.
返回订单的当前状态。
Return type:
OrderStatus
"""
...
def status_string(self) -> str:
"""
Return the orders current status as a string.
将订单的当前状态作为字符串返回。
Return type:
str
"""
...
@property
def strategy_id(self) -> "StrategyId":
"""
The strategy ID associated with the order.
与订单关联的策略 ID。
Returns:
StrategyId
"""
...
@property
def symbol(self) -> "Symbol":
"""
Return the orders ticker symbol.
返回订单的代码。
Return type:
Symbol
"""
...
@property
def tags(self) -> list[str] or None:
"""
The order custom user tags.
订单自定义用户标签。
Returns:
list[str] or None
"""
...
@property
def time_in_force(self) -> "TimeInForce":
"""
The order time in force.
订单有效时间。
Returns:
TimeInForce
"""
...
def to_dict(self) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def trade_ids(self) -> list["TradeId"]:
"""
Return the trade match IDs.
返回交易匹配 ID。
Return type:
list[TradeId]
"""
...
@property
def trader_id(self) -> "TraderId":
"""
The trader ID associated with the position.
与头寸关联的交易者 ID。
Returns:
TraderId
"""
...
@property
def trigger_instrument_id(self) -> "InstrumentId" or None:
"""
The order emulation trigger instrument ID (will be instrument_id if None).
订单模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
Returns:
InstrumentId or None
"""
...
@property
def trigger_price(self) -> "Price":
"""
The order trigger price (STOP).
订单触发价格 (STOP)。
Returns:
Price
"""
...
@property
def trigger_type(self) -> "TriggerType":
"""
The trigger type for the order.
订单的触发器类型。
Returns:
TriggerType
"""
...
@property
def ts_init(self) -> int:
"""
UNIX timestamp (nanoseconds) when the object was initialized.
对象初始化时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
@property
def ts_last(self) -> int:
"""
UNIX timestamp (nanoseconds) when the last event occurred.
上次事件发生时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
@property
def ts_triggered(self) -> int:
"""
UNIX timestamp (nanoseconds) when the order was triggered (0 if not triggered).
订单触发时的 UNIX 时间戳(纳秒)(如果未触发,则为 0)。
Returns:
uint64_t
"""
...
def type_string(self) -> str:
"""
Return the orders type as a string.
将订单类型作为字符串返回。
Return type:
str
"""
...
@property
def venue(self) -> "Venue":
"""
Return the orders trading venue.
返回订单的交易场所。
Return type:
Venue
"""
...
@property
def venue_order_id(self) -> "VenueOrderId" or None:
"""
The venue assigned order ID.
交易场所分配的订单 ID。
Returns:
VenueOrderId or None
"""
...
@property
def venue_order_ids(self) -> list["VenueOrderId"]:
"""
Return the venue order IDs.
返回交易场所订单 ID。
Return type:
list[VenueOrderId]
"""
...
def would_reduce_only(
self, position_side: "PositionSide", position_qty: "Quantity"
) -> bool:
"""
Whether the current order would only reduce the given position if applied in full.
如果当前订单完全应用,是否只会减少给定的头寸。
Parameters:
position_side (PositionSide {FLAT, LONG, SHORT}) – The side of the position to check against.
position_side (PositionSide {FLAT, LONG, SHORT}) - 要检查的头寸方向。
position_qty (Quantity) – The quantity of the position to check against.
position_qty (Quantity) - 要检查的头寸数量。
Return type:
bool
"""
...
class StopLimitOrder 止损限价订单
class StopLimitOrder(Order):
"""
StopLimitOrder(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, Quantity quantity, Price price, Price trigger_price, TriggerType trigger_type, UUID4 init_id, uint64_t ts_init, TimeInForce time_in_force=TimeInForce.GTC, uint64_t expire_time_ns=0, bool post_only=False, bool reduce_only=False, bool quote_quantity=False, Quantity display_qty=None, TriggerType emulation_trigger=TriggerType.NO_TRIGGER, InstrumentId trigger_instrument_id=None, ContingencyType contingency_type=ContingencyType.NO_CONTINGENCY, OrderListId order_list_id=None, list linked_order_ids=None, ClientOrderId parent_order_id=None, ExecAlgorithmId exec_algorithm_id=None, dict exec_algorithm_params=None, ClientOrderId exec_spawn_id=None, list tags=None)
Represents a Stop-Limit conditional order.
表示止损限价条件订单。
A Stop-Limit order is an instruction to submit a BUY (or SELL) limit order when the specified stop trigger price is attained or penetrated. The order has two basic components: the stop price and the limit price. When a trade has occurred at or through the stop price, the order becomes executable and enters the market as a limit order, which is an order to BUY (or SELL) at a specified price or better.
止损限价订单是在达到或突破指定的止损触发价格时提交买入(或卖出)限价单的指令。该订单有两个基本组成部分:止损价和限价。当以止损价或通过止损价进行交易时,订单变为可执行订单,并作为限价单进入市场,限价单是指以指定价格或更好的价格买入(或卖出)的订单。
A Stop-Limit eliminates the price risk associated with a stop order where the execution price cannot be guaranteed, but exposes the trader to the risk that the order may never fill, even if the stop price is reached.
止损限价单消除了止损单中无法保证执行价格的价格风险,但使交易者面临即使达到止损价也可能永远无法成交的风险。
Parameters:
trader_id (TraderId) – The trader ID associated with the order.
trader_id (TraderId) - 与订单关联的交易者ID。
strategy_id (StrategyId) – The strategy ID associated with the order.
strategy_id (StrategyId) - 与订单关联的策略ID。
instrument_id (InstrumentId) – The order instrument ID.
instrument_id (InstrumentId) - 订单金融工具ID。
client_order_id (ClientOrderId) – The client order ID.
client_order_id (ClientOrderId) - 客户端订单ID。
order_side (OrderSide {BUY, SELL}) – The order side.
order_side (OrderSide {BUY, SELL}) - 订单方向。
quantity (Quantity) – The order quantity (> 0).
quantity (Quantity) - 订单数量 (> 0)。
price (Price) – The order price (LIMIT).
price (Price) - 订单价格(LIMIT)。
trigger_price (Price) – The order trigger price (STOP).
trigger_price (Price) - 订单触发价格(STOP)。
trigger_type (TriggerType) – The order trigger type.
trigger_type (TriggerType) - 订单触发器类型。
init_id (UUID4) – The order initialization event ID.
init_id (UUID4) - 订单初始化事件ID。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.
ts_init (uint64_t) - 对象初始化时的UNIX时间戳(纳秒)。
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY}, default GTC) – The order time in force.
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY}, 默认GTC) - 订单有效时间。
expire_time_ns (uint64_t , default 0 *(*no expiry )) – UNIX timestamp (nanoseconds) when the order will expire.
expire_time_ns (uint64_t, 默认 0 *(*无到期*)) - 订单到期的UNIX时间戳(纳秒)。
post_only (bool , default False) – If the LIMIT order will only provide liquidity (once triggered).
post_only (bool, 默认 False) - 如果限价单仅提供流动性(一旦触发)。
reduce_only (bool , default False) – If the LIMIT order carries the ‘reduce-only’ execution instruction.
reduce_only (bool, 默认 False) - 如果限价单带有“仅减少”执行指令。
quote_quantity (bool , default False) – If the order quantity is denominated in the quote currency.
quote_quantity (bool, 默认 False) - 如果订单数量以报价货币计价。
display_qty (Quantity , optional) – The quantity of the LIMIT order to display on the public book (iceberg).
display_qty (Quantity, 可选) - 要在公开订单簿上显示的限价单数量(冰山订单)。
emulation_trigger (EmulationTrigger, default NO_TRIGGER) – The emulation trigger for the order.
emulation_trigger (EmulationTrigger, 默认 NO_TRIGGER) - 订单的模拟触发器。
trigger_instrument_id (InstrumentId , optional) – The emulation trigger instrument ID for the order (if None then will be the instrument_id).
trigger_instrument_id (InstrumentId, 可选) - 订单的模拟触发器金融工具ID(如果为None,则将为instrument_id)。
contingency_type (ContingencyType, default NO_CONTINGENCY) – The order contingency type.
contingency_type (ContingencyType, 默认 NO_CONTINGENCY) - 订单意外事件类型。
order_list_id (OrderListId , optional) – The order list ID associated with the order.
order_list_id (OrderListId, 可选) - 与订单关联的订单列表ID。
linked_order_ids (list [ClientOrderId ] , optional) – The order linked client order ID(s).
linked_order_ids (list [ClientOrderId ], 可选) - 订单链接的客户端订单ID。
parent_order_id (ClientOrderId , optional) – The order parent client order ID.
parent_order_id (ClientOrderId, 可选) - 订单父客户端订单ID。
exec_algorithm_id (ExecAlgorithmId , optional) – The execution algorithm ID for the order.
exec_algorithm_id (ExecAlgorithmId, 可选) - 订单的执行算法ID。
exec_algorithm_params (dict *[*str , Any ] , optional) – The execution algorithm parameters for the order.
exec_algorithm_params (dict *[*str , Any ], 可选) - 订单的执行算法参数。
exec_spawn_id (ClientOrderId , optional) – The execution algorithm spawning primary client order ID.
exec_spawn_id (ClientOrderId, 可选) - 执行算法生成的原始客户端订单ID。
tags (list *[*str ] , optional) – The custom user tags for the order.
tags (list *[*str ], 可选) - 订单的自定义用户标签。
Raises:
ValueError – If order_side is NO_ORDER_SIDE.
ValueError - 如果 order_side 为 NO_ORDER_SIDE。
ValueError – If quantity is not positive (> 0).
ValueError - 如果 quantity 不为正数 (> 0)。
ValueError – If trigger_type is NO_TRIGGER.
ValueError - 如果 trigger_type 为 NO_TRIGGER。
ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE.
ValueError - 如果 time_in_force 为 AT_THE_OPEN 或 AT_THE_CLOSE。
ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.
ValueError - 如果 time_in_force 为 GTD 并且 expire_time_ns <= UNIX epoch。
ValueError – If display_qty is negative (< 0) or greater than quantity.
ValueError - 如果 display_qty 为负数 (< 0) 或大于 quantity。
"""
@property
def account_id(self) -> "AccountId" or None:
"""
The account ID associated with the order.
与订单关联的账户ID。
Returns:
AccountId or None
"""
...
def apply(self, event: "OrderEvent") -> None:
"""
Apply the given order event to the order.
将给定的订单事件应用于订单。
Parameters:
event (OrderEvent) – The order event to apply.
event (OrderEvent) - 要应用的订单事件。
Raises:
ValueError – If self.client_order_id is not equal to event.client_order_id.
ValueError - 如果 self.client_order_id 不等于 event.client_order_id。
ValueError – If self.venue_order_id and event.venue_order_id are both not None, and are not equal.
ValueError - 如果 self.venue_order_id 和 event.venue_order_id 都不为 None,并且不相等。
InvalidStateTrigger – If event is not a valid trigger from the current order.status.
InvalidStateTrigger - 如果事件不是当前 order.status 的有效触发器。
KeyError – If event is OrderFilled and event.trade_id already applied to the order.
KeyError - 如果 event 是 OrderFilled 并且 event.trade_id 已经应用于订单。
"""
...
@property
def avg_px(self) -> float:
"""
The order average fill price.
订单平均成交价格。
Returns:
double
"""
...
@property
def client_order_id(self) -> "ClientOrderId":
"""
The client order ID.
客户端订单 ID。
Returns:
ClientOrderId
"""
...
@staticmethod
def closing_side(position_side: "PositionSide") -> "OrderSide":
"""
Return the order side needed to close a position with the given side.
返回平仓给定方向头寸所需的订单方向。
Parameters:
position_side (PositionSide {LONG, SHORT}) – The side of the position to close.
position_side (PositionSide {LONG, SHORT}) - 要平仓头寸的方向。
Return type:
OrderSide
Raises:
ValueError – If position_side is FLAT or invalid.
ValueError - 如果 position_side 为 FLAT 或无效。
"""
...
def commissions(self) -> list:
"""
Return the total commissions generated by the order.
返回订单产生的总佣金。
Return type:
list[Money]
"""
...
@property
def contingency_type(self) -> "ContingencyType":
"""
The orders contingency type.
订单的意外事件类型。
Returns:
ContingencyType
"""
...
@staticmethod
def create(init):
...
@property
def display_qty(self) -> "Quantity" or None:
"""
The quantity of the LIMIT order to display on the public book (iceberg).
要在公开订单簿上显示的限价单数量(冰山订单)。
Returns:
Quantity or None
"""
...
@property
def emulation_trigger(self) -> "TriggerType":
"""
The order emulation trigger type.
订单模拟触发器类型。
Returns:
TriggerType
"""
...
@property
def event_count(self) -> int:
"""
Return the count of events applied to the order.
返回应用于订单的事件计数。
Return type:
int
"""
...
@property
def events(self) -> list["OrderEvent"]:
"""
Return the order events.
返回订单事件。
Return type:
list[OrderEvent]
"""
...
@property
def exec_algorithm_id(self) -> "ExecAlgorithmId" or None:
"""
The execution algorithm ID for the order.
订单的执行算法 ID。
Returns:
ExecAlgorithmId or None
"""
...
@property
def exec_algorithm_params(self) -> dict[str, Any] or None:
"""
The execution algorithm parameters for the order.
订单的执行算法参数。
Returns:
dict[str, Any] or None
"""
...
@property
def exec_spawn_id(self) -> "ClientOrderId" or None:
"""
The execution algorithm spawning client order ID.
执行算法生成的客户端订单 ID。
Returns:
ClientOrderId or None
"""
...
@property
def expire_time(self) -> "datetime" or None:
"""
Return the expire time for the order (UTC).
返回订单的到期时间 (UTC)。
Return type:
datetime or None
"""
...
@property
def expire_time_ns(self) -> int:
"""
The order expiration (UNIX epoch nanoseconds), zero for no expiration.
订单到期时间(UNIX 纪元纳秒),0 表示无到期时间。
Returns:
uint64_t
"""
...
@property
def filled_qty(self) -> "Quantity":
"""
The order total filled quantity.
订单总成交数量。
Returns:
Quantity
"""
...
@staticmethod
def from_pyo3(pyo3_order):
...
@property
def has_price(self) -> bool:
"""
Return whether the order has a price property.
返回订单是否具有 price 属性。
Return type:
bool
"""
...
@property
def has_trigger_price(self) -> bool:
"""
Return whether the order has a trigger_price property.
返回订单是否具有 trigger_price 属性。
Return type:
bool
"""
...
def info(self) -> str:
"""
Return a summary description of the order.
返回订单的摘要描述。
Return type:
str
"""
...
@property
def init_event(self) -> "OrderInitialized":
"""
Return the initialization event for the order.
返回订单的初始化事件。
Return type:
OrderInitialized
"""
...
@property
def init_id(self) -> "UUID4":
"""
The event ID of the OrderInitialized event.
OrderInitialized 事件的事件 ID。
Returns:
UUID4
"""
...
@property
def instrument_id(self) -> "InstrumentId":
"""
The order instrument ID.
订单金融工具 ID。
Returns:
InstrumentId
"""
...
@property
def is_active_local(self) -> bool:
"""
Return whether the order is active and held in the local system.
返回订单是否处于活动状态并在本地系统中持有。
An order is considered active local when its status is any of;
当订单的状态为以下任何一种时,该订单被视为本地活动订单:
INITIALIZED
EMULATED
RELEASED
Return type:
bool
"""
...
@property
def is_aggressive(self) -> bool:
"""
Return whether the order is aggressive (order_type is MARKET).
返回订单是否为激进订单(order_type 为 MARKET)。
Return type:
bool
"""
...
@property
def is_buy(self) -> bool:
"""
Return whether the order side is BUY.
返回订单方向是否为 BUY。
Return type:
bool
"""
...
@property
def is_canceled(self) -> bool:
"""
Return whether current status is CANCELED.
返回当前状态是否为 CANCELED。
Return type:
bool
"""
...
@property
def is_child_order(self) -> bool:
"""
Return whether the order has a parent order.
返回订单是否具有父订单。
Return type:
bool
"""
...
@property
def is_closed(self) -> bool:
"""
Return whether the order is closed.
返回订单是否已平仓。
An order is considered closed when its status can no longer change. The possible statuses of closed orders include;
当订单的状态不再可以更改时,该订单被视为已平仓。已平仓订单的可能状态包括:
DENIED
REJECTED
CANCELED
EXPIRED
FILLED
Return type:
bool
"""
...
@property
def is_contingency(self) -> bool:
"""
Return whether the order has a contingency (contingency_type is not NO_CONTINGENCY).
返回订单是否具有意外事件(contingency_type 不为 NO_CONTINGENCY)。
Return type:
bool
"""
...
@property
def is_emulated(self) -> bool:
"""
Return whether the order is emulated and held in the local system.
返回订单是否被模拟并在本地系统中持有。
Return type:
bool
"""
...
@property
def is_inflight(self) -> bool:
"""
Return whether the order is in-flight (order request sent to the trading venue).
返回订单是否正在进行中(订单请求已发送到交易场所)。
An order is considered in-flight when its status is any of;
当订单的状态为以下任何一种时,该订单被视为正在进行中:
SUBMITTED
PENDING_UPDATE
PENDING_CANCEL
Return type:
bool
WARNING
An emulated order is never considered in-flight.
模拟订单永远不会被视为正在进行中。
"""
...
@property
def is_open(self) -> bool:
"""
Return whether the order is open at the trading venue.
返回订单是否在交易场所开仓。
An order is considered open when its status is any of;
当订单的状态为以下任何一种时,该订单被视为开仓:
ACCEPTED
TRIGGERED
PENDING_UPDATE
PENDING_CANCEL
PARTIALLY_FILLED
Return type:
bool
WARNING
An emulated order is never considered open.
模拟订单永远不会被视为开仓。
"""
...
@property
def is_parent_order(self) -> bool:
"""
Return whether the order has at least one child order.
返回订单是否至少有一个子订单。
Return type:
bool
"""
...
@property
def is_passive(self) -> bool:
"""
Return whether the order is passive (order_type not MARKET).
返回订单是否为被动订单(order_type 不为 MARKET)。
Return type:
bool
"""
...
@property
def is_pending_cancel(self) -> bool:
"""
Return whether the current status is PENDING_CANCEL.
返回当前状态是否为 PENDING_CANCEL。
Return type:
bool
"""
...
@property
def is_pending_update(self) -> bool:
"""
Return whether the current status is PENDING_UPDATE.
返回当前状态是否为 PENDING_UPDATE。
Return type:
bool
"""
...
@property
def is_post_only(self) -> bool:
"""
If the order will only provide liquidity (make a market).
如果订单只提供流动性(做市商)。
Returns:
bool
"""
...
@property
def is_primary(self) -> bool:
"""
Return whether the order is the primary for an execution algorithm sequence.
返回订单是否是执行算法序列的主订单。
Return type:
bool
"""
...
@property
def is_quote_quantity(self) -> bool:
"""
If the order quantity is denominated in the quote currency.
如果订单数量以报价货币计价。
Returns:
bool
"""
...
@property
def is_reduce_only(self) -> bool:
"""
If the order carries the ‘reduce-only’ execution instruction.
如果订单带有“仅减少”执行指令。
Returns:
bool
"""
...
@property
def is_sell(self) -> bool:
"""
Return whether the order side is SELL.
返回订单方向是否为 SELL。
Return type:
bool
"""
...
@property
def is_spawned(self) -> bool:
"""
Return whether the order was spawned as part of an execution algorithm sequence.
返回订单是否作为执行算法序列的一部分生成。
Return type:
bool
"""
...
@property
def is_triggered(self) -> bool:
"""
If the order has been triggered.
如果订单已触发。
Returns:
bool
"""
...
@property
def last_event(self) -> "OrderEvent":
"""
Return the last event applied to the order.
返回应用于订单的最后一个事件。
Return type:
OrderEvent
"""
...
@property
def last_trade_id(self) -> "TradeId" or None:
"""
The orders last trade match ID.
订单的最后交易匹配 ID。
Returns:
TradeId or None
"""
...
@property
def leaves_qty(self) -> "Quantity":
"""
The order total leaves quantity.
订单总剩余数量。
Returns:
Quantity
"""
...
@property
def linked_order_ids(self) -> list["ClientOrderId"] or None:
"""
The orders linked client order ID(s).
订单链接的客户端订单 ID。
Returns:
list[ClientOrderId] or None
"""
...
@property
def liquidity_side(self) -> "LiquiditySide":
"""
The order liquidity side.
订单流动性方向。
Returns:
LiquiditySide
"""
...
@staticmethod
def opposite_side(side: "OrderSide") -> "OrderSide":
"""
Return the opposite order side from the given side.
从给定的方向返回相反的订单方向。
Parameters:
side (OrderSide {BUY, SELL}) – The original order side.
side (OrderSide {BUY, SELL}) - 原始订单方向。
Return type:
OrderSide
Raises:
ValueError – If side is invalid.
ValueError - 如果方向无效。
"""
...
@property
def order_list_id(self) -> "OrderListId" or None:
"""
The order list ID associated with the order.
与订单关联的订单列表 ID。
Returns:
OrderListId or None
"""
...
@property
def order_type(self) -> "OrderType":
"""
The order type.
订单类型。
Returns:
OrderType
"""
...
@property
def parent_order_id(self) -> "ClientOrderId" or None:
"""
The parent client order ID.
父客户端订单 ID。
Returns:
ClientOrderId or None
"""
...
@property
def position_id(self) -> "PositionId" or None:
"""
The position ID associated with the order.
与订单关联的头寸 ID。
Returns:
PositionId or None
"""
...
@property
def price(self) -> "Price":
"""
The order price (LIMIT).
订单价格 (LIMIT)。
Returns:
Price
"""
...
@property
def quantity(self) -> "Quantity":
"""
The order quantity.
订单数量。
Returns:
Quantity
"""
...
@property
def side(self) -> "OrderSide":
"""
The order side.
订单方向。
Returns:
OrderSide
"""
...
def side_string(self) -> str:
"""
Return the orders side as a string.
将订单方向作为字符串返回。
Return type:
str
"""
...
def signed_decimal_qty(self):
"""
Return a signed decimal representation of the remaining quantity.
返回剩余数量的带符号十进制表示形式。
If the order is a BUY, the value is positive (e.g. Decimal(‘10.25’))
如果订单是买入,则值为正数(例如Decimal('10.25'))
If the order is a SELL, the value is negative (e.g. Decimal(‘-10.25’))
如果订单是卖出,则值为负数(例如Decimal('-10.25'))
Return type:
Decimal
"""
return
@property
def slippage(self) -> float:
"""
The order total price slippage.
订单总价格滑点。
Returns:
double
"""
...
@property
def status(self) -> "OrderStatus":
"""
Return the orders current status.
返回订单的当前状态。
Return type:
OrderStatus
"""
...
def status_string(self) -> str:
"""
Return the orders current status as a string.
将订单的当前状态作为字符串返回。
Return type:
str
"""
...
@property
def strategy_id(self) -> "StrategyId":
"""
The strategy ID associated with the order.
与订单关联的策略 ID。
Returns:
StrategyId
"""
...
@property
def symbol(self) -> "Symbol":
"""
Return the orders ticker symbol.
返回订单的代码。
Return type:
Symbol
"""
...
@property
def tags(self) -> list[str] or None:
"""
The order custom user tags.
订单自定义用户标签。
Returns:
list[str] or None
"""
...
@property
def time_in_force(self) -> "TimeInForce":
"""
The order time in force.
订单有效时间。
Returns:
TimeInForce
"""
...
def to_dict(self) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def trade_ids(self) -> list["TradeId"]:
"""
Return the trade match IDs.
返回交易匹配 ID。
Return type:
list[TradeId]
"""
...
@property
def trader_id(self) -> "TraderId":
"""
The trader ID associated with the position.
与头寸关联的交易者 ID。
Returns:
TraderId
"""
...
@property
def trigger_instrument_id(self) -> "InstrumentId" or None:
"""
The order emulation trigger instrument ID (will be instrument_id if None).
订单模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
Returns:
InstrumentId or None
"""
...
@property
def trigger_price(self) -> "Price":
"""
The order trigger price (STOP).
订单触发价格 (STOP)。
Returns:
Price
"""
...
@property
def trigger_type(self) -> "TriggerType":
"""
The trigger type for the order.
订单的触发器类型。
Returns:
TriggerType
"""
...
@property
def ts_init(self) -> int:
"""
UNIX timestamp (nanoseconds) when the object was initialized.
对象初始化时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
@property
def ts_last(self) -> int:
"""
UNIX timestamp (nanoseconds) when the last event occurred.
上次事件发生时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
@property
def ts_triggered(self) -> int:
"""
UNIX timestamp (nanoseconds) when the order was triggered (0 if not triggered).
订单触发时的 UNIX 时间戳(纳秒)(如果未触发,则为 0)。
Returns:
uint64_t
"""
...
def type_string(self) -> str:
"""
Return the orders type as a string.
将订单类型作为字符串返回。
Return type:
str
"""
...
@property
def venue(self) -> "Venue":
"""
Return the orders trading venue.
返回订单的交易场所。
Return type:
Venue
"""
...
@property
def venue_order_id(self) -> "VenueOrderId" or None:
"""
The venue assigned order ID.
交易场所分配的订单 ID。
Returns:
VenueOrderId or None
"""
...
@property
def venue_order_ids(self) -> list["VenueOrderId"]:
"""
Return the venue order IDs.
返回交易场所订单 ID。
Return type:
list[VenueOrderId]
"""
...
def would_reduce_only(
self, position_side: "PositionSide", position_qty: "Quantity"
) -> bool:
"""
Whether the current order would only reduce the given position if applied in full.
如果当前订单完全应用,是否只会减少给定的头寸。
Parameters:
position_side (PositionSide {FLAT, LONG, SHORT}) – The side of the position to check against.
position_side (PositionSide {FLAT, LONG, SHORT}) - 要检查的头寸方向。
position_qty (Quantity) – The quantity of the position to check against.
position_qty (Quantity) - 要检查的头寸数量。
Return type:
bool
"""
...
class MarketToLimitOrder 市价转限价订单
class MarketToLimitOrder(Order):
"""
MarketToLimitOrder(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, Quantity quantity, UUID4 init_id, uint64_t ts_init, TimeInForce time_in_force=TimeInForce.GTC, uint64_t expire_time_ns=0, bool reduce_only=False, bool quote_quantity=False, Quantity display_qty=None, ContingencyType contingency_type=ContingencyType.NO_CONTINGENCY, OrderListId order_list_id=None, list linked_order_ids=None, ClientOrderId parent_order_id=None, ExecAlgorithmId exec_algorithm_id=None, dict exec_algorithm_params=None, ClientOrderId exec_spawn_id=None, list tags=None)
Represents a Market-To-Limit (MTL) order.
表示市价转限价 (MTL) 订单。
A Market-to-Limit (MTL) order is submitted as a market order to execute at the current best market price. If the order is only partially filled, the remainder of the order is canceled and re-submitted as a Limit order with the limit price equal to the price at which the filled portion of the order executed.
市价转限价 (MTL) 订单作为市价单提交,以当前最佳市场价格执行。如果订单仅部分成交,则订单的剩余部分将被取消并重新提交为限价单,限价等于订单成交部分的执行价格。
Parameters:
trader_id (TraderId) – The trader ID associated with the order.
trader_id (TraderId) - 与订单关联的交易者 ID。
strategy_id (StrategyId) – The strategy ID associated with the order.
strategy_id (StrategyId) - 与订单关联的策略 ID。
instrument_id (InstrumentId) – The order instrument ID.
instrument_id (InstrumentId) - 订单金融工具 ID。
client_order_id (ClientOrderId) – The client order ID.
client_order_id (ClientOrderId) - 客户端订单 ID。
order_side (OrderSide {BUY, SELL}) – The order side.
order_side (OrderSide {BUY, SELL}) - 订单方向。
quantity (Quantity) – The order quantity (> 0).
quantity (Quantity) - 订单数量 (> 0)。
init_id (UUID4) – The order initialization event ID.
init_id (UUID4) - 订单初始化事件 ID。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.
ts_init (uint64_t) - 对象初始化时的 UNIX 时间戳(纳秒)。
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY}, default GTC) – The order time in force.
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY}, 默认 GTC) - 订单有效时间。
expire_time_ns (uint64_t , default 0 *(*no expiry )) – UNIX timestamp (nanoseconds) when the order will expire.
expire_time_ns (uint64_t, 默认 0 *(*无到期*)) - 订单到期的 UNIX 时间戳(纳秒)。
reduce_only (bool , default False) – If the order carries the ‘reduce-only’ execution instruction.
reduce_only (bool, 默认 False) - 如果订单带有“仅减少”执行指令。
quote_quantity (bool , default False) – If the order quantity is denominated in the quote currency.
quote_quantity (bool, 默认 False) - 如果订单数量以报价货币计价。
display_qty (Quantity , optional) – The quantity of the limit order to display on the public book (iceberg).
display_qty (Quantity, 可选) - 要在公开订单簿上显示的限价单数量(冰山订单)。
contingency_type (ContingencyType, default NO_CONTINGENCY) – The order contingency type.
contingency_type (ContingencyType, 默认 NO_CONTINGENCY) - 订单意外事件类型。
order_list_id (OrderListId , optional) – The order list ID associated with the order.
order_list_id (OrderListId, 可选) - 与订单关联的订单列表 ID。
linked_order_ids (list [ClientOrderId ] , optional) – The order linked client order ID(s).
linked_order_ids (list [ClientOrderId ], 可选) - 订单链接的客户端订单 ID。
parent_order_id (ClientOrderId , optional) – The order parent client order ID.
parent_order_id (ClientOrderId, 可选) - 订单父客户端订单 ID。
exec_algorithm_id (ExecAlgorithmId , optional) – The execution algorithm ID for the order.
exec_algorithm_id (ExecAlgorithmId, 可选) - 订单的执行算法 ID。
exec_algorithm_params (dict *[*str , Any ] , optional) – The execution algorithm parameters for the order.
exec_algorithm_params (dict *[*str , Any ], 可选) - 订单的执行算法参数。
exec_spawn_id (ClientOrderId , optional) – The execution algorithm spawning primary client order ID.
exec_spawn_id (ClientOrderId, 可选) - 执行算法生成的原始客户端订单 ID。
tags (list *[*str ] , optional) – The custom user tags for the order.
tags (list *[*str ], 可选) - 订单的自定义用户标签。
Raises:
ValueError – If order_side is NO_ORDER_SIDE.
ValueError - 如果 order_side 为 NO_ORDER_SIDE。
ValueError – If quantity is not positive (> 0).
ValueError - 如果 quantity 不为正数 (> 0)。
ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE.
ValueError - 如果 time_in_force 为 AT_THE_OPEN 或 AT_THE_CLOSE。
"""
@property
def account_id(self) -> "AccountId" or None:
"""
The account ID associated with the order.
与订单关联的账户ID。
Returns:
AccountId or None
"""
...
def apply(self, event: "OrderEvent") -> None:
"""
Apply the given order event to the order.
将给定的订单事件应用于订单。
Parameters:
event (OrderEvent) – The order event to apply.
event (OrderEvent) - 要应用的订单事件。
Raises:
ValueError – If self.client_order_id is not equal to event.client_order_id.
ValueError - 如果 self.client_order_id 不等于 event.client_order_id。
ValueError – If self.venue_order_id and event.venue_order_id are both not None, and are not equal.
ValueError - 如果 self.venue_order_id 和 event.venue_order_id 都不为 None,并且不相等。
InvalidStateTrigger – If event is not a valid trigger from the current order.status.
InvalidStateTrigger - 如果事件不是当前 order.status 的有效触发器。
KeyError – If event is OrderFilled and event.trade_id already applied to the order.
KeyError - 如果 event 是 OrderFilled 并且 event.trade_id 已经应用于订单。
"""
...
@property
def avg_px(self) -> float:
"""
The order average fill price.
订单平均成交价格。
Returns:
double
"""
...
@property
def client_order_id(self) -> "ClientOrderId":
"""
The client order ID.
客户端订单ID。
Returns:
ClientOrderId
"""
...
@staticmethod
def closing_side(position_side: "PositionSide") -> "OrderSide":
"""
Return the order side needed to close a position with the given side.
返回平仓给定方向头寸所需的订单方向。
Parameters:
position_side (PositionSide {LONG, SHORT}) – The side of the position to close.
position_side (PositionSide {LONG, SHORT}) - 要平仓头寸的方向。
Return type:
OrderSide
Raises:
ValueError – If position_side is FLAT or invalid.
ValueError - 如果 position_side 为 FLAT 或无效。
"""
...
def commissions(self) -> list:
"""
Return the total commissions generated by the order.
返回订单产生的总佣金。
Return type:
list[Money]
"""
...
@property
def contingency_type(self) -> "ContingencyType":
"""
The orders contingency type.
订单的意外事件类型。
Returns:
ContingencyType
"""
...
@staticmethod
def create(init):
...
@property
def display_qty(self) -> "Quantity" or None:
"""
The quantity of the limit order to display on the public book (iceberg).
要在公开订单簿上显示的限价单数量(冰山订单)。
Returns:
Quantity or None
"""
...
@property
def emulation_trigger(self) -> "TriggerType":
"""
The order emulation trigger type.
订单模拟触发器类型。
Returns:
TriggerType
"""
...
@property
def event_count(self) -> int:
"""
Return the count of events applied to the order.
返回应用于订单的事件计数。
Return type:
int
"""
...
@property
def events(self) -> list["OrderEvent"]:
"""
Return the order events.
返回订单事件。
Return type:
list[OrderEvent]
"""
...
@property
def exec_algorithm_id(self) -> "ExecAlgorithmId" or None:
"""
The execution algorithm ID for the order.
订单的执行算法 ID。
Returns:
ExecAlgorithmId or None
"""
...
@property
def exec_algorithm_params(self) -> dict[str, Any] or None:
"""
The execution algorithm parameters for the order.
订单的执行算法参数。
Returns:
dict[str, Any] or None
"""
...
@property
def exec_spawn_id(self) -> "ClientOrderId" or None:
"""
The execution algorithm spawning client order ID.
执行算法生成的客户端订单 ID。
Returns:
ClientOrderId or None
"""
...
@property
def expire_time(self) -> "datetime" or None:
"""
Return the expire time for the order (UTC).
返回订单的到期时间 (UTC)。
Return type:
datetime or None
"""
...
@property
def expire_time_ns(self) -> int:
"""
The order expiration (UNIX epoch nanoseconds), zero for no expiration.
订单到期时间(UNIX 纪元纳秒),0 表示无到期时间。
Returns:
uint64_t
"""
...
@property
def filled_qty(self) -> "Quantity":
"""
The order total filled quantity.
订单总成交数量。
Returns:
Quantity
"""
...
@property
def has_price(self) -> bool:
"""
Return whether the order has a price property.
返回订单是否具有 price 属性。
Return type:
bool
"""
...
@property
def has_trigger_price(self) -> bool:
"""
Return whether the order has a trigger_price property.
返回订单是否具有 trigger_price 属性。
Return type:
bool
"""
...
def info(self) -> str:
"""
Return a summary description of the order.
返回订单的摘要描述。
Return type:
str
"""
...
@property
def init_event(self) -> "OrderInitialized":
"""
Return the initialization event for the order.
返回订单的初始化事件。
Return type:
OrderInitialized
"""
...
@property
def init_id(self) -> "UUID4":
"""
The event ID of the OrderInitialized event.
OrderInitialized 事件的事件 ID。
Returns:
UUID4
"""
...
@property
def instrument_id(self) -> "InstrumentId":
"""
The order instrument ID.
订单金融工具 ID。
Returns:
InstrumentId
"""
...
@property
def is_active_local(self) -> bool:
"""
Return whether the order is active and held in the local system.
返回订单是否处于活动状态并在本地系统中持有。
An order is considered active local when its status is any of;
当订单的状态为以下任何一种时,该订单被视为本地活动订单:
INITIALIZED
EMULATED
RELEASED
Return type:
bool
"""
...
@property
def is_aggressive(self) -> bool:
"""
Return whether the order is aggressive (order_type is MARKET).
返回订单是否为激进订单(order_type 为 MARKET)。
Return type:
bool
"""
...
@property
def is_buy(self) -> bool:
"""
Return whether the order side is BUY.
返回订单方向是否为 BUY。
Return type:
bool
"""
...
@property
def is_canceled(self) -> bool:
"""
Return whether current status is CANCELED.
返回当前状态是否为 CANCELED。
Return type:
bool
"""
...
@property
def is_child_order(self) -> bool:
"""
Return whether the order has a parent order.
返回订单是否具有父订单。
Return type:
bool
"""
...
@property
def is_closed(self) -> bool:
"""
Return whether the order is closed.
返回订单是否已平仓。
An order is considered closed when its status can no longer change. The possible statuses of closed orders include;
当订单的状态不再可以更改时,该订单被视为已平仓。已平仓订单的可能状态包括:
DENIED
REJECTED
CANCELED
EXPIRED
FILLED
Return type:
bool
"""
...
@property
def is_contingency(self) -> bool:
"""
Return whether the order has a contingency (contingency_type is not NO_CONTINGENCY).
返回订单是否具有意外事件(contingency_type 不为 NO_CONTINGENCY)。
Return type:
bool
"""
...
@property
def is_emulated(self) -> bool:
"""
Return whether the order is emulated and held in the local system.
返回订单是否被模拟并在本地系统中持有。
Return type:
bool
"""
...
@property
def is_inflight(self) -> bool:
"""
Return whether the order is in-flight (order request sent to the trading venue).
返回订单是否正在进行中(订单请求已发送到交易场所)。
An order is considered in-flight when its status is any of;
当订单的状态为以下任何一种时,该订单被视为正在进行中:
SUBMITTED
PENDING_UPDATE
PENDING_CANCEL
Return type:
bool
WARNING
An emulated order is never considered in-flight.
模拟订单永远不会被视为正在进行中。
"""
...
@property
def is_open(self) -> bool:
"""
Return whether the order is open at the trading venue.
返回订单是否在交易场所开仓。
An order is considered open when its status is any of;
当订单的状态为以下任何一种时,该订单被视为开仓:
ACCEPTED
TRIGGERED
PENDING_UPDATE
PENDING_CANCEL
PARTIALLY_FILLED
Return type:
bool
WARNING
An emulated order is never considered open.
模拟订单永远不会被视为开仓。
"""
...
@property
def is_parent_order(self) -> bool:
"""
Return whether the order has at least one child order.
返回订单是否至少有一个子订单。
Return type:
bool
"""
...
@property
def is_passive(self) -> bool:
"""
Return whether the order is passive (order_type not MARKET).
返回订单是否为被动订单(order_type 不为 MARKET)。
Return type:
bool
"""
...
@property
def is_pending_cancel(self) -> bool:
"""
Return whether the current status is PENDING_CANCEL.
返回当前状态是否为 PENDING_CANCEL。
Return type:
bool
"""
...
@property
def is_pending_update(self) -> bool:
"""
Return whether the current status is PENDING_UPDATE.
返回当前状态是否为 PENDING_UPDATE。
Return type:
bool
"""
...
@property
def is_post_only(self) -> bool:
"""
If the order will only provide liquidity (make a market).
如果订单只提供流动性(做市商)。
Returns:
bool
"""
...
@property
def is_primary(self) -> bool:
"""
Return whether the order is the primary for an execution algorithm sequence.
返回订单是否是执行算法序列的主订单。
Return type:
bool
"""
...
@property
def is_quote_quantity(self) -> bool:
"""
If the order quantity is denominated in the quote currency.
如果订单数量以报价货币计价。
Returns:
bool
"""
...
@property
def is_reduce_only(self) -> bool:
"""
If the order carries the ‘reduce-only’ execution instruction.
如果订单带有“仅减少”执行指令。
Returns:
bool
"""
...
@property
def is_sell(self) -> bool:
"""
Return whether the order side is SELL.
返回订单方向是否为 SELL。
Return type:
bool
"""
...
@property
def is_spawned(self) -> bool:
"""
Return whether the order was spawned as part of an execution algorithm sequence.
返回订单是否作为执行算法序列的一部分生成。
Return type:
bool
"""
...
@property
def last_event(self) -> "OrderEvent":
"""
Return the last event applied to the order.
返回应用于订单的最后一个事件。
Return type:
OrderEvent
"""
...
@property
def last_trade_id(self) -> "TradeId" or None:
"""
The orders last trade match ID.
订单的最后交易匹配 ID。
Returns:
TradeId or None
"""
...
@property
def leaves_qty(self) -> "Quantity":
"""
The order total leaves quantity.
订单总剩余数量。
Returns:
Quantity
"""
...
@property
def linked_order_ids(self) -> list["ClientOrderId"] or None:
"""
The orders linked client order ID(s).
订单链接的客户端订单 ID。
Returns:
list[ClientOrderId] or None
"""
...
@property
def liquidity_side(self) -> "LiquiditySide":
"""
The order liquidity side.
订单流动性方向。
Returns:
LiquiditySide
"""
...
@staticmethod
def opposite_side(side: "OrderSide") -> "OrderSide":
"""
Return the opposite order side from the given side.
从给定的方向返回相反的订单方向。
Parameters:
side (OrderSide {BUY, SELL}) – The original order side.
side (OrderSide {BUY, SELL}) - 原始订单方向。
Return type:
OrderSide
Raises:
ValueError – If side is invalid.
ValueError - 如果方向无效。
"""
...
@property
def order_list_id(self) -> "OrderListId" or None:
"""
The order list ID associated with the order.
与订单关联的订单列表 ID。
Returns:
OrderListId or None
"""
...
@property
def order_type(self) -> "OrderType":
"""
The order type.
订单类型。
Returns:
OrderType
"""
...
@property
def parent_order_id(self) -> "ClientOrderId" or None:
"""
The parent client order ID.
父客户端订单 ID。
Returns:
ClientOrderId or None
"""
...
@property
def position_id(self) -> "PositionId" or None:
"""
The position ID associated with the order.
与订单关联的头寸 ID。
Returns:
PositionId or None
"""
...
@property
def price(self) -> "Price" or None:
"""
The order price (LIMIT).
订单价格 (LIMIT)。
Returns:
Price or None
"""
...
@property
def quantity(self) -> "Quantity":
"""
The order quantity.
订单数量。
Returns:
Quantity
"""
...
@property
def side(self) -> "OrderSide":
"""
The order side.
订单方向。
Returns:
OrderSide
"""
...
def side_string(self) -> str:
"""
Return the orders side as a string.
将订单方向作为字符串返回。
Return type:
str
"""
...
def signed_decimal_qty(self):
"""
Return a signed decimal representation of the remaining quantity.
返回剩余数量的带符号十进制表示形式。
If the order is a BUY, the value is positive (e.g. Decimal(‘10.25’))
如果订单是买入,则值为正数(例如Decimal('10.25'))
If the order is a SELL, the value is negative (e.g. Decimal(‘-10.25’))
如果订单是卖出,则值为负数(例如Decimal('-10.25'))
Return type:
Decimal
"""
return
@property
def slippage(self) -> float:
"""
The order total price slippage.
订单总价格滑点。
Returns:
double
"""
...
@property
def status(self) -> "OrderStatus":
"""
Return the orders current status.
返回订单的当前状态。
Return type:
OrderStatus
"""
...
def status_string(self) -> str:
"""
Return the orders current status as a string.
将订单的当前状态作为字符串返回。
Return type:
str
"""
...
@property
def strategy_id(self) -> "StrategyId":
"""
The strategy ID associated with the order.
与订单关联的策略 ID。
Returns:
StrategyId
"""
...
@property
def symbol(self) -> "Symbol":
"""
Return the orders ticker symbol.
返回订单的代码。
Return type:
Symbol
"""
...
@property
def tags(self) -> list[str] or None:
"""
The order custom user tags.
订单自定义用户标签。
Returns:
list[str] or None
"""
...
@property
def time_in_force(self) -> "TimeInForce":
"""
The order time in force.
订单有效时间。
Returns:
TimeInForce
"""
...
def to_dict(self) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def trade_ids(self) -> list["TradeId"]:
"""
Return the trade match IDs.
返回交易匹配 ID。
Return type:
list[TradeId]
"""
...
@property
def trader_id(self) -> "TraderId":
"""
The trader ID associated with the position.
与头寸关联的交易者 ID。
Returns:
TraderId
"""
...
@property
def trigger_instrument_id(self) -> "InstrumentId" or None:
"""
The order emulation trigger instrument ID (will be instrument_id if None).
订单模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
Returns:
InstrumentId or None
"""
...
@property
def ts_init(self) -> int:
"""
UNIX timestamp (nanoseconds) when the object was initialized.
对象初始化时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
@property
def ts_last(self) -> int:
"""
UNIX timestamp (nanoseconds) when the last event occurred.
上次事件发生时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
def type_string(self) -> str:
"""
Return the orders type as a string.
将订单类型作为字符串返回。
Return type:
str
"""
...
@property
def venue(self) -> "Venue":
"""
Return the orders trading venue.
返回订单的交易场所。
Return type:
Venue
"""
...
@property
def venue_order_id(self) -> "VenueOrderId" or None:
"""
The venue assigned order ID.
交易场所分配的订单 ID。
Returns:
VenueOrderId or None
"""
...
@property
def venue_order_ids(self) -> list["VenueOrderId"]:
"""
Return the venue order IDs.
返回交易场所订单 ID。
Return type:
list[VenueOrderId]
"""
...
def would_reduce_only(
self, position_side: "PositionSide", position_qty: "Quantity"
) -> bool:
"""
Whether the current order would only reduce the given position if applied in full.
如果当前订单完全应用,是否只会减少给定的头寸。
Parameters:
position_side (PositionSide {FLAT, LONG, SHORT}) – The side of the position to check against.
position_side (PositionSide {FLAT, LONG, SHORT}) - 要检查的头寸方向。
position_qty (Quantity) – The quantity of the position to check against.
position_qty (Quantity) - 要检查的头寸数量。
Return type:
bool
"""
...
class MarketIfTouchedOrder 触碰市价订单
class MarketIfTouchedOrder(Order):
"""
MarketIfTouchedOrder(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, Quantity quantity, Price trigger_price, TriggerType trigger_type, UUID4 init_id, uint64_t ts_init, TimeInForce time_in_force=TimeInForce.GTC, uint64_t expire_time_ns=0, bool reduce_only=False, bool quote_quantity=False, TriggerType emulation_trigger=TriggerType.NO_TRIGGER, InstrumentId trigger_instrument_id=None, ContingencyType contingency_type=ContingencyType.NO_CONTINGENCY, OrderListId order_list_id=None, list linked_order_ids=None, ClientOrderId parent_order_id=None, ExecAlgorithmId exec_algorithm_id=None, dict exec_algorithm_params=None, ClientOrderId exec_spawn_id=None, list tags=None)
Represents a Market-If-Touched (MIT) conditional order.
表示触碰市价 (MIT) 条件订单。
A Market-If-Touched (MIT) is an order to BUY (or SELL) an instrument below (or above) the market. This order is held in the system until the trigger price is touched, and is then submitted as a market order. An MIT order is similar to a Stop-Order, except that an MIT SELL order is placed above the current market price, and a stop SELL order is placed below.
触碰市价订单 (MIT) 是指以低于(或高于)市场价格买入(或卖出)金融工具的订单。此订单在系统中持有,直到触及触发价格,然后作为市价单提交。MIT 订单类似于止损单,不同之处在于 MIT 卖出订单放置在当前市场价格之上,而止损卖出订单放置在当前市场价格之下。
Parameters:
trader_id (TraderId) – The trader ID associated with the order.
trader_id (TraderId) - 与订单关联的交易者 ID。
strategy_id (StrategyId) – The strategy ID associated with the order.
strategy_id (StrategyId) - 与订单关联的策略 ID。
instrument_id (InstrumentId) – The order instrument ID.
instrument_id (InstrumentId) - 订单金融工具 ID。
client_order_id (ClientOrderId) – The client order ID.
client_order_id (ClientOrderId) - 客户端订单 ID。
order_side (OrderSide {BUY, SELL}) – The order side.
order_side (OrderSide {BUY, SELL}) - 订单方向。
quantity (Quantity) – The order quantity (> 0).
quantity (Quantity) - 订单数量 (> 0)。
trigger_price (Price) – The order trigger price (STOP).
trigger_price (Price) - 订单触发价格 (STOP)。
trigger_type (TriggerType) – The order trigger type.
trigger_type (TriggerType) - 订单触发器类型。
init_id (UUID4) – The order initialization event ID.
init_id (UUID4) - 订单初始化事件 ID。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.
ts_init (uint64_t) - 对象初始化时的 UNIX 时间戳(纳秒)。
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY}, default GTC) – The order time in force.
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY},默认 GTC) - 订单有效时间。
expire_time_ns (uint64_t , default 0 *(*no expiry )) – UNIX timestamp (nanoseconds) when the order will expire.
expire_time_ns (uint64_t, 默认 0 *(*无到期*)) - 订单到期的 UNIX 时间戳(纳秒)。
reduce_only (bool , default False) – If the order carries the ‘reduce-only’ execution instruction.
reduce_only (bool, 默认 False) - 如果订单带有“仅减少”执行指令。
quote_quantity (bool , default False) – If the order quantity is denominated in the quote currency.
quote_quantity (bool, 默认 False) - 如果订单数量以报价货币计价。
emulation_trigger (EmulationTrigger, default NO_TRIGGER) – The emulation trigger for the order.
emulation_trigger (EmulationTrigger, 默认 NO_TRIGGER) - 订单的模拟触发器。
trigger_instrument_id (InstrumentId , optional) – The emulation trigger instrument ID for the order (if None then will be the instrument_id).
trigger_instrument_id (InstrumentId, 可选) - 订单的模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
contingency_type (ContingencyType, default NO_CONTINGENCY) – The order contingency type.
contingency_type (ContingencyType, 默认 NO_CONTINGENCY) - 订单意外事件类型。
order_list_id (OrderListId , optional) – The order list ID associated with the order.
order_list_id (OrderListId, 可选) - 与订单关联的订单列表 ID。
linked_order_ids (list [ClientOrderId ] , optional) – The order linked client order ID(s).
linked_order_ids (list [ClientOrderId ], 可选) - 订单链接的客户端订单 ID。
parent_order_id (ClientOrderId , optional) – The order parent client order ID.
parent_order_id (ClientOrderId, 可选) - 订单父客户端订单 ID。
exec_algorithm_id (ExecAlgorithmId , optional) – The execution algorithm ID for the order.
exec_algorithm_id (ExecAlgorithmId, 可选) - 订单的执行算法 ID。
exec_algorithm_params (dict *[*str , Any ] , optional) – The execution algorithm parameters for the order.
exec_algorithm_params (dict *[*str , Any ], 可选) - 订单的执行算法参数。
exec_spawn_id (ClientOrderId , optional) – The execution algorithm spawning primary client order ID.
exec_spawn_id (ClientOrderId, 可选) - 执行算法生成的原始客户端订单 ID。
tags (list *[*str ] , optional) – The custom user tags for the order.
tags (list *[*str ], 可选) - 订单的自定义用户标签。
Raises:
ValueError – If order_side is NO_ORDER_SIDE.
ValueError - 如果 order_side 为 NO_ORDER_SIDE。
ValueError – If quantity is not positive (> 0).
ValueError - 如果 quantity 不为正数 (> 0)。
ValueError – If trigger_type is NO_TRIGGER.
ValueError - 如果 trigger_type 为 NO_TRIGGER。
ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE.
ValueError - 如果 time_in_force 为 AT_THE_OPEN 或 AT_THE_CLOSE。
ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.
ValueError - 如果 time_in_force 为 GTD 并且 expire_time_ns <= UNIX epoch。
"""
@property
def account_id(self) -> "AccountId" or None:
"""
The account ID associated with the order.
与订单关联的账户 ID。
Returns:
AccountId or None
"""
...
def apply(self, event: "OrderEvent") -> None:
"""
Apply the given order event to the order.
将给定的订单事件应用于订单。
Parameters:
event (OrderEvent) – The order event to apply.
event (OrderEvent) - 要应用的订单事件。
Raises:
ValueError – If self.client_order_id is not equal to event.client_order_id.
ValueError - 如果 self.client_order_id 不等于 event.client_order_id。
ValueError – If self.venue_order_id and event.venue_order_id are both not None, and are not equal.
ValueError - 如果 self.venue_order_id 和 event.venue_order_id 都不为 None,并且不相等。
InvalidStateTrigger – If event is not a valid trigger from the current order.status.
InvalidStateTrigger - 如果事件不是当前 order.status 的有效触发器。
KeyError – If event is OrderFilled and event.trade_id already applied to the order.
KeyError - 如果 event 是 OrderFilled 并且 event.trade_id 已经应用于订单。
"""
...
@property
def avg_px(self) -> float:
"""
The order average fill price.
订单平均成交价格。
Returns:
double
"""
...
@property
def client_order_id(self) -> "ClientOrderId":
"""
The client order ID.
客户端订单 ID。
Returns:
ClientOrderId
"""
...
@staticmethod
def closing_side(position_side: "PositionSide") -> "OrderSide":
"""
Return the order side needed to close a position with the given side.
返回平仓给定方向头寸所需的订单方向。
Parameters:
position_side (PositionSide {LONG, SHORT}) – The side of the position to close.
position_side (PositionSide {LONG, SHORT}) - 要平仓头寸的方向。
Return type:
OrderSide
Raises:
ValueError – If position_side is FLAT or invalid.
ValueError - 如果 position_side 为 FLAT 或无效。
"""
...
def commissions(self) -> list:
"""
Return the total commissions generated by the order.
返回订单产生的总佣金。
Return type:
list[Money]
"""
...
@property
def contingency_type(self) -> "ContingencyType":
"""
The orders contingency type.
订单的意外事件类型。
Returns:
ContingencyType
"""
...
@staticmethod
def create(init):
...
@property
def emulation_trigger(self) -> "TriggerType":
"""
The order emulation trigger type.
订单模拟触发器类型。
Returns:
TriggerType
"""
...
@property
def event_count(self) -> int:
"""
Return the count of events applied to the order.
返回应用于订单的事件计数。
Return type:
int
"""
...
@property
def events(self) -> list["OrderEvent"]:
"""
Return the order events.
返回订单事件。
Return type:
list[OrderEvent]
"""
...
@property
def exec_algorithm_id(self) -> "ExecAlgorithmId" or None:
"""
The execution algorithm ID for the order.
订单的执行算法 ID。
Returns:
ExecAlgorithmId or None
"""
...
@property
def exec_algorithm_params(self) -> dict[str, Any] or None:
"""
The execution algorithm parameters for the order.
订单的执行算法参数。
Returns:
dict[str, Any] or None
"""
...
@property
def exec_spawn_id(self) -> "ClientOrderId" or None:
"""
The execution algorithm spawning client order ID.
执行算法生成的客户端订单 ID。
Returns:
ClientOrderId or None
"""
...
@property
def expire_time(self) -> "datetime" or None:
"""
Return the expire time for the order (UTC).
返回订单的到期时间 (UTC)。
Return type:
datetime or None
"""
...
@property
def expire_time_ns(self) -> int:
"""
The order expiration (UNIX epoch nanoseconds), zero for no expiration.
订单到期时间(UNIX 纪元纳秒),0 表示无到期时间。
Returns:
uint64_t
"""
...
@property
def filled_qty(self) -> "Quantity":
"""
The order total filled quantity.
订单总成交数量。
Returns:
Quantity
"""
...
@property
def has_price(self) -> bool:
"""
Return whether the order has a price property.
返回订单是否具有 price 属性。
Return type:
bool
"""
...
@property
def has_trigger_price(self) -> bool:
"""
Return whether the order has a trigger_price property.
返回订单是否具有 trigger_price 属性。
Return type:
bool
"""
...
def info(self) -> str:
"""
Return a summary description of the order.
返回订单的摘要描述。
Return type:
str
"""
...
@property
def init_event(self) -> "OrderInitialized":
"""
Return the initialization event for the order.
返回订单的初始化事件。
Return type:
OrderInitialized
"""
...
@property
def init_id(self) -> "UUID4":
"""
The event ID of the OrderInitialized event.
OrderInitialized 事件的事件 ID。
Returns:
UUID4
"""
...
@property
def instrument_id(self) -> "InstrumentId":
"""
The order instrument ID.
订单金融工具 ID。
Returns:
InstrumentId
"""
...
@property
def is_active_local(self) -> bool:
"""
Return whether the order is active and held in the local system.
返回订单是否处于活动状态并在本地系统中持有。
An order is considered active local when its status is any of;
当订单的状态为以下任何一种时,该订单被视为本地活动订单:
INITIALIZED
EMULATED
RELEASED
Return type:
bool
"""
...
@property
def is_aggressive(self) -> bool:
"""
Return whether the order is aggressive (order_type is MARKET).
返回订单是否为激进订单(order_type 为 MARKET)。
Return type:
bool
"""
...
@property
def is_buy(self) -> bool:
"""
Return whether the order side is BUY.
返回订单方向是否为 BUY。
Return type:
bool
"""
...
@property
def is_canceled(self) -> bool:
"""
Return whether current status is CANCELED.
返回当前状态是否为 CANCELED。
Return type:
bool
"""
...
@property
def is_child_order(self) -> bool:
"""
Return whether the order has a parent order.
返回订单是否具有父订单。
Return type:
bool
"""
...
@property
def is_closed(self) -> bool:
"""
Return whether the order is closed.
返回订单是否已平仓。
An order is considered closed when its status can no longer change. The possible statuses of closed orders include;
当订单的状态不再可以更改时,该订单被视为已平仓。已平仓订单的可能状态包括:
DENIED
REJECTED
CANCELED
EXPIRED
FILLED
Return type:
bool
"""
...
@property
def is_contingency(self) -> bool:
"""
Return whether the order has a contingency (contingency_type is not NO_CONTINGENCY).
返回订单是否具有意外事件(contingency_type 不为 NO_CONTINGENCY)。
Return type:
bool
"""
...
@property
def is_emulated(self) -> bool:
"""
Return whether the order is emulated and held in the local system.
返回订单是否被模拟并在本地系统中持有。
Return type:
bool
"""
...
@property
def is_inflight(self) -> bool:
"""
Return whether the order is in-flight (order request sent to the trading venue).
返回订单是否正在进行中(订单请求已发送到交易场所)。
An order is considered in-flight when its status is any of;
当订单的状态为以下任何一种时,该订单被视为正在进行中:
SUBMITTED
PENDING_UPDATE
PENDING_CANCEL
Return type:
bool
WARNING
An emulated order is never considered in-flight.
模拟订单永远不会被视为正在进行中。
"""
...
@property
def is_open(self) -> bool:
"""
Return whether the order is open at the trading venue.
返回订单是否在交易场所开仓。
An order is considered open when its status is any of;
当订单的状态为以下任何一种时,该订单被视为开仓:
ACCEPTED
TRIGGERED
PENDING_UPDATE
PENDING_CANCEL
PARTIALLY_FILLED
Return type:
bool
WARNING
An emulated order is never considered open.
模拟订单永远不会被视为开仓。
"""
...
@property
def is_parent_order(self) -> bool:
"""
Return whether the order has at least one child order.
返回订单是否至少有一个子订单。
Return type:
bool
"""
...
@property
def is_passive(self) -> bool:
"""
Return whether the order is passive (order_type not MARKET).
返回订单是否为被动订单(order_type 不为 MARKET)。
Return type:
bool
"""
...
@property
def is_pending_cancel(self) -> bool:
"""
Return whether the current status is PENDING_CANCEL.
返回当前状态是否为 PENDING_CANCEL。
Return type:
bool
"""
...
@property
def is_pending_update(self) -> bool:
"""
Return whether the current status is PENDING_UPDATE.
返回当前状态是否为 PENDING_UPDATE。
Return type:
bool
"""
...
@property
def is_post_only(self) -> bool:
"""
If the order will only provide liquidity (make a market).
如果订单只提供流动性(做市商)。
Returns:
bool
"""
...
@property
def is_primary(self) -> bool:
"""
Return whether the order is the primary for an execution algorithm sequence.
返回订单是否是执行算法序列的主订单。
Return type:
bool
"""
...
@property
def is_quote_quantity(self) -> bool:
"""
If the order quantity is denominated in the quote currency.
如果订单数量以报价货币计价。
Returns:
bool
"""
...
@property
def is_reduce_only(self) -> bool:
"""
If the order carries the ‘reduce-only’ execution instruction.
如果订单带有“仅减少”执行指令。
Returns:
bool
"""
...
@property
def is_sell(self) -> bool:
"""
Return whether the order side is SELL.
返回订单方向是否为 SELL。
Return type:
bool
"""
...
@property
def is_spawned(self) -> bool:
"""
Return whether the order was spawned as part of an execution algorithm sequence.
返回订单是否作为执行算法序列的一部分生成。
Return type:
bool
"""
...
@property
def last_event(self) -> "OrderEvent":
"""
Return the last event applied to the order.
返回应用于订单的最后一个事件。
Return type:
OrderEvent
"""
...
@property
def last_trade_id(self) -> "TradeId" or None:
"""
The orders last trade match ID.
订单的最后交易匹配 ID。
Returns:
TradeId or None
"""
...
@property
def leaves_qty(self) -> "Quantity":
"""
The order total leaves quantity.
订单总剩余数量。
Returns:
Quantity
"""
...
@property
def linked_order_ids(self) -> list["ClientOrderId"] or None:
"""
The orders linked client order ID(s).
订单链接的客户端订单 ID。
Returns:
list[ClientOrderId] or None
"""
...
@property
def liquidity_side(self) -> "LiquiditySide":
"""
The order liquidity side.
订单流动性方向。
Returns:
LiquiditySide
"""
...
@staticmethod
def opposite_side(side: "OrderSide") -> "OrderSide":
"""
Return the opposite order side from the given side.
从给定的方向返回相反的订单方向。
Parameters:
side (OrderSide {BUY, SELL}) – The original order side.
side (OrderSide {BUY, SELL}) - 原始订单方向。
Return type:
OrderSide
Raises:
ValueError – If side is invalid.
ValueError - 如果方向无效。
"""
...
@property
def order_list_id(self) -> "OrderListId" or None:
"""
The order list ID associated with the order.
与订单关联的订单列表 ID。
Returns:
OrderListId or None
"""
...
@property
def order_type(self) -> "OrderType":
"""
The order type.
订单类型。
Returns:
OrderType
"""
...
@property
def parent_order_id(self) -> "ClientOrderId" or None:
"""
The parent client order ID.
父客户端订单 ID。
Returns:
ClientOrderId or None
"""
...
@property
def position_id(self) -> "PositionId" or None:
"""
The position ID associated with the order.
与订单关联的头寸 ID。
Returns:
PositionId or None
"""
...
@property
def quantity(self) -> "Quantity":
"""
The order quantity.
订单数量。
Returns:
Quantity
"""
...
@property
def side(self) -> "OrderSide":
"""
The order side.
订单方向。
Returns:
OrderSide
"""
...
def side_string(self) -> str:
"""
Return the orders side as a string.
将订单方向作为字符串返回。
Return type:
str
"""
...
def signed_decimal_qty(self):
"""
Return a signed decimal representation of the remaining quantity.
返回剩余数量的带符号十进制表示形式。
If the order is a BUY, the value is positive (e.g. Decimal(‘10.25’))
如果订单是买入,则值为正数(例如Decimal('10.25'))
If the order is a SELL, the value is negative (e.g. Decimal(‘-10.25’))
如果订单是卖出,则值为负数(例如Decimal('-10.25'))
Return type:
Decimal
"""
return
@property
def slippage(self) -> float:
"""
The order total price slippage.
订单总价格滑点。
Returns:
double
"""
...
@property
def status(self) -> "OrderStatus":
"""
Return the orders current status.
返回订单的当前状态。
Return type:
OrderStatus
"""
...
def status_string(self) -> str:
"""
Return the orders current status as a string.
将订单的当前状态作为字符串返回。
Return type:
str
"""
...
@property
def strategy_id(self) -> "StrategyId":
"""
The strategy ID associated with the order.
与订单关联的策略 ID。
Returns:
StrategyId
"""
...
@property
def symbol(self) -> "Symbol":
"""
Return the orders ticker symbol.
返回订单的代码。
Return type:
Symbol
"""
...
@property
def tags(self) -> list[str] or None:
"""
The order custom user tags.
订单自定义用户标签。
Returns:
list[str] or None
"""
...
@property
def time_in_force(self) -> "TimeInForce":
"""
The order time in force.
订单有效时间。
Returns:
TimeInForce
"""
...
def to_dict(self) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def trade_ids(self) -> list["TradeId"]:
"""
Return the trade match IDs.
返回交易匹配 ID。
Return type:
list[TradeId]
"""
...
@property
def trader_id(self) -> "TraderId":
"""
The trader ID associated with the position.
与头寸关联的交易者 ID。
Returns:
TraderId
"""
...
@property
def trigger_instrument_id(self) -> "InstrumentId" or None:
"""
The order emulation trigger instrument ID (will be instrument_id if None).
订单模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
Returns:
InstrumentId or None
"""
...
@property
def trigger_price(self) -> "Price":
"""
The order trigger price (STOP).
订单触发价格 (STOP)。
Returns:
Price
"""
...
@property
def trigger_type(self) -> "TriggerType":
"""
The trigger type for the order.
订单的触发器类型。
Returns:
TriggerType
"""
...
@property
def ts_init(self) -> int:
"""
UNIX timestamp (nanoseconds) when the object was initialized.
对象初始化时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
@property
def ts_last(self) -> int:
"""
UNIX timestamp (nanoseconds) when the last event occurred.
上次事件发生时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
def type_string(self) -> str:
"""
Return the orders type as a string.
将订单类型作为字符串返回。
Return type:
str
"""
...
@property
def venue(self) -> "Venue":
"""
Return the orders trading venue.
返回订单的交易场所。
Return type:
Venue
"""
...
@property
def venue_order_id(self) -> "VenueOrderId" or None:
"""
The venue assigned order ID.
交易场所分配的订单 ID。
Returns:
VenueOrderId or None
"""
...
@property
def venue_order_ids(self) -> list["VenueOrderId"]:
"""
Return the venue order IDs.
返回交易场所订单 ID。
Return type:
list[VenueOrderId]
"""
...
def would_reduce_only(
self, position_side: "PositionSide", position_qty: "Quantity"
) -> bool:
"""
Whether the current order would only reduce the given position if applied in full.
如果当前订单完全应用,是否只会减少给定的头寸。
Parameters:
position_side (PositionSide {FLAT, LONG, SHORT}) – The side of the position to check against.
position_side (PositionSide {FLAT, LONG, SHORT}) - 要检查的头寸方向。
position_qty (Quantity) – The quantity of the position to check against.
position_qty (Quantity) - 要检查的头寸数量。
Return type:
bool
"""
...
class LimitIfTouchedOrder 触碰限价订单
class LimitIfTouchedOrder(Order):
"""
LimitIfTouchedOrder(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, Quantity quantity, Price price, Price trigger_price, TriggerType trigger_type, UUID4 init_id, uint64_t ts_init, TimeInForce time_in_force=TimeInForce.GTC, uint64_t expire_time_ns=0, bool post_only=False, bool reduce_only=False, bool quote_quantity=False, Quantity display_qty=None, TriggerType emulation_trigger=TriggerType.NO_TRIGGER, InstrumentId trigger_instrument_id=None, ContingencyType contingency_type=ContingencyType.NO_CONTINGENCY, OrderListId order_list_id=None, list linked_order_ids=None, ClientOrderId parent_order_id=None, ExecAlgorithmId exec_algorithm_id=None, dict exec_algorithm_params=None, ClientOrderId exec_spawn_id=None, list tags=None)
Represents a Limit-If-Touched (LIT) conditional order.
表示触碰限价 (LIT) 条件订单。
A Limit-If-Touched (LIT) is an order to BUY (or SELL) an instrument at a specified price or better, below (or above) the market. This order is held in the system until the trigger price is touched. A LIT order is similar to a Stop-Limit order, except that a LIT SELL order is placed above the current market price, and a Stop-Limit SELL order is placed below.
触碰限价订单 (LIT) 是指以指定价格或更优价格买入(或卖出)金融工具的订单,该价格低于(或高于)市场价格。此订单在系统中持有,直到触及触发价格。LIT 订单类似于止损限价单,不同之处在于 LIT 卖出订单放置在当前市场价格之上,而止损限价卖出订单放置在当前市场价格之下。
Using a LIT order helps to ensure that, if the order does execute, the order will not execute at a price less favorable than the limit price.
使用 LIT 订单有助于确保,如果订单确实执行,订单将不会以比限价更不利的价格执行。
Parameters:
trader_id (TraderId) – The trader ID associated with the order.
trader_id (TraderId) - 与订单关联的交易者 ID。
strategy_id (StrategyId) – The strategy ID associated with the order.
strategy_id (StrategyId) - 与订单关联的策略 ID。
instrument_id (InstrumentId) – The order instrument ID.
instrument_id (InstrumentId) - 订单金融工具 ID。
client_order_id (ClientOrderId) – The client order ID.
client_order_id (ClientOrderId) - 客户端订单 ID。
order_side (OrderSide {BUY, SELL}) – The order side.
order_side (OrderSide {BUY, SELL}) - 订单方向。
quantity (Quantity) – The order quantity (> 0).
quantity (Quantity) - 订单数量 (> 0)。
price (Price) – The order price (LIMIT).
price (Price) - 订单价格 (LIMIT)。
trigger_price (Price) – The order trigger price (STOP).
trigger_price (Price) - 订单触发价格 (STOP)。
trigger_type (TriggerType) – The order trigger type.
trigger_type (TriggerType) - 订单触发器类型。
init_id (UUID4) – The order initialization event ID.
init_id (UUID4) - 订单初始化事件 ID。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.
ts_init (uint64_t) - 对象初始化时的 UNIX 时间戳(纳秒)。
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY}, default GTC) – The order time in force.
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY},默认 GTC) - 订单有效时间。
expire_time_ns (uint64_t , default 0 *(*no expiry )) – UNIX timestamp (nanoseconds) when the order will expire.
expire_time_ns (uint64_t, 默认 0 *(*无到期*)) - 订单到期的 UNIX 时间戳(纳秒)。
post_only (bool , default False) – If the LIMIT order will only provide liquidity (once triggered).
post_only (bool, 默认 False) - 如果限价单仅提供流动性(一旦触发)。
reduce_only (bool , default False) – If the LIMIT order carries the ‘reduce-only’ execution instruction.
reduce_only (bool, 默认 False) - 如果限价单带有“仅减少”执行指令。
quote_quantity (bool , default False) – If the order quantity is denominated in the quote currency.
quote_quantity (bool, 默认 False) - 如果订单数量以报价货币计价。
display_qty (Quantity , optional) – The quantity of the LIMIT order to display on the public book (iceberg).
display_qty (Quantity, 可选) - 要在公开订单簿上显示的限价单数量(冰山订单)。
emulation_trigger (EmulationTrigger, default NO_TRIGGER) – The emulation trigger for the order.
emulation_trigger (EmulationTrigger, 默认 NO_TRIGGER) - 订单的模拟触发器。
trigger_instrument_id (InstrumentId , optional) – The emulation trigger instrument ID for the order (if None then will be the instrument_id).
trigger_instrument_id (InstrumentId, 可选) - 订单的模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
contingency_type (ContingencyType, default NO_CONTINGENCY) – The order contingency type.
contingency_type (ContingencyType, 默认 NO_CONTINGENCY) - 订单意外事件类型。
order_list_id (OrderListId , optional) – The order list ID associated with the order.
order_list_id (OrderListId, 可选) - 与订单关联的订单列表 ID。
linked_order_ids (list [ClientOrderId ] , optional) – The order linked client order ID(s).
linked_order_ids (list [ClientOrderId ], 可选) - 订单链接的客户端订单 ID。
parent_order_id (ClientOrderId , optional) – The order parent client order ID.
parent_order_id (ClientOrderId, 可选) - 订单父客户端订单 ID。
exec_algorithm_id (ExecAlgorithmId , optional) – The execution algorithm ID for the order.
exec_algorithm_id (ExecAlgorithmId, 可选) - 订单的执行算法 ID。
exec_algorithm_params (dict *[*str , Any ] , optional) – The execution algorithm parameters for the order.
exec_algorithm_params (dict *[*str , Any ], 可选) - 订单的执行算法参数。
exec_spawn_id (ClientOrderId , optional) – The execution algorithm spawning primary client order ID.
exec_spawn_id (ClientOrderId, 可选) - 执行算法生成的原始客户端订单 ID。
tags (list *[*str ] , optional) – The custom user tags for the order.
tags (list *[*str ], 可选) - 订单的自定义用户标签。
Raises:
ValueError – If order_side is NO_ORDER_SIDE.
ValueError - 如果 order_side 为 NO_ORDER_SIDE。
ValueError – If quantity is not positive (> 0).
ValueError - 如果 quantity 不为正数 (> 0)。
ValueError – If trigger_type is NO_TRIGGER.
ValueError - 如果 trigger_type 为 NO_TRIGGER。
ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE.
ValueError - 如果 time_in_force 为 AT_THE_OPEN 或 AT_THE_CLOSE。
ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.
ValueError - 如果 time_in_force 为 GTD 并且 expire_time_ns <= UNIX epoch。
ValueError – If display_qty is negative (< 0) or greater than quantity.
ValueError - 如果 display_qty 为负数 (< 0) 或大于 quantity。
"""
@property
def account_id(self) -> "AccountId" or None:
"""
The account ID associated with the order.
与订单关联的账户ID。
Returns:
AccountId or None
"""
...
def apply(self, event: "OrderEvent") -> None:
"""
Apply the given order event to the order.
将给定的订单事件应用于订单。
Parameters:
event (OrderEvent) – The order event to apply.
event (OrderEvent) - 要应用的订单事件。
Raises:
ValueError – If self.client_order_id is not equal to event.client_order_id.
ValueError - 如果 self.client_order_id 不等于 event.client_order_id。
ValueError – If self.venue_order_id and event.venue_order_id are both not None, and are not equal.
ValueError - 如果 self.venue_order_id 和 event.venue_order_id 都不为 None,并且不相等。
InvalidStateTrigger – If event is not a valid trigger from the current order.status.
InvalidStateTrigger - 如果事件不是当前 order.status 的有效触发器。
KeyError – If event is OrderFilled and event.trade_id already applied to the order.
KeyError - 如果 event 是 OrderFilled 并且 event.trade_id 已经应用于订单。
"""
...
@property
def avg_px(self) -> float:
"""
The order average fill price.
订单平均成交价格。
Returns:
double
"""
...
@property
def client_order_id(self) -> "ClientOrderId":
"""
The client order ID.
客户端订单 ID。
Returns:
ClientOrderId
"""
...
@staticmethod
def closing_side(position_side: "PositionSide") -> "OrderSide":
"""
Return the order side needed to close a position with the given side.
返回平仓给定方向头寸所需的订单方向。
Parameters:
position_side (PositionSide {LONG, SHORT}) – The side of the position to close.
position_side (PositionSide {LONG, SHORT}) - 要平仓头寸的方向。
Return type:
OrderSide
Raises:
ValueError – If position_side is FLAT or invalid.
ValueError - 如果 position_side 为 FLAT 或无效。
"""
...
def commissions(self) -> list:
"""
Return the total commissions generated by the order.
返回订单产生的总佣金。
Return type:
list[Money]
"""
...
@property
def contingency_type(self) -> "ContingencyType":
"""
The orders contingency type.
订单的意外事件类型。
Returns:
ContingencyType
"""
...
@staticmethod
def create(init):
...
@property
def display_qty(self) -> "Quantity" or None:
"""
The quantity of the LIMIT order to display on the public book (iceberg).
要在公开订单簿上显示的限价单数量(冰山订单)。
Returns:
Quantity or None
"""
...
@property
def emulation_trigger(self) -> "TriggerType":
"""
The order emulation trigger type.
订单模拟触发器类型。
Returns:
TriggerType
"""
...
@property
def event_count(self) -> int:
"""
Return the count of events applied to the order.
返回应用于订单的事件计数。
Return type:
int
"""
...
@property
def events(self) -> list["OrderEvent"]:
"""
Return the order events.
返回订单事件。
Return type:
list[OrderEvent]
"""
...
@property
def exec_algorithm_id(self) -> "ExecAlgorithmId" or None:
"""
The execution algorithm ID for the order.
订单的执行算法 ID。
Returns:
ExecAlgorithmId or None
"""
...
@property
def exec_algorithm_params(self) -> dict[str, Any] or None:
"""
The execution algorithm parameters for the order.
订单的执行算法参数。
Returns:
dict[str, Any] or None
"""
...
@property
def exec_spawn_id(self) -> "ClientOrderId" or None:
"""
The execution algorithm spawning client order ID.
执行算法生成的客户端订单 ID。
Returns:
ClientOrderId or None
"""
...
@property
def expire_time(self) -> "datetime" or None:
"""
Return the expire time for the order (UTC).
返回订单的到期时间 (UTC)。
Return type:
datetime or None
"""
...
@property
def expire_time_ns(self) -> int:
"""
The order expiration (UNIX epoch nanoseconds), zero for no expiration.
订单到期时间(UNIX 纪元纳秒),0 表示无到期时间。
Returns:
uint64_t
"""
...
@property
def filled_qty(self) -> "Quantity":
"""
The order total filled quantity.
订单总成交数量。
Returns:
Quantity
"""
...
@property
def has_price(self) -> bool:
"""
Return whether the order has a price property.
返回订单是否具有 price 属性。
Return type:
bool
"""
...
@property
def has_trigger_price(self) -> bool:
"""
Return whether the order has a trigger_price property.
返回订单是否具有 trigger_price 属性。
Return type:
bool
"""
...
def info(self) -> str:
"""
Return a summary description of the order.
返回订单的摘要描述。
Return type:
str
"""
...
@property
def init_event(self) -> "OrderInitialized":
"""
Return the initialization event for the order.
返回订单的初始化事件。
Return type:
OrderInitialized
"""
...
@property
def init_id(self) -> "UUID4":
"""
The event ID of the OrderInitialized event.
OrderInitialized 事件的事件 ID。
Returns:
UUID4
"""
...
@property
def instrument_id(self) -> "InstrumentId":
"""
The order instrument ID.
订单金融工具 ID。
Returns:
InstrumentId
"""
...
@property
def is_active_local(self) -> bool:
"""
Return whether the order is active and held in the local system.
返回订单是否处于活动状态并在本地系统中持有。
An order is considered active local when its status is any of;
当订单的状态为以下任何一种时,该订单被视为本地活动订单:
INITIALIZED
EMULATED
RELEASED
Return type:
bool
"""
...
@property
def is_aggressive(self) -> bool:
"""
Return whether the order is aggressive (order_type is MARKET).
返回订单是否为激进订单(order_type 为 MARKET)。
Return type:
bool
"""
...
@property
def is_buy(self) -> bool:
"""
Return whether the order side is BUY.
返回订单方向是否为 BUY。
Return type:
bool
"""
...
@property
def is_canceled(self) -> bool:
"""
Return whether current status is CANCELED.
返回当前状态是否为 CANCELED。
Return type:
bool
"""
...
@property
def is_child_order(self) -> bool:
"""
Return whether the order has a parent order.
返回订单是否具有父订单。
Return type:
bool
"""
...
@property
def is_closed(self) -> bool:
"""
Return whether the order is closed.
返回订单是否已平仓。
An order is considered closed when its status can no longer change. The possible statuses of closed orders include;
当订单的状态不再可以更改时,该订单被视为已平仓。已平仓订单的可能状态包括:
DENIED
REJECTED
CANCELED
EXPIRED
FILLED
Return type:
bool
"""
...
@property
def is_contingency(self) -> bool:
"""
Return whether the order has a contingency (contingency_type is not NO_CONTINGENCY).
返回订单是否具有意外事件(contingency_type 不为 NO_CONTINGENCY)。
Return type:
bool
"""
...
@property
def is_emulated(self) -> bool:
"""
Return whether the order is emulated and held in the local system.
返回订单是否被模拟并在本地系统中持有。
Return type:
bool
"""
...
@property
def is_inflight(self) -> bool:
"""
Return whether the order is in-flight (order request sent to the trading venue).
返回订单是否正在进行中(订单请求已发送到交易场所)。
An order is considered in-flight when its status is any of;
当订单的状态为以下任何一种时,该订单被视为正在进行中:
SUBMITTED
PENDING_UPDATE
PENDING_CANCEL
Return type:
bool
WARNING
An emulated order is never considered in-flight.
模拟订单永远不会被视为正在进行中。
"""
...
@property
def is_open(self) -> bool:
"""
Return whether the order is open at the trading venue.
返回订单是否在交易场所开仓。
An order is considered open when its status is any of;
当订单的状态为以下任何一种时,该订单被视为开仓:
ACCEPTED
TRIGGERED
PENDING_UPDATE
PENDING_CANCEL
PARTIALLY_FILLED
Return type:
bool
WARNING
An emulated order is never considered open.
模拟订单永远不会被视为开仓。
"""
...
@property
def is_parent_order(self) -> bool:
"""
Return whether the order has at least one child order.
返回订单是否至少有一个子订单。
Return type:
bool
"""
...
@property
def is_passive(self) -> bool:
"""
Return whether the order is passive (order_type not MARKET).
返回订单是否为被动订单(order_type 不为 MARKET)。
Return type:
bool
"""
...
@property
def is_pending_cancel(self) -> bool:
"""
Return whether the current status is PENDING_CANCEL.
返回当前状态是否为 PENDING_CANCEL。
Return type:
bool
"""
...
@property
def is_pending_update(self) -> bool:
"""
Return whether the current status is PENDING_UPDATE.
返回当前状态是否为 PENDING_UPDATE。
Return type:
bool
"""
...
@property
def is_post_only(self) -> bool:
"""
If the order will only provide liquidity (make a market).
如果订单只提供流动性(做市商)。
Returns:
bool
"""
...
@property
def is_primary(self) -> bool:
"""
Return whether the order is the primary for an execution algorithm sequence.
返回订单是否是执行算法序列的主订单。
Return type:
bool
"""
...
@property
def is_quote_quantity(self) -> bool:
"""
If the order quantity is denominated in the quote currency.
如果订单数量以报价货币计价。
Returns:
bool
"""
...
@property
def is_reduce_only(self) -> bool:
"""
If the order carries the ‘reduce-only’ execution instruction.
如果订单带有“仅减少”执行指令。
Returns:
bool
"""
...
@property
def is_sell(self) -> bool:
"""
Return whether the order side is SELL.
返回订单方向是否为 SELL。
Return type:
bool
"""
...
@property
def is_spawned(self) -> bool:
"""
Return whether the order was spawned as part of an execution algorithm sequence.
返回订单是否作为执行算法序列的一部分生成。
Return type:
bool
"""
...
@property
def is_triggered(self) -> bool:
"""
If the order has been triggered.
如果订单已触发。
Returns:
bool
"""
...
@property
def last_event(self) -> "OrderEvent":
"""
Return the last event applied to the order.
返回应用于订单的最后一个事件。
Return type:
OrderEvent
"""
...
@property
def last_trade_id(self) -> "TradeId" or None:
"""
The orders last trade match ID.
订单的最后交易匹配 ID。
Returns:
TradeId or None
"""
...
@property
def leaves_qty(self) -> "Quantity":
"""
The order total leaves quantity.
订单总剩余数量。
Returns:
Quantity
"""
...
@property
def linked_order_ids(self) -> list["ClientOrderId"] or None:
"""
The orders linked client order ID(s).
订单链接的客户端订单 ID。
Returns:
list[ClientOrderId] or None
"""
...
@property
def liquidity_side(self) -> "LiquiditySide":
"""
The order liquidity side.
订单流动性方向。
Returns:
LiquiditySide
"""
...
@staticmethod
def opposite_side(side: "OrderSide") -> "OrderSide":
"""
Return the opposite order side from the given side.
从给定的方向返回相反的订单方向。
Parameters:
side (OrderSide {BUY, SELL}) – The original order side.
side (OrderSide {BUY, SELL}) - 原始订单方向。
Return type:
OrderSide
Raises:
ValueError – If side is invalid.
ValueError - 如果方向无效。
"""
...
@property
def order_list_id(self) -> "OrderListId" or None:
"""
The order list ID associated with the order.
与订单关联的订单列表 ID。
Returns:
OrderListId or None
"""
...
@property
def order_type(self) -> "OrderType":
"""
The order type.
订单类型。
Returns:
OrderType
"""
...
@property
def parent_order_id(self) -> "ClientOrderId" or None:
"""
The parent client order ID.
父客户端订单 ID。
Returns:
ClientOrderId or None
"""
...
@property
def position_id(self) -> "PositionId" or None:
"""
The position ID associated with the order.
与订单关联的头寸 ID。
Returns:
PositionId or None
"""
...
@property
def quantity(self) -> "Quantity":
"""
The order quantity.
订单数量。
Returns:
Quantity
"""
...
@property
def side(self) -> "OrderSide":
"""
The order side.
订单方向。
Returns:
OrderSide
"""
...
def side_string(self) -> str:
"""
Return the orders side as a string.
将订单方向作为字符串返回。
Return type:
str
"""
...
def signed_decimal_qty(self):
"""
Return a signed decimal representation of the remaining quantity.
返回剩余数量的带符号十进制表示形式。
If the order is a BUY, the value is positive (e.g. Decimal(‘10.25’))
如果订单是买入,则值为正数(例如Decimal('10.25'))
If the order is a SELL, the value is negative (e.g. Decimal(‘-10.25’))
如果订单是卖出,则值为负数(例如Decimal('-10.25'))
Return type:
Decimal
"""
return
@property
def slippage(self) -> float:
"""
The order total price slippage.
订单总价格滑点。
Returns:
double
"""
...
@property
def status(self) -> "OrderStatus":
"""
Return the orders current status.
返回订单的当前状态。
Return type:
OrderStatus
"""
...
def status_string(self) -> str:
"""
Return the orders current status as a string.
将订单的当前状态作为字符串返回。
Return type:
str
"""
...
@property
def strategy_id(self) -> "StrategyId":
"""
The strategy ID associated with the order.
与订单关联的策略 ID。
Returns:
StrategyId
"""
...
@property
def symbol(self) -> "Symbol":
"""
Return the orders ticker symbol.
返回订单的代码。
Return type:
Symbol
"""
...
@property
def tags(self) -> list[str] or None:
"""
The order custom user tags.
订单自定义用户标签。
Returns:
list[str] or None
"""
...
@property
def time_in_force(self) -> "TimeInForce":
"""
The order time in force.
订单有效时间。
Returns:
TimeInForce
"""
...
def to_dict(self) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def trade_ids(self) -> list["TradeId"]:
"""
Return the trade match IDs.
返回交易匹配 ID。
Return type:
list[TradeId]
"""
...
@property
def trader_id(self) -> "TraderId":
"""
The trader ID associated with the position.
与头寸关联的交易者 ID。
Returns:
TraderId
"""
...
@property
def trigger_instrument_id(self) -> "InstrumentId" or None:
"""
The order emulation trigger instrument ID (will be instrument_id if None).
订单模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
Returns:
InstrumentId or None
"""
...
@property
def trigger_price(self) -> "Price":
"""
The order trigger price (STOP).
订单触发价格 (STOP)。
Returns:
Price
"""
...
@property
def trigger_type(self) -> "TriggerType":
"""
The trigger type for the order.
订单的触发器类型。
Returns:
TriggerType
"""
...
@property
def ts_init(self) -> int:
"""
UNIX timestamp (nanoseconds) when the object was initialized.
对象初始化时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
@property
def ts_last(self) -> int:
"""
UNIX timestamp (nanoseconds) when the last event occurred.
上次事件发生时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
@property
def ts_triggered(self) -> int:
"""
UNIX timestamp (nanoseconds) when the order was triggered (0 if not triggered).
订单触发时的 UNIX 时间戳(纳秒)(如果未触发,则为 0)。
Returns:
uint64_t
"""
...
def type_string(self) -> str:
"""
Return the orders type as a string.
将订单类型作为字符串返回。
Return type:
str
"""
...
@property
def venue(self) -> "Venue":
"""
Return the orders trading venue.
返回订单的交易场所。
Return type:
Venue
"""
...
@property
def venue_order_id(self) -> "VenueOrderId" or None:
"""
The venue assigned order ID.
交易场所分配的订单 ID。
Returns:
VenueOrderId or None
"""
...
@property
def venue_order_ids(self) -> list["VenueOrderId"]:
"""
Return the venue order IDs.
返回交易场所订单 ID。
Return type:
list[VenueOrderId]
"""
...
def would_reduce_only(
self, position_side: "PositionSide", position_qty: "Quantity"
) -> bool:
"""
Whether the current order would only reduce the given position if applied in full.
如果当前订单完全应用,是否只会减少给定的头寸。
Parameters:
position_side (PositionSide {FLAT, LONG, SHORT}) – The side of the position to check against.
position_side (PositionSide {FLAT, LONG, SHORT}) - 要检查的头寸方向。
position_qty (Quantity) – The quantity of the position to check against.
position_qty (Quantity) - 要检查的头寸数量。
Return type:
bool
"""
...
class TrailingStopMarketOrder 追踪止损市价单
class TrailingStopMarketOrder(Order):
"""
TrailingStopMarketOrder(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, Quantity quantity, Price trigger_price: Price | None, TriggerType trigger_type, trailing_offset: Decimal, TrailingOffsetType trailing_offset_type, UUID4 init_id, uint64_t ts_init, TimeInForce time_in_force=TimeInForce.GTC, uint64_t expire_time_ns=0, bool reduce_only=False, bool quote_quantity=False, TriggerType emulation_trigger=TriggerType.NO_TRIGGER, InstrumentId trigger_instrument_id=None, ContingencyType contingency_type=ContingencyType.NO_CONTINGENCY, OrderListId order_list_id=None, list linked_order_ids=None, ClientOrderId parent_order_id=None, ExecAlgorithmId exec_algorithm_id=None, dict exec_algorithm_params=None, ClientOrderId exec_spawn_id=None, list tags=None)
Represents a Trailing-Stop-Market conditional order.
表示一个追踪止损市价条件订单。
Parameters:
trader_id (TraderId) – The trader ID associated with the order.
trader_id (TraderId) - 与订单关联的交易者 ID。
strategy_id (StrategyId) – The strategy ID associated with the order.
strategy_id (StrategyId) - 与订单关联的策略 ID。
instrument_id (InstrumentId) – The order instrument ID.
instrument_id (InstrumentId) - 订单金融工具 ID。
client_order_id (ClientOrderId) – The client order ID.
client_order_id (ClientOrderId) - 客户端订单 ID。
order_side (OrderSide {BUY, SELL}) – The order side.
order_side (OrderSide {BUY, SELL}) - 订单方向。
quantity (Quantity) – The order quantity (> 0).
quantity (Quantity) - 订单数量 (> 0)。
trigger_price (Price, optional with no default so None must be passed explicitly) – The order trigger price (STOP). If None then will typically default to the delta of market price and trailing_offset.
trigger_price (Price, optional with no default so None must be passed explicitly) - 订单触发价格 (STOP)。如果为 None,则通常默认为市场价格和 trailing_offset 的差值。
trigger_type (TriggerType) – The order trigger type.
trigger_type (TriggerType) - 订单触发器类型。
trailing_offset (Decimal) – The trailing offset for the trigger price (STOP).
trailing_offset (Decimal) - 触发价格 (STOP) 的追踪偏移量。
trailing_offset_type (TrailingOffsetType) – The order trailing offset type.
trailing_offset_type (TrailingOffsetType) - 订单追踪偏移量类型。
init_id (UUID4) – The order initialization event ID.
init_id (UUID4) - 订单初始化事件 ID。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.
ts_init (uint64_t) - 对象初始化时的 UNIX 时间戳(纳秒)。
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY}, default GTC) – The order time in force.
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY},默认 GTC) - 订单有效时间。
expire_time_ns (uint64_t , default 0 *(*no expiry )) – UNIX timestamp (nanoseconds) when the order will expire.
expire_time_ns (uint64_t, 默认 0 *(*无到期*)) - 订单到期的 UNIX 时间戳(纳秒)。
reduce_only (bool , default False) – If the order carries the ‘reduce-only’ execution instruction.
reduce_only (bool, 默认 False) - 如果订单带有“仅减少”执行指令。
quote_quantity (bool , default False) – If the order quantity is denominated in the quote currency.
quote_quantity (bool, 默认 False) - 如果订单数量以报价货币计价。
emulation_trigger (TriggerType, default NO_TRIGGER) – The order emulation trigger.
emulation_trigger (TriggerType, 默认 NO_TRIGGER) - 订单模拟触发器。
trigger_instrument_id (InstrumentId , optional) – The emulation trigger instrument ID for the order (if None then will be the instrument_id).
trigger_instrument_id (InstrumentId, 可选) - 订单的模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
contingency_type (ContingencyType, default NO_CONTINGENCY) – The order contingency type.
contingency_type (ContingencyType, 默认 NO_CONTINGENCY) - 订单意外事件类型。
order_list_id (OrderListId , optional) – The order list ID associated with the order.
order_list_id (OrderListId, 可选) - 与订单关联的订单列表 ID。
linked_order_ids (list [ClientOrderId ] , optional) – The order linked client order ID(s).
linked_order_ids (list [ClientOrderId ], 可选) - 订单链接的客户端订单 ID。
parent_order_id (ClientOrderId , optional) – The order parent client order ID.
parent_order_id (ClientOrderId, 可选) - 订单父客户端订单 ID。
exec_algorithm_id (ExecAlgorithmId , optional) – The execution algorithm ID for the order.
exec_algorithm_id (ExecAlgorithmId, 可选) - 订单的执行算法 ID。
exec_algorithm_params (dict *[*str , Any ] , optional) – The execution algorithm parameters for the order.
exec_algorithm_params (dict *[*str , Any ], 可选) - 订单的执行算法参数。
exec_spawn_id (ClientOrderId , optional) – The execution algorithm spawning primary client order ID.
exec_spawn_id (ClientOrderId, 可选) - 执行算法生成的原始客户端订单 ID。
tags (list *[*str ] , optional) – The custom user tags for the order.
tags (list *[*str ], 可选) - 订单的自定义用户标签。
Raises:
ValueError – If order_side is NO_ORDER_SIDE.
ValueError - 如果 order_side 为 NO_ORDER_SIDE。
ValueError – If quantity is not positive (> 0).
ValueError - 如果 quantity 不为正数 (> 0)。
ValueError – If trigger_type is NO_TRIGGER.
ValueError - 如果 trigger_type 为 NO_TRIGGER。
ValueError – If trailing_offset_type is NO_TRAILING_OFFSET.
ValueError - 如果 trailing_offset_type 为 NO_TRAILING_OFFSET。
ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE.
ValueError - 如果 time_in_force 为 AT_THE_OPEN 或 AT_THE_CLOSE。
ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.
ValueError - 如果 time_in_force 为 GTD 并且 expire_time_ns <= UNIX epoch。
"""
@property
def account_id(self) -> "AccountId" or None:
"""
The account ID associated with the order.
与订单关联的账户 ID。
Returns:
AccountId or None
"""
...
def apply(self, event: "OrderEvent") -> None:
"""
Apply the given order event to the order.
将给定的订单事件应用于订单。
Parameters:
event (OrderEvent) – The order event to apply.
event (OrderEvent) - 要应用的订单事件。
Raises:
ValueError – If self.client_order_id is not equal to event.client_order_id.
ValueError - 如果 self.client_order_id 不等于 event.client_order_id。
ValueError – If self.venue_order_id and event.venue_order_id are both not None, and are not equal.
ValueError - 如果 self.venue_order_id 和 event.venue_order_id 都不为 None,并且不相等。
InvalidStateTrigger – If event is not a valid trigger from the current order.status.
InvalidStateTrigger - 如果事件不是当前 order.status 的有效触发器。
KeyError – If event is OrderFilled and event.trade_id already applied to the order.
KeyError - 如果 event 是 OrderFilled 并且 event.trade_id 已经应用于订单。
"""
...
@property
def avg_px(self) -> float:
"""
The order average fill price.
订单平均成交价格。
Returns:
double
"""
...
@property
def client_order_id(self) -> "ClientOrderId":
"""
The client order ID.
客户端订单 ID。
Returns:
ClientOrderId
"""
...
@staticmethod
def closing_side(position_side: "PositionSide") -> "OrderSide":
"""
Return the order side needed to close a position with the given side.
返回平仓给定方向头寸所需的订单方向。
Parameters:
position_side (PositionSide {LONG, SHORT}) – The side of the position to close.
position_side (PositionSide {LONG, SHORT}) - 要平仓头寸的方向。
Return type:
OrderSide
Raises:
ValueError – If position_side is FLAT or invalid.
ValueError - 如果 position_side 为 FLAT 或无效。
"""
...
def commissions(self) -> list:
"""
Return the total commissions generated by the order.
返回订单产生的总佣金。
Return type:
list[Money]
"""
...
@property
def contingency_type(self) -> "ContingencyType":
"""
The orders contingency type.
订单的意外事件类型。
Returns:
ContingencyType
"""
...
@staticmethod
def create(init):
...
@property
def emulation_trigger(self) -> "TriggerType":
"""
The order emulation trigger type.
订单模拟触发器类型。
Returns:
TriggerType
"""
...
@property
def event_count(self) -> int:
"""
Return the count of events applied to the order.
返回应用于订单的事件计数。
Return type:
int
"""
...
@property
def events(self) -> list["OrderEvent"]:
"""
Return the order events.
返回订单事件。
Return type:
list[OrderEvent]
"""
...
@property
def exec_algorithm_id(self) -> "ExecAlgorithmId" or None:
"""
The execution algorithm ID for the order.
订单的执行算法 ID。
Returns:
ExecAlgorithmId or None
"""
...
@property
def exec_algorithm_params(self) -> dict[str, Any] or None:
"""
The execution algorithm parameters for the order.
订单的执行算法参数。
Returns:
dict[str, Any] or None
"""
...
@property
def exec_spawn_id(self) -> "ClientOrderId" or None:
"""
The execution algorithm spawning client order ID.
执行算法生成的客户端订单 ID。
Returns:
ClientOrderId or None
"""
...
@property
def expire_time(self) -> "datetime" or None:
"""
Return the expire time for the order (UTC).
返回订单的到期时间 (UTC)。
Return type:
datetime or None
"""
...
@property
def expire_time_ns(self) -> int:
"""
The order expiration (UNIX epoch nanoseconds), zero for no expiration.
订单到期时间(UNIX 纪元纳秒),0 表示无到期时间。
Returns:
uint64_t
"""
...
@property
def filled_qty(self) -> "Quantity":
"""
The order total filled quantity.
订单总成交数量。
Returns:
Quantity
"""
...
@property
def has_price(self) -> bool:
"""
Return whether the order has a price property.
返回订单是否具有 price 属性。
Return type:
bool
"""
...
@property
def has_trigger_price(self) -> bool:
"""
Return whether the order has a trigger_price property.
返回订单是否具有 trigger_price 属性。
Return type:
bool
"""
...
def info(self) -> str:
"""
Return a summary description of the order.
返回订单的摘要描述。
Return type:
str
"""
...
@property
def init_event(self) -> "OrderInitialized":
"""
Return the initialization event for the order.
返回订单的初始化事件。
Return type:
OrderInitialized
"""
...
@property
def init_id(self) -> "UUID4":
"""
The event ID of the OrderInitialized event.
OrderInitialized 事件的事件 ID。
Returns:
UUID4
"""
...
@property
def instrument_id(self) -> "InstrumentId":
"""
The order instrument ID.
订单金融工具 ID。
Returns:
InstrumentId
"""
...
@property
def is_active_local(self) -> bool:
"""
Return whether the order is active and held in the local system.
返回订单是否处于活动状态并在本地系统中持有。
An order is considered active local when its status is any of;
当订单的状态为以下任何一种时,该订单被视为本地活动订单:
INITIALIZED
EMULATED
RELEASED
Return type:
bool
"""
...
@property
def is_aggressive(self) -> bool:
"""
Return whether the order is aggressive (order_type is MARKET).
返回订单是否为激进订单(order_type 为 MARKET)。
Return type:
bool
"""
...
@property
def is_buy(self) -> bool:
"""
Return whether the order side is BUY.
返回订单方向是否为 BUY。
Return type:
bool
"""
...
@property
def is_canceled(self) -> bool:
"""
Return whether current status is CANCELED.
返回当前状态是否为 CANCELED。
Return type:
bool
"""
...
@property
def is_child_order(self) -> bool:
"""
Return whether the order has a parent order.
返回订单是否具有父订单。
Return type:
bool
"""
...
@property
def is_closed(self) -> bool:
"""
Return whether the order is closed.
返回订单是否已平仓。
An order is considered closed when its status can no longer change. The possible statuses of closed orders include;
当订单的状态不再可以更改时,该订单被视为已平仓。已平仓订单的可能状态包括:
DENIED
REJECTED
CANCELED
EXPIRED
FILLED
Return type:
bool
"""
...
@property
def is_contingency(self) -> bool:
"""
Return whether the order has a contingency (contingency_type is not NO_CONTINGENCY).
返回订单是否具有意外事件(contingency_type 不为 NO_CONTINGENCY)。
Return type:
bool
"""
...
@property
def is_emulated(self) -> bool:
"""
Return whether the order is emulated and held in the local system.
返回订单是否被模拟并在本地系统中持有。
Return type:
bool
"""
...
@property
def is_inflight(self) -> bool:
"""
Return whether the order is in-flight (order request sent to the trading venue).
返回订单是否正在进行中(订单请求已发送到交易场所)。
An order is considered in-flight when its status is any of;
当订单的状态为以下任何一种时,该订单被视为正在进行中:
SUBMITTED
PENDING_UPDATE
PENDING_CANCEL
Return type:
bool
WARNING
An emulated order is never considered in-flight.
模拟订单永远不会被视为正在进行中。
"""
...
@property
def is_open(self) -> bool:
"""
Return whether the order is open at the trading venue.
返回订单是否在交易场所开仓。
An order is considered open when its status is any of;
当订单的状态为以下任何一种时,该订单被视为开仓:
ACCEPTED
TRIGGERED
PENDING_UPDATE
PENDING_CANCEL
PARTIALLY_FILLED
Return type:
bool
WARNING
An emulated order is never considered open.
模拟订单永远不会被视为开仓。
"""
...
@property
def is_parent_order(self) -> bool:
"""
Return whether the order has at least one child order.
返回订单是否至少有一个子订单。
Return type:
bool
"""
...
@property
def is_passive(self) -> bool:
"""
Return whether the order is passive (order_type not MARKET).
返回订单是否为被动订单(order_type 不为 MARKET)。
Return type:
bool
"""
...
@property
def is_pending_cancel(self) -> bool:
"""
Return whether the current status is PENDING_CANCEL.
返回当前状态是否为 PENDING_CANCEL。
Return type:
bool
"""
...
@property
def is_pending_update(self) -> bool:
"""
Return whether the current status is PENDING_UPDATE.
返回当前状态是否为 PENDING_UPDATE。
Return type:
bool
"""
...
@property
def is_post_only(self) -> bool:
"""
If the order will only provide liquidity (make a market).
如果订单只提供流动性(做市商)。
Returns:
bool
"""
...
@property
def is_primary(self) -> bool:
"""
Return whether the order is the primary for an execution algorithm sequence.
返回订单是否是执行算法序列的主订单。
Return type:
bool
"""
...
@property
def is_quote_quantity(self) -> bool:
"""
If the order quantity is denominated in the quote currency.
如果订单数量以报价货币计价。
Returns:
bool
"""
...
@property
def is_reduce_only(self) -> bool:
"""
If the order carries the ‘reduce-only’ execution instruction.
如果订单带有“仅减少”执行指令。
Returns:
bool
"""
...
@property
def is_sell(self) -> bool:
"""
Return whether the order side is SELL.
返回订单方向是否为 SELL。
Return type:
bool
"""
...
@property
def is_spawned(self) -> bool:
"""
Return whether the order was spawned as part of an execution algorithm sequence.
返回订单是否作为执行算法序列的一部分生成。
Return type:
bool
"""
...
@property
def last_event(self) -> "OrderEvent":
"""
Return the last event applied to the order.
返回应用于订单的最后一个事件。
Return type:
OrderEvent
"""
...
@property
def last_trade_id(self) -> "TradeId" or None:
"""
The orders last trade match ID.
订单的最后交易匹配 ID。
Returns:
TradeId or None
"""
...
@property
def leaves_qty(self) -> "Quantity":
"""
The order total leaves quantity.
订单总剩余数量。
Returns:
Quantity
"""
...
@property
def linked_order_ids(self) -> list["ClientOrderId"] or None:
"""
The orders linked client order ID(s).
订单链接的客户端订单 ID。
Returns:
list[ClientOrderId] or None
"""
...
@property
def liquidity_side(self) -> "LiquiditySide":
"""
The order liquidity side.
订单流动性方向。
Returns:
LiquiditySide
"""
...
@staticmethod
def opposite_side(side: "OrderSide") -> "OrderSide":
"""
Return the opposite order side from the given side.
从给定的方向返回相反的订单方向。
Parameters:
side (OrderSide {BUY, SELL}) – The original order side.
side (OrderSide {BUY, SELL}) - 原始订单方向。
Return type:
OrderSide
Raises:
ValueError – If side is invalid.
ValueError - 如果方向无效。
"""
...
@property
def order_list_id(self) -> "OrderListId" or None:
"""
The order list ID associated with the order.
与订单关联的订单列表 ID。
Returns:
OrderListId or None
"""
...
@property
def order_type(self) -> "OrderType":
"""
The order type.
订单类型。
Returns:
OrderType
"""
...
@property
def parent_order_id(self) -> "ClientOrderId" or None:
"""
The parent client order ID.
父客户端订单 ID。
Returns:
ClientOrderId or None
"""
...
@property
def position_id(self) -> "PositionId" or None:
"""
The position ID associated with the order.
与订单关联的头寸 ID。
Returns:
PositionId or None
"""
...
@property
def quantity(self) -> "Quantity":
"""
The order quantity.
订单数量。
Returns:
Quantity
"""
...
@property
def side(self) -> "OrderSide":
"""
The order side.
订单方向。
Returns:
OrderSide
"""
...
def side_string(self) -> str:
"""
Return the orders side as a string.
将订单方向作为字符串返回。
Return type:
str
"""
...
def signed_decimal_qty(self):
"""
Return a signed decimal representation of the remaining quantity.
返回剩余数量的带符号十进制表示形式。
If the order is a BUY, the value is positive (e.g. Decimal(‘10.25’))
如果订单是买入,则值为正数(例如Decimal('10.25'))
If the order is a SELL, the value is negative (e.g. Decimal(‘-10.25’))
如果订单是卖出,则值为负数(例如Decimal('-10.25'))
Return type:
Decimal
"""
return
@property
def slippage(self) -> float:
"""
The order total price slippage.
订单总价格滑点。
Returns:
double
"""
...
@property
def status(self) -> "OrderStatus":
"""
Return the orders current status.
返回订单的当前状态。
Return type:
OrderStatus
"""
...
def status_string(self) -> str:
"""
Return the orders current status as a string.
将订单的当前状态作为字符串返回。
Return type:
str
"""
...
@property
def strategy_id(self) -> "StrategyId":
"""
The strategy ID associated with the order.
与订单关联的策略 ID。
Returns:
StrategyId
"""
...
@property
def symbol(self) -> "Symbol":
"""
Return the orders ticker symbol.
返回订单的代码。
Return type:
Symbol
"""
...
@property
def tags(self) -> list[str] or None:
"""
The order custom user tags.
订单自定义用户标签。
Returns:
list[str] or None
"""
...
@property
def time_in_force(self) -> "TimeInForce":
"""
The order time in force.
订单有效时间。
Returns:
TimeInForce
"""
...
def to_dict(self) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def trade_ids(self) -> list["TradeId"]:
"""
Return the trade match IDs.
返回交易匹配 ID。
Return type:
list[TradeId]
"""
...
@property
def trader_id(self) -> "TraderId":
"""
The trader ID associated with the position.
与头寸关联的交易者 ID。
Returns:
TraderId
"""
...
@property
def trailing_offset(self) -> "Decimal":
"""
The trailing offset for the orders trigger price (STOP).
订单触发价格 (STOP) 的追踪偏移量。
Returns:
Decimal
"""
...
@property
def trailing_offset_type(self) -> "TrailingOffsetType":
"""
The trailing offset type.
追踪偏移量类型。
Returns:
TrailingOffsetType
"""
...
@property
def trigger_instrument_id(self) -> "InstrumentId" or None:
"""
The order emulation trigger instrument ID (will be instrument_id if None).
订单模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
Returns:
InstrumentId or None
"""
...
@property
def trigger_price(self) -> "Price" or None:
"""
The order trigger price (STOP).
订单触发价格 (STOP)。
Returns:
Price or None
"""
...
@property
def trigger_type(self) -> "TriggerType":
"""
The trigger type for the order.
订单的触发器类型。
Returns:
TriggerType
"""
...
@property
def ts_init(self) -> int:
"""
UNIX timestamp (nanoseconds) when the object was initialized.
对象初始化时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
@property
def ts_last(self) -> int:
"""
UNIX timestamp (nanoseconds) when the last event occurred.
上次事件发生时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
def type_string(self) -> str:
"""
Return the orders type as a string.
将订单类型作为字符串返回。
Return type:
str
"""
...
@property
def venue(self) -> "Venue":
"""
Return the orders trading venue.
返回订单的交易场所。
Return type:
Venue
"""
...
@property
def venue_order_id(self) -> "VenueOrderId" or None:
"""
The venue assigned order ID.
交易场所分配的订单 ID。
Returns:
VenueOrderId or None
"""
...
@property
def venue_order_ids(self) -> list["VenueOrderId"]:
"""
Return the venue order IDs.
返回交易场所订单 ID。
Return type:
list[VenueOrderId]
"""
...
def would_reduce_only(
self, position_side: "PositionSide", position_qty: "Quantity"
) -> bool:
"""
Whether the current order would only reduce the given position if applied in full.
如果当前订单完全应用,是否只会减少给定的头寸。
Parameters:
position_side (PositionSide {FLAT, LONG, SHORT}) – The side of the position to check against.
position_side (PositionSide {FLAT, LONG, SHORT}) - 要检查的头寸方向。
position_qty (Quantity) – The quantity of the position to check against.
position_qty (Quantity) - 要检查的头寸数量。
Return type:
bool
"""
...
class TrailingStopLimitOrder 追踪止损限价单
class TrailingStopLimitOrder(Order):
"""
TrailingStopLimitOrder(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, Quantity quantity, Price price: Price | None, Price trigger_price: Price | None, TriggerType trigger_type, limit_offset: Decimal, trailing_offset: Decimal, TrailingOffsetType trailing_offset_type, UUID4 init_id, uint64_t ts_init, TimeInForce time_in_force=TimeInForce.GTC, uint64_t expire_time_ns=0, bool post_only=False, bool reduce_only=False, bool quote_quantity=False, Quantity display_qty=None, TriggerType emulation_trigger=TriggerType.NO_TRIGGER, InstrumentId trigger_instrument_id=None, ContingencyType contingency_type=ContingencyType.NO_CONTINGENCY, OrderListId order_list_id=None, list linked_order_ids=None, ClientOrderId parent_order_id=None, ExecAlgorithmId exec_algorithm_id=None, dict exec_algorithm_params=None, ClientOrderId exec_spawn_id=None, list tags=None)
Represents a Trailing-Stop-Limit conditional order.
表示一个追踪止损限价条件订单。
Parameters:
trader_id (TraderId) – The trader ID associated with the order.
trader_id (TraderId) - 与订单关联的交易者 ID。
strategy_id (StrategyId) – The strategy ID associated with the order.
strategy_id (StrategyId) - 与订单关联的策略 ID。
instrument_id (InstrumentId) – The order instrument ID.
instrument_id (InstrumentId) - 订单金融工具 ID。
client_order_id (ClientOrderId) – The client order ID.
client_order_id (ClientOrderId) - 客户端订单 ID。
order_side (OrderSide {BUY, SELL}) – The order side.
order_side (OrderSide {BUY, SELL}) - 订单方向。
quantity (Quantity) – The order quantity (> 0).
quantity (Quantity) - 订单数量 (> 0)。
price (Price, optional with no default so None must be passed explicitly) – The order price (LIMIT). If None then will typically default to the delta of market price and limit_offset.
price (Price,可选,无默认值,因此必须显式传递 None) - 订单价格 (LIMIT)。如果为 None,则通常默认为市场价格和 limit_offset 的差值。
trigger_price (Price, optional with no default so None must be passed explicitly) – The order trigger price (STOP). If None then will typically default to the delta of market price and trailing_offset.
trigger_price (Price,可选,无默认值,因此必须显式传递 None) - 订单触发价格 (STOP)。如果为 None,则通常默认为市场价格和 trailing_offset 的差值。
trigger_type (TriggerType) – The order trigger type.
trigger_type (TriggerType) - 订单触发器类型。
limit_offset (Decimal) – The trailing offset for the order price (LIMIT).
limit_offset (Decimal) - 订单价格 (LIMIT) 的追踪偏移量。
trailing_offset (Decimal) – The trailing offset for the order trigger price (STOP).
trailing_offset (Decimal) - 订单触发价格 (STOP) 的追踪偏移量。
trailing_offset_type (TrailingOffsetType) – The order trailing offset type.
trailing_offset_type (TrailingOffsetType) - 订单追踪偏移量类型。
init_id (UUID4) – The order initialization event ID.
init_id (UUID4) - 订单初始化事件 ID。
ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.
ts_init (uint64_t) - 对象初始化时的 UNIX 时间戳(纳秒)。
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY}, default GTC) – The order time in force.
time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY},默认 GTC) - 订单有效时间。
expire_time_ns (uint64_t , default 0 *(*no expiry )) – UNIX timestamp (nanoseconds) when the order will expire.
expire_time_ns (uint64_t, 默认 0 *(*无到期*)) - 订单到期的 UNIX 时间戳(纳秒)。
post_only (bool , default False) – If the LIMIT order will only provide liquidity (once triggered).
post_only (bool, 默认 False) - 如果限价单仅提供流动性(一旦触发)。
reduce_only (bool , default False) – If the LIMIT order carries the ‘reduce-only’ execution instruction.
reduce_only (bool, 默认 False) - 如果限价单带有“仅减少”执行指令。
quote_quantity (bool , default False) – If the order quantity is denominated in the quote currency.
quote_quantity (bool, 默认 False) - 如果订单数量以报价货币计价。
display_qty (Quantity , optional) – The quantity of the LIMIT order to display on the public book (iceberg).
display_qty (Quantity, 可选) - 要在公开订单簿上显示的限价单数量(冰山订单)。
emulation_trigger (TriggerType, default NO_TRIGGER) – The order emulation trigger.
emulation_trigger (TriggerType, 默认 NO_TRIGGER) - 订单模拟触发器。
trigger_instrument_id (InstrumentId , optional) – The emulation trigger instrument ID for the order (if None then will be the instrument_id).
trigger_instrument_id (InstrumentId, 可选) - 订单的模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
contingency_type (ContingencyType, default NO_CONTINGENCY) – The order contingency type.
contingency_type (ContingencyType, 默认 NO_CONTINGENCY) - 订单意外事件类型。
order_list_id (OrderListId , optional) – The order list ID associated with the order.
order_list_id (OrderListId, 可选) - 与订单关联的订单列表 ID。
linked_order_ids (list [ClientOrderId ] , optional) – The order linked client order ID(s).
linked_order_ids (list [ClientOrderId ], 可选) - 订单链接的客户端订单 ID。
parent_order_id (ClientOrderId , optional) – The order parent client order ID.
parent_order_id (ClientOrderId, 可选) - 订单父客户端订单 ID。
exec_algorithm_id (ExecAlgorithmId , optional) – The execution algorithm ID for the order.
exec_algorithm_id (ExecAlgorithmId, 可选) - 订单的执行算法 ID。
exec_algorithm_params (dict *[*str , Any ] , optional) – The execution algorithm parameters for the order.
exec_algorithm_params (dict *[*str , Any ], 可选) - 订单的执行算法参数。
exec_spawn_id (ClientOrderId , optional) – The execution algorithm spawning primary client order ID.
exec_spawn_id (ClientOrderId, 可选) - 执行算法生成的原始客户端订单 ID。
tags (list *[*str ] , optional) – The custom user tags for the order.
tags (list *[*str ], 可选) - 订单的自定义用户标签。
Raises:
ValueError – If order_side is NO_ORDER_SIDE.
ValueError - 如果 order_side 为 NO_ORDER_SIDE。
ValueError – If quantity is not positive (> 0).
ValueError - 如果 quantity 不为正数 (> 0)。
ValueError – If trigger_type is NO_TRIGGER.
ValueError - 如果 trigger_type 为 NO_TRIGGER。
ValueError – If trailing_offset_type is NO_TRAILING_OFFSET.
ValueError - 如果 trailing_offset_type 为 NO_TRAILING_OFFSET。
ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE.
ValueError - 如果 time_in_force 为 AT_THE_OPEN 或 AT_THE_CLOSE。
ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.
ValueError - 如果 time_in_force 为 GTD 并且 expire_time_ns <= UNIX epoch。
ValueError – If display_qty is negative (< 0) or greater than quantity.
ValueError - 如果 display_qty 为负数 (< 0) 或大于 quantity。
"""
@property
def account_id(self) -> "AccountId" or None:
"""
The account ID associated with the order.
与订单关联的账户 ID。
Returns:
AccountId or None
"""
...
def apply(self, event: "OrderEvent") -> None:
"""
Apply the given order event to the order.
将给定的订单事件应用于订单。
Parameters:
event (OrderEvent) – The order event to apply.
event (OrderEvent) - 要应用的订单事件。
Raises:
ValueError – If self.client_order_id is not equal to event.client_order_id.
ValueError - 如果 self.client_order_id 不等于 event.client_order_id。
ValueError – If self.venue_order_id and event.venue_order_id are both not None, and are not equal.
ValueError - 如果 self.venue_order_id 和 event.venue_order_id 都不为 None,并且不相等。
InvalidStateTrigger – If event is not a valid trigger from the current order.status.
InvalidStateTrigger - 如果事件不是当前 order.status 的有效触发器。
KeyError – If event is OrderFilled and event.trade_id already applied to the order.
KeyError - 如果 event 是 OrderFilled 并且 event.trade_id 已经应用于订单。
"""
...
@property
def avg_px(self) -> float:
"""
The order average fill price.
订单平均成交价格。
Returns:
double
"""
...
@property
def client_order_id(self) -> "ClientOrderId":
"""
The client order ID.
客户端订单 ID。
Returns:
ClientOrderId
"""
...
@staticmethod
def closing_side(position_side: "PositionSide") -> "OrderSide":
"""
Return the order side needed to close a position with the given side.
返回平仓给定方向头寸所需的订单方向。
Parameters:
position_side (PositionSide {LONG, SHORT}) – The side of the position to close.
position_side (PositionSide {LONG, SHORT}) - 要平仓头寸的方向。
Return type:
OrderSide
Raises:
ValueError – If position_side is FLAT or invalid.
ValueError - 如果 position_side 为 FLAT 或无效。
"""
...
def commissions(self) -> list:
"""
Return the total commissions generated by the order.
返回订单产生的总佣金。
Return type:
list[Money]
"""
...
@property
def contingency_type(self) -> "ContingencyType":
"""
The orders contingency type.
订单的意外事件类型。
Returns:
ContingencyType
"""
...
@staticmethod
def create(init):
...
@property
def display_qty(self) -> "Quantity" or None:
"""
The quantity of the LIMIT order to display on the public book (iceberg).
要在公开订单簿上显示的限价单数量(冰山订单)。
Returns:
Quantity or None
"""
...
@property
def emulation_trigger(self) -> "TriggerType":
"""
The order emulation trigger type.
订单模拟触发器类型。
Returns:
TriggerType
"""
...
@property
def event_count(self) -> int:
"""
Return the count of events applied to the order.
返回应用于订单的事件计数。
Return type:
int
"""
...
@property
def events(self) -> list["OrderEvent"]:
"""
Return the order events.
返回订单事件。
Return type:
list[OrderEvent]
"""
...
@property
def exec_algorithm_id(self) -> "ExecAlgorithmId" or None:
"""
The execution algorithm ID for the order.
订单的执行算法 ID。
Returns:
ExecAlgorithmId or None
"""
...
@property
def exec_algorithm_params(self) -> dict[str, Any] or None:
"""
The execution algorithm parameters for the order.
订单的执行算法参数。
Returns:
dict[str, Any] or None
"""
...
@property
def exec_spawn_id(self) -> "ClientOrderId" or None:
"""
The execution algorithm spawning client order ID.
执行算法生成的客户端订单 ID。
Returns:
ClientOrderId or None
"""
...
@property
def expire_time(self) -> "datetime" or None:
"""
Return the expire time for the order (UTC).
返回订单的到期时间 (UTC)。
Return type:
datetime or None
"""
...
@property
def expire_time_ns(self) -> int:
"""
The order expiration (UNIX epoch nanoseconds), zero for no expiration.
订单到期时间(UNIX 纪元纳秒),0 表示无到期时间。
Returns:
uint64_t
"""
...
@property
def filled_qty(self) -> "Quantity":
"""
The order total filled quantity.
订单总成交数量。
Returns:
Quantity
"""
...
@property
def has_price(self) -> bool:
"""
Return whether the order has a price property.
返回订单是否具有 price 属性。
Return type:
bool
"""
...
@property
def has_trigger_price(self) -> bool:
"""
Return whether the order has a trigger_price property.
返回订单是否具有 trigger_price 属性。
Return type:
bool
"""
...
def info(self) -> str:
"""
Return a summary description of the order.
返回订单的摘要描述。
Return type:
str
"""
...
@property
def init_event(self) -> "OrderInitialized":
"""
Return the initialization event for the order.
返回订单的初始化事件。
Return type:
OrderInitialized
"""
...
@property
def init_id(self) -> "UUID4":
"""
The event ID of the OrderInitialized event.
OrderInitialized 事件的事件 ID。
Returns:
UUID4
"""
...
@property
def instrument_id(self) -> "InstrumentId":
"""
The order instrument ID.
订单金融工具 ID。
Returns:
InstrumentId
"""
...
@property
def is_active_local(self) -> bool:
"""
Return whether the order is active and held in the local system.
返回订单是否处于活动状态并在本地系统中持有。
An order is considered active local when its status is any of;
当订单的状态为以下任何一种时,该订单被视为本地活动订单:
INITIALIZED
EMULATED
RELEASED
Return type:
bool
"""
...
@property
def is_aggressive(self) -> bool:
"""
Return whether the order is aggressive (order_type is MARKET).
返回订单是否为激进订单(order_type 为 MARKET)。
Return type:
bool
"""
...
@property
def is_buy(self) -> bool:
"""
Return whether the order side is BUY.
返回订单方向是否为 BUY。
Return type:
bool
"""
...
@property
def is_canceled(self) -> bool:
"""
Return whether current status is CANCELED.
返回当前状态是否为 CANCELED。
Return type:
bool
"""
...
@property
def is_child_order(self) -> bool:
"""
Return whether the order has a parent order.
返回订单是否具有父订单。
Return type:
bool
"""
...
@property
def is_closed(self) -> bool:
"""
Return whether the order is closed.
返回订单是否已平仓。
An order is considered closed when its status can no longer change. The possible statuses of closed orders include;
当订单的状态不再可以更改时,该订单被视为已平仓。已平仓订单的可能状态包括:
DENIED
REJECTED
CANCELED
EXPIRED
FILLED
Return type:
bool
"""
...
@property
def is_contingency(self) -> bool:
"""
Return whether the order has a contingency (contingency_type is not NO_CONTINGENCY).
返回订单是否具有意外事件(contingency_type 不为 NO_CONTINGENCY)。
Return type:
bool
"""
...
@property
def is_emulated(self) -> bool:
"""
Return whether the order is emulated and held in the local system.
返回订单是否被模拟并在本地系统中持有。
Return type:
bool
"""
...
@property
def is_inflight(self) -> bool:
"""
Return whether the order is in-flight (order request sent to the trading venue).
返回订单是否正在进行中(订单请求已发送到交易场所)。
An order is considered in-flight when its status is any of;
当订单的状态为以下任何一种时,该订单被视为正在进行中:
SUBMITTED
PENDING_UPDATE
PENDING_CANCEL
Return type:
bool
WARNING
An emulated order is never considered in-flight.
模拟订单永远不会被视为正在进行中。
"""
...
@property
def is_open(self) -> bool:
"""
Return whether the order is open at the trading venue.
返回订单是否在交易场所开仓。
An order is considered open when its status is any of;
当订单的状态为以下任何一种时,该订单被视为开仓:
ACCEPTED
TRIGGERED
PENDING_UPDATE
PENDING_CANCEL
PARTIALLY_FILLED
Return type:
bool
WARNING
An emulated order is never considered open.
模拟订单永远不会被视为开仓。
"""
...
@property
def is_parent_order(self) -> bool:
"""
Return whether the order has at least one child order.
返回订单是否至少有一个子订单。
Return type:
bool
"""
...
@property
def is_passive(self) -> bool:
"""
Return whether the order is passive (order_type not MARKET).
返回订单是否为被动订单(order_type 不为 MARKET)。
Return type:
bool
"""
...
@property
def is_pending_cancel(self) -> bool:
"""
Return whether the current status is PENDING_CANCEL.
返回当前状态是否为 PENDING_CANCEL。
Return type:
bool
"""
...
@property
def is_pending_update(self) -> bool:
"""
Return whether the current status is PENDING_UPDATE.
返回当前状态是否为 PENDING_UPDATE。
Return type:
bool
"""
...
@property
def is_post_only(self) -> bool:
"""
If the order will only provide liquidity (make a market).
如果订单只提供流动性(做市商)。
Returns:
bool
"""
...
@property
def is_primary(self) -> bool:
"""
Return whether the order is the primary for an execution algorithm sequence.
返回订单是否是执行算法序列的主订单。
Return type:
bool
"""
...
@property
def is_quote_quantity(self) -> bool:
"""
If the order quantity is denominated in the quote currency.
如果订单数量以报价货币计价。
Returns:
bool
"""
...
@property
def is_reduce_only(self) -> bool:
"""
If the order carries the ‘reduce-only’ execution instruction.
如果订单带有“仅减少”执行指令。
Returns:
bool
"""
...
@property
def is_sell(self) -> bool:
"""
Return whether the order side is SELL.
返回订单方向是否为 SELL。
Return type:
bool
"""
...
@property
def is_spawned(self) -> bool:
"""
Return whether the order was spawned as part of an execution algorithm sequence.
返回订单是否作为执行算法序列的一部分生成。
Return type:
bool
"""
...
@property
def last_event(self) -> "OrderEvent":
"""
Return the last event applied to the order.
返回应用于订单的最后一个事件。
Return type:
OrderEvent
"""
...
@property
def last_trade_id(self) -> "TradeId" or None:
"""
The orders last trade match ID.
订单的最后交易匹配 ID。
Returns:
TradeId or None
"""
...
@property
def leaves_qty(self) -> "Quantity":
"""
The order total leaves quantity.
订单总剩余数量。
Returns:
Quantity
"""
...
@property
def limit_offset(self) -> "Decimal":
"""
The trailing offset for the orders limit price.
订单限价的追踪偏移量。
Returns:
Decimal
"""
...
@property
def linked_order_ids(self) -> list["ClientOrderId"] or None:
"""
The orders linked client order ID(s).
订单链接的客户端订单 ID。
Returns:
list[ClientOrderId] or None
"""
...
@property
def liquidity_side(self) -> "LiquiditySide":
"""
The order liquidity side.
订单流动性方向。
Returns:
LiquiditySide
"""
...
@staticmethod
def opposite_side(side: "OrderSide") -> "OrderSide":
"""
Return the opposite order side from the given side.
从给定的方向返回相反的订单方向。
Parameters:
side (OrderSide {BUY, SELL}) – The original order side.
side (OrderSide {BUY, SELL}) - 原始订单方向。
Return type:
OrderSide
Raises:
ValueError – If side is invalid.
ValueError - 如果方向无效。
"""
...
@property
def order_list_id(self) -> "OrderListId" or None:
"""
The order list ID associated with the order.
与订单关联的订单列表 ID。
Returns:
OrderListId or None
"""
...
@property
def order_type(self) -> "OrderType":
"""
The order type.
订单类型。
Returns:
OrderType
"""
...
@property
def parent_order_id(self) -> "ClientOrderId" or None:
"""
The parent client order ID.
父客户端订单 ID。
Returns:
ClientOrderId or None
"""
...
@property
def position_id(self) -> "PositionId" or None:
"""
The position ID associated with the order.
与订单关联的头寸 ID。
Returns:
PositionId or None
"""
...
@property
def price(self) -> "Price" or None:
"""
The order price (LIMIT).
订单价格 (LIMIT)。
Returns:
Price or None
"""
...
@property
def quantity(self) -> "Quantity":
"""
The order quantity.
订单数量。
Returns:
Quantity
"""
...
@property
def side(self) -> "OrderSide":
"""
The order side.
订单方向。
Returns:
OrderSide
"""
...
def side_string(self) -> str:
"""
Return the orders side as a string.
将订单方向作为字符串返回。
Return type:
str
"""
...
def signed_decimal_qty(self):
"""
Return a signed decimal representation of the remaining quantity.
返回剩余数量的带符号十进制表示形式。
If the order is a BUY, the value is positive (e.g. Decimal(‘10.25’))
如果订单是买入,则值为正数(例如Decimal('10.25'))
If the order is a SELL, the value is negative (e.g. Decimal(‘-10.25’))
如果订单是卖出,则值为负数(例如Decimal('-10.25'))
Return type:
Decimal
"""
return
@property
def slippage(self) -> float:
"""
The order total price slippage.
订单总价格滑点。
Returns:
double
"""
...
@property
def status(self) -> "OrderStatus":
"""
Return the orders current status.
返回订单的当前状态。
Return type:
OrderStatus
"""
...
def status_string(self) -> str:
"""
Return the orders current status as a string.
将订单的当前状态作为字符串返回。
Return type:
str
"""
...
@property
def strategy_id(self) -> "StrategyId":
"""
The strategy ID associated with the order.
与订单关联的策略 ID。
Returns:
StrategyId
"""
...
@property
def symbol(self) -> "Symbol":
"""
Return the orders ticker symbol.
返回订单的代码。
Return type:
Symbol
"""
...
@property
def tags(self) -> list[str] or None:
"""
The order custom user tags.
订单自定义用户标签。
Returns:
list[str] or None
"""
...
@property
def time_in_force(self) -> "TimeInForce":
"""
The order time in force.
订单有效时间。
Returns:
TimeInForce
"""
...
def to_dict(self) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def trade_ids(self) -> list["TradeId"]:
"""
Return the trade match IDs.
返回交易匹配 ID。
Return type:
list[TradeId]
"""
...
@property
def trader_id(self) -> "TraderId":
"""
The trader ID associated with the position.
与头寸关联的交易者 ID。
Returns:
TraderId
"""
...
@property
def trailing_offset(self) -> "Decimal":
"""
The trailing offset for the orders trigger price (STOP).
订单触发价格 (STOP) 的追踪偏移量。
Returns:
Decimal
"""
...
@property
def trailing_offset_type(self) -> "TrailingOffsetType":
"""
The trailing offset type.
追踪偏移量类型。
Returns:
TrailingOffsetType
"""
...
@property
def trigger_instrument_id(self) -> "InstrumentId" or None:
"""
The order emulation trigger instrument ID (will be instrument_id if None).
订单模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
Returns:
InstrumentId or None
"""
...
@property
def trigger_price(self) -> "Price" or None:
"""
The order trigger price (STOP).
订单触发价格 (STOP)。
Returns:
Price or None
"""
...
@property
def trigger_type(self) -> "TriggerType":
"""
The trigger type for the order.
订单的触发器类型。
Returns:
TriggerType
"""
...
@property
def ts_init(self) -> int:
"""
UNIX timestamp (nanoseconds) when the object was initialized.
对象初始化时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
@property
def ts_last(self) -> int:
"""
UNIX timestamp (nanoseconds) when the last event occurred.
上次事件发生时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
@property
def ts_triggered(self) -> int:
"""
UNIX timestamp (nanoseconds) when the order was triggered (0 if not triggered).
订单触发时的 UNIX 时间戳(纳秒)(如果未触发,则为 0)。
Returns:
uint64_t
"""
...
def type_string(self) -> str:
"""
Return the orders type as a string.
将订单类型作为字符串返回。
Return type:
str
"""
...
@property
def venue(self) -> "Venue":
"""
Return the orders trading venue.
返回订单的交易场所。
Return type:
Venue
"""
...
@property
def venue_order_id(self) -> "VenueOrderId" or None:
"""
The venue assigned order ID.
交易场所分配的订单 ID。
Returns:
VenueOrderId or None
"""
...
@property
def venue_order_ids(self) -> list["VenueOrderId"]:
"""
Return the venue order IDs.
返回交易场所订单 ID。
Return type:
list[VenueOrderId]
"""
...
def would_reduce_only(
self, position_side: "PositionSide", position_qty: "Quantity"
) -> bool:
"""
Whether the current order would only reduce the given position if applied in full.
如果当前订单完全应用,是否只会减少给定的头寸。
Parameters:
position_side (PositionSide {FLAT, LONG, SHORT}) – The side of the position to check against.
position_side (PositionSide {FLAT, LONG, SHORT}) - 要检查的头寸方向。
position_qty (Quantity) – The quantity of the position to check against.
position_qty (Quantity) - 要检查的头寸数量。
Return type:
bool
"""
...
class OrderList 订单列表
class OrderList(object):
"""
OrderList(OrderListId order_list_id, list orders)
Represents a list of bulk or related contingent orders.
表示批量或相关联的条件订单列表。
Parameters:
order_list_id (OrderListId) – The order list ID.
order_list_id (OrderListId) - 订单列表 ID。
orders (list [Order ]) – The contained orders list.
orders (list [Order ]) - 包含的订单列表。
Raises:
ValueError – If orders is empty.
ValueError - 如果 orders 为空。
ValueError – If orders contains a type other than Order.
ValueError - 如果 orders 包含 Order 以外的类型。
"""
def __init__(self, order_list_id: "OrderListId", orders: list["Order"]) -> None:
...
@property
def first(self) -> list["Order"]:
"""
The first order in the list (typically the parent).
列表中的第一个订单(通常是父订单)。
Returns:
list[Order]
"""
...
@property
def id(self) -> "OrderListId":
"""
The order list ID.
订单列表 ID。
Returns:
OrderListId
"""
...
@property
def instrument_id(self) -> "InstrumentId":
"""
The instrument ID associated with the list.
与列表关联的金融工具 ID。
Returns:
InstrumentId
"""
...
@property
def orders(self) -> list["Order"]:
"""
The contained orders list.
包含的订单列表。
Returns:
list[Order]
"""
...
@property
def strategy_id(self) -> "StrategyId":
"""
The strategy ID associated with the list.
与列表关联的策略 ID。
Returns:
StrategyId
"""
...
@property
def ts_init(self) -> int:
"""
UNIX timestamp (nanoseconds) when the object was initialized.
对象初始化时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
class Order 订单
class Order(object):
"""
Order(OrderInitialized init)
The base class for all orders.
所有订单的基类。
Parameters:
init (OrderInitialized) – The order initialized event.
init (OrderInitialized) - 订单初始化事件。
WARNING
This class should not be used directly, but through a concrete subclass.
此类不应直接使用,而应通过具体的子类使用。
"""
def __init__(self, init: "OrderInitialized") -> None:
...
@property
def account_id(self) -> "AccountId" or None:
"""
The account ID associated with the order.
与订单关联的账户 ID。
Returns:
AccountId or None
"""
...
def apply(self, event: "OrderEvent") -> None:
"""
Apply the given order event to the order.
将给定的订单事件应用于订单。
Parameters:
event (OrderEvent) – The order event to apply.
event (OrderEvent) - 要应用的订单事件。
Raises:
ValueError – If self.client_order_id is not equal to event.client_order_id.
ValueError - 如果 self.client_order_id 不等于 event.client_order_id。
ValueError – If self.venue_order_id and event.venue_order_id are both not None, and are not equal.
ValueError - 如果 self.venue_order_id 和 event.venue_order_id 都不为 None,并且不相等。
InvalidStateTrigger – If event is not a valid trigger from the current order.status.
InvalidStateTrigger - 如果事件不是当前 order.status 的有效触发器。
KeyError – If event is OrderFilled and event.trade_id already applied to the order.
KeyError - 如果 event 是 OrderFilled 并且 event.trade_id 已经应用于订单。
"""
...
@property
def avg_px(self) -> float:
"""
The order average fill price.
订单平均成交价格。
Returns:
double
"""
...
@property
def client_order_id(self) -> "ClientOrderId":
"""
The client order ID.
客户端订单 ID。
Returns:
ClientOrderId
"""
...
@staticmethod
def closing_side(position_side: "PositionSide") -> "OrderSide":
"""
Return the order side needed to close a position with the given side.
返回平仓给定方向头寸所需的订单方向。
Parameters:
position_side (PositionSide {LONG, SHORT}) – The side of the position to close.
position_side (PositionSide {LONG, SHORT}) - 要平仓头寸的方向。
Return type:
OrderSide
Raises:
ValueError – If position_side is FLAT or invalid.
ValueError - 如果 position_side 为 FLAT 或无效。
"""
...
def commissions(self) -> list:
"""
Return the total commissions generated by the order.
返回订单产生的总佣金。
Return type:
list[Money]
"""
...
@property
def contingency_type(self) -> "ContingencyType":
"""
The orders contingency type.
订单的意外事件类型。
Returns:
ContingencyType
"""
...
@property
def emulation_trigger(self) -> "TriggerType":
"""
The order emulation trigger type.
订单模拟触发器类型。
Returns:
TriggerType
"""
...
@property
def event_count(self) -> int:
"""
Return the count of events applied to the order.
返回应用于订单的事件计数。
Return type:
int
"""
...
@property
def events(self) -> list["OrderEvent"]:
"""
Return the order events.
返回订单事件。
Return type:
list[OrderEvent]
"""
...
@property
def exec_algorithm_id(self) -> "ExecAlgorithmId" or None:
"""
The execution algorithm ID for the order.
订单的执行算法 ID。
Returns:
ExecAlgorithmId or None
"""
...
@property
def exec_algorithm_params(self) -> dict[str, Any] or None:
"""
The execution algorithm parameters for the order.
订单的执行算法参数。
Returns:
dict[str, Any] or None
"""
...
@property
def exec_spawn_id(self) -> "ClientOrderId" or None:
"""
The execution algorithm spawning client order ID.
执行算法生成的客户端订单 ID。
Returns:
ClientOrderId or None
"""
...
@property
def filled_qty(self) -> "Quantity":
"""
The order total filled quantity.
订单总成交数量。
Returns:
Quantity
"""
...
@property
def has_price(self) -> bool:
"""
Return whether the order has a price property.
返回订单是否具有 price 属性。
Return type:
bool
"""
...
@property
def has_trigger_price(self) -> bool:
"""
Return whether the order has a trigger_price property.
返回订单是否具有 trigger_price 属性。
Return type:
bool
"""
...
def info(self) -> str:
"""
Return a summary description of the order.
返回订单的摘要描述。
Return type:
str
"""
...
@property
def init_event(self) -> "OrderInitialized":
"""
Return the initialization event for the order.
返回订单的初始化事件。
Return type:
OrderInitialized
"""
...
@property
def init_id(self) -> "UUID4":
"""
The event ID of the OrderInitialized event.
OrderInitialized 事件的事件 ID。
Returns:
UUID4
"""
...
@property
def instrument_id(self) -> "InstrumentId":
"""
The order instrument ID.
订单金融工具 ID。
Returns:
InstrumentId
"""
...
@property
def is_active_local(self) -> bool:
"""
Return whether the order is active and held in the local system.
返回订单是否处于活动状态并在本地系统中持有。
An order is considered active local when its status is any of;
当订单的状态为以下任何一种时,该订单被视为本地活动订单:
INITIALIZED
EMULATED
RELEASED
Return type:
bool
"""
...
@property
def is_aggressive(self) -> bool:
"""
Return whether the order is aggressive (order_type is MARKET).
返回订单是否为激进订单(order_type 为 MARKET)。
Return type:
bool
"""
...
@property
def is_buy(self) -> bool:
"""
Return whether the order side is BUY.
返回订单方向是否为 BUY。
Return type:
bool
"""
...
@property
def is_canceled(self) -> bool:
"""
Return whether current status is CANCELED.
返回当前状态是否为 CANCELED。
Return type:
bool
"""
...
@property
def is_child_order(self) -> bool:
"""
Return whether the order has a parent order.
返回订单是否具有父订单。
Return type:
bool
"""
...
@property
def is_closed(self) -> bool:
"""
Return whether the order is closed.
返回订单是否已平仓。
An order is considered closed when its status can no longer change. The possible statuses of closed orders include;
当订单的状态不再可以更改时,该订单被视为已平仓。已平仓订单的可能状态包括:
DENIED
REJECTED
CANCELED
EXPIRED
FILLED
Return type:
bool
"""
...
@property
def is_contingency(self) -> bool:
"""
Return whether the order has a contingency (contingency_type is not NO_CONTINGENCY).
返回订单是否具有意外事件(contingency_type 不为 NO_CONTINGENCY)。
Return type:
bool
"""
...
@property
def is_emulated(self) -> bool:
"""
Return whether the order is emulated and held in the local system.
返回订单是否被模拟并在本地系统中持有。
Return type:
bool
"""
...
@property
def is_inflight(self) -> bool:
"""
Return whether the order is in-flight (order request sent to the trading venue).
返回订单是否正在进行中(订单请求已发送到交易场所)。
An order is considered in-flight when its status is any of;
当订单的状态为以下任何一种时,该订单被视为正在进行中:
SUBMITTED
PENDING_UPDATE
PENDING_CANCEL
Return type:
bool
WARNING
An emulated order is never considered in-flight.
模拟订单永远不会被视为正在进行中。
"""
...
@property
def is_open(self) -> bool:
"""
Return whether the order is open at the trading venue.
返回订单是否在交易场所开仓。
An order is considered open when its status is any of;
当订单的状态为以下任何一种时,该订单被视为开仓:
ACCEPTED
TRIGGERED
PENDING_UPDATE
PENDING_CANCEL
PARTIALLY_FILLED
Return type:
bool
WARNING
An emulated order is never considered open.
模拟订单永远不会被视为开仓。
"""
...
@property
def is_parent_order(self) -> bool:
"""
Return whether the order has at least one child order.
返回订单是否至少有一个子订单。
Return type:
bool
"""
...
@property
def is_passive(self) -> bool:
"""
Return whether the order is passive (order_type not MARKET).
返回订单是否为被动订单(order_type 不为 MARKET)。
Return type:
bool
"""
...
@property
def is_pending_cancel(self) -> bool:
"""
Return whether the current status is PENDING_CANCEL.
返回当前状态是否为 PENDING_CANCEL。
Return type:
bool
"""
...
@property
def is_pending_update(self) -> bool:
"""
Return whether the current status is PENDING_UPDATE.
返回当前状态是否为 PENDING_UPDATE。
Return type:
bool
"""
...
@property
def is_post_only(self) -> bool:
"""
If the order will only provide liquidity (make a market).
如果订单只提供流动性(做市商)。
Returns:
bool
"""
...
@property
def is_primary(self) -> bool:
"""
Return whether the order is the primary for an execution algorithm sequence.
返回订单是否是执行算法序列的主订单。
Return type:
bool
"""
...
@property
def is_quote_quantity(self) -> bool:
"""
If the order quantity is denominated in the quote currency.
如果订单数量以报价货币计价。
Returns:
bool
"""
...
@property
def is_reduce_only(self) -> bool:
"""
If the order carries the ‘reduce-only’ execution instruction.
如果订单带有“仅减少”执行指令。
Returns:
bool
"""
...
@property
def is_sell(self) -> bool:
"""
Return whether the order side is SELL.
返回订单方向是否为 SELL。
Return type:
bool
"""
...
@property
def is_spawned(self) -> bool:
"""
Return whether the order was spawned as part of an execution algorithm sequence.
返回订单是否作为执行算法序列的一部分生成。
Return type:
bool
"""
...
@property
def last_event(self) -> "OrderEvent":
"""
Return the last event applied to the order.
返回应用于订单的最后一个事件。
Return type:
OrderEvent
"""
...
@property
def last_trade_id(self) -> "TradeId" or None:
"""
The orders last trade match ID.
订单的最后交易匹配 ID。
Returns:
TradeId or None
"""
...
@property
def leaves_qty(self) -> "Quantity":
"""
The order total leaves quantity.
订单总剩余数量。
Returns:
Quantity
"""
...
@property
def linked_order_ids(self) -> list["ClientOrderId"] or None:
"""
The orders linked client order ID(s).
订单链接的客户端订单 ID。
Returns:
list[ClientOrderId] or None
"""
...
@property
def liquidity_side(self) -> "LiquiditySide":
"""
The order liquidity side.
订单流动性方向。
Returns:
LiquiditySide
"""
...
@staticmethod
def opposite_side(side: "OrderSide") -> "OrderSide":
"""
Return the opposite order side from the given side.
从给定的方向返回相反的订单方向。
Parameters:
side (OrderSide {BUY, SELL}) – The original order side.
side (OrderSide {BUY, SELL}) - 原始订单方向。
Return type:
OrderSide
Raises:
ValueError – If side is invalid.
ValueError - 如果方向无效。
"""
...
@property
def order_list_id(self) -> "OrderListId" or None:
"""
The order list ID associated with the order.
与订单关联的订单列表 ID。
Returns:
OrderListId or None
"""
...
@property
def order_type(self) -> "OrderType":
"""
The order type.
订单类型。
Returns:
OrderType
"""
...
@property
def parent_order_id(self) -> "ClientOrderId" or None:
"""
The parent client order ID.
父客户端订单 ID。
Returns:
ClientOrderId or None
"""
...
@property
def position_id(self) -> "PositionId" or None:
"""
The position ID associated with the order.
与订单关联的头寸 ID。
Returns:
PositionId or None
"""
...
@property
def quantity(self) -> "Quantity":
"""
The order quantity.
订单数量。
Returns:
Quantity
"""
...
@property
def side(self) -> "OrderSide":
"""
The order side.
订单方向。
Returns:
OrderSide
"""
...
def side_string(self) -> str:
"""
Return the orders side as a string.
将订单方向作为字符串返回。
Return type:
str
"""
...
def signed_decimal_qty(self):
"""
Return a signed decimal representation of the remaining quantity.
返回剩余数量的带符号十进制表示形式。
If the order is a BUY, the value is positive (e.g. Decimal(‘10.25’))
如果订单是买入,则值为正数(例如Decimal('10.25'))
If the order is a SELL, the value is negative (e.g. Decimal(‘-10.25’))
如果订单是卖出,则值为负数(例如Decimal('-10.25'))
Return type:
Decimal
"""
return
@property
def slippage(self) -> float:
"""
The order total price slippage.
订单总价格滑点。
Returns:
double
"""
...
@property
def status(self) -> "OrderStatus":
"""
Return the orders current status.
返回订单的当前状态。
Return type:
OrderStatus
"""
...
def status_string(self) -> str:
"""
Return the orders current status as a string.
将订单的当前状态作为字符串返回。
Return type:
str
"""
...
@property
def strategy_id(self) -> "StrategyId":
"""
The strategy ID associated with the order.
与订单关联的策略 ID。
Returns:
StrategyId
"""
...
@property
def symbol(self) -> "Symbol":
"""
Return the orders ticker symbol.
返回订单的代码。
Return type:
Symbol
"""
...
@property
def tags(self) -> list[str] or None:
"""
The order custom user tags.
订单自定义用户标签。
Returns:
list[str] or None
"""
...
@property
def time_in_force(self) -> "TimeInForce":
"""
The order time in force.
订单有效时间。
Returns:
TimeInForce
"""
...
def to_dict(self) -> dict:
"""
Return a dictionary representation of this object.
返回此对象的字典表示形式。
Return type:
dict[str, object]
"""
...
@property
def trade_ids(self) -> list["TradeId"]:
"""
Return the trade match IDs.
返回交易匹配 ID。
Return type:
list[TradeId]
"""
...
@property
def trader_id(self) -> "TraderId":
"""
The trader ID associated with the position.
与头寸关联的交易者 ID。
Returns:
TraderId
"""
...
@property
def trailing_offset(self) -> "Decimal":
"""
The trailing offset for the orders trigger price (STOP).
订单触发价格 (STOP) 的追踪偏移量。
Returns:
Decimal
"""
...
@property
def trailing_offset_type(self) -> "TrailingOffsetType":
"""
The trailing offset type.
追踪偏移量类型。
Returns:
TrailingOffsetType
"""
...
@property
def trigger_instrument_id(self) -> "InstrumentId" or None:
"""
The order emulation trigger instrument ID (will be instrument_id if None).
订单模拟触发器金融工具 ID(如果为 None,则将为 instrument_id)。
Returns:
InstrumentId or None
"""
...
@property
def trigger_price(self) -> "Price" or None:
"""
The order trigger price (STOP).
订单触发价格 (STOP)。
Returns:
Price or None
"""
...
@property
def trigger_type(self) -> "TriggerType":
"""
The trigger type for the order.
订单的触发器类型。
Returns:
TriggerType
"""
...
@property
def ts_init(self) -> int:
"""
UNIX timestamp (nanoseconds) when the object was initialized.
对象初始化时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
@property
def ts_last(self) -> int:
"""
UNIX timestamp (nanoseconds) when the last event occurred.
上次事件发生时的 UNIX 时间戳(纳秒)。
Returns:
uint64_t
"""
...
def type_string(self) -> str:
"""
Return the orders type as a string.
将订单类型作为字符串返回。
Return type:
str
"""
...
@property
def venue(self) -> "Venue":
"""
Return the orders trading venue.
返回订单的交易场所。
Return type:
Venue
"""
...
@property
def venue_order_id(self) -> "VenueOrderId" or None:
"""
The venue assigned order ID.
交易场所分配的订单 ID。
Returns:
VenueOrderId or None
"""
...
@property
def venue_order_ids(self) -> list["VenueOrderId"]:
"""
Return the venue order IDs.
返回交易场所订单 ID。
Return type:
list[VenueOrderId]
"""
...
def would_reduce_only(
self, position_side: "PositionSide", position_qty: "Quantity"
) -> bool:
"""
Whether the current order would only reduce the given position if applied in full.
如果当前订单完全应用,是否只会减少给定的头寸。
Parameters:
position_side (PositionSide {FLAT, LONG, SHORT}) – The side of the position to check against.
position_side (PositionSide {FLAT, LONG, SHORT}) - 要检查的头寸方向。
position_qty (Quantity) – The quantity of the position to check against.
position_qty (Quantity) - 要检查的头寸数量。
Return type:
bool
"""
...