
How to exploit the month-end flow effect for a 502% return
Fund managers report their holdings every month. They don't want to tell investors that they lost money the latest meme stock. So they will sell the meme stocks and buy higher quality assets, like bonds.
We might be able to take advantage of this month-end flow effect by buying bonds toward the end of the month and selling them at the beginning.
The month-end flow effect is one of many strategies we explore in my top selling cohort based course, Getting Started With Python for Quant Finance.
In today’s newsletter, you’ll explore a strategy that achieves a Sharpe ratio of 1.1 over 10 years. The strategy is based on the hypothesis that fund managers rotate in and out of low quality asses over time.
Let’s go!
How to exploit the month-end flow effect for a 502% return
VectorBT provides a comprehensive suite of tools for every stage of an algorithmic trading workflow.
This includes data acquisition, signal generation, portfolio optimization, strategy simulation, hyperparameter tuning, and cross-validation.
These modular components empower users to customize their analysis. We’ll use VectorBT to backtest the month-end flow effect strategy.
Let’s dive in!
Imports and set up
We’re going to use the ETF TLT as a proxy for bonds. We’ll use VectorBT to get 10 years of data in 1 line of code. But first the imports.
VectorBT has a built in data downloader. We’ll download the data and grab the closing prices.
Build the trading signals
VectorBT has a few utilities that create DataFrames to store entry and ext signals.
This code creates pandas Series of the same shape as the Series with our closing prices. Next we’ll generate the trading signals based on the day of the month.
We expect there to be positive returns, on average, toward the end of the month. We expect this because we think fund managers are buying TLT toward to the end of the month. Similarly, we expect to see negative returns, on average, toward the beginning of the month. Fund managers dump their high quality assets and go back to buying meme stocks.
Here, we get short the first trading day of every month and buy back the position after five trading days. We then get long seven days before the end of the month and exit the position on the last trading day of the month.
Run the backtest
VectorBT makes it simple to run sophisticated backtests. Here we assume trades at the closing prices. Once we run the backtest, we get a nice summary of the results.
We pass in the closing prices, long entries and exits, short entries and short exits.
The results are promising. Over 5,060 trading days, the strategy trades 483 times. It has total returns of 502% compared to a buy and hold of TLT with a 112% return. The strategy has a reasonable max drawdown of 21%, a win rate of 59%, and Sharpe ratio of 1.1.
Next steps
VectorBT makes it easy to optimize strategies in a rigorous way using walk forward optimization. As a next step, try altering the day of the month for the entries and exists. You’ll want to avoid overfitting so you can run a walk forward optimization to make sure the out of sample results are statistically signifiant.