예제 #1
0
def main():
    """"""
    qapp = create_qapp()

    event_engine = EventEngine()

    main_engine = MainEngine(event_engine)

    main_engine.add_gateway(CtpGateway)

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

    qapp.exec()
    def __init__(self, cta_engine, strategy_name, vt_symbol, setting):
        """"""
        super(BollChannelStrategy, self).__init__(cta_engine, strategy_name,
                                                  vt_symbol, setting)
        s = Settings()
        self.app = create_qapp(s)

        self.am = ArrayManager()
        self.addition_line = defaultdict(dict)
        self.trade_orders = defaultdict(list)
        self.ups = {}
        self.downs = {}
        self.mids = {}
        self.mids = {}
        self.bars = list()
        self.bar_opens = []
)

# 加载策略
# engine.initStrategy(TurtleTradingStrategy, setting)
engine.add_strategy(BollChannelStrategy, setting)
engine.load_data()
engine.run_backtesting()
engine.calculate_result()
result = engine.calculate_statistics(Output=False)
# engine.show_chart()
df = engine.daily_df

# pw = pg.plot(title='pyqtgraph.plot()')
# pw.plot(df["balance"])  # 绘制第一个图

# widget = engine.strategy.widget
# chart = engine.get_fig()
s = Settings()
app = create_qapp(s)
# #
# w = QtGui.QWidget()
# layout = QtGui.QGridLayout()
# w.setLayout(layout)
# layout.addWidget(widget, 0, 0)   # button goes in upper-left
# layout.addWidget(chart, 0, 1)   # text edit goes in middle-left
# #
# w.show()
# #
app.exec_()

# print(pprint(result))