Skip to content

Commit

Permalink
0.8.9 fix bug: 仅股票进行复权 (waditu#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
zengbin93 committed Dec 13, 2021
1 parent efd2824 commit 17d8a25
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions czsc/data/ts_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def pro_bar_minutes(self, ts_code, sdt, edt, freq='60min', asset="E", adj=None,
dt1 = dt2
dt2 = dt1 + delta
if self.verbose:
print(f"{ts_code} - {asset} - {freq} - {dt1} - {dt2}")
print(f"pro_bar_minutes: {ts_code} - {asset} - {freq} - {dt1} - {dt2}")

df_klines = pd.concat(klines, ignore_index=True)
kline = df_klines.drop_duplicates('trade_time')\
Expand All @@ -236,8 +236,8 @@ def pro_bar_minutes(self, ts_code, sdt, edt, freq='60min', asset="E", adj=None,
kline = kline.reset_index(drop=True)
kline.drop(['keep'], axis=1, inplace=True)

# 复权行情说明:https://tushare.pro/document/2?doc_id=146
if adj and adj == 'qfq':
# 只对股票有复权操作;复权行情说明:https://tushare.pro/document/2?doc_id=146
if asset == 'E' and adj and adj == 'qfq':
# 前复权 = 当日收盘价 × 当日复权因子 / 最新复权因子
factor = self.adj_factor(ts_code)
factor = factor.sort_values('trade_date', ignore_index=True)
Expand All @@ -247,7 +247,7 @@ def pro_bar_minutes(self, ts_code, sdt, edt, freq='60min', asset="E", adj=None,
for col in ['open', 'close', 'high', 'low']:
kline[col] = kline.apply(lambda x: x[col] * adj_map[x['trade_date']] / latest_factor, axis=1)

if adj and adj == 'hfq':
if asset == 'E' and adj and adj == 'hfq':
# 后复权 = 当日收盘价 × 当日复权因子
factor = self.adj_factor(ts_code)
factor = factor.sort_values('trade_date', ignore_index=True)
Expand Down

0 comments on commit 17d8a25

Please sign in to comment.