[Add]WebTrader增加习题用信号退出机制

This commit is contained in:
vn.py 2018-02-02 12:08:29 +08:00
parent 9fdfb253f0
commit d3302c2a75
2 changed files with 9 additions and 1 deletions

View File

@ -13,7 +13,10 @@ from vnpy.trader.app import dataRecorder
#----------------------------------------------------------------------
def processErrorEvent(event):
"""处理错误事件"""
"""
处理错误事件
错误信息在每次登陆后会将当日所有已产生的均推送一遍所以不适合写入日志
"""
error = event.dict_['data']
print u'错误代码:%s,错误信息:%s' %(error.errorID, error.errorMsg)

View File

@ -5,6 +5,7 @@ import sys
reload(sys)
sys.setdefaultencoding('utf8')
import signal
from time import sleep
# vn.trader模块
@ -35,6 +36,10 @@ def main():
# 创建主引擎
me = MainEngine(ee)
# 安全退出机制
for sig in [signal.SIGINT, signal.SIGHUP, signal.SIGTERM]:
signal.signal(sig, me.exit)
# 添加交易接口
me.addGateway(ctpGateway)