[R-SIG-Finance] options profit/loss graph (beginner question)

Uwe Voelker uwe at uwevoelker.de
Sun Nov 27 22:40:22 CET 2011


Hello Enrico,

> Here is a very simple example:

Thanks alot for your example. It was enough to get me starting.

> ... or you may want to have a look at
> http://dirk.eddelbuettel.com/code/rquantlib.html

That's what I did. Quant-lib is better for me than rmetrics, because
it is also available in other programming languages.

This is what I have right now for my ratio spread:

library(RQuantLib)

S         <- 1950:2400
cur_price <- 2150
time_left <- c(20/365, 10/365, 1/365)
vola      <- 0.3

long  <- EuropeanOptionArrays("put", S, 2100, 0, 0.01, time_left, vola)
short <- EuropeanOptionArrays("put", S, 2050, 0, 0.01, time_left, vola)

plot( S, long$value[, 3] - short$value[, 3] - short$value[, 3], col =
grey(.7), type="l", ylab="payoff")
lines(S, long$value[, 2] - short$value[, 2] - short$value[, 2], col =
grey(.5), type="l")
lines(S, long$value[, 1] - short$value[, 1] - short$value[, 1], col =
grey(.3), type="l")

There seems to be a problem with expiration (when the last entry in
time_left is 0), but maybe this is normal. As your code also handled
this case differently.


So, thanks a lot again,
with kind regards,
Uwe



More information about the R-SIG-Finance mailing list