Skip to content

Commit

Permalink
[Fix] 修复夜盘换日时,时间戳日期部分的误差问题
Browse files Browse the repository at this point in the history
  • Loading branch information
vnpy committed Oct 25, 2021
1 parent dd602e9 commit 723d5d1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion vnpy_ctp/gateway/ctp_gateway.py
Expand Up @@ -305,12 +305,19 @@ def onRtnDepthMarketData(self, data: dict) -> None:
if not data["UpdateTime"]:
return

# 过滤还没有收到合约数据前的行情推送
symbol: str = data["InstrumentID"]
contract: ContractData = symbol_contract_map.get(symbol, None)
if not contract:
return

timestamp: str = f"{self.current_date} {data['UpdateTime']}.{int(data['UpdateMillisec']/100)}"
# 对大商所的交易日字段取本地日期
if contract.exchange == Exchange.DCE:
date_str: str = self.current_date
else:
date_str: str = data["ActionDay"]

timestamp: str = f"{date_str} {data['UpdateTime']}.{int(data['UpdateMillisec']/100)}"
dt: datetime = datetime.strptime(timestamp, "%Y%m%d %H:%M:%S.%f")
dt = CHINA_TZ.localize(dt)

Expand Down

0 comments on commit 723d5d1

Please sign in to comment.