Skip to content

Commit

Permalink
Merge pull request #13 from noranhe/main
Browse files Browse the repository at this point in the history
[Mod] replace pytz
  • Loading branch information
vnpy authored Aug 5, 2022
2 parents fbbd34b + b378514 commit f2401c4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions vnpy_tushare/tushare_datafeed.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from datetime import timedelta, datetime
from pytz import timezone
from typing import Dict, List, Optional
from copy import deepcopy

Expand All @@ -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] = {
Expand Down Expand Up @@ -56,7 +55,7 @@
}

# 中国上海时区
CHINA_TZ = timezone("Asia/Shanghai")
CHINA_TZ = ZoneInfo("Asia/Shanghai")


def to_ts_symbol(symbol, exchange) -> Optional[str]:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit f2401c4

Please sign in to comment.