-
Notifications
You must be signed in to change notification settings - Fork 112
Description
作者您好,按照顺序执行代码之后,出现如下错误。我是Mac的环境
IndexError Traceback (most recent call last)
Cell In[17], line 37
34 from alphalens.utils import get_clean_factor_and_forward_returns
35 from alphalens.tears import create_full_tear_sheet
---> 37 ret = get_clean_factor_and_forward_returns(alpha, close,quantiles=5)
38 create_full_tear_sheet(ret, long_short=False)File ~/Documents/alphas/alphas-main/alphalens/utils.py:827, in get_clean_factor_and_forward_returns(factor, prices, groupby, binning_by_group, quantiles, bins, periods, filter_zscore, groupby_labels, max_loss, zero_aware, cumulative_returns)
666 def get_clean_factor_and_forward_returns(factor,
667 prices,
668 groupby=None,
(...)
676 zero_aware=False,
677 cumulative_returns=True):
678 """
679 Formats the factor data, pricing data, and group mappings into a DataFrame
680 that contains aligned MultiIndex indices of timestamp and asset. The
(...)
825 For use when forward returns are already available.
826 """
--> 827 forward_returns = compute_forward_returns(
828 factor,
829 prices,
830 periods,
831 filter_zscore,
832 cumulative_returns,
833 )
835 factor_data = get_clean_factor(factor, forward_returns, groupby=groupby,
836 groupby_labels=groupby_labels,
837 quantiles=quantiles, bins=bins,
838 binning_by_group=binning_by_group,
839 max_loss=max_loss, zero_aware=zero_aware)
841 return factor_dataFile ~/Documents/alphas/alphas-main/alphalens/utils.py:319, in compute_forward_returns(factor, prices, periods, filter_zscore, cumulative_returns)
316 period_len = diff_custom_calendar_timedeltas(start, end, freq)
317 days_diffs.append(period_len.components.days)
--> 319 delta_days = period_len.components.days - mode(days_diffs).mode[0]
320 period_len -= pd.Timedelta(days=delta_days)
321 label = timedelta_to_string(period_len)IndexError: invalid index to scalar variable.
期盼您的回复,谢谢