Ten Financial Applications of Machine Learning: Marcos López de Prado
Ten Financial Applications of Machine Learning: Marcos López de Prado
Ten Financial Applications of Machine Learning: Marcos López de Prado
Machine Learning
2
Electronic copy available at: https://ssrn.com/abstract=3197726
The Promise of Financial ML
4
Electronic copy available at: https://ssrn.com/abstract=3197726
2. Portfolio Construction / Risk Analysis
• Most firms continue to allocate trillions of dollars using mean-variance portfolio
optimization (MVO). “The most expensive piece of beautiful math in history.”
• It is widely known that MVO underperforms the naïve allocation out-of-sample (De
Miguel et al. [2009]).
• In contrast, ML solutions outperform MVO (and 1/N) out-of-sample, with gains in
Sharpe ratio that exceed 31% (López de Prado [2016]).
5
Electronic copy available at: https://ssrn.com/abstract=3197726
3. Structural Breaks / Outlier Detection
Cross-sectional studies are particularly sensitive to the presence of outliers. Even a
small percentage of outliers can cause a very large percentage of wrong signals: Buys
that should be sells (false positives), and sells that should be buys (false negatives).
In this plot we run a regression on a cross-section of securities,
where a very small percentage (only 5%) are outliers:
• The red dots are securities that are expensive, but the
regression wrongly classified as cheap.
• The green dots are securities that are cheap, but the regression
wrongly classified as expensive.
6
Electronic copy available at: https://ssrn.com/abstract=3197726
4. Bet Sizing
• Suppose that you have a model for making a buy-or-sell decision:
– You just need to learn the size of that bet, which includes the possibility of no bet at all (zero size).
– This is a situation that practitioners face regularly. We often know whether we want to buy or sell a
product, and the only remaining question is how much money we should risk in such bet.
– Meta-labeling: Label the outcomes of the primary model as 1 (gain) or 0 (loss).
Once we know what are the factors at play, we can develop a theory
of how.
8
Electronic copy available at: https://ssrn.com/abstract=3197726
6. Controlling for Effects and Interactions
• Consider a common econometric problem:
𝐼 𝐽
𝑦𝑡 = 𝛼 + 𝛽𝑖 𝑋𝑖,𝑡 + 𝛾𝑗 𝑍𝑗,𝑡 + 𝜀𝑡
𝑖=1 𝑗=1
where we wish to adjudicate the effect of 𝑋𝑖,𝑡 while controlling for 𝑍𝑗,𝑡 .
• Semi-parametric methods:
– Mullainathan and Spiess [2017] argue that, since we are not interested in “understanding” 𝛾𝑗 ,
where should not estimate them parametrically.
𝐽
– Instead, we should replace 𝑗=1 𝛾𝑗 𝑍𝑗,𝑡 with predictions from ML algorithms based on 𝑍𝑗,𝑡 features.
– That will give us a better assessment of the significance of 𝛽𝑖 .
• In contrast to regression approaches, ML algorithms can model complex interaction
effects, by allowing for hierarchical, non-linear and non-continuous relationships.
9
Electronic copy available at: https://ssrn.com/abstract=3197726
7. Credit Ratings, Analyst Recommendations
• Stock analysts apply a number of models and heuristics to produce credit and
investment ratings.
• These decisions are not entirely arbitrary, and correspond to a complex logic that
cannot be represented with a simple set of formulas or a well-defined procedure.
• Machine learning algorithms have been successful at replicating a large percentage
of recommendations produced by bank analysts and credit rating agencies.
In this example by Moody’s, the left figure
shows a scatter plot of bonds as a function
of two features (X,Y), where defaults are
colored in red. The middle plot shows that
traditional econometric methods fail at
modelling this complex, non-linear
relationship. The right plot shows that a
very simple ML algorithm performs well.
10
Electronic copy available at: https://ssrn.com/abstract=3197726
8. Sentiment Analysis / Recommender Systems
• In the plot below, an algorithm has identified news articles containing information
relevant to Tesla (TSLA US Equity).
– Blue bars: Daily count of the total number of articles. The average is 458 articles/day, with a
maximum of ~5000.
– Green bars: Daily count of articles expressing a positive sentiment.
– Red bars: Daily count of articles expressing a negative sentiment.
11
Electronic copy available at: https://ssrn.com/abstract=3197726
9. Execution Analytics
• Credit instruments are traded over-the-counter.
• Many investment grade bonds are not traded for days and even weeks.
• Kernel-based methods identify “similar” trades based on their common features.
– The set of common trades enables us to derive theoretical prices.
– If we buy a bond at a price higher than subsequent “similar” bonds, we can bust the trade.
This plot shows the trade efficient of buys (green) and sales (red):
• A buy has efficiency 0 when it prints at the quoted offer, and it
has efficiency 100 when it prints at the quoted bid.
• A sale has efficiency 0 when it prints at the quoted bid, and it
has efficiency 100 when it prints at the quoted offer.
• Both have efficiency 50 at the mid.
In this example, the rebalancing of the portfolio has been
profitable, as it has captured about 1/3 of the bid-ask spread
(approx. 50 bps in price).
12
Electronic copy available at: https://ssrn.com/abstract=3197726
10. Detection of False Investment Strategies
The y-axis displays the distribution of the maximum Sharpe ratios
(max{SR}) for a given number of trials (x-axis). A lighter color indicates a
higher probability of obtaining that result, and the dash-line indicates
the expected value.
For example, after only 1,000 independent backtests, the expected
maximum Sharpe ratio (E[max{SR}]) is 3.26, even if the true Sharpe ratio
of the strategy is zero!
Most quantitative firms invest in false discoveries.
Solution: Deflate the Sharpe ratio by the number and variance of trials.
Stats Cluster 0 Cluster 1 Cluster 2 Cluster 3
Strat Count 3265 1843 930 347 The selected strategy belongs to
aSR 1.5733 1.4907 2.0275 1.0158
SR 0.0974 0.0923 0.1255 0.0629 Cluster 2. After taking into
Skew -0.3333 -0.4520 -0.4194 0.8058 account the number and
Kurt 11.2773 6.0953 7.4035 14.2807
T 2172 2168 2174 2172 variance of trials involved in the
StartDt
EndDt
2010-01-04
2018-05-01
2010-01-04
2018-04-25
2010-01-04
2018-05-03
2010-01-04
2018-05-01
discovery, the probability that
Freq 261.0474 261.0821 261.1159 261.0474 𝑆𝑅 > 0 is virtually 1. Hence, the
sqrt(V[SR_k]) 0.0257 0.0256 0.0256 0.0257
E[max SR_k] 0.0270 0.0270 0.0270 0.0270
backtest is unlikely to be overfit.
DSR 0.9993 0.9985 1.0000 0.9558
13
Electronic copy available at: https://ssrn.com/abstract=3197726
The Perils of Financial ML
15
Electronic copy available at: https://ssrn.com/abstract=3197726
The “spilled samples” problem (2/2)
• Now you need to determine the features predictive of high cholesterol (diet,
exercise, age, etc.), without knowing for sure the cholesterol level of each patient.
• That is the equivalent challenge that we face in financial ML.
– Labels are decided by outcomes.
– Outcomes are decided over multiple observations.
– Because labels overlap in time, we cannot be certain about what observed features
caused an effect.
My friend Luna can recognize faces, like Google or FaceBook.
She is not so good at investing, and Google’s ML would
probably fail miserably if applied to financial markets.
PROBLEM A SOLUTION
Outcomes span multiple observations Triple barrier method, with uniqueness weighting
Low signal/noise ratio. Backtest overfitting Deflated Sharpe ratio by controlling for the number of trials
17
Electronic copy available at: https://ssrn.com/abstract=3197726
For Additional Details
The first wave of quantitative innovation in finance was led by Markowitz
optimization. Machine Learning is the second wave and it will touch every
aspect of finance. López de Prado’s Advances in Financial Machine Learning is
essential for readers who want to be ahead of the technology rather than
being replaced by it.
— Prof. Campbell Harvey, Duke University. Former President of the American
Finance Association.
Financial problems require very distinct machine learning solutions. Dr. López
de Prado’s book is the first one to characterize what makes standard machine
learning tools fail when applied to the field of finance, and the first one to
provide practical solutions to unique challenges faced by asset managers.
Everyone who wants to understand the future of finance should read this
book.
— Prof. Frank Fabozzi, EDHEC Business School. Editor of The Journal of
Portfolio Management.
18
Electronic copy available at: https://ssrn.com/abstract=3197726
THANKS FOR YOUR ATTENTION!
19
Electronic copy available at: https://ssrn.com/abstract=3197726
Disclaimer
• The views expressed in this document are the authors’ and do not necessarily
reflect those of the organizations he is affiliated with.
• No investment decision or particular course of action is recommended by this
presentation.
• All Rights Reserved. © 2018 by Marcos López de Prado
20
Electronic copy available at: https://ssrn.com/abstract=3197726