I am using Mathematica to price options (built in functions, no need to reinvent the wheel, right?). In the documentation, the Binomial method is used as an example of specifying a non-standard method. I wanted to try other methods like Finite Difference and MonteCarlo, however, these do not work when I specify them, and I cannot find a list anywhere of the different methods available. Does anyone have any resources that I can use to better understand what is going on under the hood here?
-
$\begingroup$ Can you add some of the code you are currently using, or a more detailed description of what features of the language you are using? $\endgroup$– MarcoBCommented Nov 3, 2015 at 17:01
-
$\begingroup$ Here is a link to my code: bit.ly/20rOZGU. Here is a link to the input file I am starting with; I am taking option chain data from my broker and then using mathematica to get IV and greeks: drive.google.com/file/d/0B3OadCVSa_RoQURoN0JpSVMyaTQ $\endgroup$– pyrexCommented Nov 3, 2015 at 21:07
1 Answer
I also use Mathematica for calculating derivatives prices. As I understand FinancialDerivative[(*option params*),"GridSize"->{}]
is equivalent to Finite Differences method. And FinancialDerivative[(*option params*), "Paths"->]
is equivalent to Monte-Carlo method. By default Mathematica chooses optimal method depending of option type and time to expiration.
Also I think it may be interesting that naive realization of Black-Scholes can be 32X faster. An example for the case with interest rate = 0, dividend = 0:
call[strike_, spot_, time_, vola_] := Module[ { d1 = (Log[spot/strike] + vola^2/2*time/365)/(vola*Sqrt[time/365]), d2 = (Log[spot/strike] - vola^2/2*time/365)/(vola*Sqrt[time/365]), cdf = .5 Erfc[-#/Sqrt[2]] &, dtcdf = Exp[-#^2/2]/Sqrt[2*Pi] & }, { spot*cdf[d1] - strike*cdf[d2], (*delta*)cdf[d1], (*gamma*)dtcdf[d1]/(spot*vola*Sqrt[time/365]), (*vega*)spot*dtcdf[d1]*Sqrt[time/365]/100, (*theta*)-spot*dtcdf[d1]*vola/(2*Sqrt[time/365])/365 } ] put[strike_, spot_, time_, vola_] := Module[ { d1 = (Log[spot/strike] + vola^2/2*time/365)/(vola*Sqrt[time/365]), d2 = (Log[spot/strike] - vola^2/2*time/365)/(vola*Sqrt[time/365]), cdf = .5 Erfc[-#/Sqrt[2]] &, dtcdf = Exp[-#^2/2]/Sqrt[2*Pi] & }, { strike*cdf[-d2] - spot*cdf[-d1], (*delta*)cdf[d1] - 1, (*gamma*)dtcdf[d1]/(spot*vola*Sqrt[time/365]), (*vega*)spot*dtcdf[d1]*Sqrt[time/365]/100, (*theta*)-spot*dtcdf[d1]*vola/(2*Sqrt[time/365])/365 } ]
Checking the correctness:
In[9]:= put[87500, 89040, 13, .33966] Out[9]= {1569.98, -0.380478, 0.0000667356, 64.0063, -83.6168} In[10]:= FinancialDerivative[ {"European", "Put"}, {"StrikePrice" -> 87500, "Expiration" -> 13/365}, {"InterestRate" -> 0., "Volatility" -> 0.33966, "CurrentPrice" -> 89040, "Dividend" -> 0.}, {"Value", "Delta", "Gamma", "Vega", "Theta"}]*{1, 1, 1, 1/100, 1/365} Out[10]= {1569.98, -0.380478, 0.0000667356, 64.0062, -83.6164}
Benchmarking:
In[11]:= Do[put[87500, 89040, 13, .33966], {1000}] // AbsoluteTiming Out[11]= {0.159938, Null} In[12]:= Do[ FinancialDerivative[ {"European", "Put"}, {"StrikePrice" -> 87500, "Expiration" -> 13/365}, {"InterestRate" -> 0., "Volatility" -> .33966, "CurrentPrice" -> 89040, "Dividend" -> 0.}, {"Value", "Delta", "Gamma", "Vega", "Theta"}]*{1, 1, 1, 1/100, 1/365} , {1000}] // AbsoluteTiming Out[12]= {4.79136, Null}
-
$\begingroup$ Alexey, thank you for your reply; it is exactly what I was looking for. May I ask where you learned about the Path and Gridsize options? I could not find anything in the documentation online: reference.wolfram.com/language/ref/FinancialDerivative.html Here is a link to my code: bit.ly/20rOZGU Here is a link to the input file I am starting with; I am taking option chain data from my broker and then using mathematica to get IV and greeks: drive.google.com/file/d/0B3OadCVSa_RoQURoN0JpSVMyaTQ/… $\endgroup$– pyrexCommented Nov 3, 2015 at 20:21
-
1$\begingroup$ @pyrex There is not too much information but it can be found by the same link in section Options. reference.wolfram.com/language/ref/FinancialDerivative.html $\endgroup$ Commented Nov 4, 2015 at 5:25