From noreply at r-forge.r-project.org Mon Sep 1 09:46:43 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 1 Sep 2014 09:46:43 +0200 (CEST) Subject: [Highfrequency-commits] r90 - pkg/highfrequency/man Message-ID: <20140901074643.19026186E07@r-forge.r-project.org> Author: kboudt Date: 2014-09-01 09:46:42 +0200 (Mon, 01 Sep 2014) New Revision: 90 Modified: pkg/highfrequency/man/aggregatePrice.Rd Log: Modified: pkg/highfrequency/man/aggregatePrice.Rd =================================================================== --- pkg/highfrequency/man/aggregatePrice.Rd 2014-08-31 18:18:35 UTC (rev 89) +++ pkg/highfrequency/man/aggregatePrice.Rd 2014-09-01 07:46:42 UTC (rev 90) @@ -12,7 +12,7 @@ \usage{ aggregatePrice(ts,FUN = previoustick,on="minutes",k=1, -marketopen,marketclose) + marketopen = "09:30:00", marketclose = "16:00:00", tz = "GMT")) } \arguments{ @@ -23,6 +23,7 @@ xts object to the 5 minute frequency set k=5 and on="minutes".} \item{marketopen}{the market opening time, by default: marketopen = "09:30:00". } \item{marketclose}{the market closing time, by default: marketclose = "16:00:00". } +\item{tz}{time zone used, by default: tz = "GMT". } } \section{Details}{ From noreply at r-forge.r-project.org Mon Sep 1 09:47:52 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 1 Sep 2014 09:47:52 +0200 (CEST) Subject: [Highfrequency-commits] r91 - pkg/highfrequency/R Message-ID: <20140901074752.6CC7F186E70@r-forge.r-project.org> Author: kboudt Date: 2014-09-01 09:47:51 +0200 (Mon, 01 Sep 2014) New Revision: 91 Modified: pkg/highfrequency/R/highfrequencyGSOC.R Log: Modified: pkg/highfrequency/R/highfrequencyGSOC.R =================================================================== --- pkg/highfrequency/R/highfrequencyGSOC.R 2014-09-01 07:46:42 UTC (rev 90) +++ pkg/highfrequency/R/highfrequencyGSOC.R 2014-09-01 07:47:51 UTC (rev 91) @@ -662,7 +662,7 @@ ####Realized beta#### -rBeta = function(rdata, rindex, RCOVestimator= "rCov", RVestimator= NULL, makeReturns= FALSE,...) +rBeta = function(rdata, rindex, RCOVestimator= "rCov", RVestimator= "RV", makeReturns= FALSE,...) { if (hasArg(data)) { From noreply at r-forge.r-project.org Mon Sep 1 21:07:12 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 1 Sep 2014 21:07:12 +0200 (CEST) Subject: [Highfrequency-commits] r92 - pkg/highfrequency/man Message-ID: <20140901190712.EB4F5187538@r-forge.r-project.org> Author: kboudt Date: 2014-09-01 21:07:12 +0200 (Mon, 01 Sep 2014) New Revision: 92 Modified: pkg/highfrequency/man/spotvol.Rd Log: Modified: pkg/highfrequency/man/spotvol.Rd =================================================================== --- pkg/highfrequency/man/spotvol.Rd 2014-09-01 07:47:51 UTC (rev 91) +++ pkg/highfrequency/man/spotvol.Rd 2014-09-01 19:07:12 UTC (rev 92) @@ -212,7 +212,7 @@ One way to estimate \eqn{h}, is by using cross-validation. For each day in the sample, \eqn{h} is chosen as to minimize the Integrated Square Error, which is a function of \eqn{h}. However, this function often has multiple -local minima, or no minima at all (\eqn{h -> \Inf}). To ensure a reasonable +local minima, or no minima at all (\eqn{h -> \infty}). To ensure a reasonable optimum is reached, strict boundaries have to be imposed on \eqn{h}. These can be specified by \code{lower} and \code{upper}, which by default are \eqn{0.1n^{-0.2}} and \eqn{n^{-0.2}} respectively, where \eqn{n} is the From noreply at r-forge.r-project.org Mon Sep 1 21:07:21 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 1 Sep 2014 21:07:21 +0200 (CEST) Subject: [Highfrequency-commits] r93 - pkg/highfrequency/man Message-ID: <20140901190721.356B118753F@r-forge.r-project.org> Author: kboudt Date: 2014-09-01 21:07:20 +0200 (Mon, 01 Sep 2014) New Revision: 93 Added: pkg/highfrequency/man/sample_returns_5min.Rd Log: Added: pkg/highfrequency/man/sample_returns_5min.Rd =================================================================== --- pkg/highfrequency/man/sample_returns_5min.Rd (rev 0) +++ pkg/highfrequency/man/sample_returns_5min.Rd 2014-09-01 19:07:20 UTC (rev 93) @@ -0,0 +1,13 @@ +% Generated by roxygen2 (4.0.1): do not edit by hand +\docType{data} +\name{sample_returns_5min} +\alias{sample_returns_5min} +\title{Sample returns data} +\format{matrix} +\usage{ +data(sample_returns_5min) +} +\description{ +EUR/USD returns from January to September 2004 +} + From noreply at r-forge.r-project.org Tue Sep 2 06:10:36 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 2 Sep 2014 06:10:36 +0200 (CEST) Subject: [Highfrequency-commits] r94 - pkg/highfrequency/vignettes Message-ID: <20140902041036.5D462183F89@r-forge.r-project.org> Author: kboudt Date: 2014-09-02 06:10:35 +0200 (Tue, 02 Sep 2014) New Revision: 94 Modified: pkg/highfrequency/vignettes/highfrequency.pdf Log: Modified: pkg/highfrequency/vignettes/highfrequency.pdf =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Tue Sep 2 06:11:25 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 2 Sep 2014 06:11:25 +0200 (CEST) Subject: [Highfrequency-commits] r95 - pkg/highfrequency Message-ID: <20140902041126.07C61183F89@r-forge.r-project.org> Author: kboudt Date: 2014-09-02 06:11:25 +0200 (Tue, 02 Sep 2014) New Revision: 95 Modified: pkg/highfrequency/DESCRIPTION Log: Modified: pkg/highfrequency/DESCRIPTION =================================================================== --- pkg/highfrequency/DESCRIPTION 2014-09-02 04:10:35 UTC (rev 94) +++ pkg/highfrequency/DESCRIPTION 2014-09-02 04:11:25 UTC (rev 95) @@ -1,6 +1,6 @@ Package: highfrequency Version: 0.4 -Date: 2014-08-27 +Date: 2014-08-31 Title: highfrequency Author: Jonathan Cornelissen, Kris Boudt, Scott Payseur Maintainer: Jonathan Cornelissen From noreply at r-forge.r-project.org Tue Sep 2 14:38:14 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 2 Sep 2014 14:38:14 +0200 (CEST) Subject: [Highfrequency-commits] r96 - pkg/highfrequency/src Message-ID: <20140902123815.1069518769F@r-forge.r-project.org> Author: kboudt Date: 2014-09-02 14:38:14 +0200 (Tue, 02 Sep 2014) New Revision: 96 Modified: pkg/highfrequency/src/highfrequency.c Log: Modified: pkg/highfrequency/src/highfrequency.c =================================================================== --- pkg/highfrequency/src/highfrequency.c 2014-09-02 04:11:25 UTC (rev 95) +++ pkg/highfrequency/src/highfrequency.c 2014-09-02 12:38:14 UTC (rev 96) @@ -520,7 +520,7 @@ double O[K]; double A[K*K*pMax]; double B[K*K*qMax]; - double temp[K]; + // double temp[K]; //---- initialize ----------------- for(i=0;i Author: kboudt Date: 2014-09-02 15:08:34 +0200 (Tue, 02 Sep 2014) New Revision: 97 Modified: pkg/highfrequency/R/spotvol.r Log: Modified: pkg/highfrequency/R/spotvol.r =================================================================== --- pkg/highfrequency/R/spotvol.r 2014-09-02 12:38:14 UTC (rev 96) +++ pkg/highfrequency/R/spotvol.r 2014-09-02 13:08:34 UTC (rev 97) @@ -1170,7 +1170,7 @@ # xlab = "intraday period", type = "l", lty = 3) # legend("topright", c("Parametric", "Non-parametric"), cex = 1.1, # lty = c(1,3), lwd = 1, bty = "n") - seas = highfrequency:::diurnalfit(theta = theta, P1 = P1, P2 = P2, intraT = intraT, + seas = diurnalfit(theta = theta, P1 = P1, P2 = P2, intraT = intraT, dummies = dummies) # lines(seas, lty = 1) return(list(seas, theta)) From noreply at r-forge.r-project.org Tue Sep 2 15:08:42 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 2 Sep 2014 15:08:42 +0200 (CEST) Subject: [Highfrequency-commits] r98 - pkg/highfrequency/R Message-ID: <20140902130842.23B5E18769D@r-forge.r-project.org> Author: kboudt Date: 2014-09-02 15:08:41 +0200 (Tue, 02 Sep 2014) New Revision: 98 Modified: pkg/highfrequency/R/realized.R Log: Modified: pkg/highfrequency/R/realized.R =================================================================== --- pkg/highfrequency/R/realized.R 2014-09-02 13:08:34 UTC (rev 97) +++ pkg/highfrequency/R/realized.R 2014-09-02 13:08:41 UTC (rev 98) @@ -966,7 +966,7 @@ secs = 3600 * k; tby = paste(3600 * k, "sec", sep = " "); } - g = base:::seq(start(ts), end(ts), by = tby); + g = base::seq(start(ts), end(ts), by = tby); rawg = as.numeric(as.POSIXct(g, tz = "GMT")); newg = rawg + (secs - rawg%%secs); g = as.POSIXct(newg, origin = "1970-01-01",tz = "GMT"); @@ -2078,7 +2078,7 @@ for (i in 1:length(ticker)) { tfile_name = paste(datasource, "/", ticker[i], "_trades", sep = "") - tdata = try(highfrequency:::readdata(path = tfile_name, extension = extension, + tdata = try(readdata(path = tfile_name, extension = extension, header = header, dims = 9), silent = TRUE) error = dim(tdata)[1] == 0 @@ -2259,7 +2259,7 @@ if( onefile == TRUE ){ # Load the data: ############################ This depends on the data provider if(trades == TRUE){ - if( extension=="txt"){ dataname = paste(datasource,"/",ticker,"_trades",sep=""); highfrequency:::readdata(path = datasource, extension = "txt", header = FALSE, dims = 0); } + if( extension=="txt"){ dataname = paste(datasource,"/",ticker,"_trades",sep=""); readdata(path = datasource, extension = "txt", header = FALSE, dims = 0); } if( extension=="csv"){ dataname = paste(datasource,"/",ticker,"_trades.csv",sep=""); data = read.csv(dataname);} if( extension=="tickdatacom"){ dataname = paste(datasource,"/",ticker,"_trades.asc",sep=""); @@ -2272,7 +2272,7 @@ alldata = suppressWarnings(makeXtsTrades(tdata=data,format=format)); } if (quotes == TRUE){ - if( extension=="txt"){ dataname = paste(datasource,"/",ticker,"_quotes",sep=""); highfrequency:::readdata(path = datasource, extension = "txt", header = FALSE, dims = 0); } + if( extension=="txt"){ dataname = paste(datasource,"/",ticker,"_quotes",sep=""); readdata(path = datasource, extension = "txt", header = FALSE, dims = 0); } if( extension=="csv"){ dataname = paste(datasource,"/",ticker,"_quotes.csv",sep=""); data = read.csv(dataname);} if( extension=="tickdatacom"){ dataname = paste(datasource,"/",ticker,"_quotes.asc",sep=""); @@ -3772,7 +3772,7 @@ tby = "h" } by = paste(k, tby, sep = " ") - allindex = as.POSIXct(base:::seq(start(ts3), end(ts3), + allindex = as.POSIXct(base::seq(start(ts3), end(ts3), by = by)) xx = xts(rep("1", length(allindex)), order.by = allindex) ts3 = merge(ts3, xx)[, (1:dim(ts)[2])] @@ -3790,7 +3790,7 @@ FUN = match.fun(FUN); - g = base:::seq(start(ts), end(ts), by = tby); + g = base::seq(start(ts), end(ts), by = tby); rawg = as.numeric(as.POSIXct(g,tz="GMT")); newg = rawg + (secs - rawg%%secs); g = as.POSIXct(newg,origin="1970-01-01",tz="GMT"); From noreply at r-forge.r-project.org Tue Sep 2 15:14:33 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 2 Sep 2014 15:14:33 +0200 (CEST) Subject: [Highfrequency-commits] r99 - pkg/highfrequency/man Message-ID: <20140902131433.55517186923@r-forge.r-project.org> Author: kboudt Date: 2014-09-02 15:14:32 +0200 (Tue, 02 Sep 2014) New Revision: 99 Modified: pkg/highfrequency/man/BNSjumptest.Rd Log: Modified: pkg/highfrequency/man/BNSjumptest.Rd =================================================================== --- pkg/highfrequency/man/BNSjumptest.Rd 2014-09-02 13:08:41 UTC (rev 98) +++ pkg/highfrequency/man/BNSjumptest.Rd 2014-09-02 13:14:32 UTC (rev 99) @@ -26,13 +26,17 @@ (Huang and Tauchen (2005)) } \usage{ -BNSjumptest(rdata, IVestimator= "BV", IQestimator= "TP", type= "linear", logtransform= FALSE, - max= FALSE, align.by= NULL, align.period= NULL, makeReturns = FALSE, ...) +BNSjumptest(rdata, IVestimator= "BV", IQestimator= "TP", type= "linear", + logtransform= FALSE, max= FALSE, align.by= NULL, align.period= NULL, + makeReturns = FALSE, ...) } \arguments{ \item{rdata}{a zoo/xts object containing all returns in period t for one asset.} - \item{IVestimator}{can be chosen among jump robust integrated variance estimators: BV, minRV, medRV and corrected threshold bipower variation (CTBV). If CTBV is chosen, an argument of \eqn{startV}, start point of auxiliary estimators in threshold estimation (Corsi et al. (2010) can be included. BV by default.} + \item{IVestimator}{can be chosen among jump robust integrated variance estimators: BV, minRV, medRV + and corrected threshold bipower variation (CTBV). + If CTBV is chosen, an argument of \eqn{startV}, start point of auxiliary estimators in threshold estimation + (Corsi et al. (2010)) can be included. BV by default.} \item{IQestimator}{can be chosen among jump robust integrated quarticity estimators: TP, QP, minRQ and medRQ. TP by default.} \item{type}{a method of BNS testing: can be linear or ratio. Linear by default.} \item{logtransform}{boolean, should be TRUE when QVestimator and IVestimator are in logarith form. FALSE by default.} @@ -82,4 +86,4 @@ % Add one or more standard keywords, see file 'KEYWORDS' in the % R documentation directory. \keyword{ highfrequency } -\keyword{ BNSjumptest } \ No newline at end of file +\keyword{ BNSjumptest } From noreply at r-forge.r-project.org Tue Sep 2 15:26:30 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 2 Sep 2014 15:26:30 +0200 (CEST) Subject: [Highfrequency-commits] r100 - pkg/highfrequency/man Message-ID: <20140902132630.96818186BF9@r-forge.r-project.org> Author: kboudt Date: 2014-09-02 15:26:30 +0200 (Tue, 02 Sep 2014) New Revision: 100 Modified: pkg/highfrequency/man/aggregatePrice.Rd Log: Modified: pkg/highfrequency/man/aggregatePrice.Rd =================================================================== --- pkg/highfrequency/man/aggregatePrice.Rd 2014-09-02 13:14:32 UTC (rev 99) +++ pkg/highfrequency/man/aggregatePrice.Rd 2014-09-02 13:26:30 UTC (rev 100) @@ -12,7 +12,7 @@ \usage{ aggregatePrice(ts,FUN = previoustick,on="minutes",k=1, - marketopen = "09:30:00", marketclose = "16:00:00", tz = "GMT")) + marketopen = "09:30:00", marketclose = "16:00:00", tz = "GMT") } \arguments{ From noreply at r-forge.r-project.org Tue Sep 2 15:30:55 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 2 Sep 2014 15:30:55 +0200 (CEST) Subject: [Highfrequency-commits] r101 - pkg/highfrequency/man Message-ID: <20140902133055.2803218753C@r-forge.r-project.org> Author: kboudt Date: 2014-09-02 15:30:54 +0200 (Tue, 02 Sep 2014) New Revision: 101 Modified: pkg/highfrequency/man/highfrequency-package.Rd Log: Modified: pkg/highfrequency/man/highfrequency-package.Rd =================================================================== --- pkg/highfrequency/man/highfrequency-package.Rd 2014-09-02 13:26:30 UTC (rev 100) +++ pkg/highfrequency/man/highfrequency-package.Rd 2014-09-02 13:30:54 UTC (rev 101) @@ -11,7 +11,7 @@ \tabular{ll}{ Package: \tab highfrequency\cr Type: \tab Package\cr -Version: \tab 0.3\cr +Version: \tab 0.4\cr Date: \tab 2014-08-31\cr License: \tab \cr } From noreply at r-forge.r-project.org Wed Sep 3 14:22:43 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 3 Sep 2014 14:22:43 +0200 (CEST) Subject: [Highfrequency-commits] r102 - pkg/highfrequency/man Message-ID: <20140903122243.BA977187524@r-forge.r-project.org> Author: kboudt Date: 2014-09-03 14:22:43 +0200 (Wed, 03 Sep 2014) New Revision: 102 Modified: pkg/highfrequency/man/highfrequency-package.Rd Log: Modified: pkg/highfrequency/man/highfrequency-package.Rd =================================================================== --- pkg/highfrequency/man/highfrequency-package.Rd 2014-09-02 13:30:54 UTC (rev 101) +++ pkg/highfrequency/man/highfrequency-package.Rd 2014-09-03 12:22:43 UTC (rev 102) @@ -13,7 +13,7 @@ Type: \tab Package\cr Version: \tab 0.4\cr Date: \tab 2014-08-31\cr -License: \tab \cr +License: \tab GPL (>= 2) \cr } } From noreply at r-forge.r-project.org Wed Sep 3 14:23:16 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 3 Sep 2014 14:23:16 +0200 (CEST) Subject: [Highfrequency-commits] r103 - pkg/highfrequency/vignettes Message-ID: <20140903122316.109F1187537@r-forge.r-project.org> Author: kboudt Date: 2014-09-03 14:23:15 +0200 (Wed, 03 Sep 2014) New Revision: 103 Removed: pkg/highfrequency/vignettes/spotvol.Rnw pkg/highfrequency/vignettes/spotvol.pdf Log: Deleted: pkg/highfrequency/vignettes/spotvol.Rnw =================================================================== --- pkg/highfrequency/vignettes/spotvol.Rnw 2014-09-03 12:22:43 UTC (rev 102) +++ pkg/highfrequency/vignettes/spotvol.Rnw 2014-09-03 12:23:15 UTC (rev 103) @@ -1,5 +0,0 @@ -%\VignetteIndexEntry{spotvol function manual} - -\documentclass{article} -\begin{document} -\end{document} \ No newline at end of file Deleted: pkg/highfrequency/vignettes/spotvol.pdf =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Wed Sep 3 14:23:23 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 3 Sep 2014 14:23:23 +0200 (CEST) Subject: [Highfrequency-commits] r104 - pkg/highfrequency/man Message-ID: <20140903122323.BE1E9187538@r-forge.r-project.org> Author: kboudt Date: 2014-09-03 14:23:23 +0200 (Wed, 03 Sep 2014) New Revision: 104 Removed: pkg/highfrequency/man/highfrequencyGSOC-package.Rd Log: Deleted: pkg/highfrequency/man/highfrequencyGSOC-package.Rd =================================================================== --- pkg/highfrequency/man/highfrequencyGSOC-package.Rd 2014-09-03 12:23:15 UTC (rev 103) +++ pkg/highfrequency/man/highfrequencyGSOC-package.Rd 2014-09-03 12:23:23 UTC (rev 104) @@ -1,15 +0,0 @@ -\name{highfrequencyGSOC-package} -\alias{highfrequencyGSOC-package} -\alias{highfrequencyGSOC} -\docType{package} -\title{ -Additional functionality for the highfrequency package -} - -\description{Extra functionality for the highfrequency package, written by Giang, during the Google Summer of Code.} - - -\author{ -Giang Nguyen, Kris Boudt, Jonathan Cornelissen -Maintainer: Giang Nguyen -} \ No newline at end of file From noreply at r-forge.r-project.org Wed Sep 3 14:23:34 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 3 Sep 2014 14:23:34 +0200 (CEST) Subject: [Highfrequency-commits] r105 - pkg/highfrequency Message-ID: <20140903122334.C4E09187538@r-forge.r-project.org> Author: kboudt Date: 2014-09-03 14:23:34 +0200 (Wed, 03 Sep 2014) New Revision: 105 Removed: pkg/highfrequency/man-roxygen/ Log: From noreply at r-forge.r-project.org Wed Sep 3 17:40:07 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 3 Sep 2014 17:40:07 +0200 (CEST) Subject: [Highfrequency-commits] r106 - pkg/highfrequency/man Message-ID: <20140903154007.E3BA0183B33@r-forge.r-project.org> Author: kboudt Date: 2014-09-03 17:40:07 +0200 (Wed, 03 Sep 2014) New Revision: 106 Modified: pkg/highfrequency/man/spotvol.Rd Log: Modified: pkg/highfrequency/man/spotvol.Rd =================================================================== --- pkg/highfrequency/man/spotvol.Rd 2014-09-03 12:23:34 UTC (rev 105) +++ pkg/highfrequency/man/spotvol.Rd 2014-09-03 15:40:07 UTC (rev 106) @@ -1,3 +1,4 @@ + % Generated by roxygen2 (4.0.1): do not edit by hand \name{spotvol} \alias{spotvol} @@ -7,7 +8,7 @@ marketopen = "09:30:00", marketclose = "16:00:00", tz = "GMT") } \arguments{ -\item{data}{Either an \code{\link{xts}} object, containing price data, or a +\item{data}{Either an \code{xts} object, containing price data, or a \code{matrix} containing returns. For price data, irregularly spaced observations are allowed. They will be aggregated to the level specified by parameters \code{on} and \code{k}. For return data, the observations are @@ -83,7 +84,7 @@ \code{ugarchfit} -A \code{\link{ugarchfit}} object, as used by the \code{\link{rugarch}} +A \code{ugarchfit} object, as used by the \code{rugarch} package, containing all output from fitting the GARCH model to the data. Methods that provide this output: \code{"garch"}. } @@ -146,7 +147,7 @@ Default = 5. \cr \code{P2} \tab Same as \code{P1}, but for the sinus terms. Default = 5.\cr \code{init} \tab A named list of initial values to be used in the -optimization routine (\code{"BFGS"} in \code{\link{optim}}). Default = +optimization routine (\code{"BFGS"} in \code{optim}). Default = \code{list(sigma = 0.03, sigma_mu = 0.005, sigma_h = 0.005, sigma_k = 0.05, phi = 0.2, rho = 0.98, mu = c(2, -0.5), delta_c = rep(0, max(1,P1)), delta_s = rep(0, max(1,P2)))}. See Beltratti & Morana (2001) for a definition @@ -154,7 +155,7 @@ For parameters not specified in \code{init}, the default initial value will be used.\cr \code{control} \tab A list of options to be passed down to -\code{\link{optim}}. +\code{optim}. } Outputs (see 'Value' for a full description of each component): \itemize{ @@ -166,7 +167,7 @@ a random walk, an autoregressive process, a stochastic cyclical process and a deterministic cyclical process. The model is estimated using a quasi-maximum likelihood method based on the Kalman Filter. The package -\code{\link[=fkf]{FKF}} is used to apply the Kalman filter. In addition to +\code{\FKF} is used to apply the Kalman filter. In addition to the spot volatility estimates, all parameter estimates are returned. \strong{Nonparametric filtering (\code{"kernel"})} @@ -266,15 +267,15 @@ Parameters: \tabular{ll}{ \code{model} \tab String specifying the type of test to be used. Options -include \code{"sGARCH", "eGARCH"}. See \code{\link{ugarchspec}} in the -\code{\link{rugarch}} package. Default = \code{"eGARCH"}. \cr +include \code{"sGARCH", "eGARCH"}. See \code{\ugarchspec} in the +\code{rugarch} package. Default = \code{"eGARCH"}. \cr \code{garchorder} \tab Numeric value of length 2, containing the order of the GARCH model to be estimated. Default = \code{c(1,1)}. \cr \code{dist} \tab String specifying the distribution to be assumed on the -innovations. See \code{distribution.model} in \code{\link{ugarchspec}} for +innovations. See \code{distribution.model} in \code{ugarchspec} for possible options. Default = \code{"norm"}. \cr \code{solver.control} \tab List containing solver options. -See \code{\link{ugarchfit}} for possible values. Default = \code{list()}. \cr +See \code{ugarchfit} for possible values. Default = \code{list()}. \cr \code{P1} \tab A positive integer corresponding to the number of cosinus terms used in the flexible Fourier specification of the periodicity function. Default = 5. \cr @@ -286,11 +287,11 @@ \item{\code{ugarchfit}} } This method generates the external regressors needed to model the intraday -seasonality with a Flexible Fourier form. The \code{\link{rugarch}} package +seasonality with a Flexible Fourier form. The \code{rugarch} package is then employed to estimate the specified GARCH(1,1) model. Along with the spot volatility estimates, this method will return the -\code{\link{ugarchfit}} object used by the \code{\link{rugarch}} package. +\code{ugarchfit} object used by the \code{rugarch} package. } \examples{ data(sample_real5minprices) From noreply at r-forge.r-project.org Fri Sep 5 13:17:06 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 5 Sep 2014 13:17:06 +0200 (CEST) Subject: [Highfrequency-commits] r107 - pkg/highfrequency/man Message-ID: <20140905111707.0929F1864A3@r-forge.r-project.org> Author: kboudt Date: 2014-09-05 13:17:06 +0200 (Fri, 05 Sep 2014) New Revision: 107 Removed: pkg/highfrequency/man/spotvolatility.Rd Modified: pkg/highfrequency/man/spotvol.Rd Log: Modified: pkg/highfrequency/man/spotvol.Rd =================================================================== --- pkg/highfrequency/man/spotvol.Rd 2014-09-03 15:40:07 UTC (rev 106) +++ pkg/highfrequency/man/spotvol.Rd 2014-09-05 11:17:06 UTC (rev 107) @@ -167,7 +167,7 @@ a random walk, an autoregressive process, a stochastic cyclical process and a deterministic cyclical process. The model is estimated using a quasi-maximum likelihood method based on the Kalman Filter. The package -\code{\FKF} is used to apply the Kalman filter. In addition to +\code{FKF} is used to apply the Kalman filter. In addition to the spot volatility estimates, all parameter estimates are returned. \strong{Nonparametric filtering (\code{"kernel"})} @@ -267,7 +267,7 @@ Parameters: \tabular{ll}{ \code{model} \tab String specifying the type of test to be used. Options -include \code{"sGARCH", "eGARCH"}. See \code{\ugarchspec} in the +include \code{"sGARCH", "eGARCH"}. See \code{ugarchspec} in the \code{rugarch} package. Default = \code{"eGARCH"}. \cr \code{garchorder} \tab Numeric value of length 2, containing the order of the GARCH model to be estimated. Default = \code{c(1,1)}. \cr Deleted: pkg/highfrequency/man/spotvolatility.Rd =================================================================== --- pkg/highfrequency/man/spotvolatility.Rd 2014-09-03 15:40:07 UTC (rev 106) +++ pkg/highfrequency/man/spotvolatility.Rd 2014-09-05 11:17:06 UTC (rev 107) @@ -1,78 +0,0 @@ -% Generated by roxygen2 (4.0.1): do not edit by hand -\docType{package} -\name{spotvolatility} -\alias{spotvolatility} -\alias{spotvolatility-package} -\title{Spot volatility estimation} -\description{ -The \code{spotvolatility} package offers several methods to estimate spot -volatility and its intraday seasonality, using high-frequency data. -} -\details{ -The following spot volatility estimation methods have been implemented: -} -\section{Deterministic periodicity}{ - -The spot volatility is decomposed into a a deterministic periodic factor -f_{i} (identical for every day in the sample) and a daily factor s_{t} -(identical for all observations within a day). Both components are then -estimated separately. For more details, see Taylor and Xu (1997) and -Andersen and Bollerslev (1997). The jump robust versions by Boudt et al. -(2011) have also been implemented. -} - -\section{Stochastic periodicity}{ - -This method by Beltratti and Morana (2001) assumes the periodicity factor to -be stochastic. The spot volatility estimation is split into four components: -a random walk, an autoregressive process, a stochastic cyclical process and -a deterministic cyclical process. The model is estimated using a -quasi-maximum likelihood method based on the Kalman Filter. The package -\code{\link[=fkf]{FKF}} is used to apply the Kalman filter. -} - -\section{Nonparametric filtering}{ - -This method by Kristensen (2010) filters the spot volatility in a -nonparametric way by applying kernel weights to the standard realized -volatility estimator. Different kernels and bandwidths can be used to focus -on specific characteristics of the volatility process. -} - -\section{Piecewise constant volatility}{ - -Another nonparametric method is that of Fried (2012), which assumes the -volatility to be piecewise constant over local windows. Robust two-sample -tests are applied to detect changes in variability between subsequent -windows. The spot volatility can then be estimated by evaluating -regular realized volatility estimators within each local window. -} - -\section{GARCH models with intraday seasonality}{ - -The package also includes an option to apply GARCH models, implemented by -the \code{\link{rugarch}} package, to estimate spot volatility from intraday -data. This is done by including external regressors in the model. These -regressors are based on a flexible Fourier form, which was also used in the -stochastic and deterministic periodicity estimation methods. -} -\references{ -Andersen, T. G. and T. Bollerslev (1997). Intraday periodicity and volatility -persistence in financial markets. Journal of Empirical Finance 4, 115-158. - -Beltratti, A. and C. Morana (2001). Deterministic and stochastic methods for estimation -of intraday seasonal components with high frequency data. Economic Notes 30, 205-234. - -Boudt K., Croux C. and Laurent S. (2011). Robust estimation of intraweek periodicity -in volatility and jump detection. Journal of Empirical Finance 18, 353-367. - -Fried, Roland (2012). On the online estimation of local constant volatilities. -Computational Statistics and Data Analysis 56, 3080-3090. - -Kristensen, Dennis (2010). Nonparametric filtering of the realized spot volatility: -A kernel-based approach. Econometric Theory 26, 60-93. - -Taylor, S. J. and X. Xu (1997). The incremental volatility information in one million -foreign exchange quotations. Journal of Empirical Finance 4, 317-340. -} - From noreply at r-forge.r-project.org Thu Sep 11 11:46:58 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 11 Sep 2014 11:46:58 +0200 (CEST) Subject: [Highfrequency-commits] r108 - in pkg/highfrequency: . R man Message-ID: <20140911094658.39B1818769C@r-forge.r-project.org> Author: kboudt Date: 2014-09-11 11:46:57 +0200 (Thu, 11 Sep 2014) New Revision: 108 Modified: pkg/highfrequency/DESCRIPTION pkg/highfrequency/R/realized.R pkg/highfrequency/man/highfrequency-package.Rd pkg/highfrequency/man/selectexchange.Rd pkg/highfrequency/man/tradescleanup.Rd Log: Modified: pkg/highfrequency/DESCRIPTION =================================================================== --- pkg/highfrequency/DESCRIPTION 2014-09-05 11:17:06 UTC (rev 107) +++ pkg/highfrequency/DESCRIPTION 2014-09-11 09:46:57 UTC (rev 108) @@ -2,14 +2,14 @@ Version: 0.4 Date: 2014-08-31 Title: highfrequency -Author: Jonathan Cornelissen, Kris Boudt, Scott Payseur -Maintainer: Jonathan Cornelissen - +Author: Jonathan Cornelissen, Kris Boudt, Scott Payseur +Maintainer: Kris Boudt + Description: The highfrequency package contains an extensive toolkit for the use of highfrequency financial data in R. It contains functionality to manage, clean and match highfrequency trades and quotes data. Furthermore, it enables users to: calculate easily various liquidity measures, estimate and forecast volatility, and investigate microstructure noise and intraday periodicity. License: GPL (>= 2) Depends: R (>= 2.12.0), xts, zoo Suggests: robustbase, cubature, mvtnorm, chron, timeDate, quantmod, MASS, sandwich, numDeriv, FKF, BMS, rugarch Contributors: Giang Nguyen, Maarten Schermer -Thanks: A special thanks for additional contributions from Chris Blakely +Thanks: A special thanks for additional contributions from Chris Blakely, Brian Peterson, Eric Zivot and GSoC LazyLoad: yes Modified: pkg/highfrequency/R/realized.R =================================================================== --- pkg/highfrequency/R/realized.R 2014-09-05 11:17:06 UTC (rev 107) +++ pkg/highfrequency/R/realized.R 2014-09-11 09:46:57 UTC (rev 108) @@ -3096,72 +3096,121 @@ matchtq = function(...){matchTradesQuotes(...)}; ##################### Total cleanup functions formerly in RTAQ ################################ + + tradesCleanup = function(from,to,datasource,datadestination,ticker,exchanges,tdataraw=NULL,report=TRUE,selection="median",...){ - nresult = rep(0,5); - if(is.null(tdataraw)){ - dates = timeSequence(from,to, format = "%Y-%m-%d", FinCenter = "GMT"); - dates = dates[isBizday(dates, holidays = holidayNYSE(2004:2010))]; - - for(j in 1:length(dates)){ - datasourcex = paste(datasource,"/",dates[j],sep=""); - datadestinationx = paste(datadestination,"/",dates[j],sep=""); - - for(i in 1:length(ticker)){ - dataname = paste(ticker[i],"_trades.RData",sep=""); - load(paste(datasourcex,"/",dataname,sep="")); - - if(class(tdata)[1]!="try-error"){ - exchange = exchanges[i]; + nresult = rep(0, 5) + if(!is.list(exchanges)){ exchanges = as.list(exchanges)} + if (is.null(tdataraw)) { + dates = timeSequence(from, to, format = "%Y-%m-d") + dates = dates[isBizday(dates, holidays=holidayNYSE(1960:2040))] + for (j in 1:length(dates)) { + datasourcex = paste(datasource, "/", dates[j], sep = "") + datadestinationx = paste(datadestination, "/", dates[j], sep = "") + for (i in 1:length(ticker)) { + dataname = paste(ticker[i], "_trades.RData", sep = ""); + if(file.exists(paste(datasourcex, "/", dataname, sep = ""))){ + load(paste(datasourcex, "/", dataname, sep = "")) + if (class(tdata)[1] != "try-error") { + exchange = exchanges[[i]] + if(length(tdata$PRICE)>0){ + tdata = .check_data(tdata); + nresult[1] = nresult[1] + dim(tdata)[1] + }else{tdata=NULL;} + + if(length(tdata$PRICE)>0){ + tdata = try(nozeroprices(tdata)) + nresult[2] = nresult[2] + dim(tdata)[1]; + }else{tdata=NULL;} + + + if(length(tdata$PRICE)>0){ + tdata = try(selectexchange(tdata, exch = exchange)) + nresult[3] = nresult[3] + dim(tdata)[1] + }else{tdata=NULL;} + + + if(length(tdata$PRICE)>0){ + tdata = try(salescond(tdata)) + nresult[4] = nresult[4] + dim(tdata)[1] + }else{tdata=NULL;} + + + if(length(tdata$PRICE)>0){ + tdata = try(mergeTradesSameTimestamp(tdata, selection = selection)) + nresult[5] = nresult[5] + dim(tdata)[1]; + }else{tdata=NULL;} + + + + save(tdata, file = paste(datadestinationx,"/", dataname, sep = "")) + } + if (class(tdata) == "try-error") { + abc = 1 + save(abc, file = paste(datadestinationx, "/missing_", + ticker[i], ".RData", sep = "")) + } - tdata = .check_data(tdata); nresult[1]= nresult[1]+dim(tdata)[1]; - - ##actual clean-up: - ##general: - tdata = try(nozeroprices(tdata)); nresult[2]= nresult[2]+dim(tdata)[1]; - tdata = try(selectexchange(tdata,exch=exchange)); nresult[3]= nresult[3]+dim(tdata)[1]; - - ##trade specific: - tdata = try(salescond(tdata)); nresult[4] = nresult[4] + dim(tdata)[1]; - tdata = try(mergeTradesSameTimestamp(tdata,selection=selection)); nresult[5] = nresult[5] + dim(tdata)[1]; - - save(tdata, file = paste(datadestinationx,"/",dataname,sep="")); + }else{ + next; } - - if(class(tdata)=="try-error") { - abc=1; - save(abc, file = paste(datadestinationx,"/missing_",ticker[i],".RData",sep="")); - } - } + } } - if(report==TRUE){ - names(nresult) = c("initial number","no zero prices","select exchange", - "sales condition","merge same timestamp"); + if (report == TRUE) { + names(nresult) = c("initial number", "no zero prices", + "select exchange", "sales condition", "merge same timestamp") return(nresult) } } - - if(!is.null(tdataraw)){ - if(class(tdataraw)[1]!="try-error"){ - if(length(exchanges)>1){print("The argument exchanges contains more than 1 element. Please select a single exchange, in case you provide tdataraw.")} - tdata=tdataraw; rm(tdataraw); - tdata = .check_data(tdata); nresult[1]= nresult[1]+dim(tdata)[1]; + if (!is.null(tdataraw)) { + if (class(tdataraw)[1] != "try-error") { + if (length(exchanges) > 1) { + print("The argument exchanges contains more than 1 element. Please select a single exchange, in case you provide tdataraw.") + } + exchange = exchanges[[1]]; - ##actual clean-up: - ##general: - tdata = try(nozeroprices(tdata)); nresult[2]= nresult[2]+dim(tdata)[1]; - tdata = try(selectexchange(tdata,exch=exchanges)); nresult[3]= nresult[3]+dim(tdata)[1]; + tdata = tdataraw + rm(tdataraw) - ##trade specific: - tdata = try(salescond(tdata)); nresult[4] = nresult[4] + dim(tdata)[1]; - tdata = try(mergeTradesSameTimestamp(tdata,selection=selection)); nresult[5] = nresult[5] + dim(tdata)[1]; - if(report==TRUE){ - names(nresult) = c("initial number","no zero prices","select exchange", - "sales condition","merge same timestamp"); - return(list(tdata=tdata,report=nresult)) + if(length(tdata)>0){ + tdata = .check_data(tdata); + nresult[1] = nresult[1] + dim(tdata)[1] + }else{tdata=NULL;} + + if(length(tdata)>0){ + tdata = try(nozeroprices(tdata)) + nresult[2] = nresult[2] + dim(tdata)[1]; + }else{tdata=NULL;} + + + if(length(tdata)>0){ + tdata = try(selectexchange(tdata, exch = exchange)) + nresult[3] = nresult[3] + dim(tdata)[1] + }else{tdata=NULL;} + + + if(length(tdata)>0){ + tdata = try(salescond(tdata)) + nresult[4] = nresult[4] + dim(tdata)[1] + }else{tdata=NULL;} + + + if(length(tdata)>0){ + tdata = try(mergeTradesSameTimestamp(tdata, selection = selection)) + nresult[5] = nresult[5] + dim(tdata)[1]; + }else{tdata=NULL;} + + + if (report == TRUE) { + names(nresult) = c("initial number", "no zero prices", + "select exchange", "sales condition", "merge same timestamp") + return(list(tdata = tdata, report = nresult)) } - if(report!=TRUE){return(tdata)} + if (report != TRUE) { + return(tdata) + } } } @@ -3360,7 +3409,8 @@ selectExchange = function(data,exch="N"){ data = .check_data(data); ###FUNCTION TO SELECT THE OBSERVATIONS OF A SINGLE EXCHANGE: selectexchange - filteredts = data[data$EX==exch]; + #filteredts = data[data$EX==exch]; + filteredts = data[is.element(data$EX , exch)] return(filteredts); } Modified: pkg/highfrequency/man/highfrequency-package.Rd =================================================================== --- pkg/highfrequency/man/highfrequency-package.Rd 2014-09-05 11:17:06 UTC (rev 107) +++ pkg/highfrequency/man/highfrequency-package.Rd 2014-09-11 09:46:57 UTC (rev 108) @@ -18,13 +18,13 @@ } \author{ -Jonathan Cornelissen, Kris Boudt, Scott Payseur +Jonathan Cornelissen, Kris Boudt, Scott Payseur -Maintainer: Jonathan Cornelissen +Maintainer: Kris Boudt Contributors: Giang Nguyen, Maarten Schermers. -Thanks: A special thanks for additional contributions from Chris Blakely. +Thanks: A special thanks for additional contributions from Chris Blakely, Brian Peterson, Eric Zivot and GSoC. } \keyword{ package } Modified: pkg/highfrequency/man/selectexchange.Rd =================================================================== --- pkg/highfrequency/man/selectexchange.Rd 2014-09-05 11:17:06 UTC (rev 107) +++ pkg/highfrequency/man/selectexchange.Rd 2014-09-11 09:46:57 UTC (rev 108) @@ -15,7 +15,7 @@ \arguments{ \item{data}{ an xts object containing the time series data. The object should have a column "EX", indicating the exchange by its symbol.} - \item{exch}{ The symbol of the stock exchange that should be selected. + \item{exch}{ The (vector of) symbol(s) of the stock exchange(s) that should be selected. By default the NYSE is chosen (exch="N"). Other exchange symbols are: \itemize{ \item A: AMEX @@ -41,4 +41,4 @@ } \author{ Jonathan Cornelissen and Kris Boudt} -\keyword{ cleaning } \ No newline at end of file +\keyword{ cleaning } Modified: pkg/highfrequency/man/tradescleanup.Rd =================================================================== --- pkg/highfrequency/man/tradescleanup.Rd 2014-09-05 11:17:06 UTC (rev 107) +++ pkg/highfrequency/man/tradescleanup.Rd 2014-09-11 09:46:57 UTC (rev 108) @@ -31,8 +31,8 @@ \item{datasource}{character indicating the folder in which the original data is stored.} \item{datadestination}{character indicating the folder in which the cleaned data is stored.} \item{ticker}{vector of tickers for which the data should be cleaned, e.g. ticker = c("AAPL","AIG")} -\item{exchanges}{vector of stock exchange symbols for all tickers in vector "ticker". It thus should have the same length as the vector ticker. -Only data from one exchanges will be retained for each stock respectively, e.g. exchanges = c("Q","N") +\item{exchanges}{list of vectors of stock exchange(s) for all tickers in vector "ticker". It thus should have the same length as the vector ticker. +E.g. in case of two stocks; exchanges = list("N", c("Q","T")). The possible exchange symbols are: \itemize{ \item A: AMEX @@ -70,7 +70,7 @@ data("sample_tdataraw"); head(sample_tdataraw); dim(sample_tdataraw); -tdata_afterfirstcleaning = tradesCleanup(tdataraw=sample_tdataraw,exchanges="N"); +tdata_afterfirstcleaning = tradesCleanup(tdataraw=sample_tdataraw,exchanges=list("N") ); tdata_afterfirstcleaning$report; barplot(tdata_afterfirstcleaning$report); dim(tdata_afterfirstcleaning$tdata); @@ -91,4 +91,4 @@ } \author{ Jonathan Cornelissen and Kris Boudt} -\keyword{ cleaning } \ No newline at end of file +\keyword{ cleaning } From noreply at r-forge.r-project.org Thu Sep 11 21:35:36 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 11 Sep 2014 21:35:36 +0200 (CEST) Subject: [Highfrequency-commits] r109 - pkg/highfrequency/man Message-ID: <20140911193536.A42AD1872C5@r-forge.r-project.org> Author: kboudt Date: 2014-09-11 21:35:36 +0200 (Thu, 11 Sep 2014) New Revision: 109 Modified: pkg/highfrequency/man/spotvol.Rd Log: Modified: pkg/highfrequency/man/spotvol.Rd =================================================================== --- pkg/highfrequency/man/spotvol.Rd 2014-09-11 09:46:57 UTC (rev 108) +++ pkg/highfrequency/man/spotvol.Rd 2014-09-11 19:35:36 UTC (rev 109) @@ -294,15 +294,18 @@ \code{ugarchfit} object used by the \code{rugarch} package. } \examples{ +# Load sample data + data(sample_real5minprices) +data(sample_returns_5min) -# default method, deterministic periodicity +# Default method, deterministic periodicity +\dontshow{par.def <- par(no.readonly = TRUE)} vol1 <- spotvol(sample_real5minprices) -par.def <- par(no.readonly = TRUE) plot(vol1) -par(par.def) - -# compare to stochastic periodicity +\dontshow{par(par.def)} +# Compare to stochastic periodicity +\donttest{ init = list(sigma = 0.03, sigma_mu = 0.005, sigma_h = 0.007, sigma_k = 0.06, phi = 0.194, rho = 0.986, mu = c(1.87,-0.42), delta_c = c(0.25, -0.05, -0.2, 0.13, 0.02), delta_s = c(-1.2, @@ -311,11 +314,10 @@ vol2 <- spotvol(sample_real5minprices, method = "stochper", init = init) plot(as.numeric(vol1$spot[1:780]), type="l") lines(as.numeric(vol2$spot[1:780]), col="red") -legend("topright", c("detper", "stochper"), col = c("black", "red"), lty=1) +legend("topright", c("detper", "stochper"), col = c("black", "red"), lty=1)} -data(sample_returns_5min) +# Various kernel estimates -# various kernel estimates h1 = bw.nrd0((1:nrow(sample_returns_5min))*(5*60)) vol3 <- spotvol(sample_returns_5min, method = "kernel", h = h1) vol4 <- spotvol(sample_returns_5min, method = "kernel", est = "quarticity") @@ -325,22 +327,23 @@ lines(as.numeric(t(vol5$spot))[1:2880], col="blue") legend("topright", c("h = simple estimate", "h = quarticity corrected", "h = crossvalidated"), col = c("black", "red", "blue"), lty=1) -par(par.def) - -# piecewise constant volatility, using an example from Fried (2012) +\dontshow{par(par.def)} +# Piecewise constant volatility, using an example from Fried (2012) +\donttest{ simdata <- matrix(sqrt(5/3)*rt(3000, df = 5), ncol = 500, byrow = TRUE) simdata <- c(1, 1, 1.5, 1.5, 2, 1)*simdata # the volatility of the simulated now changes at 1000, 2000 and 2500 vol6 <- spotvol(simdata, method = "piecewise", m = 200, n = 100, online = FALSE) -plot(vol6) +plot(vol6)} -# compare regular GARCH(1,1) model to eGARCH, both with external regressors +# Compare regular GARCH(1,1) model to eGARCH, both with external regressors +\donttest{ vol7 <- spotvol(sample_returns_5min, method = "garch", model = "sGARCH") vol8 <- spotvol(sample_returns_5min, method = "garch", model = "eGARCH") plot(as.numeric(t(vol7$spot)), type = "l") lines(as.numeric(t(vol8$spot)), col = "red") -legend("topleft", c("GARCH", "eGARCH"), col = c("black", "red"), lty=1) +legend("topleft", c("GARCH", "eGARCH"), col = c("black", "red"), lty=1)} } \references{ Andersen, T. G. and T. Bollerslev (1997). Intraday periodicity and volatility From noreply at r-forge.r-project.org Tue Sep 16 00:31:13 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 16 Sep 2014 00:31:13 +0200 (CEST) Subject: [Highfrequency-commits] r110 - pkg/highfrequency/R Message-ID: <20140915223113.4E144187730@r-forge.r-project.org> Author: kboudt Date: 2014-09-16 00:31:12 +0200 (Tue, 16 Sep 2014) New Revision: 110 Modified: pkg/highfrequency/R/spotvol.r Log: Modified: pkg/highfrequency/R/spotvol.r =================================================================== --- pkg/highfrequency/R/spotvol.r 2014-09-11 19:35:36 UTC (rev 109) +++ pkg/highfrequency/R/spotvol.r 2014-09-15 22:31:12 UTC (rev 110) @@ -12,7 +12,7 @@ #' (identical for all observations within a day). Both components are then #' estimated separately. For more details, see Taylor and Xu (1997) and #' Andersen and Bollerslev (1997). The jump robust versions by Boudt et al. -#' (2011) have also been implemented. +#' (2011) have also been implemented. #' #' @section Stochastic periodicity: #' This method by Beltratti and Morana (2001) assumes the periodicity factor to @@ -381,8 +381,6 @@ marketopen = "09:30:00", marketclose = "16:00:00", tz = "GMT") { - require(timeDate) - require(chron) if (on == "seconds" | on == "secs") delta <- k if (on == "minutes" | on == "mins") @@ -395,8 +393,9 @@ dates <- unique(format(time(data), "%Y-%m-%d")) cDays <- length(dates) rdata <- mR <- c() - intraday <- seq(from = times(marketopen), to = times(marketclose), - by = times(delta/(24*3600))) + intraday <- seq(from = chron::times(marketopen), + to = chron::times(marketclose), + by = chron::times(delta/(24*3600))) if (as.character(tail(intraday, 1)) != marketclose) intraday <- c(intraday, marketclose) intraday <- intraday[2:length(intraday)] @@ -510,7 +509,7 @@ # model of Beltratti & Morana (2001) stochper <- function(mR, rdata = NULL, options = list()) { - require(FKF) + #require(FKF) # default options, replace if user-specified op <- list(init = list(), P1 = 5, P2 = 5, control = list(trace=1, maxit=500)) op[names(options)] <- options @@ -563,9 +562,9 @@ # recreate model to obtain volatility estimates ss <- ssmodel(opt$par, days, N, P1 = op$P1, P2 = op$P2) - kf <- fkf(a0 = ss$a0, P0 = ss$P0, dt = ss$dt, ct = ss$ct, Tt = ss$Tt, - Zt = ss$Zt, HHt = ss$HHt, GGt = ss$GGt, - yt = matrix(rvector, ncol = length(rvector))) + kf <- FKF::fkf(a0 = ss$a0, P0 = ss$P0, dt = ss$dt, ct = ss$ct, Tt = ss$Tt, + Zt = ss$Zt, HHt = ss$HHt, GGt = ss$GGt, + yt = matrix(rvector, ncol = length(rvector))) sigmahat <- as.vector(exp((ss$Zt%*%kf$at[,1:(N*days)] + ss$ct + 1.27)/2)) # transform parameter estimates back @@ -592,8 +591,8 @@ { ss <- ssmodel(par_t, days, N, P1 = P1, P2 = P2) yt <- matrix(yt, ncol = length(yt)) - kf <- fkf(a0 = ss$a0, P0 = ss$P0, dt = ss$dt, ct = ss$ct, Tt = ss$Tt, - Zt = ss$Zt, HHt = ss$HHt, GGt = ss$GGt, yt = yt) + kf <- FKF::fkf(a0 = ss$a0, P0 = ss$P0, dt = ss$dt, ct = ss$ct, Tt = ss$Tt, + Zt = ss$Zt, HHt = ss$HHt, GGt = ss$GGt, yt = yt) return(-kf$logLik/length(yt)) } @@ -778,8 +777,6 @@ # See Fried (2012) piecewise <- function(mR, rdata = NULL, options = list()) { - require(BMS) - require(robustbase) # default options, replace if user-specified op <- list(type = "MDa", m = 40, n = 20, alpha = 0.005, volest = "bipower", online = TRUE) @@ -806,7 +803,7 @@ rv = sqrt((1/(i - lastchange + 1)) * (rCov(vR[(lastchange + 1):i]))), sd = sd(vR[(lastchange + 1):i]), - tau = scaleTau2(vR[(lastchange + 1):i])) + tau = robustbase::scaleTau2(vR[(lastchange + 1):i])) } else { from <- cp[max(which(cp < i))] to <- min(c(N*D, cp[which(cp >= i)])) @@ -816,7 +813,7 @@ medrv = sqrt((1/len)*(medRV(vR[from:to]))), rv = sqrt((1/len)*(rCov(vR[from:to]))), sd = sd(vR[from:to]), - tau = scaleTau2(vR[from:to])) + tau = robustbase::scaleTau2(vR[from:to])) } } if (is.null(rdata)) { @@ -870,7 +867,7 @@ ycor <- y - ymed delta1 <- ymed - xmed out <- density(c(xcor, ycor), kernel = "epanechnikov") - fmed <- as.numeric(quantile(out, probs = 0.5)) + fmed <- as.numeric(BMS::quantile.density(out, probs = 0.5)) fmedvalue <- (out$y[max(which(out$x < fmed))] + out$y[max(which(out$x < fmed))+1])/2 test <- sqrt((m*n)/(m + n))*2*fmedvalue*delta1 @@ -914,7 +911,6 @@ # GARCH with seasonality (external regressors) garch_s <- function(mR, rdata = NULL, options = list()) { - require(rugarch) # default options, replace if user-specified op <- list(model = "eGARCH", order = c(1,1), dist = "norm", P1 = 5, P2 = 5, solver.control = list()) @@ -925,34 +921,35 @@ mR <- mR - mean(mR) X <- intraday_regressors(D, N = N, order = 2, almond = FALSE, P1 = op$P1, P2 = op$P2) - spec <- ugarchspec(variance.model = list(model = op$model, - external.regressors = X, - garchOrder = op$order), - mean.model = list(include.mean = FALSE), - distribution.model = op$dist) + spec <- rugarch::ugarchspec(variance.model = list(model = op$model, + external.regressors = X, + garchOrder = op$order), + mean.model = list(include.mean = FALSE), + distribution.model = op$dist) if (is.null(rdata)) { cat(paste("Fitting", op$model, "model...")) - fit <- tryCatch(ugarchfit(spec = spec, data = as.numeric(t(mR)), - solver = "nloptr", - solver.control = op$solver.control), + fit <- tryCatch(rugarch::ugarchfit(spec = spec, data = as.numeric(t(mR)), + solver = "nloptr", + solver.control = op$solver.control), error = function(e) e, warning = function(w) w) if (inherits(fit, what = c("error", "warning"))) { stop(paste("GARCH optimization routine did not converge.\n", "Message returned by ugarchfit:\n", fit)) } - spot <- as.numeric(sigma(fit)) + spot <- as.numeric(rugarch::sigma(fit)) } else { cat(paste("Fitting", op$model, "model...")) - fit <- tryCatch(ugarchfit(spec = spec, data = rdata, solver = "nloptr", - solver.control = op$solver.control), + fit <- tryCatch(rugarch::ugarchfit(spec = spec, data = rdata, + solver = "nloptr", + solver.control = op$solver.control), error = function(e) e, warning = function(w) w) if (inherits(fit, what = c("error", "warning"))) { stop(paste("GARCH optimization routine did not converge.\n", "Message returned by ugarchfit:\n", fit)) } - spot <- sigma(fit) + spot <- rugarch::sigma(fit) } out <- list(spot = spot, ugarchfit = fit) class(out) <- "spotvol" @@ -960,28 +957,33 @@ } #' @export -plot.spotvol <- function(sv, length = NULL) +plot.spotvol <- function(x, ...) { + options <- list(...) plottable <- c("spot", "periodic", "daily") - elements <- names(sv) + elements <- names(x) nplots <- sum(is.element(plottable, elements)) if (nplots == 3) { par(mar = c(3, 3, 3, 1)) layout(matrix(c(1,2,1,3), nrow = 2)) } - spot <- as.numeric(t(sv$spot)) - if(is.null(length)) + spot <- as.numeric(t(x$spot)) + + if(is.element("length", names(options))) { + length = options$length + } else { length = length(spot) + } plot(spot[1:length], type = "l", xlab = "", ylab = "") title(main = "Spot volatility") if ("cp" %in% elements) - abline(v = sv$cp[-1], lty = 3, col = "gray70") + abline(v = x$cp[-1], lty = 3, col = "gray70") if ("periodic" %in% elements) { - periodic <- as.numeric(t(sv$periodic)) + periodic <- as.numeric(t(x$periodic)) if (inherits(data, what = "xts")) { - intraday <- time(sv$periodic) + intraday <- time(x$periodic) plot(x = intraday, y = periodic, type = "l", xlab = "", ylab = "") } else { plot(periodic, type = "l", xlab = "", ylab = "") @@ -989,9 +991,9 @@ title(main = "Intraday periodicity") } if ("daily" %in% elements) { - daily <- as.numeric(t(sv$daily)) + daily <- as.numeric(t(x$daily)) if (inherits(data, what = "xts")) { - dates <- as.Date(time(sv$daily)) + dates <- as.Date(time(x$daily)) plot(x = dates, y = daily, type = "l", xlab = "", ylab = "") } else { plot(daily, type = "l", xlab = "", ylab = "") From noreply at r-forge.r-project.org Tue Sep 16 00:33:19 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 16 Sep 2014 00:33:19 +0200 (CEST) Subject: [Highfrequency-commits] r111 - pkg/highfrequency/vignettes Message-ID: <20140915223319.BC5FC187731@r-forge.r-project.org> Author: kboudt Date: 2014-09-16 00:33:18 +0200 (Tue, 16 Sep 2014) New Revision: 111 Removed: pkg/highfrequency/vignettes/highfrequency.Rnw Log: Deleted: pkg/highfrequency/vignettes/highfrequency.Rnw =================================================================== --- pkg/highfrequency/vignettes/highfrequency.Rnw 2014-09-15 22:31:12 UTC (rev 110) +++ pkg/highfrequency/vignettes/highfrequency.Rnw 2014-09-15 22:33:18 UTC (rev 111) @@ -1,5 +0,0 @@ -%\VignetteIndexEntry{User manual} - -\documentclass{article} -\begin{document} -\end{document} \ No newline at end of file From noreply at r-forge.r-project.org Tue Sep 16 00:33:42 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 16 Sep 2014 00:33:42 +0200 (CEST) Subject: [Highfrequency-commits] r112 - pkg/highfrequency/man Message-ID: <20140915223342.1C6F4187731@r-forge.r-project.org> Author: kboudt Date: 2014-09-16 00:33:41 +0200 (Tue, 16 Sep 2014) New Revision: 112 Modified: pkg/highfrequency/man/spotvol.Rd Log: Modified: pkg/highfrequency/man/spotvol.Rd =================================================================== --- pkg/highfrequency/man/spotvol.Rd 2014-09-15 22:33:18 UTC (rev 111) +++ pkg/highfrequency/man/spotvol.Rd 2014-09-15 22:33:41 UTC (rev 112) @@ -16,7 +16,7 @@ and \code{k}. Return data should be in matrix form, where each row corresponds to a day, and each column to an intraday period. The output will be in the same form as the input (\code{xts} or -\code{matrix}/\code{numeric}).} +\code{matrix}/\code{numeric}).} \item{method}{specifies which method will be used to estimate the spot volatility. Options include \code{"detper"} and \code{"stochper"}. @@ -317,7 +317,7 @@ legend("topright", c("detper", "stochper"), col = c("black", "red"), lty=1)} # Various kernel estimates - +\donttest{ h1 = bw.nrd0((1:nrow(sample_returns_5min))*(5*60)) vol3 <- spotvol(sample_returns_5min, method = "kernel", h = h1) vol4 <- spotvol(sample_returns_5min, method = "kernel", est = "quarticity") @@ -326,7 +326,7 @@ lines(as.numeric(t(vol4$spot))[1:2880], col="red") lines(as.numeric(t(vol5$spot))[1:2880], col="blue") legend("topright", c("h = simple estimate", "h = quarticity corrected", - "h = crossvalidated"), col = c("black", "red", "blue"), lty=1) + "h = crossvalidated"), col = c("black", "red", "blue"), lty=1)} \dontshow{par(par.def)} # Piecewise constant volatility, using an example from Fried (2012) \donttest{ From noreply at r-forge.r-project.org Tue Sep 16 00:35:20 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 16 Sep 2014 00:35:20 +0200 (CEST) Subject: [Highfrequency-commits] r113 - pkg/highfrequency Message-ID: <20140915223520.DBD80187737@r-forge.r-project.org> Author: kboudt Date: 2014-09-16 00:35:20 +0200 (Tue, 16 Sep 2014) New Revision: 113 Removed: pkg/highfrequency/inst/ Log: