[Mod]修改futuGateway中的strptime线程安全实现方式,改为通过dummy call提前载入
This commit is contained in:
parent
d375b0f7dc
commit
6e81e5885f
@ -5,7 +5,6 @@
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import imp
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from time import sleep
|
from time import sleep
|
||||||
@ -23,6 +22,9 @@ from vnpy.trader.vtConstant import GATEWAYTYPE_INTERNATIONAL
|
|||||||
from vnpy.trader.vtFunction import getJsonPath
|
from vnpy.trader.vtFunction import getJsonPath
|
||||||
|
|
||||||
|
|
||||||
|
# 调用一次datetime,保证初始化
|
||||||
|
tmp = datetime.strptime('20171123', '%Y%m%d')
|
||||||
|
|
||||||
# 常量数据映射
|
# 常量数据映射
|
||||||
productMap = OrderedDict()
|
productMap = OrderedDict()
|
||||||
productMap[PRODUCT_EQUITY] = 'STOCK'
|
productMap[PRODUCT_EQUITY] = 'STOCK'
|
||||||
@ -429,12 +431,7 @@ class FutuGateway(VtGateway):
|
|||||||
|
|
||||||
tick.date = row['data_date'].replace('-', '')
|
tick.date = row['data_date'].replace('-', '')
|
||||||
tick.time = row['data_time']
|
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')
|
tick.datetime = datetime.strptime(' '.join([tick.date, tick.time]), '%Y%m%d %H:%M:%S')
|
||||||
imp.release_lock()
|
|
||||||
|
|
||||||
tick.openPrice = row['open_price']
|
tick.openPrice = row['open_price']
|
||||||
tick.highPrice = row['high_price']
|
tick.highPrice = row['high_price']
|
||||||
tick.lowPrice = row['low_price']
|
tick.lowPrice = row['low_price']
|
||||||
|
Loading…
Reference in New Issue
Block a user