Message Boards Message Boards

need help to price a european option using finite difference method

Posted 9 years ago

I am writing a function to price European option using backward induction finite difference method. The function is expected to price a European option taking Stock (stock), age (time), volatility (vol), interest rate (int), contractual expiry (expn), type of payoff (payoff),Strike ( strike), number of asset steps used for evaluation option (nas). I am expecting function to return price of the option based stock price and age (if option is bought today age is zero). I need help as I am only few weeks into mathematica programming so might be making basic mistakes. My code is as attached. Can anybody opine where I am going wrong.


POSTED BY: Kausik Datta

Unfortunately your code has some language errors in it. I expect you're coming from C++ or Python? If you want to price options with sequential code I'd suggest R, or whatever language you know best.

If you want to use Mathematica, you should first get to grips with the unique elements of its format:

  • All built in functions are capitalised. You've tried to make use of 'max' and 'if' for example.
  • All function arguments are specified by square bracket. You've tried to pass 'IntegerPart', 'If', 'max', and even your own 'boptval' arguments via curved bracket.
  • Brackets should be closed, this is pretty basic, and some potential culprits are even highlighted for you. Coding out 15 lines at once in an unfamiliar language is not a good idea! If you understand the innards of the function, code it line by line, run it frequently, and check that your output and variables behave as expected.

Finally, defining a single function via Module is not not great leverage of the power of Mathematica!

What's the application? Are you just interested in the market, or are you on a trading desk?

POSTED BY: David Gathercole
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract