Ticker-class {yahoofinancer} | R Documentation |
R6 Class Representing a Ticker
Description
Base class for getting all data related to ticker from Yahoo Finance API.
Format
An R6 class object
Public fields
symbol
Symbol for which data is retrieved.
Active bindings
valuation_measures
Retrieves valuation measures for most recent four quarters
recommendations
Recommended symbols
technical_insights
Technical indicators for given symbol
currency
Currency
exchange_name
Exchange name
full_exchange_name
Full exchange name
first_trade_date
First trade date
regular_market_time
Regular market time
timezone
Time zone
exchange_timezone_name
Exchange timezone name
regular_market_price
Regular market price
fifty_two_week_high
Fifty two week high
fifty_two_week_low
Fifty two week low
regular_market_day_high
Regular market day high
regular_market_day_low
Regular market day low
regular_market_volume
Regular market volume
previous_close
Previous close
Methods
Public methods
Method new()
Create a new Ticker object.
Usage
Ticker$new(symbol = NA)
Arguments
symbol
Symbol.
Returns
A new 'Ticker' object
Examples
aapl <- Ticker$new('aapl')
Method set_symbol()
Set a new symbol.
Usage
Ticker$set_symbol(symbol)
Arguments
symbol
New symbol
Examples
aapl <- Ticker$new('aapl') aapl$set_symbol('msft')
Method get_history()
Retrieves historical pricing data.
Usage
Ticker$get_history(period = "ytd", interval = "1d", start = NULL, end = NULL)
Arguments
period
Length of time. Defaults to
'ytd'
. Valid values are:-
'1d'
-
'5d'
-
'1mo'
-
'3mo'
-
'6mo'
-
'1y'
-
'2y'
-
'5y'
-
'10y'
-
'ytd'
-
'max'
-
interval
Time between data points. Defaults to
'1d'
. Valid values are:-
'1m'
-
'2m'
-
'5m'
-
'15m'
-
'30m'
-
'60m'
-
'90m'
-
'1h'
-
'1d'
-
'5d'
-
'1wk'
-
'1mo'
-
'3mo'
-
start
Specific starting date.
String
ordate
object inyyyy-mm-dd
format.end
Specific ending date.
String
ordate
object inyyyy-mm-dd
format.
Returns
A data.frame
.
Examples
\donttest{ aapl <- Ticker$new('aapl') aapl$get_history(start = '2022-07-01', interval = '1d') aapl$get_history(start = '2022-07-01', end = '2022-07-14', interval = '1d') aapl$get_history(period = '1mo', interval = '1d') }
Method clone()
The objects of this class are cloneable with this method.
Usage
Ticker$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
## ------------------------------------------------
## Method `Ticker$new`
## ------------------------------------------------
aapl <- Ticker$new('aapl')
## ------------------------------------------------
## Method `Ticker$set_symbol`
## ------------------------------------------------
aapl <- Ticker$new('aapl')
aapl$set_symbol('msft')
## ------------------------------------------------
## Method `Ticker$get_history`
## ------------------------------------------------
aapl <- Ticker$new('aapl')
aapl$get_history(start = '2022-07-01', interval = '1d')
aapl$get_history(start = '2022-07-01', end = '2022-07-14', interval = '1d')
aapl$get_history(period = '1mo', interval = '1d')