Convert .csv file for further manipulation using 'highfrequency' package on R

Greconomist

The highfrequency package has been created in a way to transform .txt and .csv files from the NYSE TAQ and WRDS TAQ respectively into .RData files of xts objects, which then can be easily manipulated through the package.

The problem is that I have limited access to the WRDS database which only enables me to download tick-data from the CRSP (The Center for Research in Security Prices) database but not the TAQ (Trades and Quotes) database. So my data look like this. The downloadable file contains tick-data for the REIT index from 2014-01-01 to 2014-01-05. I changed manually the ticker header for the header PRICE as it is proposed by Kris Boudt, one of the main authors.

The code that I use is the following:

 from="2014-03-01"
 to="2014-04-31"
 datasource="C:/Users/aris/Desktop/raw_data"
 datadestination="C:/Users/aris/Desktop/xts_data"
 convert(from = from,to=to,datasource = datasource,datadestination = datadestination,
 trades=TRUE,quotes=FALSE,ticker="REIT",dir=FALSE,extension="csv",header = TRUE,
 tradecolnames = NULL, quotecolnames = NULL,format = "%Y%m%d %H:%M:%S",onefile=TRUE)

I suspect that the problem lies at the line format = "%Y%m%d %H:%M:%S", as at the .csv file the date and the time are comma separated. I tried to put a comma between %d and %H like this format = "%Y%m%d,%H:%M:%S" but nothing.

The error reads

 Error in `$<-.data.frame`(`*tmp*`, "COND", value = numeric(0)) :   
 replacement has 0 rows, data has 1048575

All the suggestions are welcomed.

Greconomist

Thanks to Joshua Ulrich I was able to gain some additional intuition and solve the problem(s). Actually, there is no need to manipulate the .csv file itself and add extra columns. Instead of setting tradecolnames = NULL you let the machine know which columns are contained into your file by setting tradecolnames = c("DATE","TIME","PRICE"). The problem with the non-existent directories is fixed by setting dir=TRUE . The final code looks like this:

from="2014-03-01" 
to="2014-04-31"
datasource="C:/Users/aris/Desktop/raw_data"
datadestination="C:/Users/aris/Desktop/xts_data" 
convert(from,to,datasource,datadestination,trades=TRUE,quotes=FALSE,ticker="REIT",dir=TRUE,extension="csv",header= TRUE,tradecolnames=c("DATE","TIME","PRICE"),format = "%Y%m%d %H:%M:%S",onefile=TRUE)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Convert JSON file to a CSV file using R

From Dev

Convert XLS to CSV - R (Tried Rio Package)

From Dev

convert a csv to excel without using xlsx package

From Dev

How to convert CSV file to .txt file in R

From Dev

Convert an XML file to CSV file using java

From Dev

Bit Manipulation for DNA file Convert

From Java

When using Select-Object and further writing to the .csv file using Export-CSV, can I not specify the column name?

From Dev

R convert csv file to data frame

From Dev

R convert csv file to data frame

From Dev

Convert Pajek file to CSV in R Shiny

From Dev

How to convert a text file to CSV using Bash

From Dev

How to convert a CSV file using a PHP script

From Dev

Unable to convert JSON file to CSV using Python

From Dev

convert soap log file to csv using powershell

From Dev

Convert Resultset to CSV file using Java

From Dev

Using PHP how to convert csv file

From Dev

How to convert XML file to CSV using Perl?

From Dev

convert a text file to csv using shell script

From Dev

How to convert a CSV file using a PHP script

From Dev

How to convert a text file to CSV using Bash

From Dev

Unable to convert JSON file to CSV using Python

From Dev

Convert .csv file to .ods using terminal

From Dev

How to do previous tick aggregation without aggregateTrades from highfrequency package

From Dev

convert jpg to greyscale csv using R

From Dev

C# convert csv to xls (using existing csv file)

From Dev

R: Further subset a selection using the pipe %>% and placeholder

From Dev

String Manipulation To Get An Item In The Middle Of A CSV File

From Dev

perl regex CSV file and column header manipulation

From Dev

Issues with .JSON file conversion and CSV manipulation in Python

Related Related

HotTag

Archive