コード例 #1
0
ファイル: test_payoff.py プロジェクト: tshih-tw/amf_research
 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())
コード例 #2
0
ファイル: test_payoff.py プロジェクト: DragonSA/amf_research
 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())
コード例 #3
0
ファイル: test_payoff.py プロジェクト: tshih-tw/amf_research
 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)
コード例 #4
0
ファイル: test_payoff.py プロジェクト: DragonSA/amf_research
 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)
コード例 #5
0
ファイル: test_payoff.py プロジェクト: tshih-tw/amf_research
 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)
コード例 #6
0
ファイル: test_payoff.py プロジェクト: DragonSA/amf_research
 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)