跳到正文
PTrade
PTrade交易、委托与订单

after_trading_cancel_order

该接口用于盘后固定价委托取消订单,根据Order对象或order_id取消订单。

原型

after_trading_cancel_order(order_param)

适用环境

该函数仅支持PTrade客户端可用、仅在股票交易模块可用,对接ATP柜台不支持该函数

释义

该接口用于盘后固定价委托取消订单,根据Order对象或order_id取消订单。

注意事项

无

参数

order_param: Order对象或者order_id(Order/str)

返回值

None(NoneType)

示例

import time

def initialize(context):
    g.security = "300001.SZ"
    set_universe(g.security)
    # 15:00-15:30期间使用run_daily进行盘后固定价委托、盘后固定价委托撤单
    run_daily(context, order_test, time="15:15")
    g.flag = False

def order_test(context):
    snapshot = get_snapshot(g.security)
    if snapshot is not None:
        last_px = snapshot[g.security].get("last_px", 0)
        if last_px > 0:
            order_id = after_trading_order(g.security, 200, float(last_px))
            time.sleep(5)
            after_trading_cancel_order(order_id)


def handle_data(context, data):
    if not g.flag:
        snapshot = get_snapshot(g.security)
        if snapshot is not None:
            last_px = snapshot[g.security].get("last_px", 0)
            if last_px > 0:
                order_id = after_trading_order(g.security, 200, float(last_px))
                time.sleep(5)
                after_trading_cancel_order(order_id)
                g.flag = True

本页目录