Barrier¶
- class pfhedge.features.Barrier(threshold, up=True)[source]¶
A feature which signifies whether the price of the underlier have reached the barrier. The output 1.0 means that the price have touched the barrier, and 0.0 otherwise.
- Parameters
Examples
>>> from pfhedge.features import Barrier >>> from pfhedge.instruments import BrownianStock >>> from pfhedge.instruments import EuropeanOption ... >>> _ = torch.manual_seed(42) >>> derivative = EuropeanOption(BrownianStock(), maturity=5/250, strike=2.0) >>> derivative.simulate() >>> derivative.underlier.spot tensor([[1.0000, 1.0016, 1.0044, 1.0073, 0.9930, 0.9906]]) >>> f = Barrier(threshold=1.004, up=True).of(derivative) >>> f.get() tensor([[[0.], [0.], [1.], [1.], [1.], [1.]]])