From 6e81e5885fc5ae91abb8745305932afbb2dd3670 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Thu, 23 Nov 2017 10:22:34 +0800 Subject: [PATCH] =?UTF-8?q?[Mod]=E4=BF=AE=E6=94=B9futuGateway=E4=B8=AD?= =?UTF-8?q?=E7=9A=84strptime=E7=BA=BF=E7=A8=8B=E5=AE=89=E5=85=A8=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E6=96=B9=E5=BC=8F=EF=BC=8C=E6=94=B9=E4=B8=BA=E9=80=9A?= =?UTF-8?q?=E8=BF=87dummy=20call=E6=8F=90=E5=89=8D=E8=BD=BD=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/gateway/futuGateway/futuGateway.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/vnpy/trader/gateway/futuGateway/futuGateway.py b/vnpy/trader/gateway/futuGateway/futuGateway.py index ccef455b..320cea4f 100644 --- a/vnpy/trader/gateway/futuGateway/futuGateway.py +++ b/vnpy/trader/gateway/futuGateway/futuGateway.py @@ -5,7 +5,6 @@ ''' import json -import imp from collections import OrderedDict from threading import Thread from time import sleep @@ -23,6 +22,9 @@ from vnpy.trader.vtConstant import GATEWAYTYPE_INTERNATIONAL from vnpy.trader.vtFunction import getJsonPath +# 调用一次datetime,保证初始化 +tmp = datetime.strptime('20171123', '%Y%m%d') + # 常量数据映射 productMap = OrderedDict() productMap[PRODUCT_EQUITY] = 'STOCK' @@ -429,12 +431,7 @@ class FutuGateway(VtGateway): tick.date = row['data_date'].replace('-', '') tick.time = row['data_time'] - - # 这里使用imp模块来解决strptime函数的多线程安全问题 - imp.acquire_lock() tick.datetime = datetime.strptime(' '.join([tick.date, tick.time]), '%Y%m%d %H:%M:%S') - imp.release_lock() - tick.openPrice = row['open_price'] tick.highPrice = row['high_price'] tick.lowPrice = row['low_price']