access: Access Daily Stock Returns by Dates

Description Usage Arguments Value See Also Examples

View source: R/access.R

Description

Access data from a zoo type daily returns table and returns as a zoo object. Basically, it returns a table of daily returns of a given list of company ticker names for a time period given as the input.

Usage

1
access(tickers, start, end, data)

Arguments

tickers

A character vector of ticker names of companies in the portfolio.

start

Start date in the format "yyyy-mm-dd".

end

End date in the format "yyyy-mm-dd".

data

A zoo object whose rownames are dates and colnames are ticker names of the companies. Values of the table corresponds to the daily returns of the stocks of corresponding ticker names.

Value

Returns a zoo series as a table of daily returns corresponding to the company ticker names in tickers for the given time period. Basically, it picks up a block from a large table of daily returns of the stocks corresponding to the dates.

See Also

zoo

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
data(SnP500Returns)

# list all the ticker names in a character vector
tckk <- colnames(SnP500Returns)

# access the data corresponding to the first 3 ticker names
# for the time period January 1, 2013 - January 10, 2013
access(tickers = tckk[1:3],
        start = "2013-01-01",
        end = "2013-01-10",
        data = SnP500Returns)

Example output

                      A           AA         AAPL
2013-01-02  0.022692202  0.035452541  0.031184775
2013-01-03  0.003612286  0.007834399 -0.012703328
2013-01-04  0.019519782  0.020960503 -0.028238561
2013-01-07 -0.007097262 -0.017621601 -0.005896404
2013-01-08 -0.008104931  0.000000000  0.002680967
2013-01-09  0.026687143 -0.002224695 -0.015760983
2013-01-10  0.007198452 -0.011198325  0.012321048

PortRisk documentation built on May 2, 2019, 7:22 a.m.