Skip to content

Commit 5d0b31d

Browse files
committed
Working CRR with r=0
1 parent 3592458 commit 5d0b31d

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

examples/example.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ using BenchmarkTools
33

44
"""Example code with benchmarks"""
55
# Define market data and payoff
6-
market_inputs = h.BlackScholesInputs(0, 0.4, 1, 0.4)
6+
today=0
7+
rate=0
8+
spot=1
9+
sigma=0.4
10+
market_inputs = h.BlackScholesInputs(today, rate, spot, sigma)
711
payoff = h.VanillaEuropeanCall(1, 1)
812
analytical_pricer = h.Pricer(payoff, market_inputs, h.BlackScholesMethod())
9-
price = h.price(payoff, market_inputs, h.BlackScholesMethod())
13+
bs_price = h.price(payoff, market_inputs, h.BlackScholesMethod())
1014

11-
crr = h.CoxRossRubinsteinMethod(2000)
15+
crr = h.CoxRossRubinsteinMethod(800)
1216
crr_pricer = h.Pricer(payoff, market_inputs, crr)
1317
println("Cox Ross Rubinstein:")
1418
println(crr_pricer())

src/pricing_methods.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,11 @@ function price(payoff::P, market_inputs::BlackScholesInputs, method::CoxRossRubi
8686

8787
p = up_probability
8888
value = payoff(spots_at_i(method.steps))
89-
90-
for step in method.steps-1:-1:0
89+
print(spots_at_i(method.steps))
90+
for step in (method.steps-1):-1:0
9191
continuation = p * value[2:end] + (1 - p) * value[1:end-1]
9292
df = exp(-market_inputs.rate * ΔT)
9393
value = df * continuation
94-
9594
end
9695

9796
return value

0 commit comments

Comments
 (0)