weight_by_softmax#
API documentation for tradeexecutor.strategy.weighting.weight_by_softmax Python function.
- weight_by_softmax(alpha_signals, temperature=2.0)[source]#
Softmax-temperature weighting that smoothly interpolates between equal-weight and winner-take-all allocation.
Applies the softmax function with a temperature parameter to transform raw signal values into portfolio weights:
w_i = exp(signal_i / T) / sum_j(exp(signal_j / T))The temperature T controls concentration:
T → ∞: converges to equal weights (1/N)T → 0: converges to winner-take-all (100% in top signal)T ≈ 1-2: moderate tilt toward higher signals
Weights always sum to 1.0, eliminating the cash drag problem inherent in equal weighting under greedy allocation loops.
Pros:
Single tunable parameter with intuitive behaviour
Smooth, differentiable — no hard cutoffs or discontinuities
Numerically stable (uses max-subtraction trick)
Naturally handles any number of assets
Cons:
Sensitive to signal scale — signals should be comparable magnitude
Low temperatures can over-concentrate into noisy top signals
Does not account for correlation between assets
References: