calc.ret {BatchGetSymbols} | R Documentation |
Function to calculate returns from a price and ticker vector
Description
Created so that a return column is added to a dataframe with prices in the long (tidy) format.
Usage
calc.ret(P, tickers = rep("ticker", length(P)), type.return = "arit")
Arguments
P |
Price vector |
tickers |
Ticker of symbols (usefull if working with long dataframe) |
type.return |
Type of price return to calculate: 'arit' (default) - aritmetic, 'log' - log returns. |
Value
A vector of returns
Examples
P <- c(1,2,3)
R <- calc.ret(P)
[Package BatchGetSymbols version 2.6.4 Index]