Skip to content

Commit

Permalink
[Fix] 修复可能的None字段
Browse files Browse the repository at this point in the history
row.get的default value仅在字段不存在时生效。
当tushare返回的值中存在oi字段,但值为None时,依旧会取None值,从而导致后续的存入数据库失败
  • Loading branch information
kingkaki authored Nov 19, 2021
1 parent 13c7dd3 commit c783bd7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions vnpy_tushare/tushare_datafeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ def query_bar_history(self, req: HistoryRequest) -> Optional[List[BarData]]:
low_price=round_to(row["low"], 0.000001),
close_price=round_to(row["close"], 0.000001),
volume=row["vol"],
turnover=row.get("amount", 0),
open_interest=row.get("oi", 0),
turnover=row.get("amount", 0) if row.get("amount", 0) else 0,
open_interest=row.get("oi", 0) if row.get("oi", 0) else 0,
gateway_name="TS"
)

Expand Down

0 comments on commit c783bd7

Please sign in to comment.