Skip to content

Commit 597f4c4

Browse files
committed
Stop inferring business days, require freq to be passed
1 parent dce10aa commit 597f4c4

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

alphalens/performance.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ def cumulative_returns(returns):
348348
2015-01-07 1.001092
349349
2015-01-08 0.999200
350350
"""
351-
352351
return ep.cum_returns(returns, starting_value=1)
353352

354353

@@ -394,9 +393,7 @@ def positions(weights, period, freq=None):
394393
freq = weights.index.freq
395394

396395
if freq is None:
397-
freq = BDay()
398-
warnings.warn("'freq' not set, using business day calendar",
399-
UserWarning)
396+
raise Exception("'freq' not set")
400397

401398
#
402399
# weights index contains factor computation timestamps, then add returns

alphalens/tears.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,7 @@ def create_returns_tear_sheet(
269269

270270
trading_calendar = factor_data.index.levels[0].freq
271271
if trading_calendar is None:
272-
trading_calendar = pd.tseries.offsets.BDay()
273-
warnings.warn(
274-
"'freq' not set in factor_data index: assuming business day",
275-
UserWarning,
276-
)
272+
raise Exception("'freq' not set in factor_data index")
277273

278274
# Compute cumulative returns from daily simple returns, if '1D'
279275
# returns are provided.
@@ -722,11 +718,7 @@ def create_event_study_tear_sheet(factor_data,
722718

723719
trading_calendar = factor_data.index.levels[0].freq
724720
if trading_calendar is None:
725-
trading_calendar = pd.tseries.offsets.BDay()
726-
warnings.warn(
727-
"'freq' not set in factor_data index: assuming business day",
728-
UserWarning,
729-
)
721+
raise Exception("'freq' not set in factor_data index")
730722

731723
plt.show()
732724
gf.close()

0 commit comments

Comments
 (0)