Skip to content

Commit 8865b06

Browse files
committed
Added theta to greeks agreement test
1 parent 3a1a5dc commit 8865b06

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/greeks.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ import Accessors: @optic
7070

7171
@testset "Greeks Agreement Test" begin
7272
strike = 1.0
73-
expiry = Date(2020, 1, 2)
73+
expiry = Date(2021, 1, 1)
7474
reference_date = Date(2020, 1, 1)
7575
rate = 0.03
7676
spot = 1.0
7777
sigma = 1.0
7878

7979
underlying = Hedgehog2.Forward()
80-
payoff = VanillaOption(strike, expiry, European(), Put(), underlying)
80+
payoff = VanillaOption(strike, expiry, European(), Call(), underlying)
8181
market_inputs = BlackScholesInputs(reference_date, rate, spot, sigma)
8282
pricing_prob = PricingProblem(payoff, market_inputs)
8383
bs_method = BlackScholesAnalytic()
@@ -109,9 +109,11 @@ import Accessors: @optic
109109
@test isapprox(volga_ad, volga_fd; rtol=1e-3)
110110
@test isapprox(volga_ad, volga_an; rtol=1e-5)
111111

112-
# Theta (no analytic yet)
112+
# Theta (no analytic)
113113
thetaprob = GreekProblem(pricing_prob, @optic _.payoff.expiry)
114114
theta_ad = solve(thetaprob, ForwardAD(), bs_method).greek
115115
theta_fd = solve(thetaprob, FiniteDifference(1), bs_method).greek
116-
@test isapprox(theta_ad, theta_fd; rtol=1e-5)
116+
theta_analytic = solve(thetaprob, AnalyticGreek(), bs_method).greek
117+
@test isapprox(theta_ad, theta_fd; rtol=5e-3)
118+
@test isapprox(theta_ad, theta_analytic; rtol=1e-8)
117119
end

0 commit comments

Comments
 (0)