PF: Merge Adjusted prices (or returns of adjusted prices) of...

Description Usage Arguments Details Value Note Author(s) See Also Examples

Description

Given the names of symbols, merge together Adjusted columns of their xts objects

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
  makePriceFrame(Symbols, from = NULL, to = NULL,
    prefer = NULL, notional = FALSE, na.omit = TRUE,
    subset = NULL, env = .GlobalEnv, silent)

  PF(Symbols, from = NULL, to = NULL, prefer = NULL,
    notional = FALSE, na.omit = TRUE, subset = NULL,
    env = .GlobalEnv, silent)

  makeReturnFrame(Symbols, ..., from = NULL, to = NULL,
    prefer = NULL, notional = FALSE, na.omit = TRUE,
    subset = NULL, env = .GlobalEnv, silent)

  RF(Symbols, ..., from = NULL, to = NULL, prefer = NULL,
    notional = FALSE, na.omit = TRUE, subset = NULL,
    env = .GlobalEnv, silent)

Arguments

Symbols

character vector of names of xts objects

from

include no data before this date/timestamp

to

include data through this date/timestamp

prefer

column to use. If NULL, the first of the following columns that is found will be used: ‘Adjusted’, ‘Close’, ‘Mid’

notional

Should notional values be returned? Default is FALSE see Details

na.omit

Should NA values be removed? Default is TRUE

subset

xts style subsetting argument. (e.g. "T08:30/T15:00" or "last 10 days") Default is NULL

env

environment in which to look for xts objects

silent

silence warnings? (Currently, the only warning message is “Instrument not found, using contract multiplier of 1”)

...

arguments to be passed to ROC. These can be ‘n’, ‘type’, ‘na.pad’,

Details

PF and RF are aliases. makePriceFrame merges the prefer columns of several symbols if prefer is given. Otherwise, it will use the adjusted column is if it exists, or close, mid, or price if it does not. (See estAd).

If notional is TRUE and any Symbols are the names of instruments, prices will be multiplied by their multipliers unless they have a "notional" attr that has a value of TRUE (which indicates that they have already been notionalized. If the object has already been notionalized, and notional is TRUE, it will be used as is. However, if it has already been notionalized (i.e. isTRUE(attr(obj, 'notional'))) and the notional argument is FALSE, price will be divided by their multipliers to "denotionalize" them.

makeReturnFrame first calls makePriceFrame, then calculates returns on those price series

The from and to arguments are intended to be used to indicate the starting and ending date, whereas the subset argument is intended to be used to subset intraday data by time of day.

Since this function merges together the same prefer column from each Symbol, the column names can be simplified. The colnames will simply be set to be the same as Symbols. A "prefer" attr will be added to the returned object so that you can see (using str, or attr(x, "prefer")) what column was used to build the PriceFrame.

Value

xts object with same number of columns as length of Symbols, 1 for each symbol's [adjusted] prices (returns). The object will have a "prefer" attr indicating which column was used to build it.

Note

makeReturnFrame can be useful before calling functions like charts.PerformanceSummary from the PortfolioAnalytics package.

Author(s)

Garrett See

See Also

estAd, getPrice, attr, gsa, alignSymbols, merge, cbind

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
getSymbols(c('SPY','DIA','QQQ'))
pf <- makePriceFrame(c('SPY','DIA','QQQ'))
head(pf)
rf <- makeReturnFrame(c('SPY','DIA','QQQ'))
head(rf)
## See what column was used to make pf
attr(pf, "prefer")

## End(Not run)

qmao documentation built on May 2, 2019, 4:54 p.m.