buildRatio {FinancialInstrument}R Documentation

construct price ratios of 2 instruments

Description

Calculates time series of ratio of 2 instruments using available data. Returned object will be ratios calculated using Bids, Asks, and Mids, or Opens, Closes, and Adjusteds.

Usage

buildRatio(x, env = .GlobalEnv, silent = FALSE)

Arguments

x

vector of instrument names. e.g. c("SPY","DIA")

env

environment where xts data is stored

silent

silence warnings?

Details

x should be a vector of 2 instrument names. An attempt will be made to get the data for both instruments. If there are no xts data stored under either of the names, it will try to return prebuilt data with a call to .get_rate.

If the data are not of the same frequency, or are not of the same type (OHLC, BBO, etc.) An attempt will be made to make them compatible. Preference is given to the first leg.

If the data in x[1] is daily or slower and the data in x[2] is intraday (e.g. if you give it daily OHLC and intraday Bid Ask Mid, it will use all of the OHLC columns of x[1] and only the the End of Day Mid price of the BAM object.

If the data in x[1] is intraday, and the data in x[2] is daily or slower, for each day, the previous closing value of x[2] will be filled forward with na.locf

Value

An xts object with columns of Bid, Ask, Mid OR Open, Close, Adjusted OR Price

Author(s)

Garrett See

See Also

redenominate buildSpread fn_SpreadBuilder

Examples


## Not run: 
syms <- c("SPY","DIA")
getSymbols(syms)
rat <- buildRatio(syms)
summary(rat)

## End(Not run)

[Package FinancialInstrument version 1.3.1 Index]