From 8b8dfff6520f5a70f338053151b21a5a29fef271 Mon Sep 17 00:00:00 2001 From: msincenselee Date: Wed, 19 Oct 2016 21:39:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=EF=BC=9A=E9=9D=9E=E4=BA=A4?= =?UTF-8?q?=E6=98=93=E6=97=B6=E9=97=B4=EF=BC=8C=E8=87=AA=E5=8A=A8=E6=96=AD?= =?UTF-8?q?=E5=BC=80=E8=BF=9E=E6=8E=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vn.trader/vtEngine.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/vn.trader/vtEngine.py b/vn.trader/vtEngine.py index a6bc2629..6b24ceb3 100644 --- a/vn.trader/vtEngine.py +++ b/vn.trader/vtEngine.py @@ -180,7 +180,15 @@ class MainEngine(object): gateway.getAccount() else: self.writeLog(u'接口不存在:%s' %gatewayName) - + + def getAccountInfo(self): + """读取风控的账号与仓位数据 + # Added by IncenseLee + 仅支持一个账号。不支持多账号 + 以后支持跨市场套利才更新吧。 + """ + return self.rmEngine.getAccountInfo() + #---------------------------------------------------------------------- def qryPosition(self, gatewayName): """查询特定接口的持仓""" @@ -202,7 +210,12 @@ class MainEngine(object): # 保存数据引擎里的合约数据到硬盘 self.dataEngine.saveContracts() - + + def disconnect(self): + """断开底层gateway的连接""" + for gateway in self.gatewayDict.values(): + gateway.close() + # ---------------------------------------------------------------------- def writeLog(self, content): """快速发出日志事件""" @@ -271,7 +284,10 @@ class MainEngine(object): def getAllWorkingOrders(self): """查询所有的活跃的委托(返回列表)""" return self.dataEngine.getAllWorkingOrders() - + + def clearData(self): + """清空数据引擎的数据""" + self.dataEngine.clearData() ######################################################################## class DataEngine(object): @@ -368,5 +384,9 @@ class DataEngine(object): self.eventEngine.register(EVENT_CONTRACT, self.updateContract) self.eventEngine.register(EVENT_ORDER, self.updateOrder) - + def clearData(self): + """清空数据""" + + self.orderDict = {} + self.workingOrderDict = {}