From b32e5afa0f0d1e264d34999359f4f6981e08307b Mon Sep 17 00:00:00 2001 From: chenxy123 Date: Sat, 28 May 2016 22:31:47 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=A2=9E=E5=8A=A0=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E7=9A=84=E6=97=B6=E9=97=B4=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=202.=20=E4=BF=AE=E5=A4=8DqryAccount,=20qryPosition=203.=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9strategyAtrRsi=E9=87=8C=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BB=A3=E7=A0=81=EF=BC=8C=E4=BF=9D=E8=AF=81?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E7=9A=84=E5=8F=8A=E6=97=B6=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vn.trader/ctaAlgo/strategyAtrRsi.py | 10 +++------- vn.trader/uiBasicWidget.py | 3 ++- vn.trader/vtEngine.py | 4 ++-- vn.trader/vtGateway.py | 2 ++ 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/vn.trader/ctaAlgo/strategyAtrRsi.py b/vn.trader/ctaAlgo/strategyAtrRsi.py index 74aabc6f..9a5d654c 100644 --- a/vn.trader/ctaAlgo/strategyAtrRsi.py +++ b/vn.trader/ctaAlgo/strategyAtrRsi.py @@ -194,14 +194,12 @@ class AtrRsiStrategy(CtaTemplate): if self.rsiValue > self.rsiBuy: # 这里为了保证成交,选择超价5个整指数点下单 self.buy(bar.close+5, 1) - return - if self.rsiValue < self.rsiSell: + elif self.rsiValue < self.rsiSell: self.short(bar.close-5, 1) - return # 持有多头仓位 - if self.pos == 1: + elif self.pos == 1: # 计算多头持有期内的最高价,以及重置最低价 self.intraTradeHigh = max(self.intraTradeHigh, bar.high) self.intraTradeLow = bar.low @@ -210,17 +208,15 @@ class AtrRsiStrategy(CtaTemplate): # 发出本地止损委托,并且把委托号记录下来,用于后续撤单 orderID = self.sell(longStop, 1, stop=True) self.orderList.append(orderID) - return # 持有空头仓位 - if self.pos == -1: + elif self.pos == -1: self.intraTradeLow = min(self.intraTradeLow, bar.low) self.intraTradeHigh = bar.high shortStop = self.intraTradeLow * (1+self.trailingPercent/100) orderID = self.cover(shortStop, 1, stop=True) self.orderList.append(orderID) - return # 发出状态更新事件 self.putEvent() diff --git a/vn.trader/uiBasicWidget.py b/vn.trader/uiBasicWidget.py index 7fe68f35..143b37bf 100644 --- a/vn.trader/uiBasicWidget.py +++ b/vn.trader/uiBasicWidget.py @@ -458,7 +458,8 @@ class ErrorMonitor(BasicMonitor): """Constructor""" super(ErrorMonitor, self).__init__(mainEngine, eventEngine, parent) - d = OrderedDict() + d = OrderedDict() + d['errorTime'] = {'chinese':u'错误时间', 'cellType':BasicCell} d['errorID'] = {'chinese':u'错误代码', 'cellType':BasicCell} d['errorMsg'] = {'chinese':u'错误信息', 'cellType':BasicCell} d['additionalInfo'] = {'chinese':u'补充信息', 'cellType':BasicCell} diff --git a/vn.trader/vtEngine.py b/vn.trader/vtEngine.py index 4f9fe850..b947ac8a 100644 --- a/vn.trader/vtEngine.py +++ b/vn.trader/vtEngine.py @@ -165,7 +165,7 @@ class MainEngine(object): """查询特定接口的账户""" if gatewayName in self.gatewayDict: gateway = self.gatewayDict[gatewayName] - gateway.getAccount() + gateway.qryAccount() else: self.writeLog(u'接口不存在:%s' %gatewayName) @@ -174,7 +174,7 @@ class MainEngine(object): """查询特定接口的持仓""" if gatewayName in self.gatewayDict: gateway = self.gatewayDict[gatewayName] - gateway.getPosition() + gateway.qryPosition() else: self.writeLog(u'接口不存在:%s' %gatewayName) diff --git a/vn.trader/vtGateway.py b/vn.trader/vtGateway.py index 7a590964..88216377 100644 --- a/vn.trader/vtGateway.py +++ b/vn.trader/vtGateway.py @@ -331,6 +331,8 @@ class VtErrorData(VtBaseData): self.errorID = EMPTY_STRING # 错误代码 self.errorMsg = EMPTY_UNICODE # 错误信息 self.additionalInfo = EMPTY_UNICODE # 补充信息 + + self.errorTime = time.strftime('%X', time.localtime()) # 错误生成时间 ########################################################################