Trading the Breaking

Trading the Breaking

Research

​[WITH CODE​]​ Optimization: Scale-free portfolio selection

​​​​​​​​A practical guide to implementing AdaHedge with L1 turnover caps and trust bands

Quant Beckman's avatar
Quant Beckman
Nov 03, 2025
∙ Paid

Table of contents:

  1. Introduction.

  2. Risks and model limitations.

  3. Online Portfolio Selection without knobs.

  4. Mathematical framework.

    1. AdaHedge and AdaNormalHedge.

    2. The L1 turnover cap and trust band.

  5. Why this breaks common misconceptions.

  6. Algorithm design.

  7. Strongly-adaptive aggregation and diagnostics.


Before you begin, remember that you have an index with the newsletter content organized by clicking on “Read full story” in this image.


Introduction

For decades, the world of quantitative portfolio management has been sitting on a fragile foundation. This isn’t a problem of bad math or weak computing power. It’s a problem of philosophy. Whether you’re running a small, nimble fund or a massive institutional book, the core problem is the same: your model is riddled with knobs.

These knobs are the parameters, the magic numbers that you, or some sophisticated optimization routine, painstakingly tuned to make your strategy look perfect on a historical backtest. They are the ghosts in the machine.

Let’s be specific, as this isn’t an abstract complaint. These are real, structural points of failure present in 99% of models. Perhaps the most critical is the learning rate, or η. In any gradient-based allocator, like Exponentiated Gradient or Online Newton Step, this knob dictates how fast your model learns from new information. If you tune η to be high, you get a fast, twitchy model that reacts instantly and gets whipsawed by every piece of market noise, churning your portfolio to dust. If you tune η to be low, you get a stable model that smoothly integrates new information but fails to react when a real crisis hits, leaving you fully exposed as the market crashes for three weeks straight. The η you tuned for the low-vol calm of 2017 is guaranteed to be catastrophically wrong in the high-vol panic of March 2020.

Equally pervasive is the hand-picked lookback window, W. This is the 60-day in your 60-day momentum signal, or the 252-day in your annual volatility calculation. What’s magic about 60 days? Nothing. It’s a compromise. A short window is highly adaptive but incredibly noisy; a long window is stable but dangerously slow. When a regime breaks, your 252-day risk model is still averaging in data from a world that no longer exists. For the next six months, your optimal portfolio will be optimized for a dead regime.

Then there is the penalty weight, λ, the knob that governs cost. In a classic mean-variance optimization, this λ is the trade-off between expected return and expected risk. In a cost-aware allocator, it’s the λ in your λ||wt - wt-1||1 turnover penalty. You run a backtest and find that λ=0.0005 is optimal. But this λ is static. It doesn’t know that market liquidity just dried up, making your actual costs 10x higher. It doesn’t know that your AUM just doubled, meaning your market impact is now a real factor. Your optimal penalty is just an artifact of your backtest’s specific liquidity and volatility profile.

Finally, you have the heuristic rebalancing thresholds, τ. These are the simple if...then rules, like If my target weights change by less than 1%, do nothing. This is an attempt to reduce churn, but it’s just another arbitrary knob. A 1% threshold might be fine for a large-cap equity, but it’s a massive move for a bond. This single, fixed number is applied across all assets, ignoring their individual volatilities, and it’s almost certainly sub-optimal.

This entire process of knob-tuning creates a dangerous illusion of precision. Quants spend 80% of their time just turning these knobs, running thousands of backtests to find the combination that squeezes out another 0.1 of Sharpe ratio. But this isn’t finding signal. It’s overfitting. It’s a brute-force memorization of the past’s specific noise and volatility patterns.

Here’s the dilemma: in a stable, stationary, predictable market—the Gaussian-fiction market that lives in textbooks—these optimized knobs would be your friends. They would represent the true, unchanging parameters of the market, and your model would be perfectly adapted.

But we don’t trade in that market.

We trade in a market defined by non-stationarity. We live in a world of sudden, violent regime breaks. These are the events that change the underlying rules of the game: volatility spikes, correlation flips, global pandemics, sudden wars, or surprise central bank announcements.

In this context, your knobs are your enemy. Sounds familiar?

The moment the regime breaks, every single one of your tuned parameters is not just sub-optimal; it’s actively dangerous. That low η you tuned for calm markets now forces your model to under-react, making you ride the crash all the way down. That long 252-day lookback window is now feeding your optimizer toxic, irrelevant data, telling it that “everything is fine.” That λ cost-penalty you set now prevents the model from making the single, large, life-saving trade—getting to cash—because it looks too expensive relative to its historical tuning.

Your finely-tuned, optimized model is now precisely and perfectly calibrated for a market that no longer exists. This is the fragile foundation. The model’s precision was a mirage, and the knobs are the levers that ensure its failure.

But don’t worry. There are alternatives! So to learn a little more about the topic we’re going to discuss, take a look at this PDF:

Adahedge
505KB ∙ PDF file
Download
Download

But before starting, let’s clarify that scale-free is not the same in this context as in the operational-trading context where scale-free means the rules and decisions do not depend on arbitrary units (euros, ticks, fixed timeframes, account size) but on dimensionless or risk‑normalized magnitudes. In practice, it’s invariance: if prices are rebased, time is re‑sampled, or capital is resized, the logic and the risk stay (approximately) the same—up to frictional limits (costs, impact, discrete tick sizes).

Formally, let r∈RN denote the vector of (log) returns and w(r)∈ΔN the allocation chosen as a function of returns/features. After per‑strategy volatility targeting (or any equivalent scale normalization), homogeneity of degree zero is the desideratum:

\boxed{\quad w(\alpha r) = w(r)\quad \text{for all } \alpha>0.\quad}

This expresses independence from the overall return scale.

Now, even though we’re going to explore and critique the scale-free framework, remember that there are two critical aspects that make the difference between a hobby and a business:

  • Scale-free risk ensures each individual strategy behaves consistently across volatility and capital regimes.

  • Scalable strategy pool ensures your collection of strategies can grow without turning into an unmanageable mess of correlated exposures.

Risks and model limitations

The moment the market regime changes, your knobs are wrong.

You can get the math right, you can have the perfect theoretical model, and still fail. Why?

  1. Your learning rate was too low, and the allocator failed to adapt to the new volatility regime. It just sat there, bleeding.

  2. Your lookback window was too long, and your risk model was still averaging in data from a “dead” regime, making you under-allocate to the new winners.

  3. Your turn penalty was just high enough to stop you from making the one simple rebalance that actually mattered, all because it was drowned out by noise.

This leads to a horrible checkpointing culture. Quants are forced to constantly re-tune, re-backtest, and redeploy their models, effectively manually overriding the system. This isn’t alpha, it’s just brittle engineering.

The second issue, which is more insidious, is the claim of parameter-free models. Many algorithms claim to be parameter-free, but they merely hide their defaults. The success or failure of the entire strategy often hinges on some obscure η decay schedule or a default window size that the authors conveniently found. This isn’t just bad science; it’s dangerous in production.

This fragility exposes any portfolio allocator to three fundamental risks:

  1. Scale risk: Any update that isn’t scale-free is inherently dangerous. If your algorithm is tuned on 60 basis point (bp) daily volatility, it will misfire when volatility drops to 10 bps or spikes to 200 bps. A 1% loss and a 10% loss are not just different in magnitude; they are different in kind. Your allocator must react with a step size proportional to the signal, not with a fixed, arbitrary η.

  2. Cost risk: Most online learning literature ignores transaction costs, or models them in a way that doesn’t enforce them. An allocator that flips its entire portfolio every day might look great on a gross basis, but it will donate its edge (and then some) to the market makers. You need a model that is cost-aware from the ground up, not one where cost is just another penalty term to be tuned.

  3. Adaptation risk: The market is non-stationary. A static optimizer that minimizes regret against a single fixed comparator (e.g., the best-performing asset over the entire 10-year backtest) is useless. Who cares? The game is to adapt. When a multi-month regime transition happens, your allocator can’t bleed for 3 months while it waits for its long-window average to catch up. The correct target is strong local performance, not global averages.

And here is where regime breaks come into action. This is the sudden change in loss geometry, volatility, and asset correlation. This is the event that makes all your tuned parameters obsolete overnight. So how do we solve this? The answer is to build an allocator that can allocate on the simplex Δ without any hand-tuning. It must be scale-free (to handle vol changes), cost-aware (to handle turnover), and strongly-adaptive (to handle regime breaks).

The solution that the machine learning and quant world offers, as we’ll see, is to move away from classic Exponentiated Gradient or Online Newton Step and embrace scale-free Hedge updates (like AdaHedge) at the asset level. This allocator is then coupled with a lazy rebalancing mechanism and strongly-adaptive wrappers to create a system that is robust by construction, not by tuning. No learning rate search, no window selection, no brittle temperature. Just math that works.

Online Portfolio Selection without knobs

Let’s formalize this. We’re operating in the classic Online Portfolio Selection or OPS setting. This is a sequential decision problem.

At the start of each day t=1, …, T, we must choose a long-only weight vector wt. This vector must live on the N-dimensional simplex, ΔN, meaning all weights are non-negative and sum to one:

\mathbf{w}_t \in \Delta^N := \{ \mathbf{w} \ge 0, \sum_{i=1}^N w_i = 1 \}

At the end of the day, the market reveals a vector of log-returns, rt ∈RN

Our gross wealth, in log space, evolves as:

\text{Eq}_{t+1}^{\text{gross}} = \text{Eq}_t^{\text{gross}} + \langle \mathbf{w}_t, \mathbf{r}_t \rangle

This is the standard, frictionless world. But trading is not free. We must model transaction costs. The most realistic model for institutional trading is a proportional L1 turnover cost. The cost to trade is proportional to the absolute value of the change in your portfolio weights.

\text{cost}_t = \lambda \| \mathbf{w}_{t+1} - \mathbf{w}_t \|_1

Here, λ is the cost parameter (e.g., λ=0.0002 for 2 bps). The L1 norm is key. If you sell 10% of asset A to buy 10% of asset B, your L1 turnover is |-0.10| + |+0.10| = 0.20.

Our net log-wealth, the only thing that actually matters, is therefore:

\text{Eq}_{t+1}^{\text{net}} = \text{Eq}_t^{\text{net}} + \langle \mathbf{w}_t, \mathbf{r}_t \rangle - \text{cost}_t

Most OPS methods, like Exponentiated Gradient (EG) or Online Newton Step (ONS), propose an update based on the day’s losses. Let Lt,i = -rt,i be the loss for asset i. The classic EG update is:

w_{t+1, i} \propto w_{t, i} \exp(-\eta \ell_{t, i})

And here it is: η. The learning rate. The knob.

This η is poison. It is scale-sensitive. If your typical losses Lt,i are around 0.01 (1%), an η=0.5 might be fine. If the market panics and losses jump to 0.10 (10%), your update term exp(-0.5 x 0.10) is tiny, but exp(-0.5 x -0.10) is huge. The allocator’s weights will fly around, becoming brittle and unpredictable. You’ll either over-trade or under-react.

The core idea is to remove η. We will replace it with a data-driven, per-asset normalizer that automatically adapts the step size based on the history of losses for that specific asset. This is the scale-free idea.

Building this knob-less allocator forces us to confront five major obstacles that are typically swept under the rug:

  1. Costs and overtrading: We must not just model costs, we must constrain them. Even with a good update rule, a single large loss can cause a massive, costly portfolio jump. The algorithm must incorporate a trust band (to skip tiny, noisy rebalances) and a turnover cap (to prevent catastrophic, large rebalances).

  2. Non-stationarity: As discussed, the world changes. Static regret (beating the best fixed portfolio) is insufficient. We need a system that performs well on interval regret (beating the best fixed portfolio on any sub-interval) and dynamic regret (adapting to shifting regimes). This requires a strongly-adaptive wrapper.

  3. Numerical stability: Exponentials are dangerous. exp(1000) is inf. exp(-1000) is 0.0. An update like exp(-ηLt) can easily overflow or underflow. The algorithm must be numerically stabilized, likely using the log-sum-exp trick, and must handle near-zero weights gracefully.

  4. Asset-level vs. expert-level: Many online aggregation methods assume you have a set of “experts” (e.g., 10 different pre-built strategies) and you’re just weighting them. This is a cop-out. We are addressing the harder problem: allocating directly to the N assets themselves. Our experts are the assets.

  5. Live mapping to orders: A vector wt is not an order. A practical OPS algorithm must produce feasible, tradable orders. This means the weight vector must be translatable into orders that respect market freeze levels, safety ticks, partial fills, and other production realities.

Our goal is to build a single, coherent algorithm that solves all five of these problems simultaneously.

Mathematical framework

Here is the resolution. We will build our solution from the ground up, starting with a new mathematical framework.

Let’s be precise.

  • Per-asset losses are:

    \ell_t = - \mathbf{r}_t \in \mathbb{R}^N
  • The portfolio’s loss (ignoring costs for a moment) is:

    \ell_t(\mathbf{w}_t) = \langle \mathbf{w}_t, \ell_t \rangle

The entire field of Online Convex Optimization, from which OPS is derived, is built around the concept of regret. Regret is the difference between your algorithm’s cumulative loss and the loss of some optimal comparator in hindsight. The game is to minimize this regret. Check the previous article to know more about that:

[WITH CODE] Optimization: Adaptive regret for regime-shifting markets

[WITH CODE] Optimization: Adaptive regret for regime-shifting markets

𝚀𝚞𝚊𝚗𝚝 𝙱𝚎𝚌𝚔𝚖𝚊𝚗
·
October 20, 2025
Read full story

The key perspective shift is in what you choose as your comparator.

  1. Static regret → This is the classic definition. The comparator is the single best fixed-weight portfolio over the entire history T.

    R_T^{\text{stat}} = \sum_{t=1}^T \ell_t(\mathbf{w}_t) - \min_{\mathbf{w}^* \in \Delta^N} \sum_{t=1}^T \ell_t(\mathbf{w}^*)

    Algorithms like EG can guarantee a regret of

    R_T^{\text{stat}} = \mathcal{O}(\sqrt{T \log N})

    assuming bounded losses. This is a nice theoretical result, but practically useless. It tells you nothing about performance during a regime change.

  2. Interval regret → This is much stronger. We want to be competitive over all possible contiguous windows [s, e] from 1 ≤ s ≤ e ≤ T.

    R_{s,e} = \sum_{t=s}^e \ell_t(\mathbf{w}_t) - \min_{\mathbf{w}^* \in \Delta^N} \sum_{t=s}^e \ell_t(\mathbf{w}^*)

    We want to ensure that max1 ≤ s ≤ e ≤ T Rs,e is small. This is a much harder benchmark and is what diagnostics should focus on.

  3. Dynamic (shifting) regret → This is the most realistic comparator. We compare our algorithm to the best sequence of portfolios w*1, …, w*T, but we penalize that sequence for its own turnover.

    R_T^{\text{dyn}} = \sum_{t=1}^T \ell_t(\mathbf{w}_t) - \min_{\mathbf{w}_1^*, \dots, \mathbf{w}_T^* \in \Delta^N} \left( \sum_{t=1}^T \ell_t(\mathbf{w}_t^*) + C \sum_{t=1}^{T-1} \|\mathbf{w}_{t+1}^* - \mathbf{w}_t^*\|_1 \right)

    This captures the essence of adapting to S different regimes.

Our algorithm won’t explicitly optimize for all of these, but its scale-free nature will give it strong performance on all three, especially interval and dynamic regret.

AdaHedge and AdaNormalHedge

Let’s kill the η knob. The key idea is to normalize the observed loss by its own history. We replace the single, global η with a per-asset, time-varying step size, ηt-1.

We define two cumulative, per-asset trackers:

  • L1 tracker (AdaHedge-like):

\mathcal{A}_{t,i} = \sum_{s=1}^t |\ell_{s,i}|
  • L2 tracker (AdaNormalHedge-like):

\mathcal{V}_{t,i} = \sum_{s=1}^t \ell_{s,i}^2

Now, we define our step sizes:

  • AdaHedge: The step size is inversely proportional to the cumulative L1 norm of losses.

    \eta_{t,i} = 1 / \mathcal{A}_{t,i}
  • AdaNormalHedge: The step size is inversely proportional to the L2 norm (the square root of cumulative squared losses). This is very similar to AdaGrad.

    \eta_{t,i} = 1 / \sqrt{\mathcal{V}_{t,i}}

Why is this scale-free? Imagine a 10% loss (Lt,i = 0.10).

  • If this is the first day, Vt,i = 0.01, so ηt,i = 1 / √0.01 = 10. The scaled loss is ηt,iLt,i = 10 x 0.10 = 1.0.

  • Now imagine the same 10% loss happens after 100 days of 1% volatility (Vt-1 ≈ 100 x 0.012 = 0.01). The new Vt-1 = 0.01 + 0.102 = 0.02. The step size is ηt,i ≈ 1 / √0.02 ≈ 7.07. The scaled loss is 7.07 x 0.10 ≈ 0.707.

  • Now imagine the 10% loss happens after 100 days of 10% volatility (Vt-1,i ≈ 100 x 0.102 = 1.0). The new Vt,i = 1.0 + 0.102 = 1.01. The step size is ηt,i ≈ 1 / √1.01 ≈ 0.995. The scaled loss is 0.995 x 0.10 ≈ 0.0995.

The effective update (the scaled loss) is automatically tempered by the asset’s own history. High-vol assets get smaller step sizes. Low-vol assets get larger ones. If a low-vol asset suddenly wakes up, the allocator reacts aggressively (large scaled loss), and then tapers off as this becomes the new normal (as V grows). This is exactly the adaptive behavior we want, with zero tuning.

The multiplicative update rule is then:

w_{t+1, i} \propto w_{t,i} \exp( - \eta_{t,i} \ell_{t,i} )

(We’ll add stabilization terms later).

This gives us the proposed update, w̃t+1. But this update knows nothing about costs.

The L1 turnover cap and trust band

This is the second brilliant piece. We do not use a proximal step. We use a simple, two-part lazy rebalance scheme.

Let w̃t+1 be the proposed scale-free update vector (after normalization).

Let wt be our current holding.

  1. Trust Band τ: First, we compute the L1 distance of the proposed trade:

    \Delta = \| \tilde{\mathbf{w}}_{t+1} - \mathbf{w}_t \|_1

    If this trade is too small, it’s just noise. We skip it entirely.

    If Δ ≤ τ, then wt+1 = wt. A typical τ = 0.002 (20 bps) means we don’t bother trading if the total portfolio change is less than 20 bps. This kills churn.

  2. Turnover Cap κ: If the trade is larger than τ, we do want to trade, but we don’t want to over-trade. We cap the size of our L1 move.

    If Δ > τ, then compute αt = min(1, κ/Δ). Our actual new portfolio is a linear interpolation:

    \mathbf{w}_{t+1} = \mathbf{w}_t + \alpha_t (\tilde{\mathbf{w}}_{t+1} - \mathbf{w}_t) = (1 - \alpha_t) \mathbf{w}_t + \alpha_t \tilde{\mathbf{w}}_{t+1}

    A typical κ = 0.25 (25%) means that even if the scale-free update wants to trade 80% of the portfolio (Δ=0.8), we only move αt = 0.25 / 0.8 = 0.3125 of the way there. This is a “pro-rata” move that tames the allocator without distorting its direction.

The cost at this step is

\text{cost}_t = \lambda \| \mathbf{w}_{t+1} - \mathbf{w}_t \|_1 = \lambda \cdot (\alpha_t \Delta).

This is a complete, “pro-style” rebalancing framework that aligns perfectly with the theoretical L1 penalty, but is far more practical and implementable.

Trust band and turnover cap

Why this breaks common misconceptions

This framework shatters several long-held, false beliefs in quantitative finance.

  1. “Parameter-free is marketing; you still need an η”: You don’t need a fixed η. The normalizer is the data-dependent learning rate. It’s scale-free by construction. The ε we add for numerical stability is a floor, not a tuning knob.

  2. “Hedge-style (multiplicative) updates are incompatible with cost penalties”: This is a common theoretical confusion. You don’t need a complex proximal solver that mixes additive and multiplicative terms. The lazy rebalancing framework (trust band + turnover cap) is the cost-aware execution. It decouples the proposal (Hedge update) from the execution (cost control).

  3. “A trust band and turnover cap are just more knobs to tune”: This is the most important one. No. They are guards, not optimization parameters. You don’t tune η to maximize Sharpe. You set η=0.25 because your execution desk cannot trade more than 25% of the portfolio in a day without massive slippage. You set τ=0.002 because 20 bps is your cost of trading, so any trade smaller than that is guaranteed to be -EV. These are physical constraints of the market, not magic numbers for a backtest.

  4. “This is just expert-weighting. I need to design the experts first.”: We are doing this at the asset level. Each of the N assets is an expert. The comparator class is ΔN, the simplex itself. This is far more direct. The algorithm directly weights the assets based on their own scale-free loss history. This also changes the comparator class for regret: we are competing against the best fixed-weight portfolio of assets, not the best expert.

Algorithm design

This is the entire allocator. It is a learning-rate-free, cost-aware, and numerically stable algorithm.

This pseudocode maps directly to a clean Python class. The following is the exact fit method that implements the logic above, taken from the provided artifacts.

import numpy as np

class ScaleFreeOPS:
    def __init__(self, mode: str = “adah”, lam: float = 0.0002, 
                 tau: float = 0.002, turnover_cap: float = 0.25, 
                 eps: float = 1e-12):
        “”“
        Initializes the Scale-Free OPS Allocator.
        
        :param mode: “adah” (AdaHedge-like) or “anorm” (AdaNormalHedge-like)
        :param lam: L1 cost per unit of turnover (e.g., 0.0002 for 2bps)
        :param tau: Trust band (e.g., 0.002 for 20bps L1)
        :param turnover_cap: Max L1 turnover per step (e.g., 0.25 for 25%)
        :param eps: Numerical stability floor
        “”“
        assert mode in (”adah”, “anorm”)
        self.mode = mode
        self.lam = float(lam)
        self.tau = float(tau)
        self.turnover_cap = float(turnover_cap)
        self.eps = float(eps)

    def fit(self, R: np.ndarray):
        “”“
        Runs the backtest.
        :param R: T x N array of daily log-returns
        “”“
        T, N = R.shape
        
        # 1. Initialization 
        w = np.ones(N) / N         # Current weights
        A = np.zeros(N)            # L1 tracker
        V = np.zeros(N)            # L2 tracker
        
        # History Trackers 
        # Note: T+1 length to store initial state
        eq_g = np.zeros(T+1)       # Gross log equity
        eq_n = np.zeros(T+1)       # Net log equity
        costs = np.zeros(T+1)      # Cost paid at each step
        turnover = np.zeros(T+1)   # L1 turnover at each step
        ret_net = np.zeros(T)      # Net returns (for metrics)
        
        # Main Loop
        for t in range(T):
            
            # EARN (Step #1 from pseudocode) 
            # We earn returns R[t] on weights w (chosen at t-1)
            ret = float(np.dot(w, R[t]))
            
            # Gross equity up to t+1
            eq_g[t+1] = eq_g[t] + ret 
            
            # Net equity is gross - realized cost from *this* step
            # Note: The provided script differs slightly, applying cost
            # from the *previous* step. We follow the user’s script logic.
            # In the user script, net equity is calculated *after* the trade.
            # Let’s stick to the logic in the *user’s provided script*
            # which is: earn, calc new w, calc cost, update net eq.
            # This is a common convention.
            
            # BUILD GRADIENT (Step #2)
            g = -R[t]                  # Loss vector
            A += np.abs(g)             # Update L1 tracker
            V += g*g                   # Update L2 tracker
            
            if self.mode == “adah”:
                # AdaHedge-like: 1 / sqrt(L1 norm)
                theta = 1.0 / np.sqrt(np.maximum(A, self.eps))
            else: # mode == “anorm”
                # AdaNormalHedge-like: 1 / sqrt(L2 norm)
                theta = 1.0 / np.sqrt(np.maximum(V, self.eps))
                
            scaled = -g * theta        # Normalized gradient
            
            # HEDGE UPDATE (Step #3) 
            m = np.max(scaled)
            exps = w * np.exp(scaled - m)
            s = exps.sum()
            
            if not np.isfinite(s) or s <= 0:
                w_tilde = np.ones(N) / N
            else:
                w_tilde = exps / s     # Proposed new weights
                
            # LAZY REBALANCE (Step #4) 
            delta = np.abs(w_tilde - w).sum() # L1 distance
            
            if delta <= self.tau:
                # --- Skip trade ---
                w_new = w
                cost = 0.0
                turn = 0.0
            else:
                # --- Cap trade ---
                alpha = min(1.0, self.turnover_cap / max(1e-12, delta))
                w_new = w + alpha * (w_tilde - w)
                turn = np.abs(w_new - w).sum()
                cost = self.lam * turn
                
            # TRACK & UPDATE (Step #5) 
            # Now we update net equity with today’s return AND today’s cost
            net_return_t = ret - cost
            ret_net[t] = net_return_t
            eq_n[t+1] = eq_n[t] + net_return_t
            
            costs[t+1] = cost
            turnover[t+1] = turn
            w = w_new # Commit weights for next period
            
        return eq_g, eq_n, turnover, costs, ret_net

What we see here can be interpreted:

  • AdaNormalHedge is hyperactive: The SF-OPS AdaNormalHedge-like (green line) is by far the most aggressive and hyperactive strategy. Its cumulative turnover is enormous compared to the others. This confirms that the L2-norm is highly sensitive and reacts aggressively to market moves, causing it to constantly and expensively rebalance its portfolio.

  • EG and AdaHedge are conservative: The EG (blue line) and SF-OPS AdaHedge-like (orange line) are both low-turnover, conservative strategies.

    • EG(eta=0.5): This is the least active strategy. Its low, fixed learning rate, combined with the cost-control guards, results in very minimal, stable trading.

    • SF-OPS AdaHedge-like: This scale-free model trades a bit more than the tuned EG model, but it is still extremely conservative. Its L1-norm tracker (AdaHedge) is inherently more stable and less reactive than the L2-norm (AdaNormalHedge).

About the results on synth-toy data:

What does this mean? Why the performance is so similar and then, what are the advantages?

The advantage is not that SF-OPS ended with a slightly higher or lower number. The advantage is how it got there:

  1. The EG model (orange line) performed well only because we hand-picked a magic learning rate of η=0.5. It’s fragile. If we ran this test on data from 2020-2023, the correct η might have been 0.1 or 1.0. The η=0.5$ model would have likely failed. You can’t know η in advance. In live trading, you have to guess the η for the future. You will almost certainly guess wrong.

  2. The SF-OPS AdaHedge-like model (green line) achieved a similarly high Sharpe ratio (3.03 vs 3.30) with zero tuning. It is robust. The entire point is that this knob-free model was able to keep pace with a perfectly tuned (but fragile) model. This is the advantage. You can deploy the SF-OPS model on any dataset, in any regime, and it will adapt and perform robustly. You cannot do that with the EG model.

When moving from research (a fit method) to production (a live trading system), a few more things are required:

  1. Batching: Translate the final wnew into target orders.

  • Safety: Check against tickers, lot sizes, and other constraints.

  • Residuals: The allocator produces a target wnew. The trading desk tries to execute it. At the end of the day, due to partial fills, your actual portfolio wactual might be different. Your next update must start from wactual, not wnew. This residual tracking is critical.

Send me a copy

Strongly-adaptive aggregation and diagnostics

We have the algorithm. How do we know it works? How do we prove it’s better than a tuned EG? We don’t just look at the final Sharpe ratio. That’s a single, global number. We need diagnostics that measure adaptation.

This is the key. Instead of one backtest, we run thousands. The real question is: How often did my allocator underperform the best fixed portfolio over the last 3m/6m/9m windows?

This is a direct-fire test of interval regret. If your allocator is frequently lost (i.e., has high regret) over 60-day or 120-day periods, it means it’s failing to adapt, even if its total 10-year Sharpe is good.

A robust allocator should have bounded interval regret. It might be wrong for a week, but it should never be wrong for a whole quarter.

Theoretically, our scale-free hedge allocators are strongly-adaptive. This is a class of algorithm from OCO theory. A strongly-adaptive algorithm can compete against a shifting comparator. The regret bound for such an algorithm against a comparator with S switches (regimes) over T steps is:

R_T^{\text{dyn}} = \mathcal{O}(\sqrt{S(T+1)\log N})

Let’s see the results:

This plot visualizes the portfolio allocation strategy of each algorithm, revealing why their performances differed so starkly. The Uniform model (top-left) is a flat, static 1/N benchmark, while the EG(eta=0.5) model (top-right) is a very slow, conservative learner that barely moves from its initial 1/N allocation.

In contrast, the scale-free models show clear adaptation: the SF-OPS AdaHedge-like model (bottom-left) correctly identifies and increases its weight in winning assets (like Asset 1, orange) but maintains robust diversification by never fully selling out of other assets.

Finally, the SF-OPS AdaNormalHedge-like model (bottom-right) exposes its critical flaw, behaving as an aggressive, high-risk allocator that rapidly concentrates over 90% of its portfolio into Asset 1, explaining both its initial massive gains and its subsequent catastrophic collapse when the market regime changed.

Okay! Well done today team! It’s time to say goodbye, but keep this idea in mind: The fewer parameters and meta-parameters, the less tuning there is to do.

We’ll continue with more interesting algorithms next week. Until then, take care! You’ve done a great job! 🦾

Loading...

This is an invitation-only access to our QUANT COMMUNITY, so we verify numbers to avoid spammers and scammers. Feel free to join or decline at any time. Tap the WhatsApp icon below to join


Appendix

Full script:

This post is for paid subscribers

Already a paid subscriber? Sign in
© 2026 Quant Beckman · Publisher Privacy ∙ Publisher Terms
Substack · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for writing, podcasting, and media founders.