2017-12-20 00:16:57 +00:00
|
|
|
|
# encoding: UTF-8
|
|
|
|
|
|
|
|
|
|
# 重载sys模块,设置默认字符串编码方式为utf8
|
|
|
|
|
import sys
|
|
|
|
|
reload(sys)
|
|
|
|
|
sys.setdefaultencoding('utf8')
|
|
|
|
|
|
2018-01-11 08:02:59 +00:00
|
|
|
|
from time import sleep
|
2017-12-20 00:16:57 +00:00
|
|
|
|
|
|
|
|
|
# vn.trader模块
|
|
|
|
|
from vnpy.event import EventEngine
|
2018-01-11 08:02:59 +00:00
|
|
|
|
from vnpy.trader.vtEngine import MainEngine, LogEngine
|
2017-12-20 00:16:57 +00:00
|
|
|
|
from vnpy.trader.uiQt import createQApp
|
|
|
|
|
from vnpy.trader.uiMainWindow import MainWindow
|
|
|
|
|
|
|
|
|
|
# 加载底层接口
|
|
|
|
|
from vnpy.trader.gateway import ctpGateway
|
|
|
|
|
|
|
|
|
|
# 加载上层应用
|
|
|
|
|
from vnpy.trader.app import jaqsService
|
2018-01-11 08:02:59 +00:00
|
|
|
|
from vnpy.trader.app.jaqsService.jsEngine import EVENT_JS_LOG
|
2017-12-20 00:16:57 +00:00
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
def main():
|
|
|
|
|
"""主程序入口"""
|
2018-01-11 08:02:59 +00:00
|
|
|
|
le = LogEngine()
|
|
|
|
|
le.setLogLevel(le.LEVEL_INFO)
|
|
|
|
|
le.addConsoleHandler()
|
|
|
|
|
le.addFileHandler()
|
|
|
|
|
|
|
|
|
|
le.info(u'启动JAQS服务进程')
|
2017-12-20 00:16:57 +00:00
|
|
|
|
|
|
|
|
|
ee = EventEngine()
|
2018-01-11 08:02:59 +00:00
|
|
|
|
le.info(u'事件引擎创建成功')
|
2017-12-20 00:16:57 +00:00
|
|
|
|
|
|
|
|
|
me = MainEngine(ee)
|
|
|
|
|
me.addGateway(ctpGateway)
|
|
|
|
|
me.addApp(jaqsService)
|
2018-01-11 08:02:59 +00:00
|
|
|
|
le.info(u'主引擎创建成功')
|
|
|
|
|
|
|
|
|
|
ee.register(EVENT_LOG, le.processLogEvent)
|
|
|
|
|
ee.register(EVENT_JS_LOG, le.processLogEvent)
|
|
|
|
|
le.info(u'注册日志事件监听')
|
2017-12-20 00:16:57 +00:00
|
|
|
|
|
2018-01-11 08:02:59 +00:00
|
|
|
|
me.connect('CTP')
|
|
|
|
|
le.info(u'连接CTP接口')
|
2017-12-20 00:16:57 +00:00
|
|
|
|
|
2018-01-11 08:02:59 +00:00
|
|
|
|
while True:
|
|
|
|
|
sleep(1)
|
2017-12-20 00:16:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
main()
|