Appearance
事件通知
当仓位到达指定位置时触发
on_position_warning-当仓位到达指定位置时触发
当仓位到达指定位置时触发(默认 70%)。
函数
python
on_position_warning(context, msg)参数
| 参数名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| context | Context | - | 上下文对象 |
| msg | float | int | str | - | 当前仓位百分比(如 0.7 / 70 / "70%" 等,具体以实际回调传入为准) |
返回值
None
举例
python
def on_position_warning(context, msg):
print("仓位预警:", msg)
# 输出示例:
# 仓位预警:70当订单撮合成功后触发
on_order-当订单撮合成功后触发
当订单撮合成功后触发。
函数
python
on_order(context, msg)参数
| 参数名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| context | Context | - | 上下文对象 |
| msg | Order | dict | - | 当前成交/撮合成功的订单信息(可能是订单对象或字典结构,具体以实际回调传入为准) |
返回值
None
举例
python
def on_order(context, msg):
print("订单成交回报:", msg)
# 输出示例:
# 订单成交回报:Order({'order_id': 'ZLT-0000000--sz000001', 'status': 6, 'filled': 600, 'avg_price': 10.58})