| Type: | Package |
| Title: | Fetch Data from Yahoo Finance API |
| Version: | 0.5.0 |
| Description: | Obtain historical and near real time data related to stocks, index and currencies from the Yahoo Finance API. This package is community maintained and is not officially supported by 'Yahoo'. The accuracy of data is only as correct as provided on https://finance.yahoo.com/. |
| Depends: | R(≥ 3.4) |
| Imports: | curl, dplyr, httr, jsonlite, lubridate, magrittr, purrr, R6 |
| Suggests: | covr, httptest, httptest2, testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| URL: | https://yahoofinancer.rsquaredacademy.com/, https://github.com/rsquaredacademy/yahoofinancer |
| BugReports: | https://github.com/rsquaredacademy/yahoofinancer/issues |
| RoxygenNote: | 7.3.3 |
| NeedsCompilation: | no |
| Packaged: | 2026-05-21 07:44:59 UTC; HP |
| Author: | Aravind Hebbali [aut, cre] |
| Maintainer: | Aravind Hebbali <hebbali.aravind@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-05-21 08:40:02 UTC |
yahoofinancer package
Description
Fetch Data from Yahoo Finance API
Details
See the README on GitHub
Author(s)
Maintainer: Aravind Hebbali hebbali.aravind@gmail.com
See Also
Useful links:
Report bugs at https://github.com/rsquaredacademy/yahoofinancer/issues
R6 Class Representing an Index
Description
Base class for getting all data related to indices from Yahoo Finance API.
Format
An R6 class object
Super class
yahoofinancer::YahooFinanceBase -> Index
Active bindings
indexDeprecated. Returns
self$symbol.
Methods
Public methods
Inherited methods
Method new()
Create a new Index object
Usage
Index$new(symbol = NA, index = NA)
Arguments
symbolSymbol
indexDeprecated. Use
symbolinstead.
Returns
A new 'Index' object
Examples
nifty_50 <- Index$new('^NSEI')
Method set_index()
Set a new index.
Usage
Index$set_index(symbol = NA, index = NA)
Arguments
symbolNew symbol
indexDeprecated. Use
symbolinstead.
Examples
indice <- Index$new('^NSEI')
indice$set_index('^NDX')
Method clone()
The objects of this class are cloneable with this method.
Usage
Index$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
## ------------------------------------------------
## Method `Index$new`
## ------------------------------------------------
nifty_50 <- Index$new('^NSEI')
## ------------------------------------------------
## Method `Index$set_index`
## ------------------------------------------------
indice <- Index$new('^NSEI')
indice$set_index('^NDX')
R6 Class Representing a Ticker
Description
Base class for getting all data related to ticker from Yahoo Finance API.
Format
An R6 class object
Super class
yahoofinancer::YahooFinanceBase -> Ticker
Active bindings
valuation_measuresRetrieves valuation measures
Methods
Public methods
Inherited methods
Method clone()
The objects of this class are cloneable with this method.
Usage
Ticker$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Multi-Symbol Ticker Data Aggregator
Description
An R6 class to manage and aggregate data from multiple Yahoo Finance tickers
simultaneously. It wraps the Ticker class to provide a unified,
long-format data interface suitable for bulk analysis and visualization.
Details
The Tickers class automates the process of iterating over a vector of
symbols. It handles per-symbol errors gracefully via an internal
aggregate_data helper, ensuring that a failure in one symbol does
not prevent the collection of data for others.
Most properties return a data.frame where the first column is
symbol, facilitating easy filtering and joining in tidy workflows.
Public fields
symbolsA unique character vector of symbols being tracked.
ticker_objsA named list of underlying
TickerR6 objects.
Active bindings
recommendationsRelated symbols suggested by Yahoo Finance and their relevance scores.
valuation_measuresQuarterly valuation statistics including PE and Enterprise Value.
technical_insightsTechnical indicator snapshots (e.g., RSI, Moving Averages).
regular_market_priceThe current market price for each symbol.
regular_market_timeThe timestamp of the last market trade.
regular_market_volumeThe current trading volume.
regular_market_day_highThe highest price during the current trading session.
regular_market_day_lowThe lowest price during the current trading session.
previous_closeThe closing price of the previous trading day.
fifty_two_week_highThe highest price over the last 52 weeks.
fifty_two_week_lowThe lowest price over the last 52 weeks.
currencyThe currency code (e.g., "USD") for the symbols.
exchange_nameThe short name of the stock exchange.
full_exchange_nameThe full name of the stock exchange.
first_trade_dateThe Unix timestamp of the first recorded trade.
timezoneThe timezone code (e.g., "EDT").
exchange_timezone_nameThe full name of the exchange's timezone.
Methods
Public methods
Method new()
Create a new Tickers object.
Usage
Tickers$new(symbols)
Arguments
symbolsA character vector of Yahoo Finance ticker symbols.
Returns
A new Tickers object.
Method get_history()
Retrieve historical market data for all symbols.
Usage
Tickers$get_history(period = "1y", interval = "1d", start = NULL, end = NULL)
Arguments
periodThe duration of history to fetch; "1d", "5d", "1mo", "1y", "max" etc.
intervalThe frequency of data points; "1m", "2m", "5m", "1h", "1d", "1wk" etc.
startDate or timestamp for the start of the period.
endDate or timestamp for the end of the period.
Returns
A tidy data.frame containing historical prices and volumes.
Method aggregate_data()
Internal helper to execute a method across all symbols and combine results.
Usage
Tickers$aggregate_data(fn)
Arguments
fnA function or anonymous function that takes a
Tickerobject.
Returns
A combined data.frame or NULL.
Method clone()
The objects of this class are cloneable with this method.
Usage
Tickers$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
## Not run:
# Initialize for a set of tech stocks
stocks <- Tickers$new(c("AAPL", "MSFT", "GOOGL"))
# 1. Get 1 month of historical daily prices
hist_data <- stocks$get_history(period = "1mo", interval = "1d")
head(hist_data)
# 2. Get current market prices for the group
current_prices <- stocks$regular_market_price
# 3. View recommended related symbols and scores
recs <- stocks$recommendations
# 4. Get technical insights (RSI, Moving Averages)
tech <- stocks$technical_insights
## End(Not run)
R6 Class Representing a Yahoo Finance Base Object
Description
Base class for Ticker and Index classes.
Format
An R6 class object
Public fields
symbolSymbol for which data is retrieved.
Methods
Public methods
Method new()
Create a new YahooFinanceBase object.
Usage
YahooFinanceBase$new(symbol = NA)
Arguments
symbolSymbol.
Method set_symbol()
Set a new symbol.
Usage
YahooFinanceBase$set_symbol(symbol)
Arguments
symbolNew symbol
Method get_history()
Retrieves historical pricing data.
Usage
YahooFinanceBase$get_history( period = "ytd", interval = "1d", start = NULL, end = NULL )
Arguments
periodLength of time. Defaults to
'ytd'.intervalTime between data points. Defaults to
'1d'.startSpecific starting date.
Stringordateobject.endSpecific ending date.
Stringordateobject.
Returns
A data.frame.
Method clone()
The objects of this class are cloneable with this method.
Usage
YahooFinanceBase$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Currency converter
Description
Retrieve current conversion rate between two currencies as well as historical rates.
Usage
currency_converter(
from = "EUR",
to = "USD",
start = NULL,
end = NULL,
period = "ytd",
interval = "1d"
)
Arguments
from |
Currency to convert from. |
to |
Currency to convert to. |
start |
Specific starting date. |
end |
Specific ending date. |
period |
Length of time. Defaults to
|
interval |
Time between data points. Defaults to
|
Value
A data.frame.
Examples
currency_converter('GBP', 'USD', '2022-07-01', '2022-07-10')
currency_converter('GBP', 'USD', period = '1mo', interval = '1d')
Currencies
Description
List of currencies Yahoo Finance supports.
Usage
get_currencies()
Value
Symbol, short and long name of the currencies.
Examples
get_currencies()
Market Summary
Description
Summary info of relevant exchanges for specific country.
Usage
get_market_summary(country = "US")
Arguments
country |
Name of the country. |
Value
A data.frame.
Examples
get_market_summary(country = 'US')
Trending securities
Description
List of trending securities for specific country.
Usage
get_trending(country = "US", count = 10)
Arguments
country |
Name of the country. |
count |
Number of securities. |
Value
Securities trending in the country.
Examples
get_trending()
Symbol validation
Description
Validate symbols before retrieving data.
Usage
validate(symbol = NA, index = NA)
Arguments
symbol |
Ticker, index or fund name. |
index |
Deprecated. Use |
Examples
validate("aapl")
validate("aapls")