[Fix]增加富途行情接口的tick对象复制,防止被上层应用错误修改
This commit is contained in:
parent
9a1a548900
commit
c8b7870d0b
@ -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):
|
||||||
@ -462,8 +464,9 @@ class FutuGateway(VtGateway):
|
|||||||
d['bidVolume%s' %n] = bidData[1]
|
d['bidVolume%s' %n] = bidData[1]
|
||||||
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):
|
||||||
|
Loading…
Reference in New Issue
Block a user