Signal (fynance.signal)ΒΆ

The bridge from predictions to positions: mappers and a model+mapper pipeline.

The anti-churn mappers (ema_smooth, deadband, min_hold) are stateful but strictly causal; compose them on top of a position to cut turnover where transaction costs would otherwise dominate (high fees / high frequency). They pair with the train-time turnover penalty in ObjectiveModel (its cost argument).

sign(pred)

Long/short by the sign of the prediction (+1 / -1 / 0).

threshold(pred[, long, short])

Position with a flat dead-band.

rank(pred, top, bottom)

Cross-sectional long/short by rank.

vol_target_position(signal, prices[, ...])

Scale a directional signal by causal volatility-targeting leverage.

ema_smooth(pred[, alpha])

Causally smooth a position with an exponential moving average.

deadband(pred[, band])

Hold the previous position unless the target moves by more than band.

min_hold(pos, hold[, tol])

Enforce a minimum holding period between position changes.

SignalPipeline(model, mapper[, mapper_kwargs])

A SignalModel plus a position mapper.