| Title: | Fetch Data from Yahoo Finance API |
|---|---|
| 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/>. |
| Authors: | Aravind Hebbali [aut, cre] |
| Maintainer: | Aravind Hebbali <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.5.0.9000 |
| Built: | 2026-06-02 10:40:49 UTC |
| Source: | https://github.com/rsquaredacademy/yahoofinancer |
Retrieve current conversion rate between two currencies as well as historical rates.
currency_converter( from = "EUR", to = "USD", start = NULL, end = NULL, period = "ytd", interval = "1d" )currency_converter( from = "EUR", to = "USD", start = NULL, end = NULL, period = "ytd", interval = "1d" )
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
|
A data.frame.
currency_converter('GBP', 'USD', '2022-07-01', '2022-07-10') currency_converter('GBP', 'USD', period = '1mo', interval = '1d')currency_converter('GBP', 'USD', '2022-07-01', '2022-07-10') currency_converter('GBP', 'USD', period = '1mo', interval = '1d')
List of currencies Yahoo Finance supports.
get_currencies()get_currencies()
Symbol, short and long name of the currencies.
get_currencies()get_currencies()
Summary info of relevant exchanges for specific country.
get_market_summary(country = "US")get_market_summary(country = "US")
country |
Name of the country. |
A data.frame.
get_market_summary(country = 'US')get_market_summary(country = 'US')
List of trending securities for specific country.
get_trending(country = "US", count = 10)get_trending(country = "US", count = 10)
country |
Name of the country. |
count |
Number of securities. |
Securities trending in the country.
get_trending()get_trending()
Base class for getting all data related to indices from Yahoo Finance API.
An R6 class object
yahoofinancer::YahooFinanceBase -> Index
indexDeprecated. Returns self$symbol.
new()
Create a new Index object
Index$new(symbol = NA, index = NA)
symbolSymbol
indexDeprecated. Use symbol instead.
A new 'Index' object
nifty_50 <- Index$new('^NSEI')
set_index()
Set a new index.
Index$set_index(symbol = NA, index = NA)
symbolNew symbol
indexDeprecated. Use symbol instead.
indice <- Index$new('^NSEI')
indice$set_index('^NDX')
clone()
The objects of this class are cloneable with this method.
Index$clone(deep = FALSE)
deepWhether to make a deep clone.
## ------------------------------------------------ ## Method `Index$new` ## ------------------------------------------------ nifty_50 <- Index$new('^NSEI') ## ------------------------------------------------ ## Method `Index$set_index` ## ------------------------------------------------ indice <- Index$new('^NSEI') indice$set_index('^NDX')## ------------------------------------------------ ## Method `Index$new` ## ------------------------------------------------ nifty_50 <- Index$new('^NSEI') ## ------------------------------------------------ ## Method `Index$set_index` ## ------------------------------------------------ indice <- Index$new('^NSEI') indice$set_index('^NDX')
Base class for getting all data related to ticker from Yahoo Finance API.
An R6 class object
yahoofinancer::YahooFinanceBase -> Ticker
valuation_measuresRetrieves valuation measures
clone()
The objects of this class are cloneable with this method.
Ticker$clone(deep = FALSE)
deepWhether to make a deep clone.
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.
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.
symbolsA unique character vector of symbols being tracked.
ticker_objsA named list of underlying Ticker R6 objects.
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.
new()
Create a new Tickers object.
Tickers$new(symbols)
symbolsA character vector of Yahoo Finance ticker symbols.
A new Tickers object.
get_history()
Retrieve historical market data for all symbols.
Tickers$get_history(period = "1y", interval = "1d", start = NULL, end = NULL)
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.
A tidy data.frame containing historical prices and volumes.
aggregate_data()
Internal helper to execute a method across all symbols and combine results.
Tickers$aggregate_data(fn)
fnA function or anonymous function that takes a Ticker object.
A combined data.frame or NULL.
clone()
The objects of this class are cloneable with this method.
Tickers$clone(deep = FALSE)
deepWhether to make a deep clone.
## 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)## 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)
Validate symbols before retrieving data.
validate(symbol = NA, index = NA)validate(symbol = NA, index = NA)
symbol |
Ticker, index or fund name. |
index |
Deprecated. Use |
validate("aapl") validate("aapls")validate("aapl") validate("aapls")