Ejemplo n.º 1
0

@api.route(handler="trade")
def handle_trade(self, trade):
    """ """


def create_app():
    app = CtpBee("last",
                 __name__,
                 action_class=ActionMe,
                 logger_class=Vlog,
                 refresh=True,
                 risk=RiskMe)
    """ 
        载入配置信息 
    """
    app.config.from_json("config.json")
    """ 
        载入用户层定义层 你可以编写多个继承CtpbeeApi ,然后实例化它, 记得传入app, 当然你可以通过app.remove_extension("data_recorder")
        data_recorder 就是下面传入的插件名字

    """
    app.add_extension(api)
    """ 启动 """
    return [app]


if __name__ == '__main__':
    hickey.start_all(app_func=create_app)
Ejemplo n.º 2
0
def create_app():
    from ctpbee import CtpBee
    app = CtpBee("recorder", __name__)
    info = {
        "CONNECT_INFO": {
            "userid": "",  # 期货账户名
            "password": "",  # 登录密码
            "brokerid": "",  # 期货公司id
            "md_address": "",  # 行情地址
            "td_address": "",  # 交易地址
            "appid": "",  # 产品名
            "auth_code": "",  # 认证码
            "product_info": ""  # 产品信息
        },
        "INTERFACE": "ctp",  # 登录期货生产环境接口
    }
    # 载入配置信息
    app.config.from_mapping(info)
    # 创建实例
    ext = Market("market")
    # 载入容器
    app.add_extension(ext)
    return app


if __name__ == '__main__':
    from ctpbee import hickey
    # 使用24小时模块进行分发
    hickey.start_all(create_app)