Determine a Safe Withdrawal Rate for your Investment Portfolio with Python
By: Raymond R, Two Pennies Worth
Tags: Data, Data Science, Finance, Towards Data Science, Investing

Python Implementation

First, the libraries that I used for this implementation were yfinance and plotly. To use this python implementation, you need to install these libraries. You can install these libraries using pip .

pip install yfinance --upgrade --no-cache-dir

pip install plotly

After installing the necessary libraries, we can turn our focus to the python implementation. Given the amount of different portfolio compositions, payout periods and withdrawal rates that are possible to explore, I found it suitable to create a python class named sustainable_withdrawal_rate .

Before loading this class, it is helpful if you look up the symbols of your choosing on Yahoo Finance, as you will need it as input for the python class. For example, I want to determine the (nominal) sustainable withdrawal rate for an investment portfolio containing the indices of UK, Germany and France. The symbols for these indices on Yahoo Finance are:

UK FTSE index: ^FTSE

Germany DAX index: ^GDAXI

France CAC 40 index: ^FCHI

After loading the python class, you need to instantiate it. For instantiation, the symbols are required as input. Below you can find an example using the symbols mentioned above:

symbols = "^FTSE ^GDAXI ^FCHI"

port = sustainable_withdrawal_rate(symbols)

The following output is observed:

The output states that the historical (monthly) data for all three indices ranges from 1991 to 2020, which is 30 years of historical data that can be used for analysis. This is useful as it suggests that for this investment portfolio there is not enough historical data to determine a sustainable withdrawal rate for a payout period of 30 years.

Based on the amount of historical data for this investment portfolio (30 years), we could use a payout period of 10 years. If you want to determine the success rates for a given portfolio composition and a payout period of 10 years, you can use the following code:

portfolio_composition = {"^FTSE":0.4, "^GDAXI":0.4, "^FCHI":0.3}

payout_period = 10

port.portfolio_success_rate(payout_period, portfolio_composition)

The code shows that the weights for this investment portfolio consists of 40% FTSE, 40% DAX and 30% CAC 40. Running this code results in the following output:

The output is a table containing the different annual withdrawal rates and their corresponding success rates. In other words, an investment portfolio consisting of 40% FTSE, 40% DAX and 30% CAC 40 can sustain an annual withdrawal rate of up to 7% for a payout period of 10 years without being depleted.

If you wish to adjust the portfolio composition and/or payout period, and see how these changes affect the success rates. You can easily do this by adjusting the portfolio_composition and/or payout_period , and running the code port.portfolio_success_rate(payout_period, portfolio_composition) .

Lastly, you can also plot the portfolio simulations for a specific annual withdrawal rate. Let’s plot the simulations for an annual withdrawal rate of 8% based on the portfolio composition and payout period described above. You can use the following code to plot the simulations:

annual_withdrawal = 0.08

port.plotsimulations(annual_withdrawal)

Running this code should results in the following plot in your webbrowser: