From f0c9500a0e0d4bcd47df3587dd4c4b457338b63a Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Sat, 9 Jun 2018 15:12:30 +0800 Subject: [PATCH] =?UTF-8?q?[Mod]=E7=AE=80=E5=8C=96=E5=A4=A7=E5=95=86?= =?UTF-8?q?=E6=89=80=E7=9A=84Tick=E6=97=A5=E6=9C=9F=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/gateway/ctpGateway/ctpGateway.py | 25 +------------------- 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/vnpy/trader/gateway/ctpGateway/ctpGateway.py b/vnpy/trader/gateway/ctpGateway/ctpGateway.py index 2d49c8c3..38185763 100644 --- a/vnpy/trader/gateway/ctpGateway/ctpGateway.py +++ b/vnpy/trader/gateway/ctpGateway/ctpGateway.py @@ -247,10 +247,6 @@ class CtpMdApi(MdApi): self.brokerID = EMPTY_STRING # 经纪商代码 self.address = EMPTY_STRING # 服务器地址 - self.tradingDt = None # 交易日datetime对象 - self.tradingDate = EMPTY_STRING # 交易日期字符串 - self.tickTime = None # 最新行情time对象 - #---------------------------------------------------------------------- def onFrontConnected(self): """服务器连接""" @@ -298,14 +294,6 @@ class CtpMdApi(MdApi): for subscribeReq in self.subscribedSymbols: self.subscribe(subscribeReq) - # 获取交易日 - #self.tradingDate = data['TradingDay'] - #self.tradingDt = datetime.strptime(self.tradingDate, '%Y%m%d') - - # 登录时通过本地时间来获取当前的日期 - self.tradingDt = datetime.now() - self.tradingDate = self.tradingDt.strftime('%Y%m%d') - # 否则,推送错误信息 else: err = VtErrorData() @@ -388,18 +376,7 @@ class CtpMdApi(MdApi): # 大商所日期转换 if tick.exchange is EXCHANGE_DCE: - newTime = datetime.strptime(tick.time, '%H:%M:%S.%f').time() # 最新tick时间戳 - - # 如果新tick的时间小于夜盘分隔,且上一个tick的时间大于夜盘分隔,则意味着越过了12点 - if (self.tickTime and - newTime < NIGHT_TRADING and - self.tickTime > NIGHT_TRADING): - self.tradingDt += timedelta(1) # 日期加1 - self.tradingDate = self.tradingDt.strftime('%Y%m%d') # 生成新的日期字符串 - - tick.date = self.tradingDate # 使用本地维护的日期 - - self.tickTime = newTime # 更新上一个tick时间 + tick.date = datetime.now().strftime('%Y%m%d') self.gateway.onTick(tick)