In Chapter 2, we will focus on the statistics behind price fluctuations on financial markets. Do not worry, we will always take an interactive, simulation-based approach to learn about the more theoretical aspects of finance, not a math-heavy approach! While we have discussed expected returns and volatility in this introduction chapter, we will learn about another important statistical metric of return series: skewness. We will learn how skewed returns affect our risk of ruin, where skewness comes from, and the peculiar fact that skewness cannot be estimated in many cases, yet affects our investment outcomes substantially! These findings will then take us to power-law theory, investigating why there is always another, more severe market crash, and the implications of power-laws on our ability to estimate and forecast risk (or volatility). This Chapter introduces important metrics that will help us better interpret market moves and it aims to make us a bit more humble, clearly showing why and how certain models of financial markets (that are still used frequently) regularly break down under certain market conditions. Finally, we showcase a method that can help us quantify market risk in a more conservative, yet intuitive manner by introducing Bayesian regime switch models.
In Chapter 3, we will focus on portfolio optimization and first recapitulate and implement the traditional mean-variance portfolio optimization approach. We will learn about benefits and shortcomings of this approach, before we venture into a more flexible, simulation-based approach that optimizes portfolio holdings with respect to any objective that the user specifies. We will investigate how this approach can capture non-linear correlations between products that are invisible to traditional approaches. After designing our first basic portfolios that invest in assets such as stock indices, gold, and bonds, we will cover the often neglected simulation of withdrawals: if one wants to live off of an investment portfolio, they will have to withdraw money regularly, and these withdrawals may substantially change the risk-optimal allocation weights. After all, you can lose a lot of long-term gains when you have to withdraw right after a large loss, so losses need to be controlled more tightly once you live off of your investments! Finally, we will use our simulation method to answer the question that almost all investors ask at some point: I have this really stable portfolio, but I want to invest in that one single stock that I like, how much should I allocate to that? At the end of this chapter, you will be able to simulate the performance of portfolios with a handful of products according to objectives that are most important to your requirements as an investor.
In Chapter 4, we will combine the lessons that we have learned in the pervious chapters to create actively managed portfolios that react to macroeconomic changes to avoid drawdowns and maximize returns. We will adapt the Bayesian regime switch model from Chapter 2 to yield a probabilistic, regime-switching capital asset pricing model that tells us the probability that a given asset currently outperforms the global stock market. We will apply this model to Ray Dalio's all-weather portfolio that in its orginal form produces very stable returns by diversifiying across different asset classes. In our case, the regime-switching model will dynamically overexpose us to individual asset classes, and we will use the simulation method from Chapter 3 to show that this approach retains the stability of the all-weather portfolio, but increases the returns to almost match the average returns of the US stock market (but with much smaller drawdowns). At the end of Chapter 4, you will be able to implement a state-of-the-art statistical market model to create an actively managed portfolio and simulate its historical performance as well as produce current portfolio weights for your own investments.
In Chapter 5, we will venture into the derivative market of futures contracts to showcase how trading futures differs from trading equities: first, it allows you to bet on rising and falling prices at the same trading cost, and second it allows you to tune the risk of your investments much more accurately than with long-only stock market investments. To convey these insights based on easily accessible data and markets, we focus on crypto futures. Crypto futures markets allow portfolio sizes as little as $10 (instead of $100,000 for regular commodity or currency futures markets) and they readily provide high quality data. You will learn how to develop basic trading indicators and how to size your bets to achieve a targeted portfolio volatility. At the end of this chapter, you will know the concept of leveraged trading and how to develop an active crypto futures trading strategy that employs basic as well as more elaborate trend-following indicators.
In Chapter 6, we will focus on devops, that means how you can structure the code that you use for investing in a properly structured Python package that runs reliably on your home machine or on a server to execute portfolio optimization or trading strategies in an automated manner.