Search code examples
juliafinance

How to calculate the fair price of an option using Black-Scholes model in Julia?


In python, option price can be calculated using:

from math import *
def bs_call(S,X,T,r,sigma):
    d1 = (log(S/X)+(r+sigma*sigma/2.)*T)/(sigma*sqrt(T))
    d2 = d1-sigma*sqrt(T)
    return S*CND(d1)-X*exp(-r*T)*CND(d2)

Please guide me in doing it (prefer to use built in function, if any) julia.


Solution

  • You can use the BS.jl package - the readme shows how to use it. Note that it is not registered so you have to ]add https://github.com/felipenoris/BS.jl to add it.