weight_by_blend#

API documentation for tradeexecutor.strategy.weighting.weight_by_blend Python function.

weight_by_blend(alpha_signals, blend_alpha=0.5)[source]#

Linear blend of equal-weight and signal-proportional allocation.

Computes weights as:

w_i = alpha * (1/N) + (1 - alpha) * (signal_i / sum_j(signal_j))

This is equivalent to James-Stein shrinkage applied to the portfolio weight vector, shrinking signal-proportional weights toward the equal-weight prior. The literature consistently shows that shrinkage estimators outperform both pure equal-weight and pure optimised portfolios out of sample.

The blend parameter alpha controls the shrinkage intensity:

  • alpha=1.0: pure equal weight

  • alpha=0.0: pure signal-proportional (same as weight_passthrouh())

  • alpha=0.5: 50/50 blend (recommended starting point)

Pros:

  • Dead simple — one-line formula, easy to reason about

  • Grounded in shrinkage estimation theory (James & Stein, 1961)

  • Robust to signal noise — always partially diversified

  • Weights sum to 1.0

Cons:

  • Linear blending may not be optimal — equal weight is a crude prior

  • Does not adapt to signal dispersion (same alpha regardless of whether signals are tightly clustered or widely spread)

References:

Parameters:
  • alpha_signals (Dict[int, float]) – Signal objects keyed by pair ID.

  • blend_alpha (float) – Shrinkage intensity. 1.0 = pure equal, 0.0 = pure signal.

Returns:

Weight map summing to 1.0.

Return type:

Dict[int, float]