Re: [R-SIG-Finance] RQuantLib - Options value at maturity
A workaround is instead of maturity =0, pass something very close to zero e.g. maturity=1e-14 Cheers Krishna > On Apr 17, 2014, at 8:54 AM, Pedro Baltazar wrote: > > Hello, > > why this package gives the value zero, and not (underlying - strike) = > 50, at maturity? > >> EuropeanOption("call", underlying=150, strike=100, dividendYield=0.00, >> riskFreeRate=0.03, maturity=0.0,volatility=0.2) > Concise summary of valuation for EuropeanOption > value delta gamma vega thetarho divRho > 0 0 0 0 0 0 0 > > Thanks > > -- > Pedro Baltazar > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Value of risk (system) conditional the event bank=value at risk level
It might help to see the data that you are loading but presumably you have daily data then you want to compute rolling VaR estimates (with say a 1yr lookback) with that data and then do the quantile regression. On Oct 5, 2013, at 9:55 AM, schloni wrote: > Dear R-community, > > I try to calculate the Value at risk (VaR) of the financial system > conditional the event, that a single bank is on its VaR-level. This is then > called the CoVaR. > > The VaR is the 95%-(negative)quantile of a distribution, so it can be > calculated using the rq() regression function. > > My first version of the code is shown below. However, it did not work, > because the VaR of the bank is a single value e.g. -0.0038974, but the > weighted average is a vector of 3130 numbers. Furthermore, this approach is > somehow logically wrong, as it should be more like this: > > CoVaR <- rq(Xsystem~X, tau=0.05, if X=VaR(X, p = 0.95, method = > c("historical"))) or > > CoVaR <- rq(Xsystem~X, tau=0.05, if X=VaRbankq) > > Has anybody an idea, how I can solve this? > > Thanks a lot! > > > This is my code: > > # PAKETE > sessionInfo() > library(quantreg) > library(PerformanceAnalytics) > > # LADEN DER DATEN > weightssystem<-read.csv("systemweightedaveragegrowthrate.csv")# growth rate > total assets ofsystem > x <- read.csv("growthrateMVtotalassetsbank2.csv") # > growth rate of total assets of bank2 > > # DEFINITION > Xsystem <- weightssystem[,1] > X <- x[,1] > length(Xsystem) > > # length is 3130 > length(X) > > # length is 3130 > > # VaR BANK > # 2 Methods > VaRbankq <- quantile(X, 0.05) # > calculation via the 95%-quantile > VaRbankq > VaRbank <- VaR(X, p = 0.95, method = c("historical")) # VaR-function; > gaussian possible > VaRbank > > > # VaR SYSTEM CONDITIONAL ON EVENT (BANK=VaR LEVEL): CoVaR > CoVaR <- rq(Xsystem~VaRbank, tau=0.05) # this was > my first try > CoVaR > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Value-of-risk-system-conditional-the-event-bank-value-at-risk-level-tp4677672.html > Sent from the Rmetrics mailing list archive at Nabble.com. > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Options solution?
Another way to get the greeks besides Jeff's excellent package could be with AD tools in R. I just noticed that there was a GSOC to add automatic differentiation in R and the package radx on github looks promising. One could to automagically compute greeks on the fly for free. Here is a little code snippet that computes the option price and magically gives you the delta for free! #require(devtools) #make sure we have devtools installed #install_github("radx","quantumelixir") #install radx from github rm(list=ls()) require(radx) FT<-1.35 X<-1.32 Time<-1/4 rate<-0.01 vol<-0.12 putcall<-"C" #Simple blackscholesmerton pricer for options bspricer <- function(putcall,vol,FT,X,Time,rate) { d1 <- (log(FT/X)+(rate+0.5*(vol*vol))*Time)/(vol*sqrt(Time)) d2 <- d1-vol*sqrt(Time) FT=radx(FT,1) # this is where all the magic happens if(putcall=="C") { return((FT*pnorm(d1)-X*exp(-rate*Time)*pnorm(d2))) } else { return((X*exp(-rate*Time)*pnorm(-d2)-FT*pnorm(-d1))) } } #Calling this function below >bspricer(putcall,vol,FT,X,Time,rate) Value : 0.05128281 Coefficients:[1] 0.6722788 Derivatives :[1] 0.6722788 Order : 1 Directions : 1 >>> So no more worries around the appropriate shift in finite difference methods, roundoff errors from machine precision issues (IEEE 754) or knowing the exact analytical formula for the greeks. Cheers Krishna On Aug 25, 2013, at 11:14 AM, Jeff Ryan wrote: > Hi John, > > I have a package that isn't quite 'complete' that might be of use. > > https://code.google.com/p/rgreeks/ > > I'm intending on pushing what is complete to CRAN this week. > > I also gave a lightning talk at R/Finance this year as a quick 5 min > overview: > > http://www.rinfinance.com/agenda/2013/talk/JeffRyan.pdf > > HTH > Jeff > > > On Fri, Aug 23, 2013 at 4:32 PM, BBands wrote: > >> The options solution I have used forever no longer works well, so I am >> looking for a new option analysis solution. My needs are rather >> simple, really all I want are nice P&L graphs for option positions >> with a number of legs. Flexibility is key. I was thinking about >> Hoadley, which I have used on and off, but I am no longer a fan of >> analytics in Excel. So I thought that this might be a chance to expand >> my R skills. I've seen a couple of ideas and there must be a ton of R >> solutions that I am not aware of. This is one that I have found: >> http://www.r-bloggers.com/scenario-analysis-and-trading-options-using-r/ >> Do you know of any that are particularly elegant or that you like well? >> >> Thanks, >> >>John >> -- >> John Bollinger >> www.BollingerBands.com >> >> ___ >> R-SIG-Finance@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-sig-finance >> -- Subscriber-posting only. If you want to post, subscribe first. >> -- Also note that this is not the r-help list where general R questions >> should go. >> > > > > -- > Jeffrey Ryan > jeffrey.r...@lemnica.com > > www.lemnica.com > > [[alternative HTML version deleted]] > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. [[alternative HTML version deleted]] ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Monte Carlo simulations for barrier options?
If you are looking to price standard barrier options under BS assumptions (no stoch/local vol) the analytic approximations in RQuantlib or fOptions (which is from Haug's book) is your best friend. Now if you must price using MC have a look at this little paper it is simple. (and inaccurate/ big standard error) http://www.opalconsulting.ch/dataa/245de.pdf As there is a big discretization error which needs to be addressed by Importance sampling or better still brownian bridge as in Amir Atiya http://alumnus.caltech.edu/~amir/barrier.pdf Cheers Krishna On Jun 10, 2013, at 4:37 AM, Raghuraman Ramachandran wrote: > Dear guRus > > Is there any package to price up barrier options using Monte Carlo > simulations in R please? > > Thx > Raghu > >[[alternative HTML version deleted]] > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. [[alternative HTML version deleted]] ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] euro call by integration
You need to integrate payoff x density [disc factor x pmax(s-k,0) x density ] below Also the std error of the integration unlikely it is going to be that big but worth keeping in mind. On Apr 13, 2013, at 7:42 AM, Enrico Schumann wrote: > On Sat, 13 Apr 2013, Dominykas Grigonis writes: > >> Valuing european call option by taking expectation and integrating: >> >> gmb <- function(x,s0=100,r=0.05,vol=0.1){ >> s0*exp( (r - vol^2/2) + vol * x)} >> >> fun <- function(x, K=100){ >> (gbm(x) - 100) * dnorm(x)} >> >> min = -(log(1) + (0.05-0.1^2/2)) / 0.1 >> integrate(fun,min,Inf) >> >> could someone tell me what am I doing wrong? I do not even know if this is R >> related question or not... >> >> returns 7.153855, while actual risk neutral price is 6.804958 >> >> Thank you in advance. >> >> Kind regards,-- >> Dominykas Grigonis > > I did not run your code, but shouldn't you discount the result? > > > > -- > Enrico Schumann > Lucerne, Switzerland > http://enricoschumann.net > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Performance Analytics Calendar Returns
> > I am trying to use the table.CalendarReturns from the Performance Analytics > package with daily returns. > Last I checked the help/usage file states that it expects monthly return data. There are some zOo and xts functions that do this.. ?to.monthly ?table.Annualizedreturns Cheers Krishna > t(table.CalendarReturns(tradedata$daily.pnl.norm["1998/2012"],as.perc=TRUE,digits=4,geometric=TRUE)) > > 1) is there anything wrong with my command? if not, is there any way to > transform the daily results to monthly? > > 2) is there a function that would give me the same table for volatility and > sharpe? > > Thank you all in advance, > > Nikos > >[[alternative HTML version deleted]] > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.