[Fix]增加富途行情接口的tick对象复制,防止被上层应用错误修改

This commit is contained in:
vn.py 2017-11-16 14:58:28 +08:00
parent 9a1a548900
commit c8b7870d0b

View File

@ -9,6 +9,7 @@ from collections import OrderedDict
from threading import Thread from threading import Thread
from time import sleep from time import sleep
from datetime import datetime from datetime import datetime
from copy import copy
import futuquant as ft import futuquant as ft
from futuquant.open_context import (RET_ERROR, RET_OK, from futuquant.open_context import (RET_ERROR, RET_OK,
@ -427,7 +428,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']
tick.datetime = datetime.strptime(' '.join([tick.date, tick.time]), '%Y%m%d %H:%M:%S.%f') tick.datetime = datetime.strptime(' '.join([tick.date, tick.time]), '%Y%m%d %H:%M:%S')
tick.openPrice = row['open_price'] tick.openPrice = row['open_price']
tick.highPrice = row['high_price'] tick.highPrice = row['high_price']
@ -437,7 +438,8 @@ class FutuGateway(VtGateway):
tick.lastPrice = row['last_price'] tick.lastPrice = row['last_price']
tick.volume = row['volume'] tick.volume = row['volume']
self.onTick(tick) newTick = copy(tick)
self.onTick(newTick)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def processOrderBook(self, data): def processOrderBook(self, data):
@ -463,7 +465,8 @@ class FutuGateway(VtGateway):
d['askPrice%s' %n] = askData[0] d['askPrice%s' %n] = askData[0]
d['askVolume%s' %n] = askData[1] d['askVolume%s' %n] = askData[1]
self.onTick(tick) newTick = copy(tick)
self.onTick(newTick)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def processOrder(self, data): def processOrder(self, data):