How to use the quantstats.plots.snapshot 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),
github notadamking / RLTrader / lib / RLTrader.py View on Github external
rewards.append(reward)

            if render_env:
                test_env.render(mode='human')

            if done:
                net_worths = pd.DataFrame({
                    'Date': info[0]['timestamps'],
                    'Balance': info[0]['net_worths'],
                })

                net_worths.set_index('Date', drop=True, inplace=True)
                returns = net_worths.pct_change()[1:]

                if render_report:
                    qs.plots.snapshot(returns.Balance, title='RL Trader Performance')

                if save_report:
                    reports_path = path.join('data', 'reports', f'{self.study_name}__{model_epoch}.html')
                    qs.reports.html(returns.Balance, file=reports_path)

        self.logger.info(
            f'Finished testing model ({self.study_name}__{model_epoch}): ${"{:.2f}".format(np.sum(rewards))}')
github ranaroussi / quantstats / quantstats / __init__.py View on Github external
_po.curr_month = utils._pandas_current_month
    _po.date = utils._pandas_date
    _po.mtd = utils._mtd
    _po.qtd = utils._qtd
    _po.ytd = utils._ytd

    # methods that requires benchmark stats
    _po.r_squared = stats.r_squared
    _po.r2 = stats.r2
    _po.information_ratio = stats.information_ratio
    _po.greeks = stats.greeks
    _po.rolling_greeks = stats.rolling_greeks
    _po.compare = stats.compare

    # 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