11
$\begingroup$

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?

$\endgroup$
2
  • $\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$
    – MarcoB
    Commented 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$
    – pyrex
    Commented Nov 3, 2015 at 21:07

1 Answer 1

14
$\begingroup$

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}
$\endgroup$
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.