Scenario analysis for option strategies.

[This article was first published on Quant-Day, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Introduction to the project I am working on at the moment. It is more a playground for option strategies than “project” at this stage.

The idea is to develop accurate scenario analysis on portfolio, which is based on a single underlying. In the past I have written some code on simply plotting the payoffs at maturity, then followed a small piece of code, which was improved in a way that specific date could have been chosen for which the payoff is plotted.

For my current project I think the output will be self explanatory. The code is just the running bit to give a feeling of what it does and how it does what it does:


The range of the stock values are 2 standard deviations that were plugged into GBM, which was obviously adjusted for risk neutrality as we are in pricing framework. The red line indicates 1.5 standard deviation line. “step” is increment of possible stock prices via volatility.
Furthermore, it returns a function which does an interpolation over the surface, so analysis at each time point can simply be done.

x=50:300
y=outfun(Sys.Date()+days(185), x)
plot(x,y,”l”)


For now, the interest rates used are flat as well as implied volatility surface. However, the needed space was made so both can be easily implemented. Also, it is restructured in such way, that new pricing functions can be added effortlessly.

Implementing multiple assets can also be easily done, however I did not figure out, how to aggregate total pnl. One way to do it would be taking 1 stock as a reference, and using beta coefficients to sum the pnl. However, this would flaw the output via false assumption of constant beta with 0 variation.

Other derivatives in my mind are american options, powers, barriers or index linked notes that are possible to price via known pricing functions. In general, anything that could be priced without needing to calibrate model with more than one source of risk.

Comments and suggestions are more than welcome.

To leave a comment for the author, please follow the link and comment on their blog: Quant-Day.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)