Thomas Wiecki gave a presentation on Bayesian portfolio allocation. He discussed how Bayesian statistics allows flexible modeling that accounts for uncertainty, unlike traditional mean-variance optimization. His company PyMC Labs uses probabilistic programming to specify portfolio allocation models and infer posterior distributions over parameters. This allows generating predictions across many possible future scenarios and making decisions by optimizing over a loss function. The full Bayesian model can incorporate changes over time, pool information across strategies, and correlations to provide a robust allocation.
3. QU Winter school 2021
● Theme: AI and ML Enablement
○ Data Science with Python
○ AI & Machine Learning for Financial Professionals
○ Model Risk & Governance
● https://quwinterschool.splashthat.com/
5. Thomas Wiecki is the Chief Executive Officer at PyMC Labs, a
Bayesian consultancy (www.pymc-labs.io). Prior to that Thomas
was the VP of Data Science at Quantopian, where he used
probabilistic programming and machine learning to help build
the world’s first crowdsourced hedge fund. Among other open
source projects, he is involved in the development of PyMC3—a
probabilistic programming framework for Python. He holds a
PhD from Brown University.
7. Disclaimer
This presentation is for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation
for any security; nor does it constitute an offer to provide investment advisory or other services by Quantopian, Inc. ("Quantopian").
Nothing contained herein constitutes investment advice or offers any opinion with respect to the suitability of any security, and any
views expressed herein should not be taken as advice to buy, sell, or hold any security or as an endorsement of any security or
company. In preparing the information contained herein, Quantopian, Inc. has not taken into account the investment needs, objectives,
and financial circumstances of any particular investor. Any views expressed and data illustrated herein were prepared based upon
information, believed to be reliable, available to Quantopian, Inc. at the time of publication. Quantopian makes no guarantees as to their
accuracy or completeness. All information is subject to change and may quickly become unreliable for various reasons, including
changes in market conditions or economic circumstances.
8. ● Bayesian consultancy by the inventors of PyMC3
● Solving advanced analytical problems
● Team consists of PhDs, mathematicians, neuroscientists, and a former SpaceX rocket scientist
● Clients in pharma (Roche), fintech, mortgage, agriculture, adtech, biotech...
● www.pymc-labs.io
8
9. Markowitz mean-variance optimization
● Optimal portfolio - in theory - taking mean return, volatility and correlations into account
● Highly sub-optimal in practice, why?
○ Estimates are very noisy, but we do not quantify that noise
○ Leads to lack of diversification
● Many hacks… err solutions, exist:
○ Equal-weight (MVO but assuming means and vol are equal and no correlations exist)
○ Inverse-variance weighting (MVO but assuming means are equal and no correlations exist)
○ Hierarchical Risk Parity
○ ...
12. Not single most likely solution, but all probable solutions
Instead of point-estimates (scalar values) of e.g. the mean or variance, we use probability distributions that quantify
uncertainty.
Point estimates
Probability distributions
15. Bayesian Modeling: Coin flipping
Parameters
Prior p(θ)
Likelihood p(x | θ)
Model
construction:
How
parameters
relate
to
data
Inference:
Bayes
Formula
most
likely
parameters
given
data
Data x
(Heads / Tails)
Parameters
Posterior p(θ | x)
p(heads)
Observe:
HTTHTTT
belief
16. Probabilistic Programming
Parameters
Prior p(θ)
Likelihood p(x | θ)
Model
construction:
How
parameters
relate
to
data
Inference:
Bayes
Formula
most
likely
parameters
given
data
Data x
(Heads / Tails)
Parameters
Posterior p(θ | x)
p(heads)
Observe:
HTTHTTT
belief
code
a
u
t
o
m
a
t
i
c
(
M
C
M
C
)
19. ● Probabilistic Programming framework for Python, FOSS
● Specify arbitrary models in code by plugging probability distributions into each other
● Intuitive model specification syntax
○ For example: x ~ N(0,1) translates to x = Normal('x', 0, 1)
● Inference Button: Automatic and powerful inference for any model
24. Bayesian Decision Making
● So far we only have probability distributions for our strategies.
● How to construct a portfolio from them?
● Use model to generate all kinds of possible future scenarios (prediction)
● Define loss function that rates how good a solution is given a scenario
● Use optimizer to find best solution across all possible future scenarios
26. Predictions
● Generate possible future scenarios by
drawing parameter set from posterior &
sampling from likelihood
● Two sources of variability: Likelihood &
uncertainty
28. Loss function for Mean-Variance
● Utility theory tells us to minimize our
expected losses (maximizing wins leads to
overly risky behavior)
● Black-Littermann: −exp(−λr(ω)), where r(ω)
are the expected returns if we used portfolio
weights ω, λ is how averse to losses we are
29. Example
def loss_function(ω): # weight vector, e.g.
[1/16, 1/16, …]
loss = 0
for r in sampled_returns:
# compute portfolio returns
port_rets = sum(r * ω)
loss += -exp(-port_rets)
return loss
31. Optimization → Output
● Finds optimal portfolio weights ω which minimize expected loss
● In our case: loss function is convex so we can use convex solvers (cvxpy) which are much faster, otherwise, use
scipy.optimizer.fmin().
32. The full model
● Changes in volatility and mean over time using GPs
● Hierarchical estimation to pool information from batch of algorithms
● Correlations
33. Benefits
● Robust due to using posterior distributions rather than point-estimates
● Different length track-records are automatically handled
○ Short but great track-record: high uncertainty -> many potentially bad outcomes -> low weight
● Model can be improved to include all kinds of structure, like risk-factors, prior information we might have (e.g.
knowing a certain manager well).
35. Disclaimer
This presentation is for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation
for any security; nor does it constitute an offer to provide investment advisory or other services by Quantopian, Inc. ("Quantopian").
Nothing contained herein constitutes investment advice or offers any opinion with respect to the suitability of any security, and any
views expressed herein should not be taken as advice to buy, sell, or hold any security or as an endorsement of any security or
company. In preparing the information contained herein, Quantopian, Inc. has not taken into account the investment needs, objectives,
and financial circumstances of any particular investor. Any views expressed and data illustrated herein were prepared based upon
information, believed to be reliable, available to Quantopian, Inc. at the time of publication. Quantopian makes no guarantees as to their
accuracy or completeness. All information is subject to change and may quickly become unreliable for various reasons, including
changes in market conditions or economic circumstances.