From d3302c2a757c774c382857d2c4df21338292526e Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Fri, 2 Feb 2018 12:08:29 +0800 Subject: [PATCH] =?UTF-8?q?[Add]WebTrader=E5=A2=9E=E5=8A=A0=E4=B9=A0?= =?UTF-8?q?=E9=A2=98=E7=94=A8=E4=BF=A1=E5=8F=B7=E9=80=80=E5=87=BA=E6=9C=BA?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/DataRecording/runDataRecording.py | 5 ++++- examples/WebTrader/server.py | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/DataRecording/runDataRecording.py b/examples/DataRecording/runDataRecording.py index 1276330c..c230d63d 100644 --- a/examples/DataRecording/runDataRecording.py +++ b/examples/DataRecording/runDataRecording.py @@ -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) diff --git a/examples/WebTrader/server.py b/examples/WebTrader/server.py index 7337fff7..ce93d65c 100644 --- a/examples/WebTrader/server.py +++ b/examples/WebTrader/server.py @@ -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)