diff --git a/vnpy/gateway/oes/oes_md.py b/vnpy/gateway/oes/oes_md.py index fb5a1b84..25b94fbb 100644 --- a/vnpy/gateway/oes/oes_md.py +++ b/vnpy/gateway/oes/oes_md.py @@ -1,4 +1,5 @@ import time +from copy import copy from datetime import datetime from gettext import gettext as _ from threading import Thread @@ -146,7 +147,7 @@ class OesMdMessageLoop: tick.__dict__['bid_price_' + str(i + 1)] = data.BidLevels[i].Price / 10000 for i in range(min(data.OfferPriceLevel, 5)): tick.__dict__['ask_price_' + str(i + 1)] = data.OfferLevels[i].Price / 10000 - self.gateway.on_tick(tick) + self.gateway.on_tick(copy(tick)) def on_market_full_refresh(self, d: MdsMktRspMsgBodyT): """""" @@ -162,7 +163,7 @@ class OesMdMessageLoop: tick.__dict__['bid_price_' + str(i + 1)] = data.BidLevels[i].Price / 10000 for i in range(5): tick.__dict__['ask_price_' + str(i + 1)] = data.OfferLevels[i].Price / 10000 - self.gateway.on_tick(tick) + self.gateway.on_tick(copy(tick)) def on_l2_trade(self, d: MdsMktRspMsgBodyT): """""" @@ -172,7 +173,7 @@ class OesMdMessageLoop: tick.datetime = datetime.utcnow() tick.volume = data.TradeQty tick.last_price = data.TradePrice / 10000 - self.gateway.on_tick(tick) + self.gateway.on_tick(copy(tick)) def on_market_data_request(self, d: MdsMktRspMsgBodyT): """""" diff --git a/vnpy/gateway/oes/oes_td.py b/vnpy/gateway/oes/oes_td.py index b0d603c8..3878dbaf 100644 --- a/vnpy/gateway/oes/oes_td.py +++ b/vnpy/gateway/oes/oes_td.py @@ -1,4 +1,5 @@ import time +from copy import copy from dataclasses import dataclass from datetime import datetime, timedelta, timezone from gettext import gettext as _ @@ -210,7 +211,7 @@ class OesTdMessageLoop: vt_order.status = Status.REJECTED - self.gateway.on_order(vt_order) + self.gateway.on_order(copy(vt_order)) self.gateway.write_log( f"Order: {vt_order.vt_symbol}-{vt_order.vt_orderid} Code: {error_code} Rejected: {error_string}") else: @@ -230,7 +231,7 @@ class OesTdMessageLoop: vt_order.traded = data.cumQty vt_order.time = parse_oes_datetime(data.ordDate, data.ordTime) - self.gateway.on_order(vt_order) + self.gateway.on_order(copy(vt_order)) def on_order_report(self, d: OesRspMsgBodyT): """""" @@ -247,7 +248,7 @@ class OesTdMessageLoop: vt_order.traded = data.cumQty vt_order.time = parse_oes_datetime(data.ordDate, data.ordCnfmTime) - self.gateway.on_order(vt_order) + self.gateway.on_order(copy(vt_order)) def on_trade_report(self, d: OesRspMsgBodyT): """""" @@ -273,7 +274,7 @@ class OesTdMessageLoop: vt_order.traded = data.cumQty vt_order.time = parse_oes_datetime(data.trdDate, data.trdTime) self.gateway.on_trade(trade) - self.gateway.on_order(vt_order) + self.gateway.on_order(copy(vt_order)) def on_option_holding(self, d: OesRspMsgBodyT): """""" @@ -692,7 +693,7 @@ class OesTdApi: vt_order.status = STATUS_OES2VT[data.ordStatus] vt_order.volume = data.ordQty - data.canceledQty vt_order.traded = data.cumQty - self.gateway.on_order(vt_order) + self.gateway.on_order(copy(vt_order)) return 1 def query_orders(self) -> bool: @@ -718,7 +719,7 @@ class OesTdApi: vt_order.status = STATUS_OES2VT[data.ordStatus] vt_order.volume = data.ordQty - data.canceledQty vt_order.traded = data.cumQty - self.gateway.on_order(vt_order) + self.gateway.on_order(copy(vt_order)) except KeyError: # order_id = self.order_manager.new_remote_id() order_id = data.clSeqNo @@ -744,7 +745,7 @@ class OesTdApi: time=datetime.utcnow().isoformat(), ) self.save_order(order_id, vt_order) - self.gateway.on_order(vt_order) + self.gateway.on_order(copy(vt_order)) return 1 def save_order(self, order_id: int, order: OrderData):