Esempio n. 1
0
 def test_terminal(self):
     """Test value of terminal for an up-and-out call."""
     S = np.linspace(S0 - 10, S0 + 10, 21)
     V = np.maximum(S - K, 0)
     V[S >= L] = 0
     payoff = UpAndOut(CallA(T, K), L)
     self.assertTrue((payoff.terminal(S) == V).all())
Esempio n. 2
0
 def test_terminal(self):
     """Test value of terminal for an up-and-out call."""
     S = np.linspace(S0 - 10, S0 + 10, 21)
     V = np.maximum(S - K, 0)
     V[S >= L] = 0
     payoff = UpAndOut(CallA(T, K), L)
     self.assertTrue((payoff.terminal(S) == V).all())
Esempio n. 3
0
 def test_default(self):
     """Test default value for American up-and-out call."""
     S = np.linspace(S0 - 10, S0 + 10, 21)
     Vd = np.maximum(S - K, 0)
     Vd[S >= L] = 0
     payoff = UpAndOut(CallA(T, K), L)
     for t in np.linspace(0, 1, N, endpoint=False):
         self.assertTrue((payoff.default(t, S) == Vd).all())
     self.assertRaises(AssertionError, payoff.default, T, S)
Esempio n. 4
0
 def test_default(self):
     """Test default value for American up-and-out call."""
     S = np.linspace(S0 - 10, S0 + 10, 21)
     Vd = np.maximum(S - K, 0)
     Vd[S >= L] = 0
     payoff = UpAndOut(CallA(T, K), L)
     for t in np.linspace(0, 1, N, endpoint=False):
         self.assertTrue((payoff.default(t, S) == Vd).all())
     self.assertRaises(AssertionError, payoff.default, T, S)
Esempio n. 5
0
 def test_transcient(self):
     """Test value of transient for American up-and-out call."""
     S = np.linspace(S0 - 10, S0 + 10, 21)
     V = np.linspace(S0 + 10, S0 - 10, 21)
     Vm = np.maximum(V, np.maximum(S - K, 0))
     Vm[S >= L] = 0
     payoff = UpAndOut(CallA(T, K), L)
     for t in np.linspace(0, 1, N, endpoint=False):
         self.assertTrue((payoff.transient(t, V, S) == Vm).all())
     self.assertRaises(AssertionError, payoff.transient, T, V, S)
Esempio n. 6
0
 def test_transcient(self):
     """Test value of transient for American up-and-out call."""
     S = np.linspace(S0 - 10, S0 + 10, 21)
     V = np.linspace(S0 + 10, S0 - 10, 21)
     Vm = np.maximum(V, np.maximum(S - K, 0))
     Vm[S >= L] = 0
     payoff = UpAndOut(CallA(T, K), L)
     for t in np.linspace(0, 1, N, endpoint=False):
         self.assertTrue((payoff.transient(t, V, S) == Vm).all())
     self.assertRaises(AssertionError, payoff.transient, T, V, S)