calc.ret: Function to calculate returns from a price and ticker vector

Description Usage Arguments Value Examples

View source: R/Utils.R

Description

Created so that a return column is added to a dataframe with prices in the long (tidy) format.

Usage

1
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

1
2
P <- c(1,2,3)
R <- calc.ret(P)

Example output

Loading required package: rvest
Loading required package: xml2
Loading required package: dplyr

Attaching package: 'dplyr'

The following objects are masked from 'package:stats':

    filter, lag

The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

BatchGetSymbols documentation built on Jan. 13, 2021, 5:17 p.m.