Skip to content

Commit

Permalink
update black-scholes comments
Browse files Browse the repository at this point in the history
  • Loading branch information
briangu committed Jan 8, 2024
1 parent c3ff461 commit c35a161
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions examples/stocks/options/black-scholes.kg
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ ncdf::{(1+erf(x%sqrt(2)))%2}
:" Option delta computed via Black-Scholes "
optiondelta::{[s k r t iv];s::x@0;k::x@1;r::x@2;t::x@3;iv::x@4;ncdf((log(s%k)+(r+0.5*iv^2)*t)%(iv*sqrt(t)))}

:" Option price computed via Black-Scholes "
:" test the option delta "
d::optiondelta([[100] [100] [0.05] [1] [0.2]])
.d("expecting: 0.6368306511756191 computed: ");.p(d)

d1fn::{(log(s%k)+(r+0.5*iv^2)*t)%(iv*sqrt(t))}
d2fn::{d1-iv*sqrt(t)}
pricefn::{(s*ncdf(d1))-(k*exp((-r)*t)*ncdf(d2))}
optionprice::{[s k r t iv d1 d2];s::x@0;k::x@1;r::x@2;t::x@3;iv::x@4;d1::d1fn();d2::d2fn();pricefn()}
:" Option price computed via Black-Scholes "
pricefn::{[d1 d2];d1::(log(s%k)+(r+0.5*iv^2)*t)%(iv*sqrt(t));d2::d1-iv*sqrt(t);(s*ncdf(d1))-(k*exp((-r)*t)*ncdf(d2))}
optionprice::{[s k r t iv];s::x@0;k::x@1;r::x@2;t::x@3;iv::x@4;pricefn()}

:" test the option price "
d::optionprice([100 100 0.05 1 0.2])
.d("expecting: 10.4506 computed: ");.p(d)

0 comments on commit c35a161

Please sign in to comment.