Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Discuss all general (i.e. non-personal) investing questions and issues, investing news, and theory.
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

I am at the stage of life where I am becoming more concerned about decumulation than accumulation; my portfolio should be adequate to handle basic needs without too much concern but I am short of the amount that will support all of my desires for future travel. My kids are at the stage where they are going to start their investing cycle in the next few years. For most of my investing duration I simply dumped the maximum into a 403b without thought and left it at that; around five years ago I started taking more of an interest in the end game. I have a bit of a mathematical bent and work with probabilistic risk assessment for a living; once I ran across HEDGEFUNDIE’s Excellent Adventure (HFEA), I became intrigued with the ideas and now I’ve spent a fair amount of time trying to figure out a reasonable and practical approach to portfolio management compatible with my programming skills. Much of this is documented in the “Refinements to Hedgefundie’s excellent approach” thread.

Inspired by the folks on bogleheads and a variety of other sources, I’ve tried to work out my own synthesis of portfolio design that is compatible with modern and emerging capabilities for algorithmic investing. My design goals are (i) to explicitly balance returns against portfolio volatility, (ii) to work in both taxable and (especially) tax-protected, and (iii) to be compatible with both a wide range of personal utility functions and with lifecycle investing. I intend to implement the end result on a suitable trading platform, with automated daily rebalancing and weekly allocation updates, once the infrastructure is available.

The approach I am proposing is crafted to follow the boglehead guidelines: (i) never bear too much or too little risk, (ii) diversify, (iii) use index funds, and (iv) never try to time the market. I would argue that using a computer-aided algorithmic approach also hews towards investing with simplicity, especially once automated, because this removes emotion from the process, but I accept that many on the forum will disagree. The approach does not explicitly minimize costs, although leveraged ETFs (LETFs) tend to have access to funds less expensively than the retail investor and trading overhead has been trending down for a long time. Surprisingly, backtests of the approach show decreasing impact on taxes as the allocation to 3x funds increases.

The starting point for the approach is based on the following observations:
  • I have no idea what the market will do in the future. There’s every indication that the next decade or so will be fairly stagnant overall, but whether that means flatlining, gently bobbing about, or violently tossing is a complete mystery to me. I have no idea what sectors of the market may outperform the market in the future.
  • There are robust indications that volatility clusters; future volatility will tend to be correlated to recent volatility.
  • There are robust indications that near-future returns are essentially independent of recent volatility.
  • There are indications that the momentum factor exists and is fairly robust across markets. The momentum factor is defined for groups in a large collection of assets. If the assets are sorted by returns in one period and grouped into high, medium, and low returning assets, the high-returning group on average tends to outperform the low-returning group on average in the next period. However, momentum describes aggregate behavior; it says nothing about any particular asset.
  • There are indications that very frequent rebalancing with volatile assets tends to give a bonus, but the rebalancing bonus can be eaten up by slippage and taxes.
Core risk budget principle

The starting point for standard portfolio construction (i.e., with fixed asset allocations) is to define the fraction of the portfolio risk assigned to each asset, and use that risk allocation with expected returns to derive an asset allocation for a time frame measured in decades or longer. The resulting asset allocations represent estimates of multi-decadal asset characteristics, often using estimates of expected returns. With this multi-decadal time frame for risk budgeting, it is reasonable to hold the asset allocations fixed over time except for adjustments as the investor lifecycle evolves. However, while the asset allocations may reflect the long-term asset risk allocations, actual asset risk budgets fluctuate over shorter periods as asset volatilities change within the market cycles.

The core principle in the algorithmic approach is to take advantage of the relatively robust indications regarding volatility clustering and independence of volatility and returns. This core part of the algorithm can be used with at least two assets, even with the standard boglehead two- and three-fund portfolios.

The risk-budget algorithmic approach differs from the standard approach regarding the time frame for evaluating risks and adjusting allocations; the risk-budget time frame is much shorter (e.g., months instead of decades). Furthermore, the method does not consider expected returns. Just like with the standard approach, rebalancing is used to align the portfolio to the risk-budget-based asset allocations. However, in order to maintain a fixed risk budget on the shorter evaluation time frame, the asset allocations must be adjusted, which necessitates more frequent and larger portfolio adjustments than the standard approach, and obviously this may have cost consequences.

In essence, the algorithm is simply applying the standard approach at a shorter time scale. Market timing is defined by the use of predictive methods for future price movements as a basis for making trading decisions. The risk-budget approach does not use return estimates or attempt to predict future price movements (unless the investor is calculating the momentum factor), therefore it is not a market timing algorithm. I recognize that many on the forum will argue with my assessment that the approach does not try to time the market, but I respectfully disagree.

There are a number of ways to account for a risk budget; all have inputs that include volatility, some consider correlations, and some consider expected returns. A simple way to balance risk for two assets is through a risk-budget form of inverse volatility, where the asset allocation for asset i is defined by w_i = (f_i/s_i) / sum(f_j / s_j). In this equation, w is the asset allocation, f is the risk budget allocation, and s is the standard deviation (volatility). This model does not consider correlations or returns, but does bias the assets according to how much risk is allocated to the different assets.

For example, the investor may define a desired equity risk that is four times larger than the ballast (80 percent of the portfolio risk goes to equities balanced with 20 percent of the portfolio risk to alternatives). On average, the volatility of the S&P 500 is roughly 1.5x larger than the volatility of long-term treasuries; the 80/20 risk budget would correspond to a 73/27 asset allocation. A pure risk parity approach, with each asset receiving 50 percent of the risk budget, would correspond to the classic 40/60 portfolio. The classic 60/40 portfolio would correspond to an approximately 69/31 risk budget allocation, and a 90/10 portfolio would correspond to a 93/7 risk budget allocation (more than 13 times as much risk assigned to equities).

Volatility changes over time. Equity volatility swings between relatively low (in calm periods) to relatively high (in crises); with a fixed 80/20 risk budget, the equivalent equity/ballast asset allocation may swing below 40/60 in crises to 85/15 in very calm periods.
Consistently maintaining the risk budget allocations will tend to subtly improve the risk-adjusted returns. Assuming that the expected returns are independent of volatility, the expected returns will be based on the average allocation over time, but the average volatility for each asset will be biased towards periods with lower volatility (hence higher allocations).

The risk-based swing between equities and treasuries would have paid off big time in the slow-moving 2000 and 2008 crashes, greatly mitigating extended portfolio declines. It has been less effective in faster crashes (e.g., 1987, 2020), and is vulnerable when all included assets simultaneously crater (2022).

Unfortunately, neither portfolio visualizer or composer allow a risk budget tweak to the inverse volatility or risk parity algorithms (composer does not have risk parity, just inverse volatility). The risk parity approach adds to the inverse volatility approach by accounting for covariances between assets. To some extent risk budget approaches can be faked with these tools by using replicates of an asset (e.g., VFINX + SPY for S&P 500), but this is only a coarse approximation. The following approximation is roughly a 4:1 or 5:1 equity:treasury ratio.

Play with approximate risk-budget inverse volatility here.

With just a few assets, a risk-budget inverse volatility model works well and is easy to implement with a spreadsheet. With more assets, it is desirable to account for covariances between assets. I personally use a risk-budget minimum variance approach, which uses covariances and enables constraints limiting allowable asset allocations (e.g., maximum allocation to equities must be less than 80 percent, maximum allocation to defensive assets must be less than 60 percent).

Asset classes: Risk budgets with several assets

An important issue regarding assigning risk budgets arises when more than just a few assets are considered. For example, perhaps one uses five equity assets (US large-, mid-, and small-cap; developed and emerging international) but just one or two ballast assets. In this case, the risk budget approach is easily extended by (i) defining two asset classes (equities and ballast), (ii) assigning a risk budget to each asset class, and (iii) subdividing the risk assigned to each asset class by the number of assets in the class. In this example, an 80/20 risk budget goes to 80/5 = 16 for each equity asset and 20/2 = 10 for each ballast asset. This approach keeps the risk budget intact without guesswork when adding or subtracting an asset from a class.

Outlier assets

An issue arises when some of the assets have much larger or smaller volatilities than the rest. For example, consider SHY (1 to 3 year treasuries) as the ballast; its volatility is 10 times smaller than the S&P 500. The goal might be to use SHY as a de-risking asset. An inverse volatility pair of UPRO (3x S&P 500) and SHY would allocate roughly 3 percent to UPRO, which is an extreme de-risking. The equity/ballast risk budget weights could be adjusted to compensate for this simple pair, but the calculations become tedious when there are several assets.

I find that it is a practical workaround to use the general equity/ballast framework, but allow each asset to have a scaling factor for its risk fraction within its asset class. For example, suppose the generic equity/ballast risk budget was 4/1, with two ballast assets (including SHY). Decreasing the SHY risk budget to 10 times smaller than the other ballast asset, the SHY risk budget within the ballast class becomes 0.1/(1 + 0.1) = 0.09, and the overall risk budget to SHY is 0.2 * 0.09 = 0.018. The other ballast asset has a risk budget of 1/1.1 = 0.91 and an overall risk budget of 0.182.

The same approach could be followed in reverse if some very risky asset (e.g., GBTC, a bitcoin trust) is so volatile that its allocation is vanishingly small. In this case, the GBTC risk budget might be artificially increased.

Intermediate leverage levels

It is possible to create an effective portfolio leverage intermediate between 1x and 3x either by separately adjusting risk budgets based on asset leverage or by using different volatility scale factors on 1x and 3x assets. In essence, scaling volatility inversely scales the risk weight.

Consider the HFEA approach as an example of using volatility scaling to create an effective portfolio leverage intermediate between 1x and 3x. HFEA uses S&P 500 and long-term treasuries (LLTs); with 1x endpoint assets of SPY and TLT and 3x endpoint assets of UPRO and TMF, unscaled volatilities result in a 3/1 weighting of 1x to 3x assets. Increasing 1x volatilities by a factor of 1.5 and 3 results in a weighting of 1x to 3x assets of 2/1 and 1/1, respectively. Volatility scaling is a simple way to use a single scale factor to gradually tune the portfolio between 1x and 3x leverage. On a lifecycle approach, the scale factor would adjust gradually on a glide path based on portfolio size. It is conceivable to also adjust the scale factor based on other factors, such as cost of leverage or volatility, but I have not explored this avenue.

To some extent the reallocation/rebalancing frequency is a matter of taste. I find that 3x LETFs seem to reach an optimal value around weekly reallocation, especially when there are more than a few assets, but monthly is nearly as good. The weekly frequency is really only significant during periods of crisis. With 1x ETFs, I would probably use an approach that normally uses monthly reallocation but uses a band criterion on weekly trial allocations. This would identify rapidly changing market conditions, but would normally not pull the trigger. With only a few assets, it would probably be quite adequate to use a band approach triggering reallocation when some asset deviates by more than 10 or 15 percent from its calculated allocation.

Incorporating momentum

As McQ has been showing, there is normally minimal benefit to be gained by adding more than a few assets with similar returns and volatility to a portfolio. However, momentum is a relative thing among lots of assets, so a portfolio considering momentum needs a reasonably large number of assets to work with.

I propose incorporating momentum by working with a variety of concentrated index ETFs and LETFs. For example, when the portfolio does not include leverage, one might use a portfolio consisting of the State Street sector ETFs plus some international funds, resulting in perhaps 15 candidate equity assets. Without a momentum adjustment, overall performance might not be very different from just holding the broad index funds. I find that a good way to incorporate the momentum signal is to nudge each asset risk budget higher or lower based on recent momentum. The net result is to favor assets when they are doing well and de-emphasize assets when they are doing poorly. However, as a practical matter, the portfolio uses a minimum allocation level to retain an asset, and sells assets that fall below the minimum level. Back tests suggest that a minimum allocation level of 1 to 3 percent seems to be reasonable, with 2 percent as a good value.

Momentum also provides a way to adaptively adjust leverage levels based on market conditions. Using a portfolio of mirrored 1x and 3x funds, intermediate leverage levels are obtained by uniformly adjusting the risk budget for all 1x or all 3x assets. With momentum nudging the risk budget, 3x LETFs get a higher allocation in trending bull markets and 1x ETFs get a higher allocation during downturns. Even in the case with all 3x equities but some 1x and 2x ballast assets, portfolio leverage tends to drop during downturns when 3x equities are screaming down.

Momentum inherently considers price movements, therefore it can be argued that trying to exploit the momentum factor is inherently market timing. I won’t argue the point. I will say that a certain class of momentum methods makes periodic (e.g., monthly) assessments about whether to enter and leave the market (called the risk on and risk off conditions), which are intended to bypass crashes. That type of momentum method is clearly market timing, in my opinion. The HAA momentum overlay to the algorithm is implemented as a relatively mild bias to the asset risk budgets, rather than as explicit entry and exit conditions; this falls into a pale gray area, in my opinion.

As 2022 revealed, long-term treasuries are not always the best diversifier to stocks in times of stress. This was a huge motivator to identify alternative diversifiers, such as commodities, currencies, and managed futures, that tend to have a negative correlation to stocks, or at least low volatility, during market stresses. Using momentum, it starts to become practical to squeeze in effective allocations of these alternatives under adverse market conditions without too much of a drag from minimal or negative returns under normal conditions. This is likely to become important during times of rising rates, for example, when long-term treasuries are susceptible to getting killed. Using momentum for the diversifiers allows some adjustment away from treasuries to better-performing assets. I tend to use a couple of treasuries (long- and intermediate-term), a couple of levered currencies, a commodity, and a managed future fund as the available assets, and require that the total allocation to alternatives is constrained to an upper bound (e.g., no more than 60 percent of the portfolio).

The momentum adjustment seems to have a small, even negligible, benefit with 1x assets. With 3x LETFs, the momentum adjustment seems to have a noticeable, if not large, benefit. Perhaps the biggest benefit occurs when selecting among defensive assets when ol’ reliable treasuries fail.
There is a temptation to include inverse assets as potential diversifiers for adverse conditions. Even with momentum, including inverse assets tends to generate poorer long-term results in my backtests even though they may generate positive returns during certain periods. This is possibly because the cumulative effects of false inclusion under normal periods outweighs beneficial inclusion under crashes.

Gold is also often discussed as a potential diversifier. It is certainly the case that gold can be used as a diversifier, and under certain market conditions it may be effective. For example, a version of the HFEA approach using gold instead of treasuries would have performed adequately even starting in the 1970s, based on back tests. However, over the last 40 years, including gold into the algorithm generally has decreased returns in backtests without improving volatility, relative to other defensive assets, even when momentum is enabled.

Incorporating a rebalancing bonus from mean reversion

I find that a portfolio consisting largely of 3x LETFs can generate a consistent return of several hundred basis points simply from daily rebalancing compared to, say, weekly or monthly rebalancing, even accounting for trading slippage. In this case, rebalancing brings the assets back to the asset allocation; this is different from the asset reallocation, which should occur on a weekly to monthly frequency.

The effect is especially noticeable when one or two of the assets is negatively correlated to the others on a daily basis (e.g., treasuries versus equities).

The basis for the effect is that the daily rebalancing tends to continually sell high and buy low relative to the monthly trends. This is a frequent small boost. The amplitude of the price movements is generally proportional to the square root of the duration between rebalances, but the total boost is inversely proportional to the duration between boosts, so that the net boost is proportional to the inverse of the square root of the duration between rebalances. Comparing the effect on a daily basis with rebalancing every 16 days, the magnitudes are 4 times larger but the net effect is 4/16 = 1/4 as consequential.

The effect is independent of monthly asset trends, because it is targeting daily fluctuations around the trend. However, trading slippage eats a substantial fraction of the daily rebalancing effect for 1x assets.

Obviously, manual daily rebalancing is not practical over long periods. Perhaps M1 can be persuaded to offer periodic rebalancing. Composer does offer daily rebalancing (taxable only, so far), but doesn’t have the tools to implement the risk budget algorithms. There are quant-focused platforms focused on high-frequency trading, which could readily handle that chore, but I have not yet mastered the more intense coding for any of these platforms.

Summary of algorithmic approach

The reallocation algorithm is
  • Calculate asset volatilities and correlations/covariances
  • Calculate asset momentum (if used)
  • Calculate target portfolio leverage level (if between 1x and 3x)
  • Calculate base risk budgets for all assets (including leverage level, if used)
  • Adjust base risk budget based on momentum (if used)
  • Calculate asset allocations
  • Iteratively trim assets with allocations below threshold and calculate adjusted allocations
  • Rebalance portfolio with new allocations
Rebalancing to the allocations can be performed periodically between reallocations.

Examples

Three sets of simulations are used for examples: (i) a set of HFEA examples, (ii) a set of 10 multi-asset examples (ANNA), and (iii) a set of 21 to 40 assets (multisector). In all cases, reallocation/rebalancing is performed every five trading days to minimize timing luck without a large boost from daily rebalancing.

The HFEA examples compare a fixed allocation of 55/45 to 3x S&P 500/long-term treasuries (LTTs) (called HFEA5545) to simulations with fixed risk allocations at various leverage levels with an equity/treasury risk weighting of 4/1, which gives an approximate average weighting of 55/45. The leverage is 3x (HFEA), 2.33x (HFEA1x67), 2x (HFEA1x50), 1.67x (HFEA1x33), and 1x (HFEA1x). The figure lists the cases in order of CAGR. The red lines represent 1x and 3x S&P500 and blue lines represent 1x and 3x LTTs. The 3x values are simulated prior to inception of the 3x funds.

The intermediate HFEA curves are calculated by adjusting the relative risk to the 1x assets. Both CAGR and volatility scale almost linearly with the relative risk.

The first thing to notice is that the HFEA curves are all much smoother than both the equity and treasury curves, but have similar long-term returns to the weighted S&P 500. Drawdowns are considerably muted relative to the leveraged equity curve. This is a result of S&P and LTT trending in opposite directions during crises, the “flight to safety” effect that disappeared during the rising rates in 2022. The simulation period was extremely favorable to the HFEA approach, with decreasing rates giving a very nice tailwind to LTTs and major crashes (2000, 2008) slow enough that the “flight to safety” effect (found during stable or decreasing inflation) was very effective.

The risk-budget 3x model performed modestly better that the rebalanced-weekly 55/45 3x model. The outperformance appears to be due to a bit better performance in a few crises, which may be timing luck.

Edit: the original figures were overly optimistic in the simulated part of the 3x LETFs, which was brought to my attention. I fixed the error (basically getting cute with coding, with the effect of adding costs instead of subtracting them). The example figures have the corrected results, including much more dramatic drawdowns.
Image

The second example uses a multisector approach, with five equity LETFs (S&P 500, small caps, REIT, emerging market, and European market) and five ballast assets (long- and intermediate-term treasuries and a mix of 2x and 1x commodity/currency/managed futures ETFs). The example is inspired by and slightly expanded from the All Asset No Authority (ANNA) portfolio approach (https://research.leutholdgroup.com/cate ... ority.1494). There are two 1x and two 3x portfolios. The same multisector approaches are repeated, one with just risk-budget weighting 4/1 equity/ballast (green lines), and the other nudging asset risks based on momentum (yellow lines). The 3x and 1x HFEA models are included for comparison (gray lines). The momentum approach gives larger risk weights to the sectors that have been recently performing better and reducing allocations to the sectors that have been recently performing worse. Assets with allocations less than 2 percent are culled and the portfolio reallocated until all assets have at least 2 percent allocation.

Edited description based on revised figure.
The strategies are a bit of a mixed bag compared to the HFEA model, which had a very nice run from 2009 through 2021. The more diversified portfolios did better in 2022 because of the additional ballast assets. Arguably the more diversified 3x portfolio was more consistent over the entire period. Adding momentum had mixed effects.

Edit: fixed error in simulated part of the 3x LETFs
Image

The third example is based on my Roth portfolio. It again uses a multisector approach, more than doubling the available equity assets from the AANA-like portfolio, with (i) numerous 3x equity LETFs mirrored with 1x ETFs, (ii) 3x and 1x long- and intermediate-term treasuries, and (iii) a mix of 2x and 1x commodity/currency/managed futures ETFs. The ballast assets repeat from the AANA-like portfolio. The 3x cases have 21 assets, the 1x cases have 24 assets, and the mixed 1x/3x cases (with leverage settings from the HFEA13x33 case) have 40 assets. The S&P 500 is omitted from the mix as redundant. The same multisector approaches are repeated, one set with just risk-budget weighting 4/1 equity/ballast (green lines), and the other set nudging asset risks based on momentum (yellow lines). The 3x and 1x HFEA models are included for comparison (gray lines).

Including 1x and 2x ballast assets in the multisector approach means that the approach does not preserve a constant leverage, unlike the HFEA example. Total portfolio risk bounces between 2 and 3 for the 3x portfolio, and between 1 and 2 for the mixed 1x/3x portfolio.

Edited description based on revised figure.
The additional set of assets improved the consistency of the multisector approaches over the AANA-like example, and the multisector approaches were able to take advantage of some high-risk/high-return assets (e.g., semiconductors, NASDAQ-100). The overall characteristics were not that dissimilar to HFEA during most of the period, but there was clear separation in 2022 because of the additional ballast assets. It remains to be seen how HFEA recovers.

At all three leverage levels, the momentum model slightly outperformed HFEA, which outperformed the no-momentum model.

Edit: fixed error in simulated part of the 3x LETFs
Image

Summary

The risk-budget minimum variance approach appears to give a nice balance between returns while maintaining relatively low volatility in two extremes: (i) a portfolio with a few nicely matching assets and (ii) a portfolio with a large number of index assets spanning the investing universe (including some high-volatility but high-return assets). Adding sectors and additional ballast options to the mix gives a bit of boost to returns relative to the HFEA approach, mostly during parts of the period when international assets shined or LTTs tanked, improving risk-adjusted returns. Adding momentum to the mix improves performance with many available assets.

The AANA-like example demonstrated that the risk-budget approach tends to drag with scenarios where most assets having relatively modest returns; it appears to be important to have a mix of high- and low-volatility assets for the approach to shine. Momentum seems to be hit or miss with just a few assets.

I calculate the Kelly criterion for these portfolios as part of the diagnostics. The most volatile portfolios have a Kelly criterion >2.5, some of the low-leverage multisector cases have a Kelly criterion >10. These values imply that the portfolio could be levered further with relatively little risk of failure.

I don’t trust that the S&P 500 will perform as well in the next five to ten years as it has during the backtest period. It may, it may not. I do trust that some sectors may do reasonably well. I don’t trust that LTTs will keep the “flight-to-safety” characteristic that has been so valuable for forty years. It may, it may not.

Because of this lack of trust, I will be using the momentum-based risk budget machinery with lots of potential assets going forward, using the 3x version of the third approach. The displayed multisector portfolio is based on my Roth account, which I update weekly. I use the same approach in taxable, except that I will only update monthly (I expect that the tax drag will be equivalent to 2 or 3 percent ER in the long term). The approach is intentionally resilient to minor adding or dropping of assets as they become available or are closed; there are a couple of 3x LETFs that I wish were available in M1, for example.

I will allow myself a minor tweak to the equity/ballast risk budget allocation based on market conditions, allowing it to slide between 4/1 and 6/1 equity/ballast. The high end is for a robust bull market, sliding down during other periods. Currently I’m at 4/1, with no particular inclination to drift down further. I don't expect that this will have a noticeable effect, it's a psychological crutch to give me something harmless to fiddle with.

I hope folks find this of some interest.
Last edited by Hydromod on Tue Mar 21, 2023 3:18 pm, edited 2 times in total.
User avatar
David Jay
Posts: 14541
Joined: Mon Mar 30, 2015 5:54 am
Location: Michigan

Re: Hydromod's Okay Adventure

Post by David Jay »

Hydromod wrote: Sun Mar 19, 2023 9:45 pmSummary

The risk-budget minimum variance approach appears to give have given a nice balance between returns while maintaining relatively low volatility in two extremes: (i) a portfolio with a few nicely matching assets and (ii) a portfolio with a large number of index assets spanning the investing universe (including some high-volatility but high-return assets). Adding sectors and additional ballast options to the mix gives has given a bit of boost to returns relative to the HFEA approach, mostly during parts of the period when international assets shined or LTTs tanked, improving risk-adjusted returns. Adding momentum to the mix arguably slightly improves improved performance.
A few corrections (above)

Past performance is such a poor predictor of future performance that the SEC requires a warning message to that effect on the investment products they regulate.
It's not an engineering problem - Hersh Shefrin | To get the "risk premium", you really do have to take the risk - nisiprius
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure

Post by Hydromod »

David Jay wrote: Sun Mar 19, 2023 10:03 pm
Hydromod wrote: Sun Mar 19, 2023 9:45 pmSummary

The risk-budget minimum variance approach appears to give have given a nice balance between returns while maintaining relatively low volatility in two extremes: (i) a portfolio with a few nicely matching assets and (ii) a portfolio with a large number of index assets spanning the investing universe (including some high-volatility but high-return assets). Adding sectors and additional ballast options to the mix gives has given a bit of boost to returns relative to the HFEA approach, mostly during parts of the period when international assets shined or LTTs tanked, improving risk-adjusted returns. Adding momentum to the mix arguably slightly improves improved performance.
A few corrections (above)

Past performance is such a poor predictor of future performance that the SEC requires a warning message to that effect on the investment products they regulate.
Thanks. I’ve been fussing over this for so long that I rushed through the summary just to get it done, and got a smidge imprecise.
Chocolatebar
Posts: 192
Joined: Tue Feb 14, 2023 10:58 am

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Chocolatebar »

Thanks for sharing this approach. As a fellow programmer and M1 user, I've been tempted to write software that could manage my portfolio or at least calculate allocations that fit my strategy. However, since my background is in CS, I've been focusing on learning about investing first. Big fan of leveraged strategies though and still consider myself to be in the early accumulation phase of my life, so my preferred allocations are probably more aggressive. However, I'm not aiming for a very high net worth before I shift to deleverage, so preserving my wealth will hopefully become top priority for me sooner rather than later.

I'm also only interested in strategies that follow the Boglehead guidelines. I think the only one I'm still uncertain on is whether I want to only limit myself to index funds in M1 or if I'll be ok obtaining leverage via futures and box spreads (mHFEA).

Anyways, I'm interested in learning more about this strategy. The way you laid it out might make sense to veterans here, but for someone like me with only a couple years experience, this is tough to follow. It isn't clear to me how you're running the "reallocation algorithm". Is it all custom code? Do you have any interest in sharing exactly what funds you use and how your program analyzes each one to recommend weights? Or even sharing the code on GitHub with a readme?

Also - why do you consider this to be an "Okay Adventure"? If it's an improvement over the original excellent adventure from a risk-adjusted standpoint - shouldn't it get a better name? Perhaps it will in time...
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

Chocolatebar wrote: Wed Mar 22, 2023 5:28 pm Thanks for sharing this approach. As a fellow programmer and M1 user, I've been tempted to write software that could manage my portfolio or at least calculate allocations that fit my strategy. However, since my background is in CS, I've been focusing on learning about investing first. Big fan of leveraged strategies though and still consider myself to be in the early accumulation phase of my life, so my preferred allocations are probably more aggressive. However, I'm not aiming for a very high net worth before I shift to deleverage, so preserving my wealth will hopefully become top priority for me sooner rather than later.

I'm also only interested in strategies that follow the Boglehead guidelines. I think the only one I'm still uncertain on is whether I want to only limit myself to index funds in M1 or if I'll be ok obtaining leverage via futures and box spreads (mHFEA).

Anyways, I'm interested in learning more about this strategy. The way you laid it out might make sense to veterans here, but for someone like me with only a couple years experience, this is tough to follow. It isn't clear to me how you're running the "reallocation algorithm". Is it all custom code? Do you have any interest in sharing exactly what funds you use and how your program analyzes each one to recommend weights? Or even sharing the code on GitHub with a readme?

Also - why do you consider this to be an "Okay Adventure"? If it's an improvement over the original excellent adventure from a risk-adjusted standpoint - shouldn't it get a better name? Perhaps it will in time...
I'm glad you find it interesting.

I've been expecting a bit of pushback as to whether it truly follows the Boglehead Way. I personally think that it hews closely to the underlying principles of the Way, even if it does it with a different approach because of LETF volatility.

The longer thread with my exploration gets into the details a bit more. I sort of gather thoughts together around here.

In short, I've glommed together a bunch of custom Matlab software over time to do the analyses. I use an Excel spreadsheet to hold all of the input options. Most of the code is related to developing simulated LETFs, handling input, testing options, doing statistics and plotting, etc. Last summer, there was an attempt to replicate the core in Python (search for Python in the thread), which looked pretty straightforward. There's a link that might still work. I was able to do an early version in Excel, but it was clunky and hard to update.

The core of the model is pretty straightforward as long as you have an appropriate constrained minimization solver. I use Matlab's fmincon solver subject to (i) allocations constrained to between 0 and 1, and (ii) [optional] min and/or max constraints on total allocation of assets in a class. The Python folks found a solver that worked just as well. The minimization approach is lifted from here, which took me a little to get my head around. It takes a objective function based on a least-squares difference, accounting for the covariance matrix and the risk budget parameters. I take it on faith a bit.

The overall model basically just needs total returns for each asset over the momentum period (up to 10 months for me). I download from Yahoo Finance, but python has its own routines. I calculate volatility and covariances from a recent subset of total returns.

The other thread lists assets that I use. The approach is intentionally insensitive to the precise assets and uses enough assets that I have no hesitation dropping in an appropriate asset if it becomes available or cutting out an asset if it is delisted or something.

I'm from NJ, so I don't expect too much* [lyrics by John Gorka]. It should do okay, that's all I'll claim.
Chocolatebar
Posts: 192
Joined: Tue Feb 14, 2023 10:58 am

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Chocolatebar »

Hydromod wrote: Wed Mar 22, 2023 7:10 pm I'm glad you find it interesting.

I've been expecting a bit of pushback as to whether it truly follows the Boglehead Way. I personally think that it hews closely to the underlying principles of the Way, even if it does it with a different approach because of LETF volatility.

The longer thread with my exploration gets into the details a bit more. I sort of gather thoughts together around here.

In short, I've glommed together a bunch of custom Matlab software over time to do the analyses. I use an Excel spreadsheet to hold all of the input options. Most of the code is related to developing simulated LETFs, handling input, testing options, doing statistics and plotting, etc. Last summer, there was an attempt to replicate the core in Python (search for Python in the thread), which looked pretty straightforward. There's a link that might still work. I was able to do an early version in Excel, but it was clunky and hard to update.

The core of the model is pretty straightforward as long as you have an appropriate constrained minimization solver. I use Matlab's fmincon solver subject to (i) allocations constrained to between 0 and 1, and (ii) [optional] min and/or max constraints on total allocation of assets in a class. The Python folks found a solver that worked just as well. The minimization approach is lifted from here, which took me a little to get my head around. It takes a objective function based on a least-squares difference, accounting for the covariance matrix and the risk budget parameters. I take it on faith a bit.

The overall model basically just needs total returns for each asset over the momentum period (up to 10 months for me). I download from Yahoo Finance, but python has its own routines. I calculate volatility and covariances from a recent subset of total returns.

The other thread lists assets that I use. The approach is intentionally insensitive to the precise assets and uses enough assets that I have no hesitation dropping in an appropriate asset if it becomes available or cutting out an asset if it is delisted or something.

I'm from NJ, so I don't expect too much* [lyrics by John Gorka]. It should do okay, that's all I'll claim.
Here is what I found in the previous thread:
Hydromod wrote: Mon May 23, 2022 9:52 am
laurenthu wrote: Mon May 23, 2022 7:15 am Hello Hydromod, thanks for sharing this with us, this is very generous of you!

I would like to help with the coding to make sure that everyone can follow the system if they wish, and would do so via Google Colab (easy to use online python notebooks) but I would firt like to make sure I understand everything correctly. The starting basket is clear - you have shared it above. We take 6 out of 15 based on the average of 2months and 9month momentum - clear, so I take the 2 month return, the 9 month return, add them and take the top 6.
Now the issue comes after that... You are describing doing some minimum variance with risk budgetting, did you mean risk parity with budgetting? In that case, can you describe which ETF you put in which category, and how much you give per category? Also, what do you do if a category is totally absent - like commodity or gold or treasury might be totally absent from the top6 right?

Here is the first version of the code - I took the top6, lookback of 3 months for the risk parity and so far an equal budgetting (= risk parity between the top 6 assets, which means equal risk given to the equity assets (3 assets), the treasury (1 asset = TMV this week), 2x Gold and commodity. Happy to find a better way to tackle this budget part once I understand all scenarios better...
For now this is what the algo gives me:

CURE DBC SPXU TMV UGL UTSL
weights 22.5% 15.1% 21.4% 13.9% 16.3% 10.8%

https://colab.research.google.com/drive ... sp=sharing
Those numbers look reasonable off the top of my head.

I tend to set the risk budget for the stocks class at about 3 to 4 times the risk budget for bonds. The 3/1 weight applied with UPRO/TMF gives an average allocation like HFEA's 55/45.

I tend to set the risk budget for gold as a fraction of the risk budget for bonds. Maybe a third? I don't have a great basis for that, but I don't want it to get a high allocation.

Commodities also get a risk budget around 1/3 of stocks. So far just DBC and ERX (I don't have that in the example) would fall into that. Maybe SLV could be added to the "gold" or commodity categories, or the categories could be merged. ERX would be selected currently (it's trending well), but have a small weight (it's volatile).

I'm also planning on using GLDC as an example of a crypto class, but I don't have a strong basis for a class weight. Maybe halfway between equities and bonds?

These are just rules of thumb, not rigorously calibrated, but they seem to give reasonable allocations.

There's a bit of renormalization involved with the weights. I first normalize the class weights to sum to 1, and spread those to the assets (each asset usually gets 1/N of the class weight, where there are N assets in the class). Then the weights are set to zero for the assets that aren't in the basket, and everything is renormalized again. I set this up as a way to test different risk allocations in a broad brush way with relatively little bias, but there are other ways to skin the cat.

I find that sometimes there is reason to monkey with the weights inside a class when their volatilities are too different. My big example is TMF vs. TYD. I tend to prefer cutting down the risk for TYD to roughly 40 percent of TMF, just to cancel out durations. If TYD is used, it's a store of value more than anything, so I downgrade the volatility balance. Again, this is not finely tested, just a rule of thumb.

Hope that helps.
It seems a little outdated from the strategy you are using now. Do you still select the top 6 funds based on 2 and 9 month momentum?

If you are interested in sharing a google drive that contains the Matlab code and Excel input file, I'd be happy to write a Python implementation. I think this would be useful to others. We could even start a GitHub repo if we're happy with the results.

Small question - I noticed your process doesn't consider UPRO (TQQQ instead). Why is that?
er999
Posts: 1302
Joined: Wed Nov 05, 2008 10:00 am

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by er999 »

Hydromod wrote: Sun Mar 19, 2023 9:45 pm I am at the stage of life where I am becoming more concerned about decumulation than accumulation; my portfolio should be adequate to handle basic needs without too much concern but I am short of the amount that will support all of my desires for future travel.
Probably might be easier to give advice if you say your age, how many more years you have to work, and what percentage expenses you have saved.

From reading the above it sounds like you might be short of your goals and looking at some way using mathematical techniques to try to get better returns with less risk. Might work but might blow up.

There might be other less risky ways to achieve your goals. If travel expenses are a concern make sure you are looking at travel hacking with miles and points. You can get quite a bit of luxury travel for very little money, particularly if you are flexible on dates and destinations.

Perhaps you are planning on too conservative with withdrawal rate (not an expert on it myself, others know more on here) and you really don’t need to do these fancy techniques as already have enough money.
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

Chocolatebar wrote: Thu Mar 23, 2023 7:41 am
It seems a little outdated from the strategy you are using now. Do you still select the top 6 funds based on 2 and 9 month momentum?

If you are interested in sharing a google drive that contains the Matlab code and Excel input file, I'd be happy to write a Python implementation. I think this would be useful to others. We could even start a GitHub repo if we're happy with the results.

Small question - I noticed your process doesn't consider UPRO (TQQQ instead). Why is that?
I am using 1 and 10 month momentum now. It isn't very sensitive to the 9 or 10 month duration, 1 month seems to do a little better in choppy markets. 1/3/6/12 month momentum is popular for some tactical schemes.

I use a little different strategy now. I go through the allocation process with all assets, with their risk budget nudged by momentum, then prune off assets with allocations below a cutoff value. I lop the smallest allocation asset, reallocate, and repeat until all assets are above the threshold allocation (2 percent seems to work well when working with 20 assets). I don't think that the pruning process strongly affects results, just a mild effect on portfolio volatility.

One thing that I didn't discuss is that I now use a strategy of easing in the consideration of 1x and 2x ballast assets, so their maximum risk budget is reduced over a ramp when their momentum isn't in the top 25 percent or so. This is gentler and more robust to slight changes in asset allocations than using a threshold. I generally try to use few parameters, but ramping gets it a bit squishy to parameterize.

I don't use UPRO because (i) the sectors basically reproduce UPRO and (ii) UPRO is rarely selected anyway when it is available.

I'm happy for you to do a python implementation. I'm just a little nervous about passing the matlab code unless you are familiar with matlab, it's not documented as well as it should be for distribution. You'd probably need to step through the code a bit to understand all of the logic. Do you have matlab available?

I would probably reorganize the allocation/trading sections to go to an event loop sequence for robustness - the matlab code does a bunch of vector things, which reduces if statement evaluations but runs the risk of getting timings out of synch.
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

er999 wrote: Thu Mar 23, 2023 8:59 am
Hydromod wrote: Sun Mar 19, 2023 9:45 pm I am at the stage of life where I am becoming more concerned about decumulation than accumulation; my portfolio should be adequate to handle basic needs without too much concern but I am short of the amount that will support all of my desires for future travel.
Probably might be easier to give advice if you say your age, how many more years you have to work, and what percentage expenses you have saved.

From reading the above it sounds like you might be short of your goals and looking at some way using mathematical techniques to try to get better returns with less risk. Might work but might blow up.

There might be other less risky ways to achieve your goals. If travel expenses are a concern make sure you are looking at travel hacking with miles and points. You can get quite a bit of luxury travel for very little money, particularly if you are flexible on dates and destinations.

Perhaps you are planning on too conservative with withdrawal rate (not an expert on it myself, others know more on here) and you really don’t need to do these fancy techniques as already have enough money.
I appreciate the concern. Perhaps I was a little misleading about my desires. I desire an unreasonable multiple multimonth excursions annually around the world, which isn't going to be in the cards without a lottery win. I think I'm on track to handle a more reasonable travel schedule that my wife will approve of. Probably the more realistic goal for the portfolio is to generate a bit extra, plus do good things for others after 10 or 20 years. At any rate, I can't throw serious resources into the LETF portfolio until I retire or leave my current employment.

The main reason I'm putting this out is that I got intrigued by the math (I'm an engineer/scientist and deal with risk at work) as applied to my personal situation, and I thought it might be interesting/helpful for others as well.
Chocolatebar
Posts: 192
Joined: Tue Feb 14, 2023 10:58 am

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Chocolatebar »

Hydromod wrote: Thu Mar 23, 2023 9:38 am I'm happy for you to do a python implementation. I'm just a little nervous about passing the matlab code unless you are familiar with matlab, it's not documented as well as it should be for distribution. You'd probably need to step through the code a bit to understand all of the logic. Do you have matlab available?

I would probably reorganize the allocation/trading sections to go to an event loop sequence for robustness - the matlab code does a bunch of vector things, which reduces if statement evaluations but runs the risk of getting timings out of synch.
I've never used matlab, but happy to pick it up to properly reproduce the process in Python. Any documentation you can provide in the code would certainly speed up the effort. We can compare results to make sure the Python implementation perfectly follows the matlab one.

The pruning process you described reminds me of decision trees. My MS education focused on machine learning. Have you ever considered applying ML algorithms towards this approach?

I would be hesitant to implement a forecasting component to the strategy, but could test different approaches to pruning.
er999
Posts: 1302
Joined: Wed Nov 05, 2008 10:00 am

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by er999 »

Hydromod wrote: Thu Mar 23, 2023 9:56 am
er999 wrote: Thu Mar 23, 2023 8:59 am
Hydromod wrote: Sun Mar 19, 2023 9:45 pm I am at the stage of life where I am becoming more concerned about decumulation than accumulation; my portfolio should be adequate to handle basic needs without too much concern but I am short of the amount that will support all of my desires for future travel.
Probably might be easier to give advice if you say your age, how many more years you have to work, and what percentage expenses you have saved.

From reading the above it sounds like you might be short of your goals and looking at some way using mathematical techniques to try to get better returns with less risk. Might work but might blow up.

There might be other less risky ways to achieve your goals. If travel expenses are a concern make sure you are looking at travel hacking with miles and points. You can get quite a bit of luxury travel for very little money, particularly if you are flexible on dates and destinations.

Perhaps you are planning on too conservative with withdrawal rate (not an expert on it myself, others know more on here) and you really don’t need to do these fancy techniques as already have enough money.
I appreciate the concern. Perhaps I was a little misleading about my desires. I desire an unreasonable multiple multimonth excursions annually around the world, which isn't going to be in the cards without a lottery win. I think I'm on track to handle a more reasonable travel schedule that my wife will approve of. Probably the more realistic goal for the portfolio is to generate a bit extra, plus do good things for others after 10 or 20 years. At any rate, I can't throw serious resources into the LETF portfolio until I retire or leave my current employment.

The main reason I'm putting this out is that I got intrigued by the math (I'm an engineer/scientist and deal with risk at work) as applied to my personal situation, and I thought it might be interesting/helpful for others as well.
Good to hear it’s a small percentage — I got the impression it was 100% of your assets. If it’s just a small percentage have fun, hope it works out for you.
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

er999 wrote: Thu Mar 23, 2023 10:17 am Good to hear it’s a small percentage — I got the impression it was 100% of your assets. If it’s just a small percentage have fun, hope it works out for you.
Thanks. I get why that impression is there, I treat it as a silo because of constraints with my 403b. I think it would be acceptable for a fairly large percentage if I were starting out, though.
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

Chocolatebar wrote: Thu Mar 23, 2023 10:01 am I've never used matlab, but happy to pick it up to properly reproduce the process in Python. Any documentation you can provide in the code would certainly speed up the effort. We can compare results to make sure the Python implementation perfectly follows the matlab one.

The pruning process you described reminds me of decision trees. My MS education focused on machine learning. Have you ever considered applying ML algorithms towards this approach?

I would be hesitant to implement a forecasting component to the strategy, but could test different approaches to pruning.
Do you have access to matlab? It's expensive as a personal tool; a student version isn't nearly so bad, though. If you do, I can try some enhanced documentation this weekend.

The pruning is more of a logistical thing; just get rid of tracking an asset if it is only a tiny sliver. Almost all performance will be from the assets with larger allocations. Kind of like using S&P500 versus total market, the small caps just don't move the needle much. Logistically, M1 only allows increments of 1 percent, the pruning is getting rid of the rounding errors.

I don't think that there is nearly enough data to train a ML algorithm on this approach. The duration with suitable data doesn't really cover a full range of market conditions, and the reallocations really shouldn't be more frequent than weekly with this approach. I think ML is more suited to the frequency of day trading, where you'd be looking at second-to-second or minute-to-minute signals. Entirely different set of signals.

Although there are certain types of short-term signals that would apparently have been very profitable and might be added as a small overlay based on ML. That's not really a boglehead thing, though.
Chocolatebar
Posts: 192
Joined: Tue Feb 14, 2023 10:58 am

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Chocolatebar »

Hydromod wrote: Thu Mar 23, 2023 10:49 am Do you have access to matlab? It's expensive as a personal tool; a student version isn't nearly so bad, though. If you do, I can try some enhanced documentation this weekend.
The home version is 150 bucks? Or is a home license insufficient?
Hydromod wrote: Thu Mar 23, 2023 10:49 am I don't think that there is nearly enough data to train a ML algorithm on this approach. The duration with suitable data doesn't really cover a full range of market conditions, and the reallocations really shouldn't be more frequent than weekly with this approach. I think ML is more suited to the frequency of day trading, where you'd be looking at second-to-second or minute-to-minute signals. Entirely different set of signals.

Although there are certain types of short-term signals that would apparently have been very profitable and might be added as a small overlay based on ML. That's not really a boglehead thing, though.
Yeah, this is why I've never seriously pursued applying ML techniques towards my retirement portfolio. Zero interest in day trading. Still interested in at least researching whether we could find a good use-case for it here though.
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

Chocolatebar wrote: Thu Mar 23, 2023 11:37 am The home version is 150 bucks? Or is a home license insufficient?
Wow, I wasn't aware of a home license option. I was thinking that a standard license was the only option unless you were a student, and I was dreading having to buy that.

I expect that a home license would be perfectly fine, I don't think that I use any toolboxes.
User avatar
like2read
Posts: 550
Joined: Wed Jan 22, 2020 4:30 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by like2read »

I made it through the first few pages of your post, and all I kept thinking was man, a three fund portfolio sure sounds pretty good.
Chocolatebar
Posts: 192
Joined: Tue Feb 14, 2023 10:58 am

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Chocolatebar »

like2read wrote: Thu Mar 23, 2023 1:47 pm I made it through the first few pages of your post, and all I kept thinking was man, a three fund portfolio sure sounds pretty good.
Even if you might need to depend on employment longer because of it?
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

like2read wrote: Thu Mar 23, 2023 1:47 pm I made it through the first few pages of your post, and all I kept thinking was man, a three fund portfolio sure sounds pretty good.
No question about it, this approach requires either automation or some level of OCD. It's not for most, I'll be the first to say.

I do want to get to the point that my kids can take advantage and I can stop obsessing, so I am pushing towards the automation outcome. I'd be delighted if we can get there with some good safeguards.
Chocolatebar
Posts: 192
Joined: Tue Feb 14, 2023 10:58 am

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Chocolatebar »

Hydromod wrote: Thu Mar 23, 2023 2:21 pm
like2read wrote: Thu Mar 23, 2023 1:47 pm I made it through the first few pages of your post, and all I kept thinking was man, a three fund portfolio sure sounds pretty good.
No question about it, this approach requires either automation or some level of OCD. It's not for most, I'll be the first to say.

I do want to get to the point that my kids can take advantage and I can stop obsessing, so I am pushing towards the automation outcome. I'd be delighted if we can get there with some good safeguards.
I'd love to see a fully automated process. Not sure what that would look like with M1 though.
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

Chocolatebar wrote: Thu Mar 23, 2023 4:27 pm
Hydromod wrote: Thu Mar 23, 2023 2:21 pm
like2read wrote: Thu Mar 23, 2023 1:47 pm I made it through the first few pages of your post, and all I kept thinking was man, a three fund portfolio sure sounds pretty good.
No question about it, this approach requires either automation or some level of OCD. It's not for most, I'll be the first to say.

I do want to get to the point that my kids can take advantage and I can stop obsessing, so I am pushing towards the automation outcome. I'd be delighted if we can get there with some good safeguards.
I'd love to see a fully automated process. Not sure what that would look like with M1 though.
I think it’s possible through quant connect and ibkr. I saw another matlab based approach a while back that might do, I forgot the name.
Logan Roy
Posts: 1703
Joined: Sun May 29, 2022 10:15 am

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Logan Roy »

Chocolatebar wrote: Thu Mar 23, 2023 11:37 am
Hydromod wrote: Thu Mar 23, 2023 10:49 am Do you have access to matlab? It's expensive as a personal tool; a student version isn't nearly so bad, though. If you do, I can try some enhanced documentation this weekend.
The home version is 150 bucks? Or is a home license insufficient?
Hydromod wrote: Thu Mar 23, 2023 10:49 am I don't think that there is nearly enough data to train a ML algorithm on this approach. The duration with suitable data doesn't really cover a full range of market conditions, and the reallocations really shouldn't be more frequent than weekly with this approach. I think ML is more suited to the frequency of day trading, where you'd be looking at second-to-second or minute-to-minute signals. Entirely different set of signals.

Although there are certain types of short-term signals that would apparently have been very profitable and might be added as a small overlay based on ML. That's not really a boglehead thing, though.
Yeah, this is why I've never seriously pursued applying ML techniques towards my retirement portfolio. Zero interest in day trading. Still interested in at least researching whether we could find a good use-case for it here though.
I've got excellent results using ML for this kind of thing. My takeaways:

– You NEED NEED NEED at least 50 years of market data so you've got one of each of the four basic economic regimes. ML or not, anything else and you just don't have enough data. So many smart algorithms and ML approaches don't use enough data. Better to simulate asset classes and get the four basic environments in than get all the assets in and not get any stagflation.

– ML will overfit and poorly generalise with 50 years of market data. It will learn it like a landscape, and it'll just learn where it is and what it should've invested in.. So, I found just adding noise and smoothing to the inputs (more than you'd think) improved things 1000-fold. Stops it overfitting (effectively gives you 10,000x more data), and so long as you've got the four basic market environments in there, it's got enough to start learning principles (imo).. It's a bit like adding Dropout, but dropout really doesn't work well for me with anything that might be time-series.
Chocolatebar
Posts: 192
Joined: Tue Feb 14, 2023 10:58 am

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Chocolatebar »

Hydromod wrote: Thu Mar 23, 2023 12:13 pm
Chocolatebar wrote: Thu Mar 23, 2023 11:37 am The home version is 150 bucks? Or is a home license insufficient?
Wow, I wasn't aware of a home license option. I was thinking that a standard license was the only option unless you were a student, and I was dreading having to buy that.

I expect that a home license would be perfectly fine, I don't think that I use any toolboxes.
Started a 30-day free trial today. Can purchase the home license when it runs out.
Chocolatebar
Posts: 192
Joined: Tue Feb 14, 2023 10:58 am

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Chocolatebar »

Logan Roy wrote: Thu Mar 23, 2023 7:46 pm I've got excellent results using ML for this kind of thing. My takeaways:

– You NEED NEED NEED at least 50 years of market data so you've got one of each of the four basic economic regimes. ML or not, anything else and you just don't have enough data. So many smart algorithms and ML approaches don't use enough data. Better to simulate asset classes and get the four basic environments in than get all the assets in and not get any stagflation.

– ML will overfit and poorly generalise with 50 years of market data. It will learn it like a landscape, and it'll just learn where it is and what it should've invested in.. So, I found just adding noise and smoothing to the inputs (more than you'd think) improved things 1000-fold. Stops it overfitting (effectively gives you 10,000x more data), and so long as you've got the four basic market environments in there, it's got enough to start learning principles (imo).. It's a bit like adding Dropout, but dropout really doesn't work well for me with anything that might be time-series.
Makes sense and sounds like a great project. Would enjoy reading more about your models and results in a dedicated thread. You should start one!
Logan Roy
Posts: 1703
Joined: Sun May 29, 2022 10:15 am

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Logan Roy »

Chocolatebar wrote: Fri Mar 24, 2023 7:31 am
Logan Roy wrote: Thu Mar 23, 2023 7:46 pm I've got excellent results using ML for this kind of thing. My takeaways:

– You NEED NEED NEED at least 50 years of market data so you've got one of each of the four basic economic regimes. ML or not, anything else and you just don't have enough data. So many smart algorithms and ML approaches don't use enough data. Better to simulate asset classes and get the four basic environments in than get all the assets in and not get any stagflation.

– ML will overfit and poorly generalise with 50 years of market data. It will learn it like a landscape, and it'll just learn where it is and what it should've invested in.. So, I found just adding noise and smoothing to the inputs (more than you'd think) improved things 1000-fold. Stops it overfitting (effectively gives you 10,000x more data), and so long as you've got the four basic market environments in there, it's got enough to start learning principles (imo).. It's a bit like adding Dropout, but dropout really doesn't work well for me with anything that might be time-series.
Makes sense and sounds like a great project. Would enjoy reading more about your models and results in a dedicated thread. You should start one!
The problem is, if you run into something that seems to work, the one thing you mustn't do is publish how you did it.. Maybe if you've got all the money you'll ever need, and you just want to do it as an intellectual exercise, but you're killing the thing by exposing it to sunlight.. What I'd say the great opportunity seems to be is that ML types don't know anywhere near enough about macroeconomics to build models that have a hope of working robustly. Even in the industry, macro, quant, fundamentals seem so enclaved, it makes no sense to me at all.
Chocolatebar
Posts: 192
Joined: Tue Feb 14, 2023 10:58 am

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Chocolatebar »

Logan Roy wrote: Fri Mar 24, 2023 9:07 am The problem is, if you run into something that seems to work, the one thing you mustn't do is publish how you did it.. Maybe if you've got all the money you'll ever need, and you just want to do it as an intellectual exercise, but you're killing the thing by exposing it to sunlight.. What I'd say the great opportunity seems to be is that ML types don't know anywhere near enough about macroeconomics to build models that have a hope of working robustly. Even in the industry, macro, quant, fundamentals seem so enclaved, it makes no sense to me at all.
Username checks out I guess.
afan
Posts: 8106
Joined: Sun Jul 25, 2010 4:01 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by afan »

Although the OP mentions backtesting, can I ask how much you tried to separate real effects from overfitting? Did you apply the approaches to subsamples of the time data?
Did you try it with foreign markets?

Do you have an opinion as to how to begin to address the overfitting problem? There appears to be a large, perhaps arbitrarily large, number of variables with an even larger number of potential combinations. These are then used to optimize across both mean and standard deviation, without a predefined preference of one over the other. The higher moments of the distribution are not considered, if I understand your approach, but most people care about extreme drawdowns and wide tails. The approaches are chosen based on previous backtesting so one cannot do conventional statistics on the results.

With those challenges, how does one separate signal from noise?
We don't know how to beat the market on a risk-adjusted basis, and we don't know anyone that does know either | --Swedroe | We assume that markets are efficient, that prices are right | --Fama
ElJefeDelQueso
Posts: 171
Joined: Wed Mar 06, 2019 4:54 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by ElJefeDelQueso »

Chocolatebar wrote: Thu Mar 23, 2023 11:37 am
Hydromod wrote: Thu Mar 23, 2023 10:49 am Do you have access to matlab? It's expensive as a personal tool; a student version isn't nearly so bad, though. If you do, I can try some enhanced documentation this weekend.
The home version is 150 bucks? Or is a home license insufficient?
Hydromod wrote: Thu Mar 23, 2023 10:49 am I don't think that there is nearly enough data to train a ML algorithm on this approach. The duration with suitable data doesn't really cover a full range of market conditions, and the reallocations really shouldn't be more frequent than weekly with this approach. I think ML is more suited to the frequency of day trading, where you'd be looking at second-to-second or minute-to-minute signals. Entirely different set of signals.

Although there are certain types of short-term signals that would apparently have been very profitable and might be added as a small overlay based on ML. That's not really a boglehead thing, though.
Yeah, this is why I've never seriously pursued applying ML techniques towards my retirement portfolio. Zero interest in day trading. Still interested in at least researching whether we could find a good use-case for it here though.
It's often straightforward to port Matlab scripts into GNU Octave https://octave.org/

It's free, open source, and mostly Matlab compatible. I've ported some very complicated (to me) Matlab scripts to Octave with modest effort. If you aren't using toolboxes this should be easy.
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

ElJefeDelQueso wrote: Fri Mar 24, 2023 1:45 pm It's often straightforward to port Matlab scripts into GNU Octave https://octave.org/

It's free, open source, and mostly Matlab compatible. I've ported some very complicated (to me) Matlab scripts to Octave with modest effort. If you aren't using toolboxes this should be easy.
I'm aware of Octave, I've never used it. I suspect that it should port fairly well. The main caveat is that matlab expanded their convention on array operations in recent releases and I take advantage. Going back to a release from several years ago might break. I don't know Octave's convention, it might cause an issue.
User avatar
Forester
Posts: 2400
Joined: Sat Jan 19, 2019 1:50 pm
Location: UK

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Forester »

Momentum is a form of gambling which can lock in unrecoverable bad timing luck. Why not The Simplest Adventure - 100% USML, the levered min vol ETF. That's the real free lunch, levering up low vol stocks.
Amateur Self-Taught Senior Macro Strategist
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

afan wrote: Fri Mar 24, 2023 1:06 pm Although the OP mentions backtesting, can I ask how much you tried to separate real effects from overfitting? Did you apply the approaches to subsamples of the time data?
Did you try it with foreign markets?

Do you have an opinion as to how to begin to address the overfitting problem? There appears to be a large, perhaps arbitrarily large, number of variables with an even larger number of potential combinations. These are then used to optimize across both mean and standard deviation, without a predefined preference of one over the other. The higher moments of the distribution are not considered, if I understand your approach, but most people care about extreme drawdowns and wide tails. The approaches are chosen based on previous backtesting so one cannot do conventional statistics on the results.

With those challenges, how does one separate signal from noise?
I'm sorry, I guess that I wasn't as clear as I thought with the OP.

I want to make it plain that the presented material is mainly intended to show how one might take advantage of statistical characteristics (volatility clustering, momentum) that are recognized as robustly present across a wide range of markets. The computational approaches (minimum variance, momentum calculations, index funds) are pretty widely used; I just tried to put the bits together in a useful way that focuses on smoother, more consistent portfolio behavior while preserving much of the returns.

The minimum variance and index fund bits explicitly seek minimum portfolio volatility, which usually comes at the expense of returns. The risk budget and momentum bits are layered on to explicitly bias the portfolio towards higher-returning assets.

In no way is the approach "optimized"; it just uses components that tend to be harmonious with the overall goal of relatively smooth portfolio behavior with reasonably good returns.

A user needs to select their own assets and their own parameters, based on their own risk tolerances and circumstances. I suppose that one could try to tune with a lot of parameters; I try to be as parsimonious and unbiased as possible for my own portfolio, precisely because of the likelihood of overfitting.

The examples extract key aspects from hundreds to thousands of my own simulations with various combinations. The examples use representative parameters that work over a range of values, but the values in the examples are usually in a slightly sweeter spot. I generally try to just pick something near the middle of a good range of values, and leave it at that.

My main parameters include:
  • relative risk assigned to each asset class (I use two asset classes, hence one parameter, in the examples; this is the most important parameter with the approach)
  • lookback duration for volatility (this is main driver for risk estimates)
  • lookback duration for covariance (I use a bit longer duration for estimate stability)
  • lookback duration(s) used to estimate momentum (I use two, others use 3 or 4; momentum is the least robust part of the approach IMO)
  • a risk budget weight to scale for variable leverage (optional)
Less important parameters that depend on user preferences include
  • "tweaky" parameters to customize the risk assigned to "exceptional" assets with very low or very large volatilities (optional)
  • constraints on minimum and maximum allocations (optional)
  • calculation strategies
The questions about backtesting and determining signal from noise are quite on point with respect to selecting a specific portfolio, though.

You can track quite a bit of backtesting in the previous thread. That guided the adoption of the risk budget minimum variance part, which I consider the heart of the approach, with quite a bit on timing issues, timing luck, etc. These tests show typical drawdowns, moving subsampled intervals, tails, etc. Some of that considers monthly behavior prior to 1986, which gives some additional market conditions.

The momentum bits are much newer, with much less backtesting. I think a good approach is to gently nudge the risk budget using lots of assets, that seems to work more robustly than other options I've tried, but I will never push anyone into using momentum.

I don't have access to long sequences of daily records of index funds or simulated index funds across a wide range of markets and market conditions. If someone were to come up with such records, I'd be delighted to test with them. I think that records generated numerically would be less useful, because momentum is an emergent behavior that may be hard to capture appropriately.
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

Forester wrote: Fri Mar 24, 2023 3:08 pm Momentum is a form of gambling which can lock in unrecoverable bad timing luck. Why not The Simplest Adventure - 100% USML, the levered min vol ETF. That's the real free lunch, levering up low vol stocks.
You are correct on momentum, depending on how it is used in constructing a portfolio. The robust momentum factor that folks point to is a statistical thing defined for groups, where the group of stocks with best recent returns in a market tend to outperform the group of stocks with the worst recent returns.

This has nothing to do with any particular stock.

The way momentum is commonly used is to go all-in/all-out based on the individual asset momentum, but there is only a modest statistical edge with momentum. Inevitably that will make poor choices, although in the very long term the statistical edge may be captured.

That's why I am suggesting using many sectors, increasing the risk budget to the best and decreasing the risk budget to the worst. This is a gradual thing. Much less chance of outrageous performance, much less chance of catastrophic failure.

I don't know enough about USML to have an opinion. I will say that I tend to get better results with a mix of high- and low-volatility levered assets than just low-volatility assets.
Football2408
Posts: 26
Joined: Mon Sep 05, 2022 12:31 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Football2408 »

Found your Reddit posts and followed here.

Have come to a similar portfolio allocation and weighting style using portfolio visualizer Adaptive allocation model. Trying to make it easier to manage for me just using the PV tools Would love your thoughts on it.

Momentum settings: 9 and 2 month look backs. Choose top 7 holdings, drop the rest
Variance- 3 month lookback. Weight Inverse Volatility

Holdings: trying to keep to risk parity principles. Goal is to have main US equity drivers (beta) + moderate to low correlated equity tilts + defensive low to negative correlated holdings

Total inputs: 13: UPRO TMF UGL TQQQ EDC DRN UTSL MFTFX YCS ERX TNA DFEN EUO

Variations if chosen for that month period
EDC- make 50% EDC /50% CHAU (lower correlation and IMO KBA holdings are a stronger connection to Chinese economy)


Why not include more sector tits and international? Because of the correlations and purpose in portfolio. DFEN did great in 2022 and has a different type of exposure IMO that could do well when S&P isn’t. Utilities are historically super low correlated to S&P and did super strong in 2000-2003 period. Developed markets have too much correlation and reliance on S&P 500. Keeping gold bcuz I think if dollar drops and international out performs, it could have an amazing run. DRN and ERX are kind of built different too and can or May act differently in inflation or otherwise trending periods.
Did some back testing using the leveraged funds since 2012 or so (besides dfen/utsl) and some testing on the one time funds since 2001 (Soc gen trend index) and believe results are promising. However trying not to “over fit”, for instance any backtest 2011-2023 will look amazing if heavy in US large cap or growth but SHARPEs were generally .9 to 1.14 range depending on time periods tested. 2022 would have turned out suprisngly well thanks to MFTFX, ERX energy, and Ycs. Other years 2018/2015 kind of random returns but that’s too be expected.

TLDR: adaptive allocation+volatility cluster + momentum factor + risk parity volatility adjustments + low correlation + leverage = profit??
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

Football2408 wrote: Sun Jul 30, 2023 1:00 pm Total inputs: 13: UPRO TMF UGL TQQQ EDC DRN UTSL MFTFX YCS ERX TNA DFEN EUO

TLDR: adaptive allocation+volatility cluster + momentum factor + risk parity volatility adjustments + low correlation + leverage = profit??
A few things to consider.
  • An inverse volatility approach tends to have the highest allocations to the lowest volatility assets. When mixing 3x equities with things like YCS, EOU, UGL, and MFTFX, you are giving up a lot of allocation space to things that tend not to have much net return.
  • Somehow the dropping of assets helps to overcome this to some extent. I don't quite understand why.
I tried a backtest starting in 2009 with my approach, replacing MFTFX and TNA with KMLM and URTY. Some are extended with simulated returns.

If I do a straight inverse volatility, I get rather low CAGR (about half what PV gives) but decent Sharpe. The portfolio generally has a weighted leverage of about 1.5 to 2, with average weight of 84% to UGL, KMLM, EUO, and YCS combined and another 9% to TMF. Not really what you want, because these don't have much in the way of expected returns.

I usually bump up the risk assigned to equities and artificially increase calculated volatility for low-volatility assets, which helps bump up the equity allocations and that pumps up returns. PV won't do this.

I actually don't use UPRO in favor of more volatile sector assets that work together to roughly approximate UPRO.

So in summary I'm concerned that I don't understand why PV is generating the level of returns that backtesting seems to give. My intuition is that you should be so overloaded with assets that don't have much return that you won't be able to get much in the way of returns.
Football2408
Posts: 26
Joined: Mon Sep 05, 2022 12:31 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Football2408 »

Yes. I actually looked at some of those facts more before reading your response.

Trying to keep risk parity principles in mind and want to keep at least a sliver of leveraged equities / bonds / alternatives in portfolio at all times. I also noticed a few times want commodity take up 30-45+% which is too high for one defensive holding at least if I want to be risk parity esque. Looking at the back tests this would have worked fine.

So i took out the managed future portion, the EUO, and added RETL and PCLIX. PCLIX is super impressive, DBC with a BND overlay and on any back test just does super strong. EUO I’ll still include as 1/3 of YCS holding when it makes the cut. EDC will be 1/3 CHAU when it makes it. Not 100% on including TYD But probbaly good as shorter duration treasuries have done great, even better than long term for certain time frames.
Really like how I have it laid out now and how it back tested. Intuitively it makes sense and should smooth any LETF adventure.
Last edited by Football2408 on Sun Dec 31, 2023 10:32 pm, edited 1 time in total.
jkozlow3
Posts: 22
Joined: Tue Aug 09, 2016 1:13 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by jkozlow3 »

Logan Roy wrote: Thu Mar 23, 2023 7:46 pm I've got excellent results using ML for this kind of thing. My takeaways:

– You NEED NEED NEED at least 50 years of market data so you've got one of each of the four basic economic regimes.
Do you believe the market operates the same way today as it did 50 years ago? The market moves MUCH quicker today vs. when people phoned in orders to the trading floor. Wall St. algos and high frequency trading have completely changed the game. Not to mention the huge rise in popularity of 0DTE options and whatnot. I'd argue that any data more than 5 years old is quite stale and that the next 5 years will probably look a lot more like the previous 5 than they will look like the 1970s and 80s. IMHO, you're comparing VHS to streaming Netflix. Or perhaps a tricycle to a Ferrari.
Logan Roy
Posts: 1703
Joined: Sun May 29, 2022 10:15 am

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Logan Roy »

jkozlow3 wrote: Sun Sep 03, 2023 3:03 pm
Logan Roy wrote: Thu Mar 23, 2023 7:46 pm I've got excellent results using ML for this kind of thing. My takeaways:

– You NEED NEED NEED at least 50 years of market data so you've got one of each of the four basic economic regimes.
Do you believe the market operates the same way today as it did 50 years ago? The market moves MUCH quicker today vs. when people phoned in orders to the trading floor. Wall St. algos and high frequency trading have completely changed the game. Not to mention the huge rise in popularity of 0DTE options and whatnot. I'd argue that any data more than 5 years old is quite stale and that the next 5 years will probably look a lot more like the previous 5 than they will look like the 1970s and 80s. IMHO, you're comparing VHS to streaming Netflix. Or perhaps a tricycle to a Ferrari.
Sure, if you're day-trading. But 5 years of liquidity-driven bull market doesn't tell you anything whatsoever about how investments are going to behave through a stagflationary period. There are patterns in how markets are reacting today that are most similar to 1930-1945, because there are macroeconomic similarities.. Whether people are phoning in orders, or getting algorithms to place them, we're still the same animals, in a fairly similar economy, trying to make similar predictions and suffering from similar biases. It surprises me more that things like market volatility and momentum are as similar as they are over such long periods.
scout1
Posts: 233
Joined: Thu Oct 18, 2018 3:26 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by scout1 »

This feels like HFEA all over again. Your process is similar, so I would expect the outcome to be similar as well.
jkozlow3
Posts: 22
Joined: Tue Aug 09, 2016 1:13 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by jkozlow3 »

Bogleheads: home to the most skeptical and fiscally conservative investors I've ever met. :P
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

I've often thought that it would be interesting to do some sort of time scaling for backtesting, just because of the relative rapidity of today's market. It might not make too much difference with a monthly stride, but delaying the trade response by a day or two in the past and adding trade costs would be a very fair approach.

I suspect that something like HFEA with quarterly rebalancing would not have been all that influenced, because the friction is small relative to the trading interval. Something like what I'm proposing, with weekly updating, would have been considerably influenced. Although perhaps it would be more realistic to consider two or three days in the past to be like one day now.
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

scout1 wrote: Sun Sep 03, 2023 6:59 pm This feels like HFEA all over again. Your process is similar, so I would expect the outcome to be similar as well.
Perhaps. After all, they both are based on the same market, both use LETFs, and both try to use a levered "safe" portfolio. Those constraints are similar, so any outcome relying on those ingredients should have a similar outcome as well.

Not to be snippy on a holiday weekend.
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

One of the things that has kind of bugged me for quite a while is that the risk parity approaches seem to work fairly well when balancing assets that have similar volatility, but the allocations get all out of whack when including assets with much lower (or larger) volatility.

My heuristic approach to fixing this was to artificially provide the minimum variance solver with asset volatilities that are individually scaled up or down, but I didn't have a good rationale for the scaling. I provide the algorithm with an individual asset scale factor, and the volatilities provided to the solver are divided by that scale factor.

This had first popped up with TYD. I made an adjustment for TYD based on assumed duration, generating a scale factor of 10/25 = 0.4, which tended to give a fairly reasonable balance between TYD and TMF. This led me to think of the scale factor as a duration scaling. The drawback is that duration is a little hard to interpret for many assets.

When constructing portfolios with a mixture of 3x and 1x LETFs, I ended up using a scale factor of 0.1 for the 1x ETFs, which worked pretty well. Note that this is approximately (1/3)^2.

As a workaround, I set upper limits on the maximum allocation for the low-volatility assets and did some playing with creating rules for the circumstances that allow the assets to be considered. This is very unsatisfactory, because it adds all sorts of tuning parameters without much basis.

The other day I started playing with the scale factor with a model portfolio of several equity assets and several ballast assets, trying to remove the artificial maximum allocation constraints on the ballast assets. Again, I had to use scale factors much smaller than 1 to get some of the low-volatility assets like YCS.

It occurred to me the other day that perhaps this should be a volatility factor rather than a duration factor. I calculated the average long-term volatility and scaled by the ratio of volatilities, which moved things in the right direction. Scaling by the ratio of asset variance to TMF variance (again measured over long periods) seems to work quite well for the ballast assets. Similarly, scaling by the ratio of asset variance to UPRO variance (again measured over long periods) seems to work well for the equity assets. In effect, the time-varying variances used by the solver are normalized based on the long-term average, which makes it seem like all assets have similar volatility.

Just as an example, the following figure considers a portfolio based on the risk-budget minimum variance approach without considering momentum. Four risk assets and five ballast assets.

Image
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

This example has about 1/3 larger CAGR than the corresponding simulation with everything identical except for the variance switch.

The average equity allocation is equivalent to 114% allocated.

The key thing is that the simulation assumes weekly reset of the desired allocations and daily rebalancing with those allocations. The boost drops considerably with two days between rebalancing and is essentially gone with weekly rebalancing. I get similar improvements using my momentum approach.

I'm putting this out there, because it seems like it would be potentially useful. I still have to do more due diligence on it though.

My feel is that the net result is that the allocations for the individual assets tend to move with similar magnitudes, which boosts a daily rebalancing bonus. Don't hold me to that, though, it's just my thought.
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

Using the same approach without the variance scaling, the ballast assets end up with a higher allocation. The average equity allocation is equivalent to 86%.

Image

Note that I drop assets that have less than 2% allocations, which gives some allocation gaps even though most assets are always or almost always allocated.

I'm astounded that this simple change tends to keep the ballast assets in reasonable balance, even if they have rather different volatilities.
Football2408
Posts: 26
Joined: Mon Sep 05, 2022 12:31 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Football2408 »

Interesting. Using these refinements, what are the upper bounds of allocations towards the lower vol holdings like YCS and KMLM. 15-20% ?
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

Football2408 wrote: Tue Sep 05, 2023 9:05 pm Interesting. Using these refinements, what are the upper bounds of allocations towards the lower vol holdings like YCS and KMLM. 15-20% ?
You can get a bit of a feel by comparing the top subplots in each figure. The gray halos are allocations. The limits on the ballast assets are scaled by the risk budget for equities and ballast; higher risk to equities, lower limits on ballast assets. I typically have had to set limits to something like 20%.

You can see that KMLM seems to peak highest, followed by YCS, while PDBC is consistently the lowest. It looks like KMLM and YCS will exceed 40 or even 50 percent for short intervals, even though their average allocation is much smaller.

The peaking is actually a feature that I like, preserving balances by transferring out of equities to the low-volatility assets when most assets are crashing. Basically mimicking approaches that deleverage by going in and out of the market, but in a smoother way.

I'm still getting my head around this approach, but I thought it might be interesting for folks to think about. The biggest benefit is that it drops out many of my tuning constraints for the low-volatility assets. Some of my subsequent testing shows that simply changing the scaling, keeping all else equal, mostly helps returns a bit, but sometimes drops returns a bit as well. The biggest advantage seems to be with daily rebalancing.
simply_flantastic
Posts: 5
Joined: Tue Apr 04, 2023 1:40 am

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by simply_flantastic »

Your approach here is similar to one I attempted to dive into 1-2 years ago. Here are some of my notes: https://docs.google.com/document/d/1NhC ... N1NpBi9SKg

I had plans to expand and enact the strategy but ended up not having time and put the project on hold. Definitely going to give this thread a deep dive and maybe it'll reignite my interest in this type of strategy.

I've only skimmed your first post so far but one concern I immediately have is that daily rebalancing may result in significant drag on returns due to the buy/sell spread. When I was considering this kind of portfolio I was leaning toward monthly rebalancing with additional rebalances only when market conditions caused my calculated kelly to require a significant (e.g. 10%) change in asset allocations.

I'm definitely going to have some more questions after reading everything and look forward to discussing this more!
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

simply_flantastic wrote: Wed Sep 06, 2023 11:50 am Your approach here is similar to one I attempted to dive into 1-2 years ago. Here are some of my notes: https://docs.google.com/document/d/1NhC ... N1NpBi9SKg

I had plans to expand and enact the strategy but ended up not having time and put the project on hold. Definitely going to give this thread a deep dive and maybe it'll reignite my interest in this type of strategy.

I've only skimmed your first post so far but one concern I immediately have is that daily rebalancing may result in significant drag on returns due to the buy/sell spread. When I was considering this kind of portfolio I was leaning toward monthly rebalancing with additional rebalances only when market conditions caused my calculated kelly to require a significant (e.g. 10%) change in asset allocations.

I'm definitely going to have some more questions after reading everything and look forward to discussing this more!
I hope you enjoy!

I incorporate drag from rebalancing in my backtesting calculations. I don't have the actual time-dependent bid-ask information, but I do use some relatively recent estimates of median values. I always subtract half this bid-ask value from the buy and sell sides of every transaction. Note that most daily trades are only a small fraction of the asset holding.

I think that the portfolio returns benefit from Shannon's Demon (you have the link in your document) with daily rebalancing, with a more consistent improvement with lots of assets. There's just more opportunities for an asset to have a big excursion and return. I try to account for uncertainty in actual trade prices by randomly setting the price at trade based on the OHLC prices, but the noise is assumed uncorrelated and it's always possible that I'm overestimating the effect. However, the minimum variance approach tends to allocate based on minimizing portfolio variance, which means that it seeks to balance out expected excursions above and below the trend to the extend feasible based on recent correlations.

I do monthly rebalancing in my taxable account, although I suspect that the returns benefit of daily rebalancing may outweigh the tax drag.

In practice, I would not consider daily rebalancing without some fully automated mechanism. I don't mind weekly rebalancing, I have a nice automation going and I have an interest. Manually logging in and pushing rebalance daily seems to be more than I find of interest, because the tracking data gets to be more than I want to do. If I could reliably and safely do this in an automated way, I think I would take the plunge, at least in my Roth portfolio.
simply_flantastic
Posts: 5
Joined: Tue Apr 04, 2023 1:40 am

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by simply_flantastic »

There are some platforms with API's that allow you to execute python code to make trades but I never got to the point of looking into if my plans were feasible on them. Alpaca and Interactive Brokers were two I wanted to check out if/when I got to later stages of planning.

The python algorithm I was using comes from the Bogleheads user Uncorrelated but I never tested the robustness and accuracy of it. I made a few tweaks but here was the code I was running for generating my allocations. My expertise is also with software development and not data analysis so using algo libraries and jupyter notebook can make my head spin.

I was just using google sheets for my data as it was free and these were just initial tests. I was going to pick a paid API for financial data later but never got the project out of initial testing stages.

Code: Select all

import gspread
import scipy.optimize
import numpy as np
from datetime import datetime

gc = gspread.service_account(filename='credentials.json')
sh = gc.open_by_key('GOOGLE_SHEETS_KEY_HERE')
worksheet = sh.worksheet("pythondata")

cashInfo = worksheet.row_values(2)
spyInfo = worksheet.row_values(3)
tltInfo = worksheet.row_values(4)
gldInfo = worksheet.row_values(5)
gbtcInfo = worksheet.row_values(6)
corrInfo = worksheet.get('B8:B13')

# RETURNS
asset_returns = np.array([
    # cash: 0.5% per year (also represents borrowing costs)
    float(cashInfo[2].strip('%')) / 100,
    float(spyInfo[2].strip('%')) / 100,     # SPY
    float(tltInfo[2].strip('%')) / 100,    # TLT
    float(gldInfo[2].strip('%')) / 100,   # GLDM
    float(gbtcInfo[2].strip('%')) / 100,     # GBTC
])

# VOLATILITY
asset_volatility = np.array([
    .0,     # cash: 0% volatility
    float(spyInfo[3].strip('%')) / 100,    # SPY
    float(tltInfo[3].strip('%')) / 100,   # TLT
    float(gldInfo[3].strip('%')) / 100,    # GLDM
    float(gbtcInfo[3].strip('%')) / 100,   # GBTC
])

# CORRELATIONS
spy_tlt = float(corrInfo[0][0])
spy_gld = float(corrInfo[1][0])
spy_gbtc = float(corrInfo[2][0])
tlt_gld = float(corrInfo[3][0])
tlt_gbtc = float(corrInfo[4][0])
gld_gbtc = float(corrInfo[5][0])
asset_correlations = np.array([
    [1,              0,              0,              0,              0],
    [0,              1,              spy_tlt,        spy_gld,        spy_gbtc],
    [0,              spy_tlt,        1,              tlt_gld,        tlt_gbtc],
    [0,              spy_gld,        tlt_gld,        1,              gld_gbtc],
    [0,              spy_gbtc,       tlt_gbtc,       gld_gbtc,       1],
])

# GAMMA: Coefficient of risk aversion
# 1.0 = Highly risk seeking. Maximizes returns irrespective of risk
# 3.0 = Risk neutral. Maximizes returns at moderate risk level
# 5.0+ = Highly risk averse. Maximizes returns at very low risk level
gamma = 3.0


# Cash / asset upper and lower bounds
cash_bounds = (-1, 1)
spy_bounds = (0.001, np.inf)
tlt_bounds = (0.001, np.inf)
gld_bounds = (0.001, .15)
gbtc_bounds = (.001, .1)


def mean_and_std(asset_weights):
    r = np.dot(asset_weights, asset_returns)
    std = asset_weights * asset_volatility
    std = std.reshape((1, len(std)))
    var = np.matmul(np.matmul(std, asset_correlations), std.transpose())
    return r, var[0][0]**.5


def utility(asset_weights):
    mean, std = mean_and_std(asset_weights)
    return mean - .5 * gamma * std**2


solution = scipy.optimize.minimize(
    lambda x: -utility(x),
    x0=np.full_like(asset_returns, .5),
    bounds=[cash_bounds] + [spy_bounds] +
    [tlt_bounds] + [gld_bounds] + [gbtc_bounds],
    constraints=[{'type': 'eq', 'fun': lambda x: x.sum() - 1}, ],
    method='SLSQP',
    tol=1e-20
)


print(solution.message)
print("asset weights: ", solution.x)
print("return: {:6.2%}, std: {:6.2%}".format(*mean_and_std(solution.x)))
I'm not sure if this is the most up-to-date version of the code. I'd have to check later if I made any changes. I can see last time I ran this code the borrowing cost was only 0.5% compared to over 5% today.

I think it may be risky to not have updated bid/ask information in your calculations. The biggest trades you're going to be making are going to be during volatile periods when big/ask spreads are likely to rise. This won't be a concern for a fund like SPY but may be a substantial concern for less traded funds or leveraged funds like UPRO.

Again, I may have additional comments but really need to read the full thread before commenting!
comeinvest
Posts: 2617
Joined: Mon Mar 12, 2012 6:57 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by comeinvest »

simply_flantastic wrote: Wed Sep 06, 2023 2:14 pm There are some platforms with API's that allow you to execute python code to make trades but I never got to the point of looking into if my plans were feasible on them. Alpaca and Interactive Brokers were two I wanted to check out if/when I got to later stages of planning.

The python algorithm I was using comes from the Bogleheads user Uncorrelated but I never tested the robustness and accuracy of it. I made a few tweaks but here was the code I was running for generating my allocations. My expertise is also with software development and not data analysis so using algo libraries and jupyter notebook can make my head spin.

I was just using google sheets for my data as it was free and these were just initial tests. I was going to pick a paid API for financial data later but never got the project out of initial testing stages.

Code: Select all

import gspread
import scipy.optimize
import numpy as np
from datetime import datetime

gc = gspread.service_account(filename='credentials.json')
sh = gc.open_by_key('GOOGLE_SHEETS_KEY_HERE')
worksheet = sh.worksheet("pythondata")

cashInfo = worksheet.row_values(2)
spyInfo = worksheet.row_values(3)
tltInfo = worksheet.row_values(4)
gldInfo = worksheet.row_values(5)
gbtcInfo = worksheet.row_values(6)
corrInfo = worksheet.get('B8:B13')

# RETURNS
asset_returns = np.array([
    # cash: 0.5% per year (also represents borrowing costs)
    float(cashInfo[2].strip('%')) / 100,
    float(spyInfo[2].strip('%')) / 100,     # SPY
    float(tltInfo[2].strip('%')) / 100,    # TLT
    float(gldInfo[2].strip('%')) / 100,   # GLDM
    float(gbtcInfo[2].strip('%')) / 100,     # GBTC
])

# VOLATILITY
asset_volatility = np.array([
    .0,     # cash: 0% volatility
    float(spyInfo[3].strip('%')) / 100,    # SPY
    float(tltInfo[3].strip('%')) / 100,   # TLT
    float(gldInfo[3].strip('%')) / 100,    # GLDM
    float(gbtcInfo[3].strip('%')) / 100,   # GBTC
])

# CORRELATIONS
spy_tlt = float(corrInfo[0][0])
spy_gld = float(corrInfo[1][0])
spy_gbtc = float(corrInfo[2][0])
tlt_gld = float(corrInfo[3][0])
tlt_gbtc = float(corrInfo[4][0])
gld_gbtc = float(corrInfo[5][0])
asset_correlations = np.array([
    [1,              0,              0,              0,              0],
    [0,              1,              spy_tlt,        spy_gld,        spy_gbtc],
    [0,              spy_tlt,        1,              tlt_gld,        tlt_gbtc],
    [0,              spy_gld,        tlt_gld,        1,              gld_gbtc],
    [0,              spy_gbtc,       tlt_gbtc,       gld_gbtc,       1],
])

# GAMMA: Coefficient of risk aversion
# 1.0 = Highly risk seeking. Maximizes returns irrespective of risk
# 3.0 = Risk neutral. Maximizes returns at moderate risk level
# 5.0+ = Highly risk averse. Maximizes returns at very low risk level
gamma = 3.0


# Cash / asset upper and lower bounds
cash_bounds = (-1, 1)
spy_bounds = (0.001, np.inf)
tlt_bounds = (0.001, np.inf)
gld_bounds = (0.001, .15)
gbtc_bounds = (.001, .1)


def mean_and_std(asset_weights):
    r = np.dot(asset_weights, asset_returns)
    std = asset_weights * asset_volatility
    std = std.reshape((1, len(std)))
    var = np.matmul(np.matmul(std, asset_correlations), std.transpose())
    return r, var[0][0]**.5


def utility(asset_weights):
    mean, std = mean_and_std(asset_weights)
    return mean - .5 * gamma * std**2


solution = scipy.optimize.minimize(
    lambda x: -utility(x),
    x0=np.full_like(asset_returns, .5),
    bounds=[cash_bounds] + [spy_bounds] +
    [tlt_bounds] + [gld_bounds] + [gbtc_bounds],
    constraints=[{'type': 'eq', 'fun': lambda x: x.sum() - 1}, ],
    method='SLSQP',
    tol=1e-20
)


print(solution.message)
print("asset weights: ", solution.x)
print("return: {:6.2%}, std: {:6.2%}".format(*mean_and_std(solution.x)))
I'm not sure if this is the most up-to-date version of the code. I'd have to check later if I made any changes. I can see last time I ran this code the borrowing cost was only 0.5% compared to over 5% today.

I think it may be risky to not have updated bid/ask information in your calculations. The biggest trades you're going to be making are going to be during volatile periods when big/ask spreads are likely to rise. This won't be a concern for a fund like SPY but may be a substantial concern for less traded funds or leveraged funds like UPRO.

Again, I may have additional comments but really need to read the full thread before commenting!
The bid/ask however does not give you accurate information on the actual trading cost. The displayed bid and ask are basically just indicative numbers from the lit exchanges. Most retail trades are filled off exchange between the NBBO bid and ask. The actual slippage, or effective spread from the midpoint, is dependent on the broker. The only way that I know to estimate the trading cost with your broker and for the securities in question, is by trying it out over longer times and collecting the fill quality statistics.
Like you said, the slippage will probably increase with volatility and other market conditions.
Topic Author
Hydromod
Posts: 1046
Joined: Tue Mar 26, 2019 10:21 pm

Re: Hydromod's Okay Adventure: Leverage, Momentum, and Risk Management

Post by Hydromod »

I've been intrigued by the rebalancing bonus that I've been seeing with daily rebalancing, ever since my early experiments with HFEA. It's an example of Shannon's demon operating on short-term fluctuations, selling relative winners to buy relative losers.

The Breaking the Market site tries to promote frequent rebalancing to improve geometric returns. I must say I never quite understood the arguments from the blog posts, but I heard an older podcast the other day where he tried to explain verbally and I got the gist a bit better.

I decided to check out the rebalancing bonus using the set of LETFs that are selected from in my model (leaving out crypto), calculated the daily correlations and variances of the log returns over the period all were active (since November 2014), and generated a series of portfolios with daily rebalancing, assuming the returns were lognormally distributed with mean zero (actual daily returns are fatter tailed than lognormal, so this is only approximate). Every day, the allocations are reset to 1/N of the portfolio, where N is the number of assets.

The figure shows the cumulative CAGR of the portfolio minus the average of the cumulative CAGR over all assets.

The leverage = 1 set multiplies all standard deviations by 1/3 (almost all LETFs are 3x), the leverage = 2 set multiplies by 2/3, and the leverage = 3 set is unmodified.

Image

In this, each of the individual assets converge to CAGR = 0.

We see that the rebalancing balance is proportional to the square of the leverage. In theory, the rebalancing bonus is proportional to (N-1)/N. So there is diminishing benefit by adding assets: 25 assets instead of 5 would have about 1.2 times larger CAGR. The convergence occurs sooner with more assets, however.

Interestingly, if the comparison is to the CAGR of a portfolio constructed by selecting the initial asset allocations and without ever rebalancing, the rebalancing bonus takes much longer to converge and the never-rebalanced portfolio often wins over a typical investor's lifetime. Something about arithmetic averages versus geometric averages, so it may be easy to find counter examples where not doing the daily rebalancing will win. I suspect that advantage would diminish if the comparison portfolio is rebalanced periodically.

A key point is that slippage is assumed negligible in the figure. Slippage may kill the bonus for leverage = 1; I've had it pointed out several times that daily rebalancing is not effective with unlevered portfolios. Slippage should be proportional to volatility, while the bonus is proportional to volatility^2, so some of the benefit should persist. I tend to get an increase of 6 to 8 percent in CAGR with daily rebalancing versus weekly rebalancing in my portfolio backtests, approximately accounting for slippage. Taxes will be on top of that.

Importantly, this effect is superimposed on other asset behaviors, such as compounding and volatility decay. The effect takes hundreds to thousands of repetitions to separate from random noise.

I'm speculating now, but I suspect that most of the benefits can be gained using a bands approach that operates asset by asset. If the asset goes above some threshold allocation, sell enough to reset it to the target allocation and redistribute the proceeds to the assets with underweight allocations. Judging from watching daily behavior, a threshold of 1 or 2 percent might be triggered almost daily (3x LETFs have volatilities of 3 to 6 percent). Unfortunately, M1 requires that all assets are rebalanced with a rebalance trigger, which is probably wasteful.
Post Reply