[Blotter-commits] r244 - pkg/RTAQ/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Feb 12 16:49:36 CET 2010
Author: jonathan
Date: 2010-02-12 16:49:35 +0100 (Fri, 12 Feb 2010)
New Revision: 244
Modified:
pkg/RTAQ/R/manipulation.R
pkg/RTAQ/R/volatility.R
Log:
taqload, rowcov update
Modified: pkg/RTAQ/R/manipulation.R
===================================================================
--- pkg/RTAQ/R/manipulation.R 2010-02-11 13:18:24 UTC (rev 243)
+++ pkg/RTAQ/R/manipulation.R 2010-02-12 15:49:35 UTC (rev 244)
@@ -1,11 +1,13 @@
#MANIPULATION FUNCTIONS:
-TAQload = function(ticker,from,to,trades=TRUE,quotes=FALSE,datasource="V:\\Jobstudent\\TAQdata"){
+TAQload = function(ticker,from,to,trades=TRUE,quotes=FALSE,datasource=NULL){
##Function to load the taq data from a certain stock
#From&to (both included) should be in the format "%Y-%m-%d" e.g."2008-11-30"
- dates = timeSequence(from,to, format = "%Y-%m-%d", FinCenter = "GMT")
+ dates = timeSequence(as.character(from),as.character(to), format = "%Y-%m-%d", FinCenter = "GMT")
dates = dates[isBizday(dates, holidays = holidayNYSE(2004:2010))];
+ if( is.null(datasource)){print("Please provide the argument 'datasource' to indicate in which folder your data is stored")};
+
if(trades){
for(i in 1:length(dates)){
datasourcex = paste(datasource,"\\",dates[i],sep="");
Modified: pkg/RTAQ/R/volatility.R
===================================================================
--- pkg/RTAQ/R/volatility.R 2010-02-11 13:18:24 UTC (rev 243)
+++ pkg/RTAQ/R/volatility.R 2010-02-12 15:49:35 UTC (rev 244)
@@ -111,11 +111,12 @@
}
-ROWCov = function( R , seasadjR=R , alphaMCD = 0.75 )
+ROWCov = function( R , seasadjR=NULL , alphaMCD = 0.75, alpha = 0.05 )
{
- require(robustbase)
+ require(robustbase);
# Function that computes the ROWQCov matrix, assumption of normality
# R is a intraT*N matrix holding in column i de intraT returns of asset i
+ if( is.null( seasadjR) ){ seasadjR = R };
intraT = nrow(R); N = ncol(R)
perczeroes = apply( seasadjR , 2, countzeroes )/intraT;
select = c(1:N)[perczeroes<0.5]
@@ -127,12 +128,12 @@
}else{
print( c( "MCD cannot be calculated" ) )
}
- alpha = 0.05; k = qchisq(p=1-alpha,df=N) ; halfk = sqrt(k)
+ k = qchisq(p=1-alpha,df=N) ;
outlierindic = outlyingness>k;
weights = rep(1,intraT);
weights[outlierindic] = k/outlyingness[outlierindic];
wR = sqrt(weights)*R;
- return( conhuber(di=N)*t(wR)%*%wR )
+ return( ( conhuber(di = N,alpha=alpha) * t(wR) %*% wR)/mean(weights) )
}
#Realized BiPower Covariation (RBPCov)
More information about the Blotter-commits
mailing list