def main(): """主程序入口""" # 创建Qt应用对象 qApp = createQApp() # 创建事件引擎 ee = EventEngine() # 创建主引擎 me = MainEngine(ee) # 添加交易接口 me.addGateway(secGateway) me.addGateway(ctpGateway) me.addGateway(ctpsecGateway) # 添加上层应用 me.addApp(riskManager) me.addApp(optionMaster) # 创建主窗口 mw = MainWindow(me, ee) mw.showMaximized() # 在主线程中启动Qt事件循环 sys.exit(qApp.exec_())
def main(): """主程序入口""" # 创建Qt应用对象 qApp = createQApp() # 创建事件引擎 ee = EventEngine() # 创建主引擎 me = MainEngine(ee) # 添加交易接口 me.addGateway(ctpGateway) # me.addGateway(oandaGateway) # me.addGateway(ibGateway) # 添加上层应用 me.addApp(ctaStrategy) me.addApp(riskManager) me.addApp(spreadTrading) me.addApp(dataRecorder) # 创建主窗口 mw = MainWindow(me, ee) mw.showMaximized() # 在主线程中启动Qt事件循环 sys.exit(qApp.exec_())
def __init__(self, repAddress, pubAddress): """Constructor""" super(VtServer, self).__init__(repAddress, pubAddress) self.usePickle() # 创建事件引擎 self.ee = EventEngine2() # 创建主引擎对象 self.engine = MainEngine(self.ee) # 注册主引擎的方法到服务器的RPC函数 self.register(self.engine.connect) self.register(self.engine.subscribe) self.register(self.engine.sendOrder) self.register(self.engine.cancelOrder) self.register(self.engine.qryAccount) self.register(self.engine.qryPosition) self.register(self.engine.exit) self.register(self.engine.writeLog) self.register(self.engine.dbConnect) self.register(self.engine.dbInsert) self.register(self.engine.dbQuery) self.register(self.engine.dbUpdate) self.register(self.engine.getContract) self.register(self.engine.getAllContracts) self.register(self.engine.getOrder) self.register(self.engine.getAllWorkingOrders) self.register(self.engine.getAllGatewayDetails) # 注册事件引擎发送的事件处理监听 self.engine.eventEngine.registerGeneralHandler(self.eventHandler)
def main(): """主程序入口""" le = LogEngine() le.setLogLevel(le.LEVEL_INFO) le.addConsoleHandler() le.addFileHandler() le.info(u'服务器进程启动') # 创建事件引擎 ee = EventEngine2() le.info(u'事件引擎创建成功') # 创建主引擎 me = MainEngine(ee) # 添加交易接口 me.addGateway(ctpGateway) # 添加上层应用 me.addApp(ctaStrategy) me.addApp(rpcService) le.info(u'主引擎创建成功') # 阻塞运行 le.info(u'服务器启动成功') while 1: sleep(1)
def main(): """主程序入口""" le = LogEngine() le.setLogLevel(le.LEVEL_INFO) le.addConsoleHandler() le.addFileHandler() le.info(u'启动JAQS服务进程') ee = EventEngine() le.info(u'事件引擎创建成功') me = MainEngine(ee) me.addGateway(ctpGateway) me.addApp(jaqsService) le.info(u'主引擎创建成功') ee.register(EVENT_LOG, le.processLogEvent) ee.register(EVENT_JS_LOG, le.processLogEvent) le.info(u'注册日志事件监听') me.connect('CTP') le.info(u'连接CTP接口') while True: sleep(1)
class VtServer(RpcServer): """vn.trader服务器""" #---------------------------------------------------------------------- def __init__(self, repAddress, pubAddress): """Constructor""" super(VtServer, self).__init__(repAddress, pubAddress) self.usePickle() # 创建事件引擎 self.ee = EventEngine2() # 创建主引擎对象 self.engine = MainEngine(self.ee) # 注册主引擎的方法到服务器的RPC函数 self.register(self.engine.connect) self.register(self.engine.subscribe) self.register(self.engine.sendOrder) self.register(self.engine.cancelOrder) self.register(self.engine.qryAccount) self.register(self.engine.qryPosition) self.register(self.engine.exit) self.register(self.engine.writeLog) self.register(self.engine.dbConnect) self.register(self.engine.dbInsert) self.register(self.engine.dbQuery) self.register(self.engine.dbUpdate) self.register(self.engine.getContract) self.register(self.engine.getAllContracts) self.register(self.engine.getOrder) self.register(self.engine.getAllWorkingOrders) self.register(self.engine.getAllGatewayDetails) # 注册事件引擎发送的事件处理监听 self.engine.eventEngine.registerGeneralHandler(self.eventHandler) #---------------------------------------------------------------------- def eventHandler(self, event): """事件处理""" self.publish(event.type_, event) #---------------------------------------------------------------------- def stopServer(self): """停止服务器""" # 关闭引擎 self.engine.exit() # 停止服务器线程 self.stop()
def runChildProcess(): """子进程运行函数""" print '-' * 20 # 创建日志引擎 le = LogEngine() le.setLogLevel(le.LEVEL_INFO) le.addConsoleHandler() le.addFileHandler() le.info(u'启动CTA策略运行子进程') ee = EventEngine2() le.info(u'事件引擎创建成功') me = MainEngine(ee) me.addGateway(ctpGateway) me.addApp(ctaStrategy) le.info(u'主引擎创建成功') ee.register(EVENT_LOG, le.processLogEvent) ee.register(EVENT_CTA_LOG, le.processLogEvent) ee.register(EVENT_ERROR, processErrorEvent) le.info(u'注册日志事件监听') me.connect('CTP') le.info(u'连接CTP接口') sleep(10) # 等待CTP接口初始化 cta = me.getApp(ctaStrategy.appName) cta.loadSetting() le.info(u'CTA策略载入成功') cta.initAll() le.info(u'CTA策略初始化成功') cta.startAll() le.info(u'CTA策略启动成功') while True: sleep(1)
def main(): """主程序入口""" le = LogEngine() le.setLogLevel(le.LEVEL_INFO) le.addConsoleHandler() le.addFileHandler() le.info(u'服务器进程启动') # 创建事件引擎 ee = EventEngine2() le.info(u'事件引擎创建成功') # 创建主引擎 me = MainEngine(ee) # 安全退出机制 def shutdown(signal, frame): le.info(u'安全关闭进程') me.exit() sys.exit() for sig in [signal.SIGINT, signal.SIGTERM]: signal.signal(sig, shutdown) # 添加交易接口 me.addGateway(ctpGateway) # 添加上层应用 me.addApp(ctaStrategy) me.addApp(rpcService) le.info(u'主引擎创建成功') # 阻塞运行 le.info(u'服务器启动成功') while 1: sleep(1)
def main(): """主程序入口""" # 创建Qt应用对象 qApp = createQApp() # 创建事件引擎 ee = EventEngine() # 创建主引擎 me = MainEngine(ee) # 添加交易接口 me.addGateway(ctpGateway) # 添加上层应用 me.addApp(jaqsService) # 创建主窗口 mw = MainWindow(me, ee) mw.showMaximized() # 在主线程中启动Qt事件循环 sys.exit(qApp.exec_())