From 73979d94763ae46bb32827b597be6036a3cff38b Mon Sep 17 00:00:00 2001 From: msincenselee Date: Sun, 24 Feb 2019 16:51:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/uiBasicWidget.py | 5 ++--- vnpy/trader/vtUtility.py | 17 +++++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/vnpy/trader/uiBasicWidget.py b/vnpy/trader/uiBasicWidget.py index 59b39ea1..b26d2635 100644 --- a/vnpy/trader/uiBasicWidget.py +++ b/vnpy/trader/uiBasicWidget.py @@ -1358,7 +1358,7 @@ class ContractMonitor(BasicMonitor): class ContractManager(QtWidgets.QWidget): """合约管理组件""" - #---------------------------------------------------------------------- + # ---------------------------------------------------------------------- def __init__(self, mainEngine, parent=None): """Constructor""" super(ContractManager, self).__init__(parent=parent) @@ -1367,7 +1367,7 @@ class ContractManager(QtWidgets.QWidget): self.initUi() - #---------------------------------------------------------------------- + # ---------------------------------------------------------------------- def initUi(self): """初始化界面""" self.setWindowTitle(vtText.CONTRACT_SEARCH) @@ -1426,7 +1426,6 @@ class WorkingOrderMonitor(OrderMonitor): row = self.row(cell) self.hideRow(row) - ######################################################################## class SettingEditor(QtWidgets.QWidget): """配置编辑器""" diff --git a/vnpy/trader/vtUtility.py b/vnpy/trader/vtUtility.py index 94604421..31b0ae08 100644 --- a/vnpy/trader/vtUtility.py +++ b/vnpy/trader/vtUtility.py @@ -5,7 +5,7 @@ import numpy as np import talib from vnpy.trader.vtObject import VtBarData - +from vnpy.trader.app.ctaStrategy.ctaBase import CtaBarData ######################################################################## class BarGenerator(object): @@ -34,20 +34,24 @@ class BarGenerator(object): # 尚未创建对象 if not self.bar: - self.bar = VtBarData() + #self.bar = VtBarData() + self.bar = CtaBarData() + newMinute = True # 新的一分钟 elif self.bar.datetime.minute != tick.datetime.minute: # 生成上一分钟K线的时间戳 self.bar.datetime = self.bar.datetime.replace(second=0, microsecond=0) # 将秒和微秒设为0 - self.bar.date = self.bar.datetime.strftime('%Y%m%d') - self.bar.time = self.bar.datetime.strftime('%H:%M:%S.%f') - + self.bar.date = self.bar.datetime.strftime('%Y-%m-%d') + self.bar.time = self.bar.datetime.strftime('%H:%M:%S') + self.bar.tradingDay = self.bar.date # 推送已经结束的上一分钟K线 self.onBar(self.bar) + print(u'BarGenerate:Onbar:{},{},o:{},h:{},l:{},c:{}'.format(self.bar.vtSymbol,self.bar.datetime,self.bar.open,self.bar.high,self.bar.low,self.bar.close)) # 创建新的K线对象 - self.bar = VtBarData() + #self.bar = VtBarData() + self.bar = CtaBarData() newMinute = True # 初始化新一分钟的K线数据 @@ -59,6 +63,7 @@ class BarGenerator(object): self.bar.open = tick.lastPrice self.bar.high = tick.lastPrice self.bar.low = tick.lastPrice + # 累加更新老一分钟的K线数据 else: self.bar.high = max(self.bar.high, tick.lastPrice)