diff --git a/vnpy_tushare/tushare_datafeed.py b/vnpy_tushare/tushare_datafeed.py index 2d0c87e..796e572 100644 --- a/vnpy_tushare/tushare_datafeed.py +++ b/vnpy_tushare/tushare_datafeed.py @@ -1,5 +1,4 @@ from datetime import timedelta, datetime -from pytz import timezone from typing import Dict, List, Optional from copy import deepcopy @@ -12,7 +11,7 @@ from vnpy.trader.datafeed import BaseDatafeed from vnpy.trader.constant import Exchange, Interval from vnpy.trader.object import BarData, HistoryRequest -from vnpy.trader.utility import round_to +from vnpy.trader.utility import round_to, ZoneInfo # 数据频率映射 INTERVAL_VT2TS: Dict[Interval, str] = { @@ -56,7 +55,7 @@ } # 中国上海时区 -CHINA_TZ = timezone("Asia/Shanghai") +CHINA_TZ = ZoneInfo("Asia/Shanghai") def to_ts_symbol(symbol, exchange) -> Optional[str]: @@ -184,7 +183,7 @@ def query_bar_history(self, req: HistoryRequest) -> Optional[List[BarData]]: dt: str = row["trade_time"] dt: datetime = datetime.strptime(dt, "%Y-%m-%d %H:%M:%S") - adjustment - dt = CHINA_TZ.localize(dt) + dt = dt.replace(tzinfo=CHINA_TZ) turnover = row.get("amount", 0) if turnover is None: