本地停止单在VNPY系统中的是在本地维护的,符合条件后立即转化为限价委托单而执行的。
CTA策略管理界面CtaManager中,包含有一个停止单监视器StopOrderMonitor,用来显示策略已经发出的停止单的。
StopOrderMonitor包含如下的信息:
headers = {
"stop_orderid": {"display": "停止委托号","cell": BaseCell,"update": False,},
"vt_orderids": {"display": "限价委托号", "cell": BaseCell, "update": True},
"vt_symbol": {"display": "本地代码", "cell": BaseCell, "update": False},
"direction": {"display": "方向", "cell": EnumCell, "update": False},
"offset": {"display": "开平", "cell": EnumCell, "update": False},
"price": {"display": "价格", "cell": BaseCell, "update": False},
"volume": {"display": "数量", "cell": BaseCell, "update": False},
"status": {"display": "状态", "cell": EnumCell, "update": True},
"lock": {"display": "锁仓", "cell": BaseCell, "update": False},
"strategy_name": {"display": "策略名", "cell": BaseCell, "update": False},
}
在实际使用的时候,大家是否有这种感觉,这么多停止单,你可以知道停止单的编号,却不知道它是:
- 何时发出的,
- 何时被撤销的,
- 何时被触发的。
这对观察策略的行为很重要的信息。虽然编号可以描述停止单的时间顺序,但是不够具体,当有多个停止单没有被触发,你看着它们除了单号和价格外,其他长的都是一样,心中是一头雾水的。
建议还是增加字段。
目前StopOrder的字段
@dataclass
class StopOrder:
vt_symbol: str
direction: Direction
offset: Offset
price: float
volume: float
stop_orderid: str
strategy_name: str
lock: bool = False
vt_orderids: list = field(default_factory=list)
status: StopOrderStatus = StopOrderStatus.WAITING
缺少下单时间和结束时间
- start_time:下单时间
- end_time:结束时间
因为已经有了状态status字段,所以当状态status是StopOrderStatus.CANCELLED时,end_time就是撤销时间;如果状态status是StopOrderStatus.TRIGGERED时end_time就是触发时间。