From a674c1c72b2c6b41eb034674b09500cf1576d9fc Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Sun, 5 Aug 2018 22:03:43 +0800 Subject: [PATCH] [Fix]Close #1019 --- examples/CryptoTrader/uiCryptoWidget.py | 9 +++++---- vnpy/trader/app/algoTrading/algo/blAlgo.py | 2 +- vnpy/trader/app/algoTrading/algo/icebergAlgo.py | 10 ++++++++-- vnpy/trader/app/algoTrading/algo/sniperAlgo.py | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/examples/CryptoTrader/uiCryptoWidget.py b/examples/CryptoTrader/uiCryptoWidget.py index d90a6bda..c4b8e08a 100644 --- a/examples/CryptoTrader/uiCryptoWidget.py +++ b/examples/CryptoTrader/uiCryptoWidget.py @@ -497,10 +497,11 @@ class LogMonitor(BasicMonitor): cellLogContent = BasicCell(logContent) cellGatewayName = BasicCell(error.gatewayName) - self.setItem(0, 0, cellLogTime) - self.setItem(0, 1, cellLogContent) - self.setItem(0, 2, cellGatewayName) - + self.setItem(0, 0, cellGatewayName) + self.setItem(0, 1, cellLogTime) + self.setItem(0, 2, cellLogContent) + + ######################################################################## class TradeMonitor(BasicMonitor): diff --git a/vnpy/trader/app/algoTrading/algo/blAlgo.py b/vnpy/trader/app/algoTrading/algo/blAlgo.py index 70aba8e5..8a9bc154 100644 --- a/vnpy/trader/app/algoTrading/algo/blAlgo.py +++ b/vnpy/trader/app/algoTrading/algo/blAlgo.py @@ -188,7 +188,7 @@ class BlWidget(AlgoWidget): def getAlgoSetting(self): """""" setting = OrderedDict() - setting['templateName'] = StopAlgo.templateName + setting['templateName'] = self.templateName setting['vtSymbol'] = str(self.lineVtSymbol.text()) setting['direction'] = text_type(self.comboDirection.currentText()) setting['offset'] = text_type(self.comboOffset.currentText()) diff --git a/vnpy/trader/app/algoTrading/algo/icebergAlgo.py b/vnpy/trader/app/algoTrading/algo/icebergAlgo.py index 954d3459..027659a9 100644 --- a/vnpy/trader/app/algoTrading/algo/icebergAlgo.py +++ b/vnpy/trader/app/algoTrading/algo/icebergAlgo.py @@ -34,7 +34,7 @@ class IcebergAlgo(AlgoTemplate): self.price = float(setting['price']) # 价格 self.volume = float(setting['volume']) # 数量 self.display = float(setting['display']) # 挂出数量 - self.interval = text_type(setting['interval']) # 间隔 + self.interval = int(setting['interval']) # 间隔 self.offset = text_type(setting['offset']) # 开平 self.count = 0 # 执行计数 @@ -73,12 +73,18 @@ class IcebergAlgo(AlgoTemplate): def onTimer(self): """""" self.count += 1 + if self.count < self.interval: self.varEvent() return self.count = 0 + contract = self.getContract(self.vtSymbol) + if not contract: + self.writeLog(u'找不到合约%s' %self.vtSymbol) + return + if not self.vtOrderID: orderVolume = self.volume - self.tradedVolume orderVolume = min(orderVolume, self.display) @@ -193,7 +199,7 @@ class IcebergWidget(AlgoWidget): def getAlgoSetting(self): """""" setting = OrderedDict() - setting['templateName'] = StopAlgo.templateName + setting['templateName'] = self.templateName setting['vtSymbol'] = str(self.lineVtSymbol.text()) setting['direction'] = text_type(self.comboDirection.currentText()) setting['offset'] = text_type(self.comboOffset.currentText()) diff --git a/vnpy/trader/app/algoTrading/algo/sniperAlgo.py b/vnpy/trader/app/algoTrading/algo/sniperAlgo.py index 2bb396cc..2153f775 100644 --- a/vnpy/trader/app/algoTrading/algo/sniperAlgo.py +++ b/vnpy/trader/app/algoTrading/algo/sniperAlgo.py @@ -178,7 +178,7 @@ class SniperWidget(AlgoWidget): def getAlgoSetting(self): """""" setting = OrderedDict() - setting['templateName'] = StopAlgo.templateName + setting['templateName'] = self.templateName setting['vtSymbol'] = str(self.lineVtSymbol.text()) setting['direction'] = text_type(self.comboDirection.currentText()) setting['offset'] = text_type(self.comboOffset.currentText())