Skip to content

Commit

Permalink
[Mod] 优化循环逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
vnpy committed Sep 29, 2021
1 parent 8195ed6 commit 106715e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions vnpy_dolphindb/dolphindb_database.py
Expand Up @@ -230,17 +230,16 @@ def load_bar_data(
)

df.set_index("datetime", inplace=True)
ds = df.tz_localize(DB_TZ)
df = df.tz_localize(DB_TZ)

# 转换为BarData格式
bars: List[BarData] = []

for tp, dt in zip(ds.itertuples(), ds.index):

for tp in df.itertuples():
bar = BarData(
symbol=symbol,
exchange=exchange,
datetime=dt.to_pydatetime(),
datetime=tp.Index.to_pydatetime(),
interval=interval,
volume=tp.volume,
turnover=tp.turnover,
Expand Down Expand Up @@ -283,17 +282,16 @@ def load_tick_data(
)

df.set_index("datetime", inplace=True)
ds = df.tz_localize(DB_TZ)
df = df.tz_localize(DB_TZ)

# 转换为TickData格式
ticks: List[TickData] = []

for tp, dt in zip(ds.itertuples(), ds.index):

for tp in df.itertuples():
tick = TickData(
symbol=symbol,
exchange=exchange,
datetime=dt.to_pydatetime(),
datetime=tp.Index.to_pydatetime(),
name=tp.name,
volume=tp.volume,
turnover=tp.turnover,
Expand Down

0 comments on commit 106715e

Please sign in to comment.