diff --git a/quantstats_lumi/_plotting/core.py b/quantstats_lumi/_plotting/core.py index 44c1a08..1dee056 100644 --- a/quantstats_lumi/_plotting/core.py +++ b/quantstats_lumi/_plotting/core.py @@ -418,7 +418,7 @@ def plot_histogram( colors, _, _ = _get_colors(grayscale) - apply_fnc = _stats.comp if compounded else _np.sum + apply_fnc = _stats.comp if compounded else 'sum' if benchmark is not None: benchmark = ( benchmark.fillna(0) @@ -1003,7 +1003,7 @@ def plot_distribution( port = _pd.DataFrame(returns.fillna(0)) port.columns = ["Daily"] - apply_fnc = _stats.comp if compounded else _np.sum + apply_fnc = _stats.comp if compounded else 'sum' port["Weekly"] = port["Daily"].resample("W-MON").apply(apply_fnc) port["Weekly"] = port["Weekly"].ffill() diff --git a/quantstats_lumi/_plotting/wrappers.py b/quantstats_lumi/_plotting/wrappers.py index 3b4ec24..3f85f7d 100644 --- a/quantstats_lumi/_plotting/wrappers.py +++ b/quantstats_lumi/_plotting/wrappers.py @@ -26,7 +26,6 @@ import seaborn as _sns from matplotlib.ticker import FuncFormatter as _FuncFormatter from matplotlib.ticker import StrMethodFormatter as _StrMethodFormatter -from pandas import DataFrame as _df from .. import stats as _stats from .. import utils as _utils @@ -552,7 +551,7 @@ def yearly_returns( if compounded: returns = returns.resample("YE").apply(_stats.comp) else: - returns = returns.resample("YE").apply(_df.sum) + returns = returns.resample("YE").sum() returns = returns.resample("YE").last() fig = _core.plot_returns_bars( diff --git a/quantstats_lumi/reports.py b/quantstats_lumi/reports.py index b340fae..8ca94b8 100644 --- a/quantstats_lumi/reports.py +++ b/quantstats_lumi/reports.py @@ -993,7 +993,7 @@ def metrics( # returns metrics["~~"] = blank - comp_func = _stats.comp if compounded else _np.sum + comp_func = _stats.comp if compounded else lambda x: _np.sum(x, axis=0) today = df.index[-1] # _dt.today() metrics["MTD %"] = comp_func(df[df.index >= _dt(today.year, today.month, 1)]) * pct diff --git a/quantstats_lumi/stats.py b/quantstats_lumi/stats.py index f5f99f4..810bab6 100644 --- a/quantstats_lumi/stats.py +++ b/quantstats_lumi/stats.py @@ -79,7 +79,7 @@ def get_outliers(data): else: returns = returns[returns.columns[0]] - apply_fnc = comp if compounded else _np.sum + apply_fnc = comp if compounded else 'sum' daily = returns.dropna() if prepare_returns: @@ -594,7 +594,7 @@ def cagr(returns, rf=0.0, compounded=True, periods=365): if compounded: total = comp(total) else: - total = _np.sum(total) + total = _np.sum(total, axis=0) years = (returns.index[-1] - returns.index[0]).days / periods