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

after_trading_order

该接口用于盘后固定价委托申报

原型

after_trading_order(security, amount, entrust_price)

适用环境

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

释义

该接口用于盘后固定价委托申报

注意事项

entrust_price为必传字段。

参数

security:

股票代码(str);

amount:

交易数量,正数表示买入,负数表示卖出(int);

entrust_price:

买卖限价(float);

返回值

Order对象中的id或者None。如果创建订单成功,则返回Order对象的id(str),失败则返回None(NoneType)。

示例

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:
            after_trading_order(g.security, 200, float(last_px))

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:
                after_trading_order(g.security, 200, float(last_px))
                g.flag = True

本页目录