How much can you lose when the market tumbles?
Big crashes are rare, but that is when a portfolio suffers most. The research used B3 stock prices every 30 seconds to measure these extreme losses with two classic yardsticks and tested whether a neural network could forecast them. Explained in 12 screens.
Not investment advice. This page explains academic research on how to measure risk.
illustration Each column is a size of price change; its height, how often it happens. The blue plate is the VaR line; to its left, in red, the worst 5%: the "tail" of the distribution.
In the stock market, big crashes happen more often than the usual curve promises
The 1987 crash, the currency crises of the 1990s, the dot-com bubble in 2000, the 2008 crisis and the 2020 pandemic reminded investors that extreme losses exist. This is "tail risk": losses at the far left of the distribution of returns, caused by rare or catastrophic events.
illustration Curves drawn by us, with the same mean and the same typical spread; the fat-tailed one is a Student’s t with 3 degrees of freedom. "Fat tail" is one of the dissertation’s keywords; the crises come from its introduction.
One yardstick draws the line; the other measures the fall beyond it
VaR (Value-at-Risk) answers: "95% of the time, the loss is no bigger than what?". ES (Expected Shortfall) asks what VaR forgets: "and when it is bigger, how much is lost on average?". They are the two most widely used loss measures.
illustration 500 days of price changes invented by us (with a fat tail) just to show the two yardsticks. The dissertation’s real figures are on screens 06 to 08.
Instead of one price a day, one price every 30 seconds
High-frequency data give many more observations and show how the price moves within the trading day. The research started from B3 records in milliseconds and summarised them every 30 seconds, the time the Ibovespa index takes to update.
illustration Trading day invented by us. The stocks (section 3.3): B3SA3 (B3), BBAS3 (Banco do Brasil), BBDC4 (Bradesco), ITUB3 and ITUB4 (Itaú Unibanco), PETR3 and PETR4 (Petrobras); ending 3 = common share, 4 = preferred share.
Hardly anyone had looked at tail risk with Brazilian data
Before the models, the author searched the Web of Science for articles combining "tail risk" and "high-frequency data", and classified each one on 11 questions.
Articles from 2005 to 2022, up to 4 a year (Table 01 and Figure 01). Removed from the intermediate sample were, for example, studies on banks (8), exchange rates (5) and futures prices (4).
In all seven stocks, the average fall beyond the line was at least twice the line itself
Using the method of moments (GMM), the author estimated each stock’s VaR and ES over 2022, at 95%. The values are price changes over a short window: −0.48% means a 0.48% drop.
Table 11, losses in absolute value. Striped: the ES of ITUB3 and PETR3 appears in the table with an extra zero (−0.001172 and −0.001301), smaller than the VaR itself, which the definition does not allow; the points in Figure 15 sit near −0.01, so we use −1.17% and −1.30% (our correction).
Petrobras shares had the heaviest tail
Dividing ES by VaR shows how far the average fall goes past the line. In PETR3 and PETR4 it was more than three times larger; in the others, between two and three times.
Blue bar: VaR; red bar: ES, on the same scale. The number on the right (ES ÷ VaR) is our calculation from Table 11 (ITUB3 and PETR3 with the correction from screen 06).
Put it in reais
Choose a stock and an amount invested in it. The calculation multiplies the amount by Table 11’s VaR and ES.
Not investment advice. The values hold for the research’s short window and for 2022; they do not forecast the future nor add up over a day.
In the dissertation’s count, falls beyond the line were extremely rare
ES comes from the points that fell below the VaR. For B3SA3 there were 136 out of almost 3 million records in 2022: a 0.0045% chance. For the author, this shows that VaR and ES detect tail risk in high-frequency data.
Table 11 ("Obs." columns) and section 4.1; "per 100,000" is our calculation. In Figure 15, the worst points come close to −18% for PETR3 and −19% for PETR4 (our reading of the chart).
A neural network with memory tried to forecast PETR3’s losses
An LSTM (Long Short-Term Memory) is a neural network built for sequences: it keeps what matters from the past and discards the rest. It received PETR3 and Ibovespa changes every 30 seconds, from April 2019 to December 2021, and learned from 80% of the series to try to forecast the final 20%.
Two LSTM layers and 221,132 adjustable parameters (Table 12). The training error fell from ~0.0008 to ~0.00014 and stopped falling from the 3rd round on (Figure 16, values read from the chart). Cell diagram: our illustration based on the introduction’s description.
The network learned its training data but did not forecast the losses
In the test period, PETR3’s real changes stayed near zero, with a few jumps. The network’s forecast hovered around −7.6, a very distant scale. For the author, the forecast values are not significant, and the hypothesis that the LSTM improves tail-risk management was not confirmed.
redrawing Lines redrawn by us from Figures 18 and 19, with the ranges read from the charts (real: ~−0.03 to ~0.10; forecast: ~−7.75 to ~−7.37). The shape of each line is approximate.
One hypothesis held and the other did not
After all you have seen, place your bet: did each hypothesis hold?
What changes for those who invest, manage risk or do research
Risk managers
Looking only at VaR hides the size of the fall: here, the average loss beyond the line was at least twice the line. ES completes the yardstick, as the Basel Committee suggested, as cited in the dissertation.
Investors
Different stocks have different tails: in 2022, Petrobras shares had the heaviest falls relative to the line. It is a reading of the past, not a forecast.
Those using AI in finance
A low training error does not guarantee a good forecast. Before trusting a network, it is worth comparing the forecast with the real series, on the same scale.
Researchers
Next steps suggested by the author: networks with more complex architectures, other kinds of data and a closer look at the extreme values that hampered the network.
What this research does not say
- Stocks chosen by the data available. High-frequency data are hard to get; the seven stocks and the period came from what was available. · according to the author
- Measuring is not hedging. Despite the title, the dissertation measures losses; it does not build or test a hedging strategy with derivatives, nor its costs. · our observation
- Counts without explanation. With a 95% VaR, about 5% of records should cross the line; the dissertation counts less than 0.03% and does not explain the gap. There are also millions of records per stock, more than the 30-second intervals in a trading year. · our observation
- A basic network, one stock. The LSTM was tested only on PETR3, in a period with the pandemic’s jumps, and the forecast was not compared with another model. · according to the author and our observation
Credits
MACEDO JUNIOR, Richard Willians. Tail risk hedging: gestão de risco em dados de alta frequência. Master’s dissertation (Business Administration), Mackenzie Presbyterian University, São Paulo, 2023. Advisor: Prof. Dr. Eli Hadad Junior.
Data from B3 Market Data. VaR and ES in Stata/SE 17; LSTM network in Python on Google Colab. This version simplifies the work for a general audience; the formulas and full tables are in the original text. Not investment advice.