def main(): """主程序入口""" # 创建事件引擎 ee = EventEngine() # 创建主引擎 me = MainEngine(ee) # 添加交易接口 me.addGateway(stubNullGateway) # 添加上层应用 me.addApp(riskManager) print("1111111") me.addApp(stubStrategy) me.addApp(dataRecorder) print("22222") # 创建主窗口 mw = MainWindow(me, ee) mw.showMaximized() # 在主线程中启动Qt事件循环 qApp.exec_() sys.exit(0)
def main(): """主程序入口""" # 创建事件引擎 ee = EventEngine2() # 创建主引擎 me = MainEngine(ee) # 添加交易接口 me.addGateway(ctpGateway) me.addGateway(femasGateway) me.addGateway(xspeedGateway) me.addGateway(sgitGateway) me.addGateway(oandaGateway) me.addGateway(ibGateway) me.addGateway(shzdGateway) me.addGateway(huobiGateway) me.addGateway(okcoinGateway) # 添加上层应用 me.addApp(riskManager) me.addApp(dataRecorder) me.addApp(ctaStrategy) # 创建主窗口 mw = MainWindow(me, ee) mw.showMaximized() # 在主线程中启动Qt事件循环 sys.exit(qApp.exec_())
def main(): """主程序入口""" print("main start") # 创建事件引擎 ee = EventEngine() # 创建主引擎 me = MainEngine(ee) # 添加交易接口, 包括行情数据接口和交易接口两部分 print("添加gateway接口, addGatewayClass") me.addGatewayClass(eastMoneyGateway) # 添加上层应用, 应用管理 #me.addApp(strategyManager) print("添加上层应用, addRiskCtrlClass") me.addRiskCtrlClass(riskCtrl1) print("添加上层应用, addStrategyClass") me.addStrategyClass(strategyDualThrust) me.addStrategyClass(strategyAtrRsi) me.addStrategyClass(strategyMacdShake) me.addApp(dataRecorder) print("添加上层应用, dataRecorder") # 创建主窗口 mw = MainWindow(me, ee) mw.showMaximized() # 在主线程中启动Qt事件循环 qApp.exec_() try: me.exit() sys.exit(0) except: print('GoodBye!') pass
def main(): """客户端主程序入口""" # 创建事件引擎 eventEngine = EventEngine2() eventEngine.start(timer=False) # 创建客户端 reqAddress = 'tcp://localhost:2014' subAddress = 'tcp://localhost:0602' client = VtClient(reqAddress, subAddress, eventEngine) client.subscribeTopic('') client.start() # 初始化主引擎和主窗口对象 mainEngine = ClientEngine(client, eventEngine) mainWindow = MainWindow(mainEngine, mainEngine.eventEngine) mainWindow.showMaximized() # 在主线程中启动Qt事件循环 sys.exit(qApp.exec_())
def main(): """主程序入口""" # 创建事件引擎 ee = EventEngine() # 创建主引擎 me = MainEngine(ee) # 添加交易接口 me.addGateway(ctpGateway) # 添加上层应用 me.addApp(riskManager) me.addApp(ctaStrategy) # 创建主窗口 mw = MainWindow(me, ee) mw.showMaximized() # 在主线程中启动Qt事件循环 sys.exit(qApp.exec_())
def main(): """主程序入口""" # 重载sys模块,设置默认字符串编码方式为utf8 reload(sys) sys.setdefaultencoding('utf8') """ # 设置Windows底部任务栏图标 if 'Windows' in platform.uname(): ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('vn.trader') # 初始化Qt应用对象 app = QtGui.QApplication(sys.argv) app.setWindowIcon(QtGui.QIcon(ICON_FILENAME)) app.setFont(BASIC_FONT) # 设置Qt的皮肤 try: from vnpy.trader.vtGlobal import globalSetting if globalSetting['darkStyle']: import qdarkstyle app.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False)) except: pass """ # 初始化主引擎和主窗口对象 mainEngine = MainEngine() for gw_name in init_gateway_names['CTP']: print 'add {0}'.format(gw_name) mainEngine.addGateway(ctpGateway, gw_name) mainWindow = MainWindow(mainEngine, mainEngine.eventEngine) mainWindow.showMaximized() # 在主线程中启动Qt事件循环 sys.exit(qApp.exec_())
self.tianqinGateway = TianQinGateway(self.eventEngine) def start(self): self.tianqinGateway.connect() self.tianqinGateway.subscribe_quote( ["cu1803", "SR801", "c1801", "IF1708"], self.on_quote_data) self.tianqinGateway.subscribe_chart("cu1803", 5, 1000, self.on_chart_data) self.tianqinGateway.subscribe_chart("au1712", 0, 1000, self.on_chart_data) def on_quote_data(self, ins_id): quote = self.tianqinGateway.get_quote(ins_id) print("quote_update", ins_id, quote) def on_chart_data(self, ins_id, dur_seconds): if dur_seconds == 0: tick_serial = self.tianqinGateway.get_tick_serial(ins_id) print("tick_serial_update", tick_serial) else: kline_serial = self.tianqinGateway.get_kline_serial( ins_id, dur_seconds) print("kline_serial_update", kline_serial) #---------------------------------------------------------------------- if __name__ == '__main__': app = DemoApp() app.start() sys.exit(qApp.exec_())