thresholdΒΆ

Defined in fynance.signal

threshold(pred, long=0.0, short=0.0)[source]

Position with a flat dead-band.

+1 where pred > long, -1 where pred < short, 0 between.

Examples

>>> import numpy as np
>>> threshold(np.array([0.5, 0.05, -0.5]), long=0.1, short=-0.1)
array([ 1.,  0., -1.])