Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
pyfolio bayesian tearsheet - how to increase the number of tuning steps

Hello
Am getting the following messages when i run pf.create_bayesian_tear_sheet():


Running T model
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
Multiprocess sampling (2 chains in 2 jobs)
NUTS: [nu_minus_two_log_, volatility_log_, mean returns]
100%|██████████| 2500/2500 [00:09<00:00, 273.88it/s]
INFO (theano.gof.compilelock): Waiting for existing lock by process '1015' (I am process '1673')
INFO (theano.gof.compilelock): To manually release the lock, delete /Users/steffen/.theano/compiledir_Darwin-17.6.0-x86_64-i386-64bit-i386-3.6.5-64/lock_dir
The acceptance probability does not match the target. It is 0.9429128220005182, but should be close to 0.8. Try to increase the number of tuning steps.
The acceptance probability does not match the target. It is 0.9473825385101929, but should be close to 0.8. Try to increase the number of tuning steps.
100%|██████████| 2000/2000 [00:01<00:00, 1048.09it/s]

Finished T model (required 99.26 seconds).

Running BEST model
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
Multiprocess sampling (2 chains in 2 jobs)
NUTS: [nu_minus_two_log_, group2_std_interval, group1_std_interval_, group2_mean, group1_mean]
100%|██████████| 2500/2500 [00:31<00:00, 79.53it/s]
The acceptance probability does not match the target. It is 0.9702583846031229, but should be close to 0.8. Try to increase the number of tuning steps.
The acceptance probability does not match the target. It is 0.9931941892844904, but should be close to 0.8. Try to increase the number of tuning steps.

Finished BEST model (required 49.82 seconds).

Finished plotting Bayesian cone (required 0.06 seconds).
No handles with labels found to put in legend.

Finished plotting BEST results (required 0.56 seconds).

Finished computing Bayesian predictions (required 0.05 seconds).

Finished plotting Bayesian VaRs estimate (required 0.03 seconds).

Running alpha beta model
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
Multiprocess sampling (2 chains in 2 jobs)
NUTS: [beta, alpha, nu_minus_two_log_, sigma_log_]
100%|██████████| 2500/2500 [00:08<00:00, 287.35it/s]
The acceptance probability does not match the target. It is 0.943993774763292, but should be close to 0.8. Try to increase the number of tuning steps.

The acceptance probability does not match the target. It is 0.8949906122538989, but should be close to 0.8. Try to increase the number of tuning steps.

How can I increase the number of tuning steps? tried to pass in tune but that doesnt work.

Cheers, Steffen

6 responses

Hi, one of the pymc3 developers here :-)
Unfortunately pyfolio doesn't allow you to pass kwargs to pm.sample, so without a change to the pyfolio code you can not change the number of tuning samples. (PRs welcome)

In this case however I really wouldn't worry about it, the acceptance probability is higher than the target. That means that we waste some time in this calculation, but it only takes a couple of seconds anyway...

Thanks Adrian. thats what i thought indeed. Would be great of one could pass several benchmarks into pyfolio. I like to use 60/40 (SPY/AGG) and SG CTA and SG Trend index as benchmark for absolute return strategies.

Steffen,

Unfortunately we don't expose that API (although we probably should). My guess, however, is that your returns are faulty. Are there perhaps outliers or large number of nans in there?

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Hi Thomas,
no NaNs but a few bigger PnL swings. The backtest is for my option strategy fwiw. Pyfolio and especially the bayesian stuff was extremely helpful to get a decent idea of the statistical significance. DANKE! ;-)
Steffen

Hi Steffen,
That might be it then. Are you running things locally? In that case you could just change the code manually (and submit a pull request :)).
Viele Grüße
Thomas

Yes. running it locally. Had to develop everything from scratch as there is no open source framework even remotely able to accommodate what I am trying to do. Was an arduous journey over the past year. The backtest was a major pain as you can imagine when you are dealing with weekly option expiries. All that is left to do now is cleaning up the code and implementing live trading which will be really easy with ib_insync package. Am afraid my coding skills are probably not up to scratch for a pull request and i am really swamped getting my system ready.
Cheers
Steffen