How to use the quantstats.plots.monthly_heatmap function in QuantStats

To help you get started, we’ve selected a few QuantStats examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ranaroussi / quantstats / quantstats / reports.py View on Github external
def plots(returns, benchmark=None, grayscale=False,
          figsize=(8, 5), mode='basic', compounded=True):

    if mode.lower() != 'full':
        _plots.snapshot(returns, grayscale=grayscale,
                        figsize=(figsize[0], figsize[0]),
                        show=True, mode=("comp" if compounded else "sum"))

        _plots.monthly_heatmap(returns, grayscale=grayscale,
                               figsize=(figsize[0], figsize[0]*.5),
                               show=True, ylabel=False,
                               compounded=compounded)

        return

    _plots.returns(returns, benchmark, grayscale=grayscale,
                   figsize=(figsize[0], figsize[0]*.6),
                   show=True, ylabel=False)

    _plots.log_returns(returns, benchmark, grayscale=grayscale,
                       figsize=(figsize[0], figsize[0]*.5),
                       show=True, ylabel=False)

    if benchmark is not None:
        _plots.returns(returns, benchmark, match_volatility=True,
github ranaroussi / quantstats / quantstats / reports.py View on Github external
figsize=(figsize[0], figsize[0]*.3),
                          show=True, ylabel=False)

    _plots.rolling_sortino(returns, grayscale=grayscale,
                           figsize=(figsize[0], figsize[0]*.3),
                           show=True, ylabel=False)

    _plots.drawdowns_periods(returns, grayscale=grayscale,
                             figsize=(figsize[0], figsize[0]*.5),
                             show=True, ylabel=False)

    _plots.drawdown(returns, grayscale=grayscale,
                    figsize=(figsize[0], figsize[0]*.4),
                    show=True, ylabel=False)

    _plots.monthly_heatmap(returns, grayscale=grayscale,
                           figsize=(figsize[0], figsize[0]*.5),
                           show=True, ylabel=False)

    _plots.distribution(returns, grayscale=grayscale,
                        figsize=(figsize[0], figsize[0]*.5),
                        show=True, ylabel=False)
github ranaroussi / quantstats / quantstats / reports.py View on Github external
figfile = _utils._file_stream()
    _plots.drawdowns_periods(returns, grayscale=grayscale,
                             figsize=(8, 4), subtitle=False,
                             savefig={'fname': figfile, 'format': 'svg'},
                             show=False, ylabel=False, compounded=compounded)
    tpl = tpl.replace('{{dd_periods}}', figfile.getvalue().decode())

    figfile = _utils._file_stream()
    _plots.drawdown(returns, grayscale=grayscale,
                    figsize=(8, 3), subtitle=False,
                    savefig={'fname': figfile, 'format': 'svg'},
                    show=False, ylabel=False)
    tpl = tpl.replace('{{dd_plot}}', figfile.getvalue().decode())

    figfile = _utils._file_stream()
    _plots.monthly_heatmap(returns, grayscale=grayscale,
                           figsize=(8, 4), cbar=False,
                           savefig={'fname': figfile, 'format': 'svg'},
                           show=False, ylabel=False, compounded=compounded)
    tpl = tpl.replace('{{monthly_heatmap}}', figfile.getvalue().decode())

    figfile = _utils._file_stream()
    _plots.distribution(returns, grayscale=grayscale,
                        figsize=(8, 4), subtitle=False,
                        savefig={'fname': figfile, 'format': 'svg'},
                        show=False, ylabel=False, compounded=compounded)
    tpl = tpl.replace('{{returns_dist}}', figfile.getvalue().decode())

    tpl = _regex.sub(r'\{\{(.*?)\}\}', '', tpl)
    tpl = tpl.replace('white-space:pre;', '')

    if output is None:
github ranaroussi / quantstats / quantstats / __init__.py View on Github external
# plotting methods
    _po.plot_snapshot = plots.snapshot
    _po.plot_earnings = plots.earnings
    _po.plot_daily_returns = plots.daily_returns
    _po.plot_distribution = plots.distribution
    _po.plot_drawdown = plots.drawdown
    _po.plot_drawdowns_periods = plots.drawdowns_periods
    _po.plot_histogram = plots.histogram
    _po.plot_log_returns = plots.log_returns
    _po.plot_returns = plots.returns
    _po.plot_rolling_beta = plots.rolling_beta
    _po.plot_rolling_sharpe = plots.rolling_sharpe
    _po.plot_rolling_sortino = plots.rolling_sortino
    _po.plot_rolling_volatility = plots.rolling_volatility
    _po.plot_yearly_returns = plots.yearly_returns
    _po.plot_monthly_heatmap = plots.monthly_heatmap

    _po.metrics = reports.metrics
# extend_pandas()