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

fix: 修复使用 pro_bar 查询多个股票时,会发生交叉计算的问题 #1407

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tushare/pro/data_pro.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ def pro_bar(ts_code='', pro_api=None, start_date=None, end_date=None, freq='D',
if freq == 'M':
df = api.monthly(ts_code=ts_code, start_date=start_date, end_date=end_date)
if adj is not None:
fcts = api.adj_factor(ts_code=ts_code, start_date=start_date, end_date=end_date)[['trade_date', 'adj_factor']]
data = df.set_index('trade_date', drop=False).merge(fcts.set_index('trade_date'), left_index=True, right_index=True, how='left')
fcts = api.adj_factor(ts_code=ts_code, start_date=start_date, end_date=end_date)[['trade_date', 'ts_code', 'adj_factor']]
data = df.set_index(['trade_date', 'ts_code'], drop=False).merge(fcts.set_index(['trade_date', 'ts_code']), left_index=True, right_index=True, how='left')
data['adj_factor'] = data['adj_factor'].fillna(method='bfill')
for col in PRICE_COLS:
if adj == 'hfq':
Expand Down