1
0
mirror of https://github.com/bspeice/Quant.jl synced 2025-07-04 23:35:12 -04:00
Files
Quant.jl/test/blackscholes.jl
2016-03-05 18:50:53 -05:00

23 lines
777 B
Julia
Raw 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, 2, 1) < 15.0471
@test blackscholes_call(100, 95, .25, .05, 2, 1) ==
blackscholes_call(100, 95, .25, .05, 1)
precompute_low = [15.047, 15.047]
precompute_high = [15.0471, 15.0471]
S = [100, 100]; K = [95, 95]; σ = [.25, .25]; r = [.05, .05]
T = [2, 2]; t = [1, 1]
@test all(precompute_low .< blackscholes_call(S, K, σ, r, T, t)
.< precompute_high)
@test 5.413 < blackscholes_put(100, 95, .25, .05, 2, 1) < 5.414
@test blackscholes_put(100, 95, .25, .05, 2, 1) == blackscholes_put(100, 95, .25, .05, 1)
precompute_low = [5.413, 5.413]
precompute_high = [5.414, 5.414]
@test all(precompute_low .< blackscholes_put(S, K, σ, r, T, t)
.< precompute_high)