1
0
mirror of https://github.com/bspeice/Quant.jl synced 2025-07-01 13:56:23 -04:00
Files
Quant.jl/test/blackscholes.jl
2016-05-17 22:38:30 -04:00

30 lines
1.0 KiB
Julia
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Base.Test
#include("../src/blackscholes.jl")
using Quant
@test 15.047 < blackscholes_call(100, 95, .25, .05, 0, 2, 1) < 15.0471
@test blackscholes_call(100, 95, .25, .05, 0, 2, 1) ==
blackscholes_call(100, 95, .25, .05, 0, 1)
precompute_low = [15.047, 15.047]
precompute_high = [15.0471, 15.0471]
S = [100, 100]; K = [95, 95]; σ = [.25, .25]; r = [.05, .05]
q = [.0, .0]; T = [2, 2]; t = [1, 1]
@test all(precompute_low .< blackscholes_call(S, K, σ, r, q, T, t)
.< precompute_high)
@test 5.413 < blackscholes_put(100, 95, .25, .05, .0, 2, 1) < 5.414
@test blackscholes_put(100, 95, .25, .05, .0, 2, 1) ==
blackscholes_put(100, 95, .25, .05, 0, 1)
precompute_low = [5.413, 5.413]
precompute_high = [5.414, 5.414]
@test all(precompute_low .< blackscholes_put(S, K, σ, r, q, T, t)
.< precompute_high)
@test blackscholes_call(100, 95, .25, .05, 0, 2, 1) ==
blackscholes_call(BlackScholes(100, 95, .25, .05, 0, 1, 2))
@test blackscholes_put(100, 95, .25, .05, 0, 2, 1) ==
blackscholes_put(BlackScholes(100, 95, .25, .05, 0, 1, 2))