Пример #1
0
    def test_example(self):
        from pfhedge import Hedger
        from pfhedge.instruments import BrownianStock
        from pfhedge.instruments import EuropeanBinaryOption

        deriv = EuropeanBinaryOption(BrownianStock())
        model = BSEuropeanBinaryOption(deriv)
        hedger = Hedger(model, model.features())
        price = hedger.price(deriv)

        assert torch.allclose(price, torch.tensor(0.5004), atol=1e-4)
Пример #2
0
 def test_features(self):
     m = BSEuropeanBinaryOption()
     assert m.features() == ["log_moneyness", "expiry_time", "volatility"]
     _ = [get_feature(f) for f in m.features()]