[Add]新增无界面的JaqsService服务程序

This commit is contained in:
vn.py 2018-01-11 16:02:59 +08:00
parent ccbec40abe
commit 53b8aa058e
2 changed files with 70 additions and 17 deletions

View File

@ -5,13 +5,11 @@ import sys
reload(sys) reload(sys)
sys.setdefaultencoding('utf8') sys.setdefaultencoding('utf8')
# 判断操作系统 from time import sleep
import platform
system = platform.system()
# vn.trader模块 # vn.trader模块
from vnpy.event import EventEngine from vnpy.event import EventEngine
from vnpy.trader.vtEngine import MainEngine from vnpy.trader.vtEngine import MainEngine, LogEngine
from vnpy.trader.uiQt import createQApp from vnpy.trader.uiQt import createQApp
from vnpy.trader.uiMainWindow import MainWindow from vnpy.trader.uiMainWindow import MainWindow
@ -20,31 +18,35 @@ from vnpy.trader.gateway import ctpGateway
# 加载上层应用 # 加载上层应用
from vnpy.trader.app import jaqsService from vnpy.trader.app import jaqsService
from vnpy.trader.app.jaqsService.jsEngine import EVENT_JS_LOG
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def main(): def main():
"""主程序入口""" """主程序入口"""
# 创建Qt应用对象 le = LogEngine()
qApp = createQApp() le.setLogLevel(le.LEVEL_INFO)
le.addConsoleHandler()
le.addFileHandler()
le.info(u'启动JAQS服务进程')
# 创建事件引擎
ee = EventEngine() ee = EventEngine()
le.info(u'事件引擎创建成功')
# 创建主引擎
me = MainEngine(ee) me = MainEngine(ee)
# 添加交易接口
me.addGateway(ctpGateway) me.addGateway(ctpGateway)
# 添加上层应用
me.addApp(jaqsService) me.addApp(jaqsService)
le.info(u'主引擎创建成功')
# 创建主窗口 ee.register(EVENT_LOG, le.processLogEvent)
mw = MainWindow(me, ee) ee.register(EVENT_JS_LOG, le.processLogEvent)
mw.showMaximized() le.info(u'注册日志事件监听')
# 在主线程中启动Qt事件循环 me.connect('CTP')
sys.exit(qApp.exec_()) le.info(u'连接CTP接口')
while True:
sleep(1)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -0,0 +1,51 @@
# encoding: UTF-8
# 重载sys模块设置默认字符串编码方式为utf8
import sys
reload(sys)
sys.setdefaultencoding('utf8')
# 判断操作系统
import platform
system = platform.system()
# vn.trader模块
from vnpy.event import EventEngine
from vnpy.trader.vtEngine import MainEngine
from vnpy.trader.uiQt import createQApp
from vnpy.trader.uiMainWindow import MainWindow
# 加载底层接口
from vnpy.trader.gateway import ctpGateway
# 加载上层应用
from vnpy.trader.app import jaqsService
#----------------------------------------------------------------------
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_())
if __name__ == '__main__':
main()