yuchenamberlu / options-calculator Goto Github PK
View Code? Open in Web Editor NEWOption Calculator using Black-Scholes model and Binomial model
Option Calculator using Black-Scholes model and Binomial model
Hi, thanks for the great upload. Do you know why I get an error ?
Thanks
NameError Traceback (most recent call last)
in
1 ## calculate the call / put option price and the greeks of the call / put option
2 r = r/100; sigma = sigma/100;
----> 3 price_and_greeks = {'Call' : [bs_call(S,K,T,r,sigma), call_delta(S,K,T,r,sigma), call_gamma(S,K,T,r,sigma),call_vega(S,K,T,r,sigma), call_rho(S,K,T,r,sigma), call_theta(S,K,T,r,sigma)],
4 'Put' : [bs_put(S,K,T,r,sigma), put_delta(S,K,T,r,sigma), put_gamma(S,K,T,r,sigma),put_vega(S,K,T,r,sigma), put_rho(S,K,T,r,sigma), put_theta(S,K,T,r,sigma)]}
5 price_and_greeks_frame = DataFrame(price_and_greeks, columns=['Call','Put'], index=['Price', 'delta', 'gamma','vega','rho','theta'])
NameError: name 'bs_call' is not defined
the formula for d1 should be:
def d1(S,K,T,r,sigma): return((log(S/K)+(r+0.5*sigma**2)*T))/(sigma*sqrt(T))
Think you need to tweak d1 part of your formula:
currently it reads as,
def d1(S,K,T,r,sigma):
return(log(S/K)+(r+sigma**2/2.)T)/sigmasqrt(T)
which will produce incorrect outcome for it, you need extra bracket, should read as:
def d1(S,K,T,r,sigma):
return(log(S/K)+(r+((sigma**2)/2))T)/(sigmasqrt(T))
otherwise great write up on blacksholes python model.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.