Skip to content

Commit 5e748c0

Browse files
sbussmanntwiecki
authored andcommitted
Add stochastic volatility to tear plots
Posterior PDF for log(sigma) and log(nu). Also plots the stochastic volatility on top of the returns. Add text to Bayesian notebook Explain the 8th and 9th rows in the Bayesian ipython notebook demonstrating the tear sheet. Also, a few grammatical edits to the rest of the Bayesian notebook.
1 parent 151f61e commit 5e748c0

File tree

3 files changed

+44
-23
lines changed

3 files changed

+44
-23
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,9 @@ docs/_build/
5555

5656
# PyBuilder
5757
target/
58+
59+
# VIM
60+
*.sw?
61+
62+
# IPython notebook checkpoints
63+
.ipynb_checkpoints/

pyfolio/examples/bayesian.ipynb

+17-23
Large diffs are not rendered by default.

pyfolio/tears.py

+21
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,27 @@ def create_bayesian_tear_sheet(returns, benchmark_rets=None,
663663
ax_beta.set_xlabel('Beta')
664664
ax_beta.set_ylabel('Belief')
665665

666+
# run stochastic volatility model
667+
trace_stoch_vol = bayesian.model_stoch_vol(df_train)
668+
669+
# plot log(sigma) and log(nu)
670+
row += 1
671+
ax_sigma_log = plt.subplot(gs[row, 0])
672+
ax_nu_log = plt.subplot(gs[row, 1])
673+
sigma_log = trace_stoch_vol['sigma_log']
674+
sns.distplot(sigma_log, ax=ax_sigma_log)
675+
ax_sigma_log.set_xlabel('log(Sigma)')
676+
ax_sigma_log.set_ylabel('Belief')
677+
nu_log = trace_stoch_vol['nu_log']
678+
sns.distplot(nu_log, ax=ax_nu_log)
679+
ax_nu_log.set_xlabel('log(nu)')
680+
ax_nu_log.set_ylabel('Belief')
681+
682+
# plot latent volatility
683+
row += 1
684+
ax_volatility = plt.subplot(gs[row, :])
685+
bayesian.plot_stoch_vol(df_train, trace=trace_stoch_vol, ax=ax_volatility)
686+
666687
gs.tight_layout(fig)
667688

668689
plt.show()

0 commit comments

Comments
 (0)