Skip to content

Commit

Permalink
Support Diffractor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rcalxrc08 committed Feb 14, 2024
1 parent 254dbb4 commit 10709bf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 4 additions & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
[deps]
AbstractDifferentiation = "c29ec348-61ec-40c8-8164-b8c60e9d9f3d"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Diffractor = "9f5e2b26-1114-432f-b630-d3fe2085c51c"
DualNumbers = "fa6b7ba4-c1ee-5f82-b5fc-ecf0adba8f74"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
HyperDualNumbers = "50ceba7f-c3ee-5a84-a6e8-3ad40456ec97"
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
TaylorSeries = "6aa5eb33-94cf-58f4-a9d0-e4b2c4fc25ea"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[compat]
Diffractor = "0.2.4"
DualNumbers = "0.5, 0.6"
ForwardDiff = "0.10"
HyperDualNumbers = "4"
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function print_colored(in::String, color1)
end
end

test_list = ["testRealNumbers.jl", "test_implied_volatility.jl", "test_implied_volatility_black.jl", "testComplexNumbers.jl", "testForwardDiff.jl", "testReverseDiff.jl", "testDual_.jl", "testHyperDualNumbers.jl", "testDates.jl", "testTaylor.jl", "testZygote.jl"]
test_list = ["testRealNumbers.jl", "test_implied_volatility.jl", "test_implied_volatility_black.jl", "testComplexNumbers.jl", "testForwardDiff.jl", "testReverseDiff.jl", "testDual_.jl", "testHyperDualNumbers.jl", "testDates.jl", "testTaylor.jl", "testZygote.jl", "testDiffractor.jl"]

println("Running tests:\n")
for (current_test, i) in zip(test_list, 1:length(test_list))
Expand Down
13 changes: 13 additions & 0 deletions test/testDiffractor.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using FinancialToolbox, Diffractor, AbstractDifferentiation
S0 = 100.0;
K = 100.0;
r = 0.02;
T = 1.0;
σ = 0.2;
d = 0.01;
price = blsprice(S0, K, r, T, σ, d);

price_grad = AbstractDifferentiation.gradient(Diffractor.DiffractorForwardBackend(), x -> blsprice(x...), [S0, K, r, T, σ, d])
price_grad_r = Diffractor.reversediff(x -> blsprice(x...), [S0, K, r, T, σ, d])
sigma_grad = AbstractDifferentiation.gradient(Diffractor.DiffractorForwardBackend(), x -> blsimpv(x...), [S0, K, r, T, price, d])
sigma_grad_r = Diffractor.reversediff(x -> blsimpv(x...), [S0, K, r, T, price, d])

0 comments on commit 10709bf

Please sign in to comment.