Operations Research topics: SAS/OR,
SAS Optimization, and SAS Simulation Studio

calculate implied volatillity by Black-Schole model and NLP

Reply
Occasional Contributor bqk
Occasional Contributor
Posts: 16

calculate implied volatillity by Black-Schole model and NLP

i want to calculate implied volatility using proc NLP

the code is like following

proc nlp data=AA outest=BB;
min error ;
PARMS sig=0.01;
d1=(log(SPXclose/(strike_price/1000))+(rate+((sig**2)/2))*TTM)/(sig*sqrt(TTM));
d2=d1-(sig*sqrt(TTM));
ee=((strike_price/1000)*exp((-rate)*TTM)*probnorm(-d2) - SPXclose*probnorm(-d1))-(best_ask+best_bid)/2;
error=abs(ee);
run;


however it does not work

the information in the log is following

NOTE: Your code contains 4 program statements.
NOTE: Gradient is computed using analytic formulas.
NOTE: Hessian is computed using analytic formulas.
ERROR: The variable SPXclose was referenced but not given a value.
ERROR: The variable strike_price was referenced but not given a value.
ERROR: The variable rate was referenced but not given a value.
ERROR: The variable TTM was referenced but not given a value.
ERROR: The variable best_ask was referenced but not given a value.
ERROR: The variable best_bid was referenced but not given a value.
WARNING: Your program statements contain 6 symbols used but not given a value.
WARNING: None of the data set variables are used in the program statements.
ERROR: There are references to missing variables when the program code is executed for _OBS_= 1
WARNING: Your program statements cannot be executed completely.
WARNING: In a total of 1 calls an error occurred during execution of the program statements.
NLP attempted to recover by using a shorter step size.

i can not understand where is the problem?

please help me, thanks for your help~
Ask a Question
Discussion stats
  • 0 replies
  • 245 views
  • 0 likes
  • 1 in conversation