vh.get.data.frame {VhayuR}R Documentation

Get data from Vhayu.

Description

Retrieve data from Vhayu server (or file if in demo mode).

Usage

vh.get.data.frame(x, ...)
vh.get.zoo(x, ...)

Arguments

x Name of Vhayu table (or if in demo mode then the name or the name and filepath of the file).
... Other arguments.

Details

If the Vhayu option "demo" is FALSE, which it is by default, then these functions retrieve data from the Vhayu server. In that case the arguments "frDef", "startTime", "endTime", "fieldNames", "filter" and "maxRows" may be specified or will be taken from the Vhayu options if not specified. As discussed in the Vhayu R Integration Guide, "frDef" is the name of a flex record definition (see the command vh.flexrecdef which can display the possible names usable here), "startTime" and "endTime" are each strings of the form "yyyymmdd HH:MM:SS", filter is the name of a Vhayu filter and maxRows is the maximum number of rows to retrieve or 0 if all records are desired.

If the Vhayu option "demo" is TRUE then vh.get.zoo will call read.zoo instead of Vhayu and vh.get.data.frame will call read.table. Any arguments known to these two functions may be passed while the remaining arguments will be ignored. The x argument is interpreted as a file name which is looked up along the path defined by the Vhayu option "datapath". If not found it will also search a file of the same name suffixed with ".csv", ".txt" or ".dat". If a pathname and filename are specified rather than just a filename then that path is used. If the read.zoo and read.table arguments of "sep" or "header" are not specified then there will be an attempt to infer them from the first line of the file assuming a file with a comma in the first line should have sep = "," and a file with an alphabetic in its first line should have header = TRUE.

In the case of vh.get.zoo the aggregate argument can be used to specify an R function such as vh.tail1, mean or median to aggregate data values corresponding to a single time value. If aggregate is not specified and if there are multiple values for any time then a warning will be issued; however, a zoo object will still be produced. Such an object may not participate in merges but may be printed, plotted or aggregated. In the case of vh.get.data.frame aggregate is not used and these comments do not apply.

Value

vh.get.data.frame returns a data frame and vh.get.zoo returns a zoo object. The times are returned as POSIXct objects unless the FUN argument is specified. In this latter case, FUN is an R function that converts times from POSIXct to whatever class is desired. See DateTimeClasses.

References

Vahyu Velocity Vhayu R Integration Guide. Vhayu Velocity API Reference Guide.

Examples

## Not run: 
vh.flexrecdef() # check which flex record definitions are available
vh.flexrecdef("VhTrade") # view definition for VhTrade

goog.df <- vh.get.data.frame("GOOG", 
        frDef = "VhTrade",  
        startTime = "20051201 09:30:00", 
        endTime = "20051201 16:00:00", 
        fieldNames = "VhExchgTime VhPrice",
        FUN = as.chron)

goog.zoo <- vh.get.zoo("GOOG", 
        frDef = "VhTrade",  
        startTime = "20051201 09:30:00", 
        endTime = "20051201 16:00:00", 
        fieldNames = "VhExchgTime VhPrice",
        FUN = as.chron,
        aggregate = vh.tail1)

## same but set arguments through options
## We have also set the format option which is not application and ignored.

vh.options(frDef = "VhTrade",  
        startTime = "20051201 09:30:00", 
        endTime = "20051201 16:00:00", 
        fieldNames = "VhExchgTime VhPrice",
        FUN = as.chron,
        aggregate = vh.tail1,
        format = "%Y%m%d")

# Assume there is a csv formatted file called GOOG.csv
# with yyyymmdd dates and assume the vh.options is still as above.
# Since only options format, FUN and aggregate 
# apply to read.zoo only those will be used.
# Thus by setting options appropriate the same script may work
# with files and Vhayu.
vh.options(demo = TRUE)
goog.file <- goog <- vh.get.zoo("GOOG")

## End(Not run)

[Package VhayuR version 1.1.2 Index]