A Dead Simple 2-Asset Portfolio that Crushes the S&P500 (Part 3)

BlackArbs Admin
A Dead Simple 2-Asset Portfolio that Crushes the S&P500 (Part 3)

Recap

This is an update to the original blog series that explored a simple strategy of being long UPRO and TMF in equal weight, inverse volatility and inverse-inverse volatility. This strategy crushed the cumulative and risk-adjusted returns of the benchmark SPY etf. However through our research we determined that this strategy is heavily dependent on the correlation between the two assets. This strategy works best when correlations are positive and prices are trending positively, however, theoretically it is most stable when correlations are negative. Previously we determined the strategy is most exposed when correlations are positive or rising and prices are declining. The problem is that we don’t know ex-ante if, during periods of increasing correlations, prices will trend up or down, which exposes our capital to large risks. In the past I eluded to a potential workable solution to this issue. In this blog post and associated materials we will explore some potential solutions to this problem.

Outline

  • Introduction
  • Setup
  • Correlations
  • Strategy Goals
  • Prototype Strategies
  • Results
  • Conclusions
  • Future Work
  • References

Introduction

In the first portion of this experiment, we will rehash the previous analysis of conditional returns based on correlation, this time using a higher quality dataset resampled from a 1 minute resolution. We will also explore conditional returns based on the information theoretic measure of Mutual Information. The benefit of mutual information is that it is designed to detect linear and non-linear relationships. The values are between 0 and 1 with a relatively simplified interpretation that 0 means no relationship (or no shared information between random variables), while a 1 means a perfect relationship (or total information shared between random variables). Note that this is a more generalized metric than correlation, which only captures linear dependency.

From there we will setup the benchmark, determine our strategy goals, and potential improvements. We will evaluate the prototype strategies using Pyfolio and ffn modules to get a quick understanding if any of our adjustments have improved the strategy. If these updates show promise then we will move forward with a more comprehensive implementation within the Quantconnect platform.

Setup

This analysis was run in a Jupyter notebook. What follows is are my imports. Please note that some functions and tools are stored within a local project package. If the functions they import are required I will reproduce them here or attach a python file that contains the code for the functions. Also note not all the imports are required. For example, I import a package called modin.pandas which is made to replicate the original pandas yet use multiprocessing in the backend. For those who prefer to use the regular version of pandas that will work too. Also I use the package gcmi for the mutual information calculations. See the link for instructions on how to install and use the package.

I split these imports into 2 blocks because I also use an extension called nb_black which is an automatic code formatter which will make your code look clean and easier to interpret.

 Package Import versions

Package Import versions

The data set is 1 min trade data from tradestation (no affiliation). I cannot share this data due to the terms of use but it is easy and simple to get access to a lot of data from tradestation and I don’t think they have any account minimums. One thing is their platform only works for Windows, so if you have linux you will have to use a virtual box to run it.

Get Data

RESAMPLE

 EXAMPLE OF RESAMPLED DATA.

EXAMPLE OF RESAMPLED DATA.

 resampled price series.

resampled price series.

LOG RETURNS

CORRELATIONS

MUTUAL INFORMATION

We can see that there is a seemingly inverse relationship between the correlation and mutual information in this particular case.

returns given average correlation is decreasing

UPRO appears to have stable increasing returns when average correlation is decreasing (correlation moving towards to zero). TMF underperforms with a decreasing trend over time.

RETURNS GIVEN MUTUAL INFORMATION IS DECREASING

When the mutual Information of the two assets is declining it appears as if both assets and the Index trend upwards.

RETURNS GIVEN AVERAGE CORRELATION INCREASING

We see TMF outperform when average correlation is increasing (becoming more negative, and in rare cases, increasingly positive). Overall returns from the Index trend higher compared to the decreasing state, almost doubling the cumulative return.

RETURNS GIVEN MUTUAL INFORMATION IS INCREASING

When mutual information is increasing UPRO is very strong while TMF is mostly negative but there is 20% difference between the performance of the Index between the two states. When M.I. is decreasing, the cumulative sum is 0.99 compared to 0.82. However I don’t know if anything economically significant can be drawn from this distinction.

NOTE:

I ran this analysis on multiple resampled resolutions including 10 minute, 30 minute, 1 hour, 2 hour, 4 hour and daily. The results were mostly similar across all resolutions except for the 1 hour. For some reason, that particular resolution, all the results were inverted in terms of performance. It is a strange phenomenon but I would like readers to be aware of these peculiarities when working with resampled data.

Strategy Goals

As we will see below the original UPRO + TMF returns over 1000% over the backtest period. Even the risk-adjusted metrics are solid given the simplicity of the strategy. However, my issues with the strategy are the drawdown depth, and length of drawdowns. My personal preference is a strategy that is lower volatility, low drawdowns and shorter drawdown periods.

Thus the goals to improve the strategy are to reduce drawdowns to below 15% or less but really 10% is ideal. Preferably we can get max drawdown durations to less than 6 months, and positive returns each year for the backtest period. Ideally we can try to achieve this with minimal data-mining or optimization.

The reason for the focus on drawdown versus total returns is that realistically it will be hard to stay invested in a algorithmic strategy with a drawdown of 20% of invested equity for 10 months.

Prototype Strategies

Below we'll be evaluating some prototype strategies to see if we can improve on the `risk-adjusted` performance of the benchmark UPRO-TMF Equal weight strategy. To do this we will be using pyfolio and ffn packages to evaluate relevant metrics. Note that for some reason pyfolio is not computing the correct performance metrics even though the plot displays seem to be correct. This is also why we will use ffn for comparison.

NOTE

The following analysis does not incorporate transaction costs like commissions, slippage, or price impact. The purpose is to evaluate prototype strategies to understand which, if any, strategies are worth exploring further using more a more realistic backtest environment.

BENCHMARK

First up is the benchmark version which is equal weight UPRO and TMF.

 All returns hypothetical and simulated. past performance does not necessarily predict future performance.

All returns hypothetical and simulated. past performance does not necessarily predict future performance.

EQUAL RISK CONTRIBUTION

 All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

MOMERSION FILTER

This implements a custom indicator developed by the author Michael Harris. It is a measure meant to capture the amount of trendiness or mean reversion of a return series. Values less than 50 indicate more mean reversion vs values over 50 indicating more trending.

EQUAL WEIGHT + MOMERSION LESS THAN 50

 All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

EQUAL WEIGHT + MOMERSION GREATER THAN 50

 All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

ERC + MOMERSION LESS THAN 50

 All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

erc + momersion greater than 50

 All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

MOMERSION CROSSOVER

EQUAL WEIGHT + MOMERSION CROSSOVER FAST LESS THAN SLOW

 All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

EQUAL WEIGHT + MOMERSION FAST GREATER THAN SLOW

 All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

ERC + MOMERSION FAST LESS THAN SLOW

 All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

ERC + MOMERSION FAST GREATER THAN SLOW

 All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

MARKET MEANNESS INDEX

This is an indicator developed by the Financial Hacker with the intent to help distinguish when a market is moving into or out of trend. According to the author:

Trend itself is trending

EQUAL WEIGHT + MMI CROSSOVER

EQUAL WEIGHT + MMI FAST GREATER THAN SLOW

 All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

EQUAL WEIGHT + MMI FAST LESS THAN SLOW

 All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

equal risk contribution + mmi crossover

erc + mmi fast less than slow

 All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

ERC + MMI FAST GREATER THAN SLOW

 All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

RESULTS

Now we will evaluate the strategy prototypes comparatively and see which strategies, if any, meet our stated strategy goals.

 All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

COMMON SENSE RATIO

This ratio was developed by Laurent Bernut. It is the tail ratio * gain to pain ratio. A value greater than 1 implies the strategy has potential to be tradeable.

 All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

Most prototype strategies meet the minimum of a common sense ratio greater than 1 over the period.

CALMAR

 All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

Looking at the calmar ratio we see more differentiation with only 6 strategies making the cut of a value of greater than 1.

MAX DRAWDOWN

Only one strategy appears to meet the max drawdown goal of being “less” than 15%.

AVERAGE OF WORST 5 DRAWDOWNS VS AVERAGE OF 5 WORST DRAWDOWN DURATIONS

 All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

All strategies fail the drawdown duration of less than 6 months or ~120 days. This is somewhat conservative however, because we are only considering the average drawdown duration of the 5 worst drawdowns. A few strategies manage to have an average drawdown better than 15% though.

max drawdown vs common sense ratio

 All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

Only one of the strategies beat the 15% drawdown, so we extend the threshold to better than 20% and we see that there are a few more strategies that fall in the upper right area that may be worth implementing.

MAX DRAWDOWN VS CALMAR

 All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

All returns hypothetical and simulated. Past performance does not necessarily predict future performance.

Again the separation for viable strategies is greater when using Calmar as the delineator.

CONCLUSION

There are a couple of strategies that appear to meet some of the more critical goals. In this analysis it appears that using momersion as a trade filter proxy is helpful to improving the risk-adjusted metrics of the prototype strategies. However, in the interest of transparency this particular part of the analysis changes based on the resolution of the resampled data. In some cases MMI was the better trade filter.

FUTURE WORK

If you read this far and are interested in more content like this, in the next installment of this series we will be evaluating these strategies in a more comprehensive framework using the Quantconnect platform, which will be provide results that are more realistic than what is shown here, in that we can estimate transaction costs, and slippage, although price impact from interacting with the limit order book is still an unknown. That content will likely be available as premium content to those who wish to support the work, with discounts offered to the newsletter subscribers.

REFERENCES

  1. Exploring the Relationship Between SPY and TLT by blackarbsceo
  2. Price Action Lab by Michael Harris - Momersion
  3. Market Meanness Index by Financial Hacker - Market Meanness Index
  4. Common Sense Ratio - Laurent Bernut

Enjoyed this post?

Subscribe for more research and trading insights.

By clicking "Subscribe," you agree to our Terms of Use and acknowledge our Privacy Policy. You can unsubscribe at any time.

No spam. Unsubscribe anytime.