Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timezone问题 #14

Closed
dalitang opened this issue Oct 5, 2022 · 2 comments
Closed

timezone问题 #14

dalitang opened this issue Oct 5, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@dalitang
Copy link

dalitang commented Oct 5, 2022

有好意思又开一个

更新数据时候

ib_gateway.py

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/py310/lib/python3.10/site-packages/vnpy_datamanager/ui/widget.py", line 384, in update_data
    self.engine.download_bar_data(
  File "/opt/homebrew/Caskroom/miniforge/base/envs/py310/lib/python3.10/site-packages/vnpy_datamanager/engine.py", line 206, in download_bar_data
    data: List[BarData] = self.main_engine.query_history(
  File "/opt/homebrew/Caskroom/miniforge/base/envs/py310/lib/python3.10/site-packages/vnpy/trader/engine.py", line 223, in query_history
    return gateway.query_history(req)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/py310/lib/python3.10/site-packages/vnpy_ib/ib_gateway.py", line 232, in query_history
    return self.api.query_history(req)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/py310/lib/python3.10/site-packages/vnpy_ib/ib_gateway.py", line 773, in query_history
    delta: timedelta = end - req.start
TypeError: can't subtract offset-naive and offset-aware datetimes

换掉pytz的原因?
`@dataclass
class HistoryRequest:
"""
Request sending to specific gateway for querying history data.
"""

symbol: str
exchange: Exchange
start: datetime
end: datetime = None
interval: Interval = None

def __post_init__(self) -> None:
    """"""
    self.vt_symbol: str = f"{self.symbol}.{self.exchange.value}"`
@vnpy vnpy added the enhancement New feature or request label Oct 6, 2022
@noranhe
Copy link
Contributor

noranhe commented Oct 19, 2022

veighna3.3.0全面调整了相关交易接口、数据服务接口、数据库适配器、应用模块,使用新的ZoneInfo对象来标识时区信息。

@vnpy vnpy closed this as completed Oct 20, 2022
@abz53378
Copy link

寫給後人看
我遇到跟樓主一樣的問題 debug 後發現 end 和 req.start 的時區不同導致的
後來改了一段 code 就好了

delta: timedelta = end - req.start(tzinfo=LOCAL_TZ)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants