Ejemplo n.º 1
0
def run():
    """
    Running in the child process.
    """
    SETTINGS["log.file"] = True

    event_engine = EventEngine()
    main_engine = MainEngine(event_engine)
    main_engine.add_gateway(BinancesGateway)
    cta_engine = main_engine.add_app(CtaStrategyApp)
    main_engine.write_log("主引擎创建成功")

    log_engine = main_engine.get_engine("log")
    event_engine.register(EVENT_CTA_LOG, log_engine.process_log_event)
    main_engine.write_log("注册日志事件监听")

    main_engine.connect(binances_setting, "BINANCES")
    main_engine.write_log("连接BINANCES接口")

    sleep(10)

    cta_engine.init_engine()
    main_engine.write_log("CTA策略初始化完成")

    cta_engine.init_all_strategies()
    sleep(60)  # Leave enough time to complete strategy initialization
    main_engine.write_log("CTA策略全部初始化")

    cta_engine.start_all_strategies()
    main_engine.write_log("CTA策略全部启动")

    while True:
        sleep(10)
Ejemplo n.º 2
0
def main():
    """"""

    qapp = create_qapp()

    event_engine = EventEngine()

    main_engine = MainEngine(event_engine)

    main_engine.add_gateway(BinanceGateway)
    main_engine.add_gateway(BinancesGateway)
    main_engine.add_app(CtaStrategyApp)
    main_engine.add_app(CtaBacktesterApp)
    main_engine.add_app(DataManagerApp)
    main_engine.add_app(AlgoTradingApp)
    main_engine.add_app(DataRecorderApp)
    main_engine.add_app(RiskManagerApp)
    main_engine.add_app(SpreadTradingApp)

    main_window = MainWindow(main_engine, event_engine)
    main_window.showMaximized()

    qapp.exec()
Ejemplo n.º 3
0
                         start=start,
                         end=end)

    data = gate_way.query_history(req)
    print("start12_end13", data)


if __name__ == "__main__":
    """
        for crawling data from Binance exchange.
    """
    SETTINGS["log.file"] = True

    event_engine = EventEngine()
    main_engine = MainEngine(event_engine)
    main_engine.add_gateway(BinanceGateway)  # spot
    # main_engine.add_gateway(BinancesGateway)  # future
    main_engine.connect(binance_setting, "BINANCE")  # spot
    # main_engine.connect(binances_setting, "BINANCES")  # future

    sleep(3)

    main_engine.write_log("连接BINANCE接口")  # spot
    # main_engine.write_log("连接BINANCES接口") # future
    gate_way = main_engine.get_gateway("BINANCE")  # spot
    # gate_way = main_engine.get_gateway("BINANCES")  # future
    print(gate_way)

    symbol = "btcusdt"  # spot for lower case while the future will be upper case.

    exchange = Exchange.BINANCE  # binance.