MCPcopy
hub / github.com/ranaroussi/quantstats / plots

Function plots

quantstats/reports.py:1205–1472  ·  view source on GitHub ↗
(
    returns,
    benchmark=None,
    grayscale=False,
    figsize=(8, 5),
    mode="basic",
    compounded=True,
    periods_per_year=252,
    prepare_returns=True,
    match_dates=True,
    **kwargs,
)

Source from the content-addressed store, hash-verified

1203
1204
1205def plots(
1206 returns,
1207 benchmark=None,
1208 grayscale=False,
1209 figsize=(8, 5),
1210 mode="basic",
1211 compounded=True,
1212 periods_per_year=252,
1213 prepare_returns=True,
1214 match_dates=True,
1215 **kwargs,
1216):
1217
1218 benchmark_colname = kwargs.get("benchmark_title", "Benchmark")
1219 strategy_colname = kwargs.get("strategy_title", "Strategy")
1220 active = kwargs.get("active", "False")
1221
1222 if isinstance(returns, _pd.DataFrame):
1223 if len(returns.columns) > 1:
1224 if isinstance(strategy_colname, str):
1225 strategy_colname = list(returns.columns)
1226
1227 win_year, win_half_year = _get_trading_periods(periods_per_year)
1228
1229 if match_dates is True:
1230 returns = returns.dropna()
1231
1232 if prepare_returns:
1233 returns = _utils._prepare_returns(returns)
1234
1235 if isinstance(returns, _pd.Series):
1236 returns.name = strategy_colname
1237 elif isinstance(returns, _pd.DataFrame):
1238 returns.columns = strategy_colname
1239
1240 if mode.lower() != "full":
1241 _plots.snapshot(
1242 returns,
1243 grayscale=grayscale,
1244 figsize=(figsize[0], figsize[0]),
1245 show=True,
1246 mode=("comp" if compounded else "sum"),
1247 benchmark_title=benchmark_colname,
1248 strategy_title=strategy_colname,
1249 )
1250
1251 if isinstance(returns, _pd.Series):
1252 _plots.monthly_heatmap(
1253 returns,
1254 benchmark,
1255 grayscale=grayscale,
1256 figsize=(figsize[0], figsize[0] * 0.5),
1257 show=True,
1258 ylabel='',
1259 compounded=compounded,
1260 active=active,
1261 )
1262 elif isinstance(returns, _pd.DataFrame):

Callers 2

fullFunction · 0.85
basicFunction · 0.85

Calls 2

_get_trading_periodsFunction · 0.85
_match_datesFunction · 0.85

Tested by

no test coverage detected