getStockInfo: Retreives info for a stock

Description Usage Arguments Details Value Functions Note See Also Examples

Description

Function family to retrieve specific info for a given ticker.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
getStockInfo(ticker, clean.mcap = TRUE, clean.sector = TRUE,
  auto.assign = FALSE, env = .GlobalEnv)

getStockInfo.name(ticker)

getStockInfo.sector(ticker, clean.sector = TRUE)

getStockInfo.exchange(ticker)

getStockInfo.last(ticker)

getStockInfo.industry(ticker)

getStockInfo.IPO.year(ticker)

getStockInfo.market.cap(ticker, clean.mcap = TRUE)

Arguments

ticker

Character; the ticker for the stock you need info about

clean.mcap

Logical; should the Market.Cap element be returned cleaned. If TRUE: Market.Cap returns as a numeric. If FALSE: Market.Cap returns as a character string. Defaults to TRUE

clean.sector

Logical; should the Sector element be returned cleaned. Sector cleaning is done using cleanSector. Defaults to TRUE

auto.assign

Logical; should the results be assigned to env. If FALSE returns results. Defaults to FALSE

env

Environment; where to auto.assign objects. Setting env=NULL is equal to auto.assign=FALSE. Defaults to .GlobalEnv.

Details

Based off of the TTR function stockSymbols it compensates for different data types and difficulty in accessing specific ticker data. Data retrieval depends on the TTR package, which retrieves its data from NASDAQ

Value

Returns a list containing the elements:

Name

Character; name of the company

Last.Trade

Numeric; price of the last trade for the company

Sector

Character; sector of the company

Industry

Character; descriptive industry name

IPO.Year

Integer; year of the company's IPO

Exchange

Character; exchange that the company currently trades on. One of: "AMEX", "NASDAQ", NYSE.

Market.Cap

Numeric (or Character); current market capitalization for the company

Functions

Note

Values for Sector may not be identical to sectors listed in getSectorWeights. Values for Sector, IPO.Year, and Market.Cap are occasionally missing and will default to NA. getStockInfo caches the data for stockSymbols in a hidden global variable (.ss) to massively increase speed on subsequent uses of the function.

See Also

Other data retrieval functions: getHoldings.SMIF, getSectorETF, getSymbols.SMIF

Examples

1
2
3
4
5
6
7
8

alec25/smif.package documentation built on May 22, 2019, 12:36 p.m.