PureBytes Links
Trading Reference Links
|
Here is an updated Black scholes option pricing formula in Amibroker. It
is matching Excel exactly from about 15 points above stock price to
anything below stock price. Gives Call Fair Value and Put Fair Value.
I am currently working on the pricing formula when strike price is
further above stock price by more than 15 points , at that point excel
and amibroker do not return the same values..
Anthony
//BLACK SHCOLES OPTION PRICING FORMULA
//Interpreted and coded by Anthony Faragasso
// Enter Variables
Vshort=0; // setting this variable, will use volatility of Market
// ( ex. setting to 20,is a 20 period historical volatility
StockPrice = 100; //Stock Price for testing( replace with Close )
Timedays = 182; //Time to expiry ( days to exp/365 )
StrikePrice = 90; //strike Price of Option to evaluate
InterestRate= 0.1; //prevailing interest rate
V =0.2; //Setting Vshort to 0, you can insert Known volatility here.
V = IIf(vshort > 0,StDev(log(C/Ref(C,-1)),Vshort)*sqrt(365)*100,V);
time=timedays/365;// days to expire conversion for formula
/*************************************************/
// Solves for ( X )
x = (ln(stockPrice/strikePrice) + (interestrate + V*V/2)*time)/(V*sqrt(time));
/*************************************************/
P = 0.2316419; //0.33267; //koeficient
bb1 = 0.31938153; //0.4361836; //koef
bb2 = -0.3565638; //-0.1201676; //koef
bb3 = 1.78147794; //0.937298; //koef
bb4 = -1.821256;
bb5 = 1.33027443;
pi = 3.141592654; // PI
t1 = 1/(1+ P*x);
A2 = 1/sqrt(2*pi);
A3 = exp(-(x^2)/2);
A4 = exp(-interestrate*time);
A5=(bb1*t1)+(bb2*t1^2) +( bb3*t1^3)+(bb4*t1^4)+(bb5*t1^5);
/************************************************************/
//Standard Normal Distribution Function of ( x )
N = 1- A2* A3 * A5 ; //1-(-x);//,IIf(x==0,0.5,0)));
/************************************************************/
X1=x-V*sqrt(TIME);
N0=exp(-(x1^2)/2);
T2=1/(1+ P*X1);
A6=(bb1*t2)+(bb2*t2^2) +( bb3*t2^3)+(bb4*t2^4)+(bb5*t2^5);
A7=exp(-interestrate*time);
/************************************************************/
/* Standard Normal Distribution Function OF ( x1 )*/
/***********************************************************/
N2= 1-A2 * N0 * A6;
/************ CALL OPTION FAIR VALUE************/
Call = stockPrice * N - strikePrice * A4 * N2 ;
/************ PUT OPTION FAIR VALUE*************/
Put = Call - stockprice + strikeprice*A7;
Filter = 1;
AddColumn(stockPrice,"AssetP",2.2);
AddColumn(strikeprice,"StrikeP",1.2);
AddColumn(timedays,"DaysToExpire ",1);
AddColumn(Call,"Call FV",1.2);
AddColumn(put,"Put FV",1.2);
/************************************/
/* test columns */
//AddColumn(x,"X",1.2);
//AddColumn(time,"time",1.2);
//AddColumn(n,"N",1.2);
//AddColumn(A4,"A4",1.2);
|