diff --git a/quantstats/_plotting/core.py b/quantstats/_plotting/core.py index d76dd566..08157fd3 100644 --- a/quantstats/_plotting/core.py +++ b/quantstats/_plotting/core.py @@ -100,7 +100,7 @@ def plot_returns_bars( hlw=None, hlcolor="red", hllabel="", - resample="A", + resample="YE", title="Returns", match_volatility=False, log_scale=False, @@ -1018,10 +1018,10 @@ def plot_distribution( port["Monthly"] = port["Daily"].resample("ME").apply(apply_fnc) port["Monthly"].ffill(inplace=True) - port["Quarterly"] = port["Daily"].resample("Q").apply(apply_fnc) + port["Quarterly"] = port["Daily"].resample("QE").apply(apply_fnc) port["Quarterly"].ffill(inplace=True) - port["Yearly"] = port["Daily"].resample("A").apply(apply_fnc) + port["Yearly"] = port["Daily"].resample("YE").apply(apply_fnc) port["Yearly"].ffill(inplace=True) fig, ax = _plt.subplots(figsize=figsize) diff --git a/quantstats/_plotting/wrappers.py b/quantstats/_plotting/wrappers.py index 735910e4..1a08dea1 100644 --- a/quantstats/_plotting/wrappers.py +++ b/quantstats/_plotting/wrappers.py @@ -552,9 +552,9 @@ def yearly_returns( title += " vs Benchmark" benchmark = ( _utils._prepare_benchmark(benchmark, returns.index) - .resample("A") + .resample("YE") .apply(_stats.comp) - .resample("A") + .resample("YE") .last() ) @@ -562,10 +562,10 @@ def yearly_returns( returns = _utils._prepare_returns(returns) if compounded: - returns = returns.resample("A").apply(_stats.comp) + returns = returns.resample("YE").apply(_stats.comp) else: - returns = returns.resample("A").apply(_df.sum) - returns = returns.resample("A").last() + returns = returns.resample("YE").apply(_df.sum) + returns = returns.resample("YE").last() fig = _core.plot_returns_bars( returns, @@ -646,9 +646,9 @@ def histogram( title = "Weekly " elif resample == "ME": title = "Monthly " - elif resample == "Q": + elif resample == "QE": title = "Quarterly " - elif resample == "A": + elif resample == "YE": title = "Annual " else: title = "" diff --git a/quantstats/reports.py b/quantstats/reports.py index a3b0d59e..b7dab076 100644 --- a/quantstats/reports.py +++ b/quantstats/reports.py @@ -155,7 +155,7 @@ def html( if benchmark is not None: yoy = _stats.compare( - returns, benchmark, "A", compounded=compounded, prepare_returns=False + returns, benchmark, "YE", compounded=compounded, prepare_returns=False ) if isinstance(returns, _pd.Series): yoy.columns = [benchmark_title, strategy_title, "Multiplier", "Won"] @@ -859,7 +859,7 @@ def metrics( # metrics['Prob. Sortino/√2 Ratio %'] = _stats.probabilistic_adjusted_sortino_ratio(df, rf, win_year, False) * pct metrics["Smart Sortino/√2"] = metrics["Smart Sortino"] / _sqrt(2) # metrics['Prob. Smart Sortino/√2 Ratio %'] = _stats.probabilistic_adjusted_sortino_ratio(df, rf, win_year, False, True) * pct - metrics["Omega"] = _stats.omega(df, rf, 0.0, win_year) + metrics["Omega"] = _stats.omega(df["returns"], rf, 0.0, win_year) metrics["~~~~~~~~"] = blank metrics["Max Drawdown %"] = blank @@ -936,7 +936,7 @@ def metrics( _stats.expected_return(df, compounded=compounded, aggregate="ME", prepare_returns=False) * pct ) metrics["Expected Yearly %%"] = ( - _stats.expected_return(df, compounded=compounded, aggregate="A", prepare_returns=False) * pct + _stats.expected_return(df, compounded=compounded, aggregate="YE", prepare_returns=False) * pct ) metrics["Kelly Criterion %"] = ( _stats.kelly_criterion(df, prepare_returns=False) * pct @@ -959,9 +959,9 @@ def metrics( metrics["Gain/Pain Ratio"] = _stats.gain_to_pain_ratio(df, rf) metrics["Gain/Pain (1M)"] = _stats.gain_to_pain_ratio(df, rf, "ME") # if mode.lower() == 'full': - # metrics['GPR (3M)'] = _stats.gain_to_pain_ratio(df, rf, "Q") + # metrics['GPR (3M)'] = _stats.gain_to_pain_ratio(df, rf, "QE") # metrics['GPR (6M)'] = _stats.gain_to_pain_ratio(df, rf, "2Q") - # metrics['GPR (1Y)'] = _stats.gain_to_pain_ratio(df, rf, "A") + # metrics['GPR (1Y)'] = _stats.gain_to_pain_ratio(df, rf, "YE") metrics["~~~~~~~"] = blank metrics["Payoff Ratio"] = _stats.payoff_ratio(df, prepare_returns=False) @@ -1013,10 +1013,10 @@ def metrics( _stats.worst(df, aggregate="ME", prepare_returns=False) * pct ) metrics["Best Year %"] = ( - _stats.best(df, compounded=compounded, aggregate="A", prepare_returns=False) * pct + _stats.best(df, compounded=compounded, aggregate="YE", prepare_returns=False) * pct ) metrics["Worst Year %"] = ( - _stats.worst(df, compounded=compounded, aggregate="A", prepare_returns=False) * pct + _stats.worst(df, compounded=compounded, aggregate="YE", prepare_returns=False) * pct ) # dd @@ -1041,10 +1041,10 @@ def metrics( _stats.win_rate(df, compounded=compounded, aggregate="ME", prepare_returns=False) * pct ) metrics["Win Quarter %%"] = ( - _stats.win_rate(df, compounded=compounded, aggregate="Q", prepare_returns=False) * pct + _stats.win_rate(df, compounded=compounded, aggregate="QE", prepare_returns=False) * pct ) metrics["Win Year %%"] = ( - _stats.win_rate(df, compounded=compounded, aggregate="A", prepare_returns=False) * pct + _stats.win_rate(df, compounded=compounded, aggregate="YE", prepare_returns=False) * pct ) if "benchmark" in df: @@ -1574,7 +1574,7 @@ def _download_html(html, filename="quantstats-tearsheet.html"): " ", """