Skip to main content
Ultra Feature. Requires an Ultra subscription. Get started at api.mathematicalcompany.com

Portable Alpha

A strategy can appear profitable when it is just riding market beta. Horizon’s portable alpha module decomposes returns into alpha (skill) and beta (market exposure), tracks factor betas incrementally, and calculates the hedge ratios needed to neutralize unwanted exposures. All regression math is in Rust.

Overview

Beta Decomposition

hz.beta_decompose() separates alpha from market exposure via OLS.

Factor Exposures

hz.compute_factor_exposures() computes betas across multiple factors.

Neutrality Adjustment

hz.neutrality_adjustment() calculates hedge ratios to reach target betas.

Incremental Beta

hz.incremental_beta_update() tracks beta in O(1) per cycle via EWMA.

Core Functions

hz.beta_decompose

Decompose portfolio returns into alpha + beta * factor returns via OLS.
Returns an AlphaDecomposition with fields: alpha, beta, r_squared, tracking_error, information_ratio.

hz.compute_factor_exposures

Multi-factor regression: compute betas across multiple factors.

hz.neutrality_adjustment

Calculate hedge ratios needed to reach target betas.

hz.incremental_beta_update

O(1) EWMA-based beta tracking. No need to store full history.

Pipeline Functions

hz.beta_decompose_pipeline

Decompose returns into alpha + beta each cycle.

hz.market_neutral

Track live beta and calculate hedge ratios for neutrality.
Returns each cycle:

hz.portable_alpha

Full multi-factor portable alpha with exposure tracking and adjustment signals.

hz.factor_model

Track factor betas incrementally (O(1) per cycle).

Examples

Market-Neutral Strategy


Mathematical Background

For portfolio returns R_p and factor returns R_f:R_p = alpha + beta * R_f + epsilonBeta = Cov(R_p, R_f) / Var(R_f). Alpha is the intercept (excess return after removing factor exposure). R-squared measures the fraction of variance explained by the factor.
Instead of storing full history, use exponentially weighted moving averages:cov_t = decay * cov_{t-1} + (1 - decay) * R_p * R_fvar_t = decay * var_{t-1} + (1 - decay) * R_f^2beta_t = cov_t / var_tWith decay = 0.94 (approx 15-day half-life), recent observations matter more. This runs in O(1) per update.
To reach target beta from current beta:hedge_ratio = -(current_beta - target_beta)A positive hedge_ratio means add long factor exposure; negative means short it.