← Back to Docs

ALPHA OPERATORS

podium_sdk.alpha_ops is a library of 40 formulaic operators for building signals. Import them directly (from podium_sdk.alpha_ops import rank) or call them on the context (ctx.ops.rank(...)) — they are the same callables. Most operate on pandas panels (dates × symbols).

python
from podium_sdk import Strategy, StrategyContext
from podium_sdk.alpha_ops import rank, decay_linear, returns

class FormulaicAlpha(Strategy):
    def universe(self, ctx):
        r = ctx.data.returns(lookback=130)
        return list(r.columns)

    def signal(self, ctx):
        close = ctx.data.close(lookback=130)
        # delta over 5 days, decayed, then cross-sectional rank
        mom = close.pct_change(5)
        score = rank(decay_linear(mom, 5).iloc[-1])
        # Equivalent via the context namespace: ctx.ops.rank(...)
        top = score.nlargest(20)
        w = 1.0 / len(top)
        return {s: w for s in top.index}

Cross-Sectional (9)

Operate across symbols within a single date (each row of a panel).

SignatureDescription
rank(x, method='average', pct=True)Cross-sectional percentile rank within each row.
scale(x, a=1.0)Scale cross-sectionally so abs sum equals a.
zscore(x)Cross-sectional z-score.
winsorize(x, lower=0.01, upper=0.99)Winsorize cross-sectionally at quantiles.
indneutralize(x, groups)Industry-neutralize by subtracting group mean.
inverse_volatility_weights(returns, lookback=20, min_weight=0.0, max_weight=0.1)Inverse-volatility position weights from a returns panel.
risk_parity_weights(returns, lookback=60, min_weight=0.0, max_weight=0.1)Risk-parity-lite weights from a returns panel.
turnover_smooth_weights(target_weights, current_weights, max_turnover=0.3)Smooth target weights to respect a turnover budget.
capacity_check(target_weights, portfolio_value, adv_20, max_pct_adv=0.05)Check position sizes against ADV capacity limits.

Time-Series (10)

Operate along the date axis for each symbol independently.

SignatureDescription
delay(x, d)Lag values by d periods.
delta(x, d)Difference vs d periods ago.
ts_sum(x, d)Rolling sum over d periods.
ts_product(x, d)Rolling product over d periods.
ts_min(x, d)Rolling minimum.
ts_max(x, d)Rolling maximum.
ts_argmin(x, d)1-indexed position of rolling minimum (oldest=1).
ts_argmax(x, d)1-indexed position of rolling maximum (oldest=1).
ts_rank(x, d)Percentile rank of current value within rolling window.
decay_linear(x, d)Linear-decay weighted moving average (recent-heavy).

Statistics (5)

Rolling pairwise and distributional statistics.

SignatureDescription
correlation(x, y, d)Rolling correlation.
covariance(x, y, d)Rolling covariance.
stddev(x, d)Rolling standard deviation.
rolling_mean(x, d)Rolling mean.
ewm_mean(x, halflife)Exponentially weighted mean.

Price / Volume (4)

Return and volume transforms.

SignatureDescription
returns(prices, d=1)Simple returns over d periods.
cum_return(ret)Cumulative compounded return.
adv(volume, d)Average daily volume.
vwap_ratio(close, vwap)Close relative to VWAP minus 1.

Elemental (5)

Element-wise math primitives.

SignatureDescription
abs(x)Absolute value.
log(x)Natural logarithm.
sign(x)Sign of input (-1, 0, 1).
signedpower(x, a)Signed power: sign(x) * abs(x)**a.
log_returns(prices, d=1)Log returns over d periods.

Technical Indicators (7)

Standard indicators composed from core operators.

SignatureDescription
rsi(close, period=14)Relative Strength Index (Wilder).
macd(close, fast=12, slow=26, signal=9)MACD line, signal, and histogram.
bollinger_bands(close, period=20, std=2.0)Bollinger upper, middle, lower bands.
atr(high, low, close, period=14)Average True Range (Wilder).
adx(high, low, close, period=14)Average Directional Index.
obv(close, volume)On-Balance Volume.
mfi(high, low, close, volume, period=14)Money Flow Index.

Worked Examples

The SDK ships 4 Kakushadze formulaic-alpha reproductions (Alpha #2, #3, #41, #101) under examples/formulaic_alphas/. See the Multi-Factor Model example to combine operators into a composite signal.