Refinements to Hedgefundie's excellent approach

Discuss all general (i.e. non-personal) investing questions and issues, investing news, and theory.
Kbg
Posts: 353
Joined: Thu Mar 23, 2017 11:33 am

Re: Refinements to Hedgefundie's excellent approach

Post by Kbg »

Two words…fat tails.

There is a lot of moving parts with any properly developed TA based strategy and if you capture all of the aspects and model them properly, good luck on finding anything that actually works.

With RSI you are exploiting return to mean tendencies and that generally works well except for a severe bear market. The other, and probably larger issue, is cash management. Unless you are taking on margin these types of strategies require a cash reserve which is a performance hit when not employed.

And a final observation…anything optimal in terms of trigger values is unstable…guaranteed.

If you are thinking about a rtm strategy, perform a percentile analysis of all market drawdowns and then just pick a percentile level or levels to buy (I.e. down x percent associated with the percentile of choice) based on your analysis. You can also determine generally how long drawdowns take to occur and to recover. If you do this you may be quite surprised at what you find. Of course this lends itself to buying based on standard deviation.

And a nice side benefit, you learn a lot about market behavior that is unfiltered by opinion.
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

perplexed wrote: Sun Aug 07, 2022 3:55 pm Is there a way I can replicate your data? Your analysis has been always very insightful and data driven, and I read your posts with a lot of interest.
I use finance.yahoo.com for my primary data source. I use the adjusted close value to account for splits and dividends (essentially assuming that dividends are immediately reinvested). For trading, I use a strategy of randomly sampling between the open/high/low/close values, scaled to match the adjusted close.

When I first started, I simply downloaded the historical data manually. That works okay as a one-shot deal for a few tickers, but it gets awkward for repeated acquisitions, and it doesn't always download the entire sequence.

Now I use a matlab routine (getMarketDataViaYahoo, you can search for it with google if interested) to download the sequence automatically for something like 150 tickers. I don't regularly use many of them, but I've added them one by one as I've checked things that people have brought up or identified funds of interest. Many of the 1x tickers are used to provide synthetic LETF sequences prior to the actual LETF inception, using the methods in the Simba thread; these are probably optimistic with respect to expenses.

I use google sheets to acquire VIX-related data. I ended up buying synthetic data to extend the sequences earlier. I played with these data for a while, but never got anything to come of it. I still update the data weekly for completeness.

I also use google sheets to skim economic data and interest rates from the FRED site and transfer to an Excel spreadsheet for safekeeping. I use the interest rates to make the synthetic part of the LETF sequences.

I go through this acquisition sequence on Saturday morning, maybe during the week once as well. The transfer from google sheets to excel is by hand, otherwise everything else is automated. By the time I'm done, I have a 50-MB matlab binary file.

I'll note that yahoo data had glitches once or twice, where some of the tickers apparently were incorrectly updated internal to yahoo. The issues resolved themselves after a few days, but I recommend periodically archiving the dataset so that there is a basis for comparison if some issue pops up.

Hope that helps.
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

Kbg wrote: Sun Aug 07, 2022 7:52 pm Two words…fat tails.

There is a lot of moving parts with any properly developed TA based strategy and if you capture all of the aspects and model them properly, good luck on finding anything that actually works.

With RSI you are exploiting return to mean tendencies and that generally works well except for a severe bear market. The other, and probably larger issue, is cash management. Unless you are taking on margin these types of strategies require a cash reserve which is a performance hit when not employed.

And a final observation…anything optimal in terms of trigger values is unstable…guaranteed.

If you are thinking about a rtm strategy, perform a percentile analysis of all market drawdowns and then just pick a percentile level or levels to buy (I.e. down x percent associated with the percentile of choice) based on your analysis. You can also determine generally how long drawdowns take to occur and to recover. If you do this you may be quite surprised at what you find. Of course this lends itself to buying based on standard deviation.

And a nice side benefit, you learn a lot about market behavior that is unfiltered by opinion.
I endorse these thoughts.
Professoro
Posts: 55
Joined: Sat Oct 09, 2021 8:29 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Professoro »

Hydromod wrote: Sun Aug 07, 2022 1:53 pm I ran across a short-term trading strategy that a redditor published recently. The core of the idea was to have a boring and sedate portfolio (equal weight SPY/XLP/SHY), but to use mean reversion ideas to temporarily deviate to leveraged funds when the market is sufficiently oversold (SPXL or TECL) or overbought (UVXY) using a 10-day relative strength index (RSI) for signals.

The strategy was developed using the composer site, which makes its money by providing automated trading using algorithms that the user can develop with their tool set.

The composer site calculated that the strategy would return >85% annual returns from January 2016 to present, using daily checks for the conditionals. The site doesn't provide a log scale for the strategy performance, so it is extremely difficult to understand where performance is coming from, but the strategy has very noticeable stair steps with up to 50% portfolio gain in a few days.

I found this a bit unbelievable, so I did a very simple test case of UUP unless the 10-day RSI for QQQ was >79%. The RSI is basically (sum of gainers) / (sum of gainers + sum of |losers|), where the gainers and losers are daily returns. I used VIXY when the trigger was on.

I could not reproduce the site values, or even the daily allocations provided by the site, using independent calculations. Comparing the allocations provided by the site with my independent RSI values, it seemed that the site was missing a substantial fraction of the days that I calculated as exceeding the trigger value. Even with the reported allocations, I calculated much smaller portfolio returns. I sent an email notifying them of the issue, but as of now I'd be very cautious about relying on algorithms developed with the site.
Any result on a Composer portfolio that involves frequent trades especially with very volatile assets such as UVXY will be significantly inaccurate. Composer connects to Alpaca end executes the trades at 3 pm ET. However, when it calculates the result of the daily profit/loss, it uses the opening and closing prices for the day.

e.g. If your portfolio switches to UVXY on June 13, 2022. You may think that you had a handsome profit for the day: open: 16.61 and close at 17.80. It will show a 7% profit for the day. However, your trade will execute late afternoon and you will end up losing money the next day on June 14 open at 17.58 and close at 16.98. A loss of 3.4% instead of any profits. If you look at your composer results however, it will show it as a profit and this is for a single day. Over the course of months and years, it could be off 10s and even 100s of percentage points. I would not trust results such as 15000% cumulative gain with a Sharpe ratio of 1.8 over six years (I just put together one symphony using SOXL and UVXY that has this result).
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

Professoro wrote: Mon Aug 08, 2022 3:27 pm Any result on a Composer portfolio that involves frequent trades especially with very volatile assets such as UVXY will be significantly inaccurate. Composer connects to Alpaca end executes the trades at 3 pm ET. However, when it calculates the result of the daily profit/loss, it uses the opening and closing prices for the day.

e.g. If your portfolio switches to UVXY on June 13, 2022. You may think that you had a handsome profit for the day: open: 16.61 and close at 17.80. It will show a 7% profit for the day. However, your trade will execute late afternoon and you will end up losing money the next day on June 14 open at 17.58 and close at 16.98. A loss of 3.4% instead of any profits. If you look at your composer results however, it will show it as a profit and this is for a single day. Over the course of months and years, it could be off 10s and even 100s of percentage points. I would not trust results such as 15000% cumulative gain with a Sharpe ratio of 1.8 over six years (I just put together one symphony using SOXL and UVXY that has this result).
That's very good to know and explains part of the problem. I gave composer a spreadsheet documenting my issues and hopefully they are grinding on it. I applaud you for figuring out this particular issue, it's subtle.

It occurred to me that one way to do this swing trading would be using margin to tactically buy VIXY or UVXY. Can't do a whole lot unless most of the portfolio is unlevered, though. Again, not something I am advocating, it's for the intellectual interest for me.
Professoro
Posts: 55
Joined: Sat Oct 09, 2021 8:29 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Professoro »

Hydromod wrote: Mon Aug 08, 2022 3:39 pm
Professoro wrote: Mon Aug 08, 2022 3:27 pm Any result on a Composer portfolio that involves frequent trades especially with very volatile assets such as UVXY will be significantly inaccurate. Composer connects to Alpaca end executes the trades at 3 pm ET. However, when it calculates the result of the daily profit/loss, it uses the opening and closing prices for the day.

e.g. If your portfolio switches to UVXY on June 13, 2022. You may think that you had a handsome profit for the day: open: 16.61 and close at 17.80. It will show a 7% profit for the day. However, your trade will execute late afternoon and you will end up losing money the next day on June 14 open at 17.58 and close at 16.98. A loss of 3.4% instead of any profits. If you look at your composer results however, it will show it as a profit and this is for a single day. Over the course of months and years, it could be off 10s and even 100s of percentage points. I would not trust results such as 15000% cumulative gain with a Sharpe ratio of 1.8 over six years (I just put together one symphony using SOXL and UVXY that has this result).
That's very good to know and explains part of the problem. I gave composer a spreadsheet documenting my issues and hopefully they are grinding on it. I applaud you for figuring out this particular issue, it's subtle.

It occurred to me that one way to do this swing trading would be using margin to tactically buy VIXY or UVXY. Can't do a whole lot unless most of the portfolio is unlevered, though. Again, not something I am advocating, it's for the intellectual interest for me.
Let me know if you hear back from Composer. I have a small test account with them with real money at Alpaca. I did not hear back when I contacted them before.

Most brokerage firms would not let purchase of volatility funds using margin for good reason. M1 only allows VIXY with 75% maintenance requirement.
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

Professoro wrote: Mon Aug 08, 2022 3:48 pm Let me know if you hear back from Composer. I have a small test account with them with real money at Alpaca. I did not hear back when I contacted them before.

Most brokerage firms would not let purchase of volatility funds using margin for good reason. M1 only allows VIXY with 75% maintenance requirement.
I'll update with any response.

And it's also good to know about margin and volatility funds. I've never looked into margin, I'm pretty naive that way.
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

I got back a reply from composer. They were nice enough to modify the spreadsheet that I gave them to show what they were doing.

Indeed it seems like composer is implementing the RSI according to the definition. My main mistake was to omit a smoothing step. Usually the values are fairly similar, but occasionally they are quite far apart (e.g., a difference of 25 in a 0 to 100 range).

There's another little subtlety, insofar as the RSI definition is using returns in dollars while I was using returns as a relative change. This usually has a negligible effect.

Now that I use the consistent result, the VIXY trigger is doing much better, especially starting in 2018. It seems that a threshold value between 70 and 74, with RSI based on SPY, does especially well in a fairly consistent way. A threshold value between 76 and 80, with RSI based on QQQ, seems to do even a bit better.
perplexed
Posts: 76
Joined: Thu Feb 02, 2012 3:32 pm

Re: Refinements to Hedgefundie's excellent approach

Post by perplexed »

Interesting observation about vixy role and correct levels for RSI. I simulated a bit of these, and found vixy to give sudden leaps in net asset. I will check with your lower RSI for SPY when simulating with UPRO. Getting in and out at the right time vixy/inverse (SQQQ) is critical looks like. What are your thoughts on how well it is doing with inverse funds entry/exit?
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

perplexed wrote: Fri Aug 12, 2022 4:56 pm Interesting observation about vixy role and correct levels for RSI. I simulated a bit of these, and found vixy to give sudden leaps in net asset. I will check with your lower RSI for SPY when simulating with UPRO. Getting in and out at the right time vixy/inverse (SQQQ) is critical looks like. What are your thoughts on how well it is doing with inverse funds entry/exit?
I haven't had a chance to do any systematic checking on this. I started looking at a more complex algorithm in composer that was TQQQ most of the time, with shots of UVXY, SOXL, TECL, and either BSV or SQQQ. Most of the signals were RSI-based, except for some moving-average trends for TQQQ. It used a signal to enter TQQQ if RSI < 36 or so; if I used this for a SQQQ sequence, it very strongly cut the long-term SQQQ losses. The complex algorithm gets into a mode to select between BSV and SQQQ just based on TQQQ signals, but it uses RSI to select BSV or SQQQ (not a lot of events over the test period). I will say composer-calculated returns were unbelievable.

I'm going to try to understand this a little more systematically, it seems like the statistics are pretty good even though there aren't an overwhelming number of test cases.

It's interesting that switching between TQQQ and UVXY gives better returns combined than separate. It looks like TQQQ tends to lose over the duration of the RSI signal, so swapping one for the other gives a bit of an extra boost by avoiding a loss.
perplexed
Posts: 76
Joined: Thu Feb 02, 2012 3:32 pm

Re: Refinements to Hedgefundie's excellent approach

Post by perplexed »

Hydromod wrote: Mon Aug 08, 2022 10:00 pm I got back a reply from composer. They were nice enough to modify the spreadsheet that I gave them to show what they were doing.

Indeed it seems like composer is implementing the RSI according to the definition. My main mistake was to omit a smoothing step. Usually the values are fairly similar, but occasionally they are quite far apart (e.g., a difference of 25 in a 0 to 100 range).

There's another little subtlety, insofar as the RSI definition is using returns in dollars while I was using returns as a relative change. This usually has a negligible effect.

Now that I use the consistent result, the VIXY trigger is doing much better, especially starting in 2018. It seems that a threshold value between 70 and 74, with RSI based on SPY, does especially well in a fairly consistent way. A threshold value between 76 and 80, with RSI based on QQQ, seems to do even a bit better.
If I may ask, what did you use to exit out of vixy/uvxy?
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

perplexed wrote: Sat Aug 13, 2022 12:05 pm
Hydromod wrote: Mon Aug 08, 2022 10:00 pm Now that I use the consistent result, the VIXY trigger is doing much better, especially starting in 2018. It seems that a threshold value between 70 and 74, with RSI based on SPY, does especially well in a fairly consistent way. A threshold value between 76 and 80, with RSI based on QQQ, seems to do even a bit better.
If I may ask, what did you use to exit out of vixy/uvxy?
So far I've only looked at using the same threshold for entry and exit. I'm curious as to whether there might be some benefit to using a different threshold, which I haven't tested. I do see that waiting just one day after the threshold is crossed substantially drops the returns, so I'm a little dubious that a lower threshold for exit will be the way to go.
perplexed
Posts: 76
Joined: Thu Feb 02, 2012 3:32 pm

Re: Refinements to Hedgefundie's excellent approach

Post by perplexed »

Got it. Looking at the charts, it looks like it is approaching/already_there (?) a time to hold vixy/uvxy.
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

perplexed wrote: Sat Aug 13, 2022 4:12 pm Got it. Looking at the charts, it looks like it is approaching/already_there (?) a time to hold vixy/uvxy.
I obtained some simulated VIXY and UVXY back to 2004 (https://sixfigureinvesting.com/2014/09/ ... -xiv-svxy/); the simulated UVXY has the same 1.5 leverage as the current UVXY.

If I'm splicing correctly, the inference that the TQQQ threshold should be between 78 and 81 still holds. There wasn't much action prior to the mid 2010s at those levels, but much lower than 76 and the signal was pretty unstable until 2012. Since then, the effect seems to be growing exponentially(!). It feels like some AIs are grinning and cackling maniacally off in a corner someplace...

It looks like a bit more to run before the signal, RSI10(TQQQ) is ~71 right now. The trends suggest maybe another week or so to get to 80.

My momentum flags have dropped all of my safe assets this week. Another cautionary sign, maybe.
perplexed
Posts: 76
Joined: Thu Feb 02, 2012 3:32 pm

Re: Refinements to Hedgefundie's excellent approach

Post by perplexed »

I used yfinance python package to get vixy data. It goes back to 2733 trading days (12ish years?).

Using a 10 day lookahead, and a threshold of 100% gains in uvxy, I am yet to see a consistent pattern using RSI , SMA 200, SMA 50. Of course, this is hot of the press code, so easily possible that it is bug infested. There are indeed a few instances where RSI are above 70 in 4 etfs I am considering (SPY, QQQ, UPRO and TQQQ), but there are many others where RSI values are well below. I have not yet analyzed false positives yet (i.e., when RSI was over 75+ and there was no jump in UVXY). A lower jump (50% say instead of 100%) furthers muddies the water.

Will love to hear more as you analyze ..
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

Are you using RSI of TQQQ as your trigger for VIXY? That seems to have been the magic sauce.

I'm just now breaking down trade by trade to see how it behaves. Looks like huge moves can occur with the trigger, both up and down.
perplexed
Posts: 76
Joined: Thu Feb 02, 2012 3:32 pm

Re: Refinements to Hedgefundie's excellent approach

Post by perplexed »

I was checking RSI of all four etfs: SPY, QQQ, UPRO and TQQQ. Could not find anything really solid indicator among those uvxy jumps. Some time large jumps happenned even with RSI in mid 50s or lower. Perhaps brought on by some major events (?)

I will do a bit more check up tomorrow to understand. In the composer algo you shared from reddit, I did backtest that some and found UVXY giving solid gains (with a few not much gain, and on rare occasion large loss). I have been also doing some rolling return simulation for that, and will happily share my results if you are interested. It may be good to cross-validate some data :-)
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

perplexed wrote: Sun Aug 14, 2022 4:01 pm I was checking RSI of all four etfs: SPY, QQQ, UPRO and TQQQ. Could not find anything really solid indicator among those uvxy jumps. Some time large jumps happenned even with RSI in mid 50s or lower. Perhaps brought on by some major events (?)

My impression is that jumps based on UVXY stats are not easily predictable. This algorithm is targeting the fairly rare condition that does appear to be predictable.

I will do a bit more check up tomorrow to understand. In the composer algo you shared from reddit, I did backtest that some and found UVXY giving solid gains (with a few not much gain, and on rare occasion large loss). I have been also doing some rolling return simulation for that, and will happily share my results if you are interested. It may be good to cross-validate some data :-)
I'm doing calculations in Matlab and saving the steps in Excel to check.

In order to compare consistently, my first cut checks the trigger every day at the end-of-day value.

When the trigger flips on, the trade is made at the next end-of-day price, and returns are accumulated based on close-to-close prices starting at the trade (e.g., the first return that counts is from end-of-day T+1 to end-of-day T+2, where T is the day with the trigger flipping on at end of day.

A similar approach is taken once the trigger flips off (i.e., the trade is made at the end of the day following the trigger flipping off, so returns accumulate until end-of-day T+1).

I get an increase in TQQQ CAGR between 6 and 9% from 2004 to present with VIXY replacement at various thresholds (i.e., 41.6% increasing to a max of 50.8%).

This is probably not the best approach; ideally one would (i) use the signal near the end of the day and make the trade the same day, or (ii) make the trade at the open the next day. The signal based on high/low for the day might be a decent surrogate trigger for late-day trading.

If one could trade at the close on the same day as the signal, I calculate peak CAGR over the same period of roughly 59 to 61%. So a huge improvement. I need more coding to test the trade-at-open case, but I expect that it would be somewhere between.

It doesn't look like it makes much of a difference whether you use the same threshold for on and off or use a different threshold, as long as they aren't too different. I get degradation if the off signal is 0.1 less than the on signal, but essentially the same if the off signal is 0.05 higher or lower than the on signal.

A quick check suggests that TMF returns only mildly increase if they are replaced with VIXY, because they tend to have positive returns while the signal is on.

A quick check suggests that next-day-switch returns are bumped by a few percent using UVXY instead of VIXY and same-day-switch returns are bumped by roughly an additional 10% using UVXY instead of VIXY.

All this is subject to more verification, but my inspection of the switching in the output Excel file seems to be done according to the logic I expect.
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

The figure below considers two cases where TQQQ is temporarily replaced by UVXY when the RSI(10) for TQQQ exceeds a threshold value c. The trade on signal (replace TQQQ with UVXY) occurs when RSI(10) matches or exceeds the threshold value, and the trade off signal (replace UVXY with TQQQ) occurs when RSI(10) returns below the threshold value. For these calculations, the signal and the trades are made with end-of-day values and trading expenses are neglected.

Two trading options are shown: (i) trading occurs on the day that the signal is reached (left column), and (ii) trading occurs the day after the signal occurs. An intermediate option might be to trade at open on the day after the signal is reached, which would likely be intermediate between the two.

The top row in the figure gives the cumulative distribution of returns for the individual events. The vertical bars at the bottom axis show the mean event return. The event return is the return of UVXY between the pair of trades minus the return of TQQQ over the same period. The lines are labeled with (i) the cutoff RSI(10), (ii) the change in CAGR for the TQQQ sequence from 2004 to present with replacement minus the CAGR without replacement, and (iii) the number of events. There's a bit of tradeoff between the number of events (fewer events as the cutoff increases) and the average return per event (smaller average return as the cutoff decreases).

The bottom row in the figure is a tell-tale plot, which is the ratio of cumulative return for the sequence with replacement to the sequence without replacement. The color coding is the same in both plots.

The canary is the asset used for the RSI signal. For some reason, TQQQ and QLD seem to be just a hair better than QQQ, and all three are noticeably better than the NASDAQ price index. The comparable S&P 500 assets do not perform as well as the NASDAQ assets.

The raw asset is the asset that is replaced, and the replace asset is the volatility asset doing the replacement.

Image

I interpret these results as suggesting that
  • It's important to be ready to trade; UVXY will spike and drop quickly. RSI(10) also tends to drop very quickly.
  • Using a cutoff value of 80 or larger would have been fairly consistently profitable
  • UVXY becomes increasingly random as the further that the cutoff value is below 78 and the longer the delay between signal and trade
  • The period between 2014 and 2022 was especially good for the strategy (sort of flattish bull market)
  • The best opportunities flash for a few days, on average two to three times a year
I tried several other assets as the raw asset. Equities tend to do best, followed by low-volatility assets, followed by treasuries. Equities tend to dip over the replacement period, while treasuries tend to rise a little.

VIXY, as expected, performs about 2/3 as well as UVXY. Replacement with VIXY and no lag still tends to outperform TMF, but it may not be particularly attractive to replace TMF with VIXY once slippage costs and risks are accounted for.

In summary, this seems like something that is best if a bot is monitoring the daily behavior. I would be tempted to ramp up involvement in stages starting perhaps at an RSI of 78 and reaching a maximum involvement by an RSI of 82. The exit signal is less important because RSI drops very rapidly.

Hope this is interesting for folks.
bigblue1ca
Posts: 28
Joined: Sat Jul 17, 2021 8:09 am
Location: Canada

Re: Refinements to Hedgefundie's excellent approach

Post by bigblue1ca »

Hydromod wrote: Sun Aug 21, 2022 1:08 pm Hope this is interesting for folks.
Yes, thanks for the detailed analysis and your thoughts.

When I read about this on reddit, I did a rough excel test back to Nov 2011. It showed a ~10% CAGR with TQQQ as the trigger and ~7% for SPY as a trigger. I used the market close price for UVXY, as I assumed I did an after hours trade, which is usually pretty close to the close price if the trade is done within a few minutes of close.
perplexed
Posts: 76
Joined: Thu Feb 02, 2012 3:32 pm

Re: Refinements to Hedgefundie's excellent approach

Post by perplexed »

Hydromod wrote: Sun Aug 21, 2022 1:08 pm
Hope this is interesting for folks.
This is really interesting. I wanted to double check that you are using RSI signal only when the stock price is over SMA200?
perplexed
Posts: 76
Joined: Thu Feb 02, 2012 3:32 pm

Re: Refinements to Hedgefundie's excellent approach

Post by perplexed »

bigblue1ca wrote: Mon Aug 22, 2022 2:57 am
Hydromod wrote: Sun Aug 21, 2022 1:08 pm Hope this is interesting for folks.
Yes, thanks for the detailed analysis and your thoughts.

When I read about this on reddit, I did a rough excel test back to Nov 2011. It showed a ~10% CAGR with TQQQ as the trigger and ~7% for SPY as a trigger. I used the market close price for UVXY, as I assumed I did an after hours trade, which is usually pretty close to the close price if the trade is done within a few minutes of close.
That sounds orders of magnitude lower than what the composer site says, as well as, my back tests using python that use yfinance data (close price). Admittedly, there will be slippage etc, but I don't expect to make several orders of magnitude difference. Which data source did you use?

I am curious if Hydromod may please comment on CAGR he is seeing using his methods.
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

perplexed wrote: Tue Aug 23, 2022 9:46 am
bigblue1ca wrote: Mon Aug 22, 2022 2:57 am When I read about this on reddit, I did a rough excel test back to Nov 2011. It showed a ~10% CAGR with TQQQ as the trigger and ~7% for SPY as a trigger. I used the market close price for UVXY, as I assumed I did an after hours trade, which is usually pretty close to the close price if the trade is done within a few minutes of close.
That sounds orders of magnitude lower than what the composer site says, as well as, my back tests using python that use yfinance data (close price). Admittedly, there will be slippage etc, but I don't expect to make several orders of magnitude difference. Which data source did you use?

I am curious if Hydromod may please comment on CAGR he is seeing using his methods.
The figure above shows some CAGR values over the period from 2004 to present. The dC values represent the change in CAGR from TQQQ alone versus TQQQ with the short-term UVXY replacement (not accounting for slippage). The benefit is a bit less if one simply bought and sold UVXY with cash or treasuries.

The absolute best increase in returns was ~29% CAGR increase, assuming perfect trading at the close. That's unrealistically high IMO; a one-day delay gets to the 10% CAGR increase bigblue1ca reports. In my testing with SPY vs. QQQ, I also showed a similar fraction for reduction in returns with SPY.

I don't see anywhere near the composer returns, which imply that the strategy of just swapping TQQQ for UVXY generates additional 50% CAGR. I think there is something with how composer calculates returns; I seem to remember returns being calculated as open to close rather than close to close.
perplexed
Posts: 76
Joined: Thu Feb 02, 2012 3:32 pm

Re: Refinements to Hedgefundie's excellent approach

Post by perplexed »

Are you using "Close" price column? Composer also spits out a csv for your symphony, and just using that one can also verify their returns. I never get perfect agreement with theirs, but I do see pretty astonishing numbers nonetheless!

In my experiments, I get many orders higher than 10% CAGR, even for 5 year period. The actual CAGR varies a lot based on pricing model, RSI etc. For example, using 1/4th of daily sum of OHLC cuts the return substantially (crude way to look at slippage?). Specific RSI value has pretty strong dependence, especially when we look 1+ year in the past. I have also done some basic rolling returns (rolling window of 1 year) looking how a given investment period will vary if the starting date is not just 3 years ago for a 3 year return. Again variance is high, but even the minimum CAGR among all rolling returns are well over 10% when we look at a period that is 1+ year long. Unless we go 3+ year in period, drawdowns of all rolling returns seems to have a median around 30-35%, with max below 50%. Covid drawdown looks like about 50-55%, still decent imo. All of this is using TQQQ as the core. I have not done much experiments with UPRO or other. Other than UVXY, the algo also gets boost from getting into SQQQ and exiting soonish, looks like (but have not systematically analyzed this).
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

perplexed wrote: Tue Aug 23, 2022 11:18 am Are you using "Close" price column? Composer also spits out a csv for your symphony, and just using that one can also verify their returns. I never get perfect agreement with theirs, but I do see pretty astonishing numbers nonetheless!

In my experiments, I get many orders higher than 10% CAGR, even for 5 year period. The actual CAGR varies a lot based on pricing model, RSI etc. For example, using 1/4th of daily sum of OHLC cuts the return substantially (crude way to look at slippage?). Specific RSI value has pretty strong dependence, especially when we look 1+ year in the past. I have also done some basic rolling returns (rolling window of 1 year) looking how a given investment period will vary if the starting date is not just 3 years ago for a 3 year return. Again variance is high, but even the minimum CAGR among all rolling returns are well over 10% when we look at a period that is 1+ year long. Unless we go 3+ year in period, drawdowns of all rolling returns seems to have a median around 30-35%, with max below 50%. Covid drawdown looks like about 50-55%, still decent imo. All of this is using TQQQ as the core. I have not done much experiments with UPRO or other. Other than UVXY, the algo also gets boost from getting into SQQQ and exiting soonish, looks like (but have not systematically analyzed this).
I didn't see your original question about 200 SMA. No, I followed just the RSI trigger, no trend following.

I am using a separate implementation with yahoo finance downloads, using the adjusted close column to account for splits. I go back before 2011 with simulated TQQQ and UVXY.

I checked signals against the CSV output early on. I originally had significant discrepancies, but the composer folks clued me in on my mistake. Very small discrepancies remained, basically composer rounds RSI before checking.

Dunno about the return discrepancies. Seems like a big difference. You are talking about the difference between CAGR calculated with TQQQ+UVXY and TQQQ without UVXY, correct? As opposed to the overall CAGR with TQQQ+UVXY?
perplexed
Posts: 76
Joined: Thu Feb 02, 2012 3:32 pm

Re: Refinements to Hedgefundie's excellent approach

Post by perplexed »

My bad! I am talking about the reddit post based you shared few weeks ago (near the end of page 7). It is a composer algo . Its primary holding is TQQQ, but it switches to one in {UVXY, TECL, SOXL, SQQQ, BSV} based on a combination of RSI and SMA criteria. Here is the link in reddit: https://www.reddit.com/r/LETFs/comments ... _together/
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

That one has a couple of key strategies: (i) the UVXY replacement and (ii) the SQQQ replacement.

I think composer overstates the UVXY replacement by a considerable margin, even though it does seem credible as a strategy.

The SQQQ replacement component really blew things out of the water the last few years. I don't know how much is luck and how much is reasonable. But again I wouldn't be at all surprised if the composer returns are systematically overstated.

I'll have to try to figure out the discrepancy.

I've been just trying to understand one bit at a time to see if there is some statistical basis for taking the action. That's why I did just TQQQ and UVXY in composer and separately.
perplexed
Posts: 76
Joined: Thu Feb 02, 2012 3:32 pm

Re: Refinements to Hedgefundie's excellent approach

Post by perplexed »

Indeed there is luck! These are heuristic anyway, so what worked in the past may not work in the future. Standard disclaimer, I guess.

I have done some testing just using their daily position download from the CSV file. Then, I will seek the security price for each day (yfinance python). I found that when I use "Adjusted Close" as the transaction price (all buy and sell), it tracks pretty close to composer. By pretty close, I mean 10-20% difference at most.
However, when I use the average of (open, adj close, low, high), my code estimates substantially lower from composer (by more than an order of magnitude). Regardless, returns shown even then are super, with a capital S, LOL!
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

As we have come to the turn of a new year after a very difficult year, I thought that I'd share a few little tweaks that I've been working on since last spring.

Last year was a big eye-opener about the desirability to access diversified asset sets during adverse times while not overdoing the safety during the good times.

I had previously hit on a combination of lots of 3x equities balanced with TMF using a risk-budget minimum variance approach. Basically, I set a risk budget by class (equity, bond, etc.) then partition the class risk across the assets in the class. This way the overall equity risk budget is preserved regardless of how many equity assets are included. The risk budget for the equity class is set considerably higher than the risk budget for the bond class, emphasizing gains during the bear market and relying on heightened volatility to decrease the equity allocations during downturns. That approach would have worked very well up until 2015, and started to get a bit shakier after 2015.

2022 showed that this approach can be fragile. I got serious about thinking by May, after big drops.

I tried adding commodities to the mix. ERX (a 2x fund) helped, but PDBC (a 1x fund) has such low volatility relative to the 3x assets that it dominated the portfolio, greatly reducing volatility in downturns but trashing returns during good periods. I had previous found that GLD and UGL had a similar squelch effect.

The next step was to try to take advantage of momentum. It seems like a combination of 1- and 9-month momentum was a reasonable compromise over the last 25 years or so, with the 9-month momentum better for trending markets and the 1-month momentum better for choppy markets. The idea is to keep the assets with positive momentum (up to a limit of perhaps 75% of assets), and always keep at least a minimum fraction of assets (perhaps 25%) even if some have negative momentum. Low-volatility assets (e.g., DBC) are only included if their momentum is in the top 20% or so of assets, so that they serve as risk-off assets. For this purpose, I update allocations and rebalance on a weekly basis in my Roth account.

I added a little tweak where the recent momentum adjusts the asset risk budget within the class. That helped a little.

Then I came across the idea proposed by logical invest for a defensive rotation based on gold and currency ratios. I was intrigued by the observation that the dollar tends to strengthen during periods of crisis, similar to the flight-to-safety for treasuries. For US investors, there are the 1x UUP and UDN (dollar bull and bear relative to other currencies) and the 2x EUO/ULE (short/long Euro relative to USD) and the 2x YCS/YCL (short/long JPY relative to USD). UUP is 57% from USD/EUR. These have significant bid/ask spreads and fairly substantial ERs as well.

After fooling around with various combinations, it seems to me that YCS is the most appropriate for a long-only approach, because it has the largest volatility; opportunity cost increases with EUO and even more with UUP. The USD/JPY index tends to trend, so a YCS/YCL pair may be appropriate for a momentum-based approach. I include one of these currency index funds if it has combined momentum in the top 20% of all assets.

The following plots are a cross comparison using the identical relative risk budget allocations: equity (0.4), bond (0.1), and commodities (0.1). Two cases are included for the currency relative risk budget: 0.2 and 0.01. The actual risk budget allocation is normalized based on the included classes. For example, if just equities and bonds are considered, the risk budget is 0.8 to equities and 0.2 to bonds. If equities, bonds, and commodities are included, it's 0.667/0.167/0.167 to equities/bonds/commodities.

All cases start on the same day (prior to the 2008 crash), then reallocate and rebalance every five days. Trades occur with some random component between highs and lows for the trade day, and include slippage from current bid/ask spreads. Assets that were not in existence during some period of the back test are synthesized from 1x assets, accounting for leverage and ER.

The first case is the risk-budget minimum variance HFEA. Note that the minimum variance approach smoothed right over the 2008 crash, helped with the 2020 crash, but was unable to do much with 2023. Also note that the UPRO and TMF allocations bounced around quite a bit, albeit fairly smoothly. The Sharpe/sigma ratio (called gamma) is useful for comparing utility functions. For comparison, over this period SPY had a gamma of 3.4 and the Vanguard balanced index fund had a gamma of 5.6.

Image

Adding in YCS to the mix with a small risk budget reduces CAGR but improves volatility, Sharpe and gamma. The YCS addition is largely as a replacement for TMF.

Image

Adding in YCS to the mix with a large risk budget further reduces CAGR but improves volatility and gamma. Sharpe takes a bit of a hit because the hit to CAGR outweighs the improvement in volatility. Even so, gamma is a little better than the Vanguard balanced index fund with nearly three times the return over the same period.

Image

YCS was not as effective as TMF for buffering drops. Top: small YCS risk budget, bottom: large YCS risk budget.

Image

Image

Including PDBC and YCS also improved Sharpe and gamma relative to HFEA alone. Top: small YCS risk budget, bottom: large YCS risk budget.

Image

Image

With all of these insights, I'll present the momentum-based risk-budget minimum variance results over the same period. Top: small currency risk budget, bottom: large currency risk budget. This case allowed UUP as well, again if the momentum was in the top 20%. The larger risk budget for currencies actually improved overall performance slightly, because the momentum approach tended to cut out periods where the currency assets are drags on performance (same for PDBC). Even with all of the switching around, drawdowns were generally less than 40%.

Image

Image

Just food for thought.
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

A few thoughts on the momentum-based model.

The underlying philosophy is that the portfolio (i) uses a well-diversified set of assets, (ii) sets a risk allocation that is consistent over time, and (iii) closely adheres to the risk allocation.

The approach has stark differences to a buy-and-hold portfolio, in that it is interrogating market conditions on a very frequent basis and making statistically significant adjustments to allocations. With weekly updates, the strong assumption is that volatility and covariances established over the previous few months are likely to persist for the next week. The weak assumption is that trends established over the previous 1 and 9 months are likely to continue for the next week.

The strong assumption tends to cut the allocations to an asset when its volatility is large, and increase it when the volatility is small. Over time, the time-averaged allocation can be called w. Over time, one can calculate asset returns and volatility for a fixed allocation of w and for the time-varying allocation that has an average allocation of w. If recent volatility has very little correlation to future expected returns, which seems to be the case for most assets, then one would expect similar returns for the two approaches but the time-varying allocation should have lower average volatility. This means that risk-adjusted returns are improved, not actual returns.

Therefore, adjusting allocations purely based on recent volatility and covariances is a risk management strategy. It is only a fortuitous side effect that high market volatility in a time of crisis has historically been associated with a move to treasuries, which has boosted the adaptive portfolio performance in several historical crashes (but not in 2022, when the flight to safety effect was counteracted by increasing rates).

The weak assumption relies on momentum effects. IMO this has a much weaker statistical strength than the volatility clustering effect, which means that it needs many bets to get a statistical edge. There is a cost to trading, as well, so there would be expected to be a tradeoff between predictive capability and frequency of reallocation; too frequent, trading costs may overwhelm, and too infrequent, not enough bets to take advantage of the opportunity and weaker statistical behavior.

The last example in the previous entry may be a bit misleading, because it includes a very favorable environment for momentum following during 2009 through 2018, so returns are a bit gaudy. As they say, everyone is a genius during a bull market. The key bits to consider are what happens during the crashes and sideways markets.

For the last example above (reallocating and rebalancing every five days), I compiled some statistics on the different assets.

2008 through 2022 (15 years)
Image

The very impressive (at least to me) thing about this table is that the momentum-following approach very consistently resulted in the capture of increased returns (or smaller losses, in the case of YCL). Only CURE and UUP did worse than simple buy-and-hold at a fixed allocation. The trend following approach squeezed substantial returns from assets that had overall losses (ERX, EDC, and PDBC), some substantial.

The effective return statistics at the bottom of the table are quite interesting. For Asset CAGR, this represents the sum of time-averaged allocation times the asset CAGR over all assets. For the Asset CAGR while allocated, this represents the sum of (percent of time allocated) * (average allocation) * (asset CAGR while allocated). There is a rather substantial jump in effective return. The effective return is still less than the portfolio CAGR of 36% over the period, which implies that asset allocations tended to be larger during periods of larger returns. This may be in part because the asset allocations were adjusted to allow a greater risk budget for assets with larger momentum.

The last 8 years (2015 through 2022) were much tougher than the previous years, both overall (half of the assets with losses) and for momentum (3 assets performing worse with trend following than with constant allocation, and the net losses were worse). The momentum-following model returned roughly 24.7% during this period, down from 36% over the entire 15-yr period. A constant-allocation portfolio would have returned around 2.9% CAGR, a terrible return over 8 years. Again, asset returns were biased a bit towards periods with higher allocations.

The average allocation in the 8-yr period was 64.5% to LETF equities (!), almost identical to the full 15-yr period (65.8% to LETF equities). Over time, this is essentially a 2x portfolio in equities, ranging from 0x to 3x, which is accommodated by aggressive risk mitigation in adverse periods.

2015 through 2022 (8 years)
Image

It still seems remarkable that the trend-following approach was biased towards winners in the sideways period, with 15 of 18 adding value.

It seems like an obvious thing to make a few tweaks, but it's not necessarily so.

Presumably it would be beneficial to force CURE to always be active, instead of allowing momentum to determine inclusion. Interestingly, completely removing CURE would have dropped the 8-year portfolio CAGR from 23.1% to 21.6%, a very disproportionate response based on the very low returns and allocations that the momentum-following approach got from CURE. I don't have an explanation for the outsize response.

It would seem at first glance removing UUP and YCL would improve performance, although they were active so infrequently that any conclusions have a strong timing luck aspect and are likely quite sensitive to thresholds. The portfolio role for UUP, YCS, YCL, and PDBC (and to a lesser extent TYD) is to stem the loss tide with a relatively stable asset if everything else is performing poorly. Because of their low volatility, these funds tend to dominate the portfolio when they are present, greatly reducing the average portfolio leverage. For this role, it is acceptable to include assets that consistently incur small losses if the alternative is to incur larger losses. Including several options for this role allows variable allocations to low-volatility assets (a higher allocation to stable values occurs when 2 low-volatility assets are included than when 1 low-volatility asset is included).

For example, running the same 8-yr simulation with YCL removed actually performed a bit worse by forcing other assets to be included during declines. This resulted in decreased returns for 13 of 17 other assets.

I will make a final note regarding the rebalancing bonus. Weekly calculation of allocations with daily rebalancing to the allocation resulted in a CAGR of 25.6%, up from 23.1%, for the 8-yr period, even accounting for slippage from bid-ask spreads. I had a comparable percentage increase over the 15-yr period. Reallocating daily took CAGR to 15.9%, biweekly reallocation with daily rebalancing to 19.7%, and biweekly reallocation and rebalancing to 16.7%.

The 5-day reallocation/rebalance seems to have been a sweet spot, but there is quite likely some timing luck involved (this is a rather short period, after all) and there's no reason to think it will necessarily persist going forward.

It will definitely be interesting to see how this portfolio behaves going forward.
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

A little bit of subsequent thought.

I think that CURE is working a bit as a defensive asset. It tends to remain as the least worst equity asset when others are failing (I require a minimum number of assets at all times), so it takes the hit instead of other worse-performing equity assets. This is the case with this week's guess: CURE and UTSL have negative trends, but are included to make up my imposed requirement of a minimum number of active assets. So a very useful sacrifice, although perhaps a smaller minimum number of assets might be worthwhile.

The second point that seems appropriate is that a momentum-following approach requires many bets to take advantage of a small statistical significance, and at best there will be a slightly higher percentage of correct guesses relative to incorrect guesses. The proposed portfolio has 18 funds, with trend estimated weekly (52 guesses a year). The trend estimates usually don't change all that much from week to week, but over time errors can correct. That gives 936 bets per year or 9,360 bets per decade. Again, it should be emphasized that momentum-following component of the algorithm is intended as a bit of a goose to the risk-budget minimum-variance part of the algorithm, which does pretty well on its own.

A third point is that the momentum-following component is sensitive to threshold settings in downturns, plus switching in and out of assets causes significant portfolio volatility relative to simple risk-based minimum variance. I think the next thing to try is to use graduated inclusion. For example, have a higher threshold for incipient inclusion in the portfolio and a lower threshold for full inclusion in the portfolio. So PDBC might have full inclusion if its momentum is in the top 10% and incipient inclusion if its momentum is in the top 40%. A portfolio is first calculated using all assets passing the incipient inclusion threshold, then the allocation is scaled back for the assets between full and incipient inclusion, and a second portfolio is calculated with those assets held fixed at the scaled allocation. So PDBC would (i) have its full calculated weight w if momentum is <= 10% of all assets, (ii) have zero weight if momentum >= 40% of all assets, and (iii) scale between w and 0 if momentum is between these thresholds. I strongly suspect that this would be especially useful in taxable, because the allocation swings will be milder.

I suspect that would considerably reduce portfolio variability while still maintaining outperformance with respect to returns.
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

I think that I've pretty much settled on the approach that I will use in Roth going forward. This will be the trend-based risk-budget minimum variance approach I've been discussing.

The concept is to have two asset classes: (i) 3x/2x LETF equities and (ii) ballast. The risk balance between equities and ballast is 2/1 to 4/1.

The equities class includes TQQQ, SOXL, URTY, FAS, RETL, NAIL, LABU, CURE, UTSL, DFEN, UDOW, EDC, EURL, DRN, and ERX. I will add WANT and DUSL if M1 someday allows them to be used. Not all of these will be active at any particular time, because the trend following cuts out the ones with the worse momentum.

The ballast class includes TMF, TYD, YCS, and PDBC.

I use the long/short momentum value to modify the risk assigned to each asset, within a limited range. The range is set to include assets with mildly negative momentum and caps the value at a reasonable momentum value to avoid over-concentration. Assets with less than 3 percent allocation are not retained.

As a constraint, I require that the equities class never has more than 80 of the total allocation.

The evolution here is to consider equities/ballast as the two classes. I realized that the returns are going to be driven by 3x equity LETFs, and everything else that I was considering all were relatively low-volatility compared to the 3x LETFs, which makes ballast a more descriptive term. Could be store of value as well. These terms are relative to the 3x equities, not necessarily in general.

I ended up keeping TMF and TYD as the classic ballast terms. TYD can only enter the portfolio if it is in the top 45% of the relative momentum, however.

I added YCS and PDBC as two additional assets based on a bunch of back testing. I only allow these to enter the portfolio if they are one of the assets in the top group of relative momentum (top 20% for YCS, top 50% for PDBC), because otherwise they are a drag on returns. PDBC is not allowed to occupy more than 40% of the asset allocation.

I tried a variety of options for ballast assets, including EUO, ULE, YCS, YCL, UUP, UDN (currency), SHY and FIGTX (short-term bonds), PDBC, DBA, DBB, DBE, REMX, GLD, UGL, SLV (commodities/metals), and KMLM (managed futures). The desire is for the strongest response when TMF and TYD are falling down on the job; not necessarily gains, but a parachute for stability.

YCS had the strongest currency response; others seemed to have more of a drag effect with less of a parachute.

PDBC seemed to offer as good as anything of the commodity options.

Metals (including precious metals) tended to be more of an anchor to returns than benefit during downturns.

I was hopeful for KMLM. It turns out that it did not test as well as PDBC since 2008 (using the MLM index to simulate KMLM back to 1992). I suspect that benefit for the trend-following approach was muted because the long/short approach in managed futures damps both the highs and lows. That makes it good for store of value but less useful for providing returns using external trend-following approaches.

I update allocations weekly. If I had an automated system, I would rebalance daily (holding the allocations fixed) to take advantage of daily mean reversion, which I expect would reduce portfolio volatility and increase CAGR by 1 or 2 percent (e.g., 16 percent increases to 17 or 18 percent).

I don't recommend this strategy for taxable, it's too active, which makes it have a considerable tax hit. I'm trying to work out something a bit gentler for taxable.
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

I pulled out the old Philosophical Economics predictor for future returns routine with updated data. It is a great read (here and here).

The plots show future market returns (various durations) based on the current fraction of the investable money in equities. I follow the same procedure as in the links, just plotted as scatterplots.

Image

These suggest very low returns for the next decade, then starting to pick up. The last time I did this was near the end of 2020; the predicted future returns were just a smidge smaller back then.

I'm also seeing a continual decline in returns since the late 1990s for most index funds, really flattening since 2015. The attached is a typical set of assets; the red curve is the risk-parity amalgamation of the assets. It's been very difficult to get good returns without concentration luck for the last 8 years or so.

Image

These trends are consistent with the very high P/E ratios nowadays.

It makes me suspicious that the best chance for decent returns for the next decade may be some riding of big waves, like the 2000-2010 period. Hope that the hedges work.
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

I'd like to report a simple experiment regarding bond returns that seems relevant to this environment. This returns to some of my early preoccupation.

I obtained simulated monthly returns and standard deviations for S&P 500, STT, ITT(3-7), ITT(7-10), and LTT from Siamond's spreadsheet of monthly returns 1955 - 2019 (I got lazy on augmenting with 2019 - present). For each treasury, I created a simulated 1x, 2x, 3x, -1x, -2x, and -3x ETF accounting for LIBOR borrowing costs and ER using the magic formula that Siamond uses combining returns and standard deviations. This gives 24 possible treasury ETFs with monthly returns (yes, not all of these simulated LETFs actually exist). I also created simulated 2x and 3x S&P 500 ETFs the same way.

Siamond will tell you that the inverse funds may not be all that well represented, so caveat emptor.

For each S&P ETF, I calculated the inverse volatility monthly return for each S&P/treasury pair with S&P assigned twice the risk budget, scaling the treasuries by (duration LTT/duration ETF). This gives approximately the same allocations for each treasury duration.

I then ran a tactical portfolio that switched into whichever of the 24 combinations did best in the previous month.

Finally, I divided the cumulative return of each portfolio by the cumulative return of 1x S&P 500 (the tell-tale plot).

The net effect was that the 1x, 2x, and 3x portfolios all consistently gained on the 1x S&P on a decade-over-decade basis from 1955 through 2019, with approximately the same slope throughout in log space. The 1x, 2x, and 3x mixes were up 3x, 50x, and 200x by 2019, even though the 2x and 3x S&P were only up 2 and 3.5x. That's an equivalent of 1.8, 6.4, and 8.8 percent excess CAGR over 1x S&P. The switching mixes outperformed every portfolio holding one of the treasury assets throughout.

The 2x and -2x ETFs were almost never picked. 1x, 2x, -1x, and -2x cases were almost never picked for STTs, ITT(3-7), and ITT(7-10). About 70% were 3x (22%), -3x (20%), -1x (15%), or 1x (13%) LTT. The rest were more or less evenly distributed between 3x and -3x STT, ITT(3-7), and ITT(7-10), biased towards 3x and biased towards longer duration.

With just the 1x and 3x treasuries allowed (no possibility of inverse funds), the 3x S&P basically mirrored the 1x S&P from 1960 through 1985 and arguably did slightly better than the full cohort 1985 through 2018.

This seems like a remarkably simple way to navigate changing rates using momentum. It doesn't preclude the big dips, but it seems to consistently outperform the S&P.

Next step is to test with longer trends, daily returns to present, and the actual ETFs when they existed. I'm trying to develop simulated bond ETFs given daily yields, which is a learning experience.
ag811987
Posts: 15
Joined: Sun Jan 24, 2021 10:34 pm

Re: Refinements to Hedgefundie's excellent approach

Post by ag811987 »

Hydromod wrote: Sat Jul 06, 2019 12:03 am All of the following analyses were done in MATLAB. I wouldn't dream of trying this in Excel.

In the next set of figures, I consider (i) rebalancing frequency, (ii) sequence duration, and (iii) volatility window for a number of schemes. In each figure, different rebalancing frequencies (not volatility window!) are indicated with the line color. I considered rebalancing frequency cases of 1 (daily), 2, 5 (weekly), 10 (biweekly), 20 ("monthly"), 40 ("bimonthly"), 60 ("quarterly"), 120 ("semiannual"), and 250 ("annual") trading days. I assume 250 trading days per year. The color scale runs from red (daily) to blue (annual) rebalancing. Each figure considers one sequence duration and one volatility window.

To give context to the 3x schemes, I created simulated 1x S&P and 1x LTT sequences from UPROSIM and TMFSIM by dividing each daily return by three. The next figure shows the rolling nominal CAGR for a sequence of five-year periods using the 1x sequences. The three plots show (i) just the 1x LTT, (ii) just the 1x S&P, and (iii) a 60/40 mix of the two (mimicking a 60/40 portfolio). Rebalancing frequency is only meaningful for the mix. My code always tracks the volatility window, but the volatility window is not used for these cases.

Image

Rebalancing frequency has a small effect on the 60/40 mix, indicated by a little blue (annual rebalance) peeking out from under the daily rebalance line and the blue line slightly to the left of the red line in the cumulative exceedance figure. In essence, this means that annual rebalancing may have done a little better or worse than frequent rebalancing for any particular start day, but frequent rebalancing would have been slightly favored most of the time (the small offset in the cumulative exceedance lines). This is consistent with annual rebalancing of standard index funds.

Several 3x schemes are shown in the following figures. In the first figure, the plots show the rolling 5-yr CAGR for the (i) 3x LLT (TMFSIM), (ii) 3x S&P (UPROSIM), (iii) constant 40/60 UPRO/TMF (Hedgefundie’s scheme), and (iv) an adaptive scheme considering volatility and trend following based on the monthly unemployment rate. In the second figure, the plots show the rolling 5-yr CAGR for the (i) constant 40/60 UPRO/TMF (Hedgefundie’s scheme), (ii) adaptive weights using symmetric volatility, (iii) adaptive weights using downward volatility, and (iv) the same adaptive scheme considering volatility and trend following based on the monthly unemployment rate. The second figure illustrates the effect of adaptively updating the weights.

The TMF returns were relatively consistent over the entire period, with 80 percent of the 5-year nominal CAGR values between 7 and 22 percent and 50 percent greater than 13 percent. In contrast, the UPRO returns varied dramatically due to recessions. The nominal Hedgefundie scheme behaved in an intermediate way, with some negative periods but 80 percent of the 5-year nominal CAGR values between around 3 and 32 percent. Notice that longer rebalance periods tend to yield scattered CAGR values with different start dates in the Hedgefundie scheme, suggesting that rebalancing periods longer than quarterly may give unexpectedly high or low return rates. This is even more the case with adaptive weights, especially with small volatility windows.

The example suggests that downward volatility calculations may provide substantially improved adaptive weights with very frequent rebalancing (daily to weekly). The advantage is essentially lost with biweekly or longer rebalancing.

Image

Image

Notice that the longer rebalancing periods show indications of annual cycles, with just a few months separation yielding very different returns. This type of offset is why it is important to compare different schemes over the same interval. Also note that extremely frequent rebalancing gives a wider spread in 5 year CAGR than the annual rebalancing.

The adaptive scheme in the bottom plot includes the adaptive risk parity weights, and selectively adjusts the weights to account for macroeconomic risk climate.

The macroeconomic risk is estimated using the trend for unemployment rate, which historically has been found to be a leading indicator for recessions. In essence, the risk parity weights are (i) readjusted to track TMF if a recession is indicated, (ii) readjusted to emphasize UPRO if a recession is unlikely, and (iii) left unchanged if the macroeconomic climate is uncertain. This is a slightly more nuanced version of the approach using the same unemployment rate indicator that is discussed in the willthrill81 (memberlist.php?mode=viewprofile&u=116799) thread. Recessions are signaled by rising unemployment, and are unlikely with falling unemployment. Over the example period, the scheme ends up basically tracking whichever index is more favorable, UPRO or TMF, but the decision is not made using market signals.

The macroeconomic indicator is intended to mitigate the risk of big drops. I know that market timing is a big issue with many Bogleheads, but given the excellent performance of the method Hedgefundie has provided, I’m quite comfortable sitting out and even missing the initial bounce-back. Trend followers have long recognized that a rise in the monthly unemployment rate is a useful macroeconomic indicator that has tended to lead each recession by zero to six months since 1919. The FRED site (https://fred.stlouisfed.org/series/UNRATE) provides this data. One indicator that has been suggested is comparing the latest monthly unemployment rate with a moving average over N months. If the latest rate is higher, that is an indicator sensitive to recession. If the latest rate is lower, that is an indicator of economic health.

This information is particularly useful in two ways. It can indicate when to get out of the market (e.g., go completely to TMF), and it can indicate when the market is unlikely to badly misbehave in the short term. Folks tend to use averaging durations of 7 to 12 months as a crossover criterion between states. Short averaging durations give spurious signals, which can lead to whiplash. Long averaging durations may lag the actual start of a recession. I’ve done some playing with the index, and it seems like each of the recession events since 1986 would have been captured with an averaging period of 12 to 16 months.

I think that it is reasonable to use the index to systematically bias the overall strategy. If there is a clear signal of a recession, I would go completely to TMF. If there is a clear signal that there is no recession, I would bias the UPRO weights higher than calculated using the inverse-volatility method. In transitions, or if it is ambiguous whether there is a transition, I would stick with the weights calculated using the inverse-volatility method.

As a first approximation, I calculated a biased UPRO weight by increasing it a fraction of the way to 1 (full UPRO). For example, if the UPRO weight from the inverse-volatility calculation is w = 0.5, the biased weight is 1 * f + w * (1 – f), where f is the bias fraction. If f = 0, there is no bias. If f = 1, the UPRO weight is 1 and the TMF weight is 0.

I played with the strategies to some extent. I settled on a 15-month moving average period to detect crossovers, but the exact duration doesn’t seem too important. The best results, in terms of expected CAGR, seem to be dependent on the criterion for ambiguity. Overall, it appears that as soon as the sign changes on unemployment index criterion, the state should be considered ambiguous and no bias applied to the weights. Each succeeding month afterwards can be treated as unambiguous.

The bias fraction f is a matter of taste. Pushing f towards 1 improves the expected overall return by a couple of percentage points, but adds exposure to large dips. Black Monday (1987) is the largest crash in the sample period that does not show up with the unemployment index. When f is close to 1, the portfolio takes a large dive. When f is close to 0, the portfolio is largely buffered. I would likely tend to split the difference by setting f < 0.5, which buffers the Black Monday drop substantially. One may argue about whether a Black Monday will occur again within the next 20 or 30 years, of course. Note that the volatility weights become unimportant as f goes to 1 (the UPRO weight = 1 regardless of volatility).

The example provides an especially positive outcome; assuming monthly rebalancing, 90 percent of the periods return at least 14 percent nominal CAGR and 50 percent of the periods return at least 26 percent nominal CAGR. For comparison, the nominal scheme returns 3 and 18 percent nominal CAGR for 90 and 50 percent of the periods with monthly rebalancing.

The scheme does not handle sudden shocks, like Black Monday, that are not signaled by the unemployment rate. The scheme is more resilient when the risk parity weights are used. Accordingly, I would be judicious in how much to push the weights towards full UPRO weighting.

The next figures calculate the difference in nominal CAGR between two 3x schemes and the three nominal 1x schemes over the same integration intervals. The first 3x scheme is the Hedgefundie scheme and the second is the adaptive weight macroeconomic scheme. The third figure compares the adaptive scheme to the Hedgefundie scheme. Comparing apples to apples with respect to integration period, the Hedgefundie scheme essentially always would have done better than the 1x S&P, and almost always would have done better than the 60/40 portfolio. The 1x LTT index would have done better for 10 to 20 percent of the intervals. The adaptive weight macroeconomic scheme would have done even better compared to the 1x schemes.

Image

Image

Image



So what have I learned so far?

• I can easily reproduce the risk parity weights selected by Hedgefundie.
• The Hedgefundie scheme would have beaten any scheme based on the unleveraged (1x) versions of UPRO and TMF for approximately 90 percent of the possible 5-year intervals starting at the end of 1986. The exception is for periods with the S&P tanking but not treasuries. The scheme would have easily overcome the 1 percent ER for almost all of the outperformance sequences.
• Adaptively adjusting the risk parity weights would have provided some additional performance. The largest performance boost would have been with short volatility windows, downward volatility calculations, and very frequent rebalancing. Of course, this approach begs for automated calculations and trading, and will not be practical for most, and the effect of trading drag will likely degrade the boost.
• The performance boost from downward volatility is largely lost with biweekly or longer rebalancing.
• The volatility window should be tuned to the rebalance frequency. Performance degrades if the volatility window is much shorter than the rebalance frequency.
• The macroeconomic indicator provided by the unemployment rate had value as a predictor over the example period, and typically has provided a leading signal for every recession, of up to several months, since 1919.

I hope that this is interesting for folks. I guarantee that folks will be lost, so don't hesitate to ask questions.

I have a couple of ideas for followup analyses.

One question is the behavior if treasuries are long-term declining. I think this could be examined by simply adding a small negative return to every daily return.

Concurrent slumps in the S&P with declining LTT is a harder problem. I suspect that the trend indicator may help out in this scenario, so I hope to look at the trend indicator with prior recessions. This will likely be using monthly data, so conclusions will necessarily be murkier. It may take a while to get this done.
This is absolutely fantastic and provides some of the best possible evidence for 1) Why Hedgefundie's excellent adventure makes sense and 2) Why dynamic rebalancing makes sense.

The hedgefundie 40/60 does so much better than 1x SPY I was astonished. The cumulative exceedance metric is very useful for contextualization. Similarly, the benefit of both downward volatility with weekly rebalancing vs static hedgefundie was also pretty dramatic. Lastly, you were able to show a clear case for macro-economic "trendlike" signal.
ag811987
Posts: 15
Joined: Sun Jan 24, 2021 10:34 pm

Re: Refinements to Hedgefundie's excellent approach

Post by ag811987 »

Hydromod wrote: Sat Jul 06, 2019 4:45 pm
klaus14 wrote: Sat Jul 06, 2019 3:44 pm
Hydromod wrote: Sat Jul 06, 2019 12:03 am So what have I learned so far?

• I can easily reproduce the risk parity weights selected by Hedgefundie.
• The Hedgefundie scheme would have beaten any scheme based on the unleveraged (1x) versions of UPRO and TMF for approximately 90 percent of the possible 5-year intervals starting at the end of 1986. The exception is for periods with the S&P tanking but not treasuries. The scheme would have easily overcome the 1 percent ER for almost all of the outperformance sequences.
• Adaptively adjusting the risk parity weights would have provided some additional performance. The largest performance boost would have been with short volatility windows, downward volatility calculations, and very frequent rebalancing. Of course, this approach begs for automated calculations and trading, and will not be practical for most, and the effect of trading drag will likely degrade the boost.
• The performance boost from downward volatility is largely lost with biweekly or longer rebalancing.
• The volatility window should be tuned to the rebalance frequency. Performance degrades if the volatility window is much shorter than the rebalance frequency.
• The macroeconomic indicator provided by the unemployment rate had value as a predictor over the example period, and typically has provided a leading signal for every recession, of up to several months, since 1919.
Can you try to formulate your synthesis in a paragraph?
Is it:
Adjust UPRO/TMF weights, every week, based on inverse (downwards) volatility. Further bias the weights based on unemployment trend.

so you are always 100% invested in these two funds.
You've just about hit it. I'm always 100% in at least one of the funds, but not always both at once. I haven't tried to see if there are cases that favor complete retreat to cash.

The unemployment trend puts me into three conditions: (i) clear recession, (ii) clear expansion, or (iii) ambiguous. This condition is updated monthly.

My general strategy would be:

While it is a clear recession, retreat to 100% TMF.

If it isn't a clear recession, I would adjust the UPRO/TMF weights based on the inverse volatility. I would use these weights unless the unemployment trend indicates clear expansion. If so, I would move the weights about halfway to full UPRO.

If trading costs were a factor, I would probably use quarterly rebalancing by default and calculate the inverse volatility weights based on a two-month volatility window or so. It shouldn't make a difference if you use symmetric or downward volatility. However, I would at least check on the unemployment rate monthly when it comes out, and adjust the scheme weights if the signal changes to a more adverse condition: to clear recession or from clear expansion. I don't want to take chances when the risk signal increases. One might also change early if the signal goes to clear expansion.

If trading costs were not a factor, I would probably drop to weekly as you said. I'd use a 10-day volatility window with downward volatility for the weights. However, there would be no need to rebalance while the recession signal is on, because I'd be 100% TMF.

If I were an even less cautious sort, I would go full UPRO during clear expansion in addition to full TMF during clear recession. This would have the benefit of not requiring frequent trading and only monthly checking most of the time. This is essentially the willthrill81 strategy. This would be a strong bet that there's not a black swan event like Black Monday, though, and probably better for younger folks.

Now that I've stated this strategy, I will say that it is predicated on the assumption that the economic conditions over the last 30 years will generally continue (Hedgefundie's hypothesis).
By trading costs do you mean bid/ask spreads are wide enough on brokerages today given trading is mostly commission free or very low commission that that alone would push you from weekly to quarterly rebalancing?
ag811987
Posts: 15
Joined: Sun Jan 24, 2021 10:34 pm

Re: Refinements to Hedgefundie's excellent approach

Post by ag811987 »

Are you willing to share the weekly weights in a newletter/email chain or share the code haha
kennethyau
Posts: 1
Joined: Wed Mar 06, 2024 1:04 pm

Re: Refinements to Hedgefundie's excellent approach

Post by kennethyau »

laurenthu wrote: Thu May 26, 2022 7:14 am OK I changed my code to take your allocations into account, and actually made it something changeable in the code.
https://colab.research.google.com/drive ... sp=sharing
The allocation seems ballpark OK to me with currently the following:
DBC ERX SPXU TMV UGL UTSL
weights 18.0% 9.5% 22.0% 18.0% 6.6% 25.8%
The gold weight will always be quite small with the 1/9th risk weight but I suppose that is OK.

I would still be interested to have your full backtest to better gauge risk and understand the exact parameters you used when testing for your post above, as this is very hard to test in PV or anything else... Please PM to me if you do not desire to post it here?
Also please do tell me if you want any modification of the code, any questions / suggestions you have etc.
Hi, do you have any updates to the code?

I have tried to run it but it has error.
nadocollin
Posts: 1
Joined: Sat Mar 09, 2024 9:11 am

Re: Refinements to Hedgefundie's excellent approach

Post by nadocollin »

kennethyau wrote: Thu Mar 07, 2024 7:55 am
laurenthu wrote: Thu May 26, 2022 7:14 am OK I changed my code to take your allocations into account, and actually made it something changeable in the code.
https://colab.research.google.com/drive ... sp=sharing
The allocation seems ballpark OK to me with currently the following:
DBC ERX SPXU TMV UGL UTSL
weights 18.0% 9.5% 22.0% 18.0% 6.6% 25.8%
The gold weight will always be quite small with the 1/9th risk weight but I suppose that is OK.

I would still be interested to have your full backtest to better gauge risk and understand the exact parameters you used when testing for your post above, as this is very hard to test in PV or anything else... Please PM to me if you do not desire to post it here?
Also please do tell me if you want any modification of the code, any questions / suggestions you have etc.
Hi, do you have any updates to the code?

I have tried to run it but it has error.
I updated laurenthu’s code to resolve the runtime errors. Note I also added a few additional assets which you can also use or just copy the assets list from laurenthu’s code.

https://colab.research.google.com/drive ... sp=sharing

I will probably take this and plug it into some TAA back testing code I have later to run back tests, happy to post that here once done.
Last edited by nadocollin on Sat Mar 09, 2024 9:29 am, edited 1 time in total.
Topic Author
Hydromod
Posts: 1048
Joined: Tue Mar 26, 2019 10:21 pm

Re: Refinements to Hedgefundie's excellent approach

Post by Hydromod »

nadocollin wrote: Sat Mar 09, 2024 9:19 am I updated laurenthu’s code to resolve the runtime errors. Note I also added a few additional assets which you can also use or just copy the assets list from laurenthu’s code.

https://colab.research.google.com/drive ... sp=sharing

I will probably take this and plug it into some TAA back testing code I have later to run back tests, happy to post that here once done.
Excellent. Thanks for updating.
Post Reply