1
1
using FinancialDerivatives
2
2
using Test
3
3
4
- op = AmericanOption (100.0 , 90.0 , 0.05 , 0.3 , 180 / 365 , - 1 )
5
- oc = AmericanOption (100.0 , 90.0 , 0.05 , 0.3 , 180 / 365 , 1 )
4
+ eu_put = AmericanOption (100.0 , 90.0 , 0.05 , 0.3 , 180 / 365 , - 1 )
5
+ eu_call = AmericanOption (100.0 , 90.0 , 0.05 , 0.3 , 180 / 365 , 1 )
6
+
7
+ am_put = AmericanOption (100.0 , 90.0 , 0.05 , 0.3 , 180 / 365 , - 1 )
8
+ am_call = AmericanOption (100.0 , 90.0 , 0.05 , 0.3 , 180 / 365 , 1 )
6
9
7
10
@testset " Black-Scholes" begin
8
- @test isapprox (evaluate (op , BlackScholes ()), 3.22 , atol= 0.1 )
9
- @test isapprox (evaluate (oc , BlackScholes ()), 15.42 , atol= 0.1 )
11
+ @test isapprox (evaluate (eu_put , BlackScholes ()), 3.22 , atol= 0.1 )
12
+ @test isapprox (evaluate (eu_call , BlackScholes ()), 15.42 , atol= 0.1 )
10
13
end
11
14
12
15
@testset " Cox-Ross-Rubinstein" begin
13
- @test isapprox (evaluate (op , CoxRossRubinstein ()), 3.22 , atol= 0.1 )
14
- @test isapprox (evaluate (oc , CoxRossRubinstein ()), 15.42 , atol= 0.1 )
16
+ @test isapprox (evaluate (am_put , CoxRossRubinstein ()), 3.22 , atol= 0.1 )
17
+ @test isapprox (evaluate (am_call , CoxRossRubinstein ()), 15.42 , atol= 0.1 )
15
18
end
16
19
17
20
@testset " Jarrow-Rudd" begin
18
- @test isapprox (evaluate (op , JarrowRudd ()), 3.22 , atol= 0.25 )
19
- @test isapprox (evaluate (oc , JarrowRudd ()), 15.42 , atol= 0.25 )
20
- @test isapprox (evaluate (op , JarrowRudd (), false ), 3.22 , atol= 0.25 )
21
- @test isapprox (evaluate (oc , JarrowRudd (), false ), 15.42 , atol= 0.25 )
21
+ @test isapprox (evaluate (am_put , JarrowRudd ()), 3.22 , atol= 0.25 )
22
+ @test isapprox (evaluate (am_call , JarrowRudd ()), 15.42 , atol= 0.25 )
23
+ @test isapprox (evaluate (am_put , JarrowRudd (), false ), 3.22 , atol= 0.25 )
24
+ @test isapprox (evaluate (am_call , JarrowRudd (), false ), 15.42 , atol= 0.25 )
22
25
end
23
26
24
27
@testset " Longstaff-Schwartz" begin
25
- @test isapprox (evaluate (op , LongstaffSchwartz ()), 3.22 , atol= 1 )
26
- @test isapprox (evaluate (oc , LongstaffSchwartz ()), 15.42 , atol= 1 )
28
+ @test isapprox (evaluate (am_put , LongstaffSchwartz ()), 3.22 , atol= 1 )
29
+ @test isapprox (evaluate (am_call , LongstaffSchwartz ()), 15.42 , atol= 1 )
27
30
end
28
31
29
32
@testset " Tian" begin
30
- @test isapprox (evaluate (op , Tian ()), 5.15 , atol= 0.25 )
31
- @test isapprox (evaluate (oc , Tian ()), 11.87 , atol= 0.25 )
33
+ @test isapprox (evaluate (am_put , Tian ()), 5.15 , atol= 0.25 )
34
+ @test isapprox (evaluate (am_call , Tian ()), 11.87 , atol= 0.25 )
32
35
end
33
36
34
37
@testset " Garman–Kohlhagen" begin
@@ -45,8 +48,8 @@ ird = InterestRateDerivative(0.01875, 0.20, 0.01, 0.012, 180/365)
45
48
end
46
49
47
50
@testset " Rendleman-Bartter" begin
48
- @test isapprox (evaluate (op , RendlemanBartter ()), 3.22 , atol= 0.25 )
49
- @test isapprox (evaluate (oc , RendlemanBartter ()), 15.42 , atol= 0.25 )
51
+ @test isapprox (evaluate (am_put , RendlemanBartter ()), 3.22 , atol= 0.25 )
52
+ @test isapprox (evaluate (am_call , RendlemanBartter ()), 15.42 , atol= 0.25 )
50
53
@test isapprox (evaluate (ird, RendlemanBartter (), 2 ), [0.2 , 0.2 , 0.2 , 0.2 ], atol= 0.025 )
51
54
end
52
55
0 commit comments