Пример #1
0
def subscribe(symbol: Text, app_name: str = "current_app") -> None:
    """订阅"""
    if app_name == "current_app":
        app = current_app
    else:
        app = get_app(app_name)
    if not app.config.get("MD_FUNC"):
        raise MarketError(message="行情功能未开启, 无法进行订阅")
    app.market.subscribe(symbol)
Пример #2
0
def cancel_order(cancel_req: CancelRequest, app_name: str = "current_app"):
    """ 撤单 """
    if app_name == "current_app":
        app = current_app
    else:
        app = get_app(app_name)
    if not app.config.get("TD_FUNC"):
        raise TraderError(message="交易功能未开启", args=("交易功能未开启", ))
    cancel_monitor.send(cancel_req)
    app.trader.cancel_order(cancel_req)
Пример #3
0
def send_order(order_req: OrderRequest, app_name: str = "current_app"):
    """ 发单 """
    if app_name == "current_app":
        app = current_app
    else:
        app = get_app(app_name)
    if not app.config.get("TD_FUNC"):
        raise TraderError(message="交易功能未开启", args=("交易功能未开启", ))
    send_monitor.send(order_req)
    return app.trader.send_order(order_req)
Пример #4
0
def query_func(type: Text, app_name: str = "current_app") -> None:
    """ 查询持仓或者账户 """
    if app_name == "current_app":
        app = current_app
    else:
        app = get_app(app_name)
    if not app.config.get("TD_FUNC"):
        raise TraderError(message="交易功能未开启", args=("交易功能未开启", ))
    if type == "position":
        app.trader.query_position()
    if type == "account":
        app.trader.query_account()