min_hold¶
Defined in fynance.signal
- min_hold(pos, hold, tol=1e-9)[source]
Enforce a minimum holding period between position changes.
Once the position changes, it is frozen for ``hold`` bars before another change can take effect — a hard cap on trade frequency. Strictly causal.
- Parameters:
- posarray-like, shape (T,)
Position series (e.g. already mapped to a target).
- holdint
Minimum number of bars between two changes (
hold <= 1is a no-op).- tolfloat
Changes smaller than
tolare treated as no change.
Examples
>>> import numpy as np >>> min_hold(np.array([1., -1., 1., -1., 1., -1.]), hold=3) array([ 1., 1., 1., -1., -1., -1.])