Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stochastic volatility to Bayesian tear sheet #174

Closed
wants to merge 11 commits into from

Conversation

sbussmann
Copy link
Contributor

Adds the following three plots to Bayesian tear sheet:

  1. Posterior PDF for log(sigma)
  2. Posterior PDF for log(nu)
  3. Stochastic volatility overlaid on returns.

twiecki and others added 4 commits October 16, 2015 16:26
row += 1
ax_sigma_log = plt.subplot(gs[row, 0])
ax_nu_log = plt.subplot(gs[row, 1])
sigma_log = trace_stoch_vol['sigma_log']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the below to be a separate function?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, might not be worth it.

@twiecki
Copy link
Contributor

twiecki commented Oct 18, 2015

Looks great, thanks. Can you remove pyfolio/examples/.ipynb_checkpoints/bayesian-checkpoint.ipynb and reset spy.csv? Also, adding some text to the Bayesian NB that describes the additional outputs would be a great addition.

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.

Reset spy.csv
Add a line to gitignore so that new notebook checkpoints are ignored.
Time to complete each model and plot is printed as each task is
completed.
Stochastic volatility model takes as much time to run as rest of models
combined, so turn it off by default.
@sbussmann
Copy link
Contributor Author

If you are happy with these changes, I'm ready to close this pull request. I'm going to start working on understanding the runtime of the stochastic volatility model as a function of the size of the returns dataset.

@twiecki
Copy link
Contributor

twiecki commented Oct 20, 2015

Looks great! One last thing: I think we should add the truncation to the last 400 days and display a warning that we're truncating if the data passed in is more than 400 days.

@sbussmann
Copy link
Contributor Author

I just implemented this change on my local working copy. However, I only noticed a minor performance improvement. Using 400 days of returns (instead of the full set of 858 days), running the stochastic volatility model requires 88 seconds instead of ~110 seconds. This is on a Macbook Air from late 2013. How much testing have you done as far as number of days of returns and time required to run the stochastic volatility model?

@twiecki
Copy link
Contributor

twiecki commented Oct 21, 2015

Not much, but I have seen it fail for a larger number. If it works just as well on 858 days maybe this is fine. It's not rare though to pass in a 10 year backtest which would be ~2520 days and I would expect the model to fail in that case. Worth a try though.

Use only the most recent 400 days of returns.
@sbussmann
Copy link
Contributor Author

I'm going to open a new branch to explore time required to run model_stoch_vol as a function of number of returns and to work on caching.

I wasn’t quite finished running the Bayesian IPython notebook when I
last pushed, apparently.
@sbussmann
Copy link
Contributor Author

Do you mean something other than "cutoff"?

@twiecki
Copy link
Contributor

twiecki commented Oct 21, 2015

No, something other than replacing df_returns.

df_train is unchanged if the user wants to run the stochastic
volatility model.
@twiecki
Copy link
Contributor

twiecki commented Oct 21, 2015

Thanks! Can you rebase this off of master and we can merge.

@sbussmann
Copy link
Contributor Author

I don't have experience with rebasing in git. From looking at the git book, I'm thinking I need to do something like git rebase pyfolio/master. But I'm not sure, and it seems that this is an area that can cause trouble if done poorly. So I'd rather make sure I get it right the first time. Let me know if this sounds right to you.

@twiecki
Copy link
Contributor

twiecki commented Oct 21, 2015

Rebased and merged via 15663a6. Thanks!

@twiecki twiecki closed this Oct 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants