1
0
mirror of https://github.com/bspeice/Quant.jl synced 2025-07-01 22:07:18 -04:00

Add new Black-Scholes type for easy use

This commit is contained in:
bspeice
2016-05-17 22:38:30 -04:00
parent da2483088b
commit 3a0e0cf0c0
3 changed files with 44 additions and 16 deletions

View File

@ -2,21 +2,28 @@ 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)
@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]
T = [2, 2]; t = [1, 1]
@test all(precompute_low .< blackscholes_call(S, K, σ, r, T, t)
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, 2, 1) < 5.414
@test blackscholes_put(100, 95, .25, .05, 2, 1) == blackscholes_put(100, 95, .25, .05, 1)
@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, T, t)
@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))