| Type: | Package |
| Title: | Fetch Data from Yahoo Finance API |
| Version: | 0.4.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, httr, jsonlite, lubridate, magrittr, purrr, R6, stringr |
| Suggests: | covr, httptest, 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.2 |
| NeedsCompilation: | no |
| Packaged: | 2024-11-14 15:52:09 UTC; HP |
| Author: | Aravind Hebbali [aut, cre] |
| Maintainer: | Aravind Hebbali <hebbali.aravind@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2024-11-14 16:20: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 a Ticker
Description
Base class for getting all data related to indices from Yahoo Finance API.
Format
An R6 class object
Public fields
indexIndex for which data is retrieved
Methods
Public methods
Method new()
Create a new Index object
Usage
Index$new(index = NA)
Arguments
indexIndex
Returns
A new 'Index' object
Examples
nifty_50 <- Index$new('^NSEI')
Method set_index()
Set a new index.
Usage
Index$set_index(index)
Arguments
indexNew index
Examples
indice <- Index$new('^NSEI')
indice$set_index('^NDX')
Method get_history()
Retrieves historical data
Usage
Index$get_history(period = "ytd", interval = "1d", start = NULL, end = NULL)
Arguments
periodLength of time. Defaults to
'ytd'. Valid values are:-
'1d' -
'5d' -
'1mo' -
'3mo' -
'6mo' -
'1y' -
'2y' -
'5y' -
'10y' -
'ytd' -
'max'
-
intervalTime between data points. Defaults to
'1d'. Valid values are:-
'1m' -
'2m' -
'5m' -
'15m' -
'30m' -
'60m' -
'90m' -
'1h' -
'1d' -
'5d' -
'1wk' -
'1mo' -
'3mo'
-
startSpecific starting date.
Stringordateobject inyyyy-mm-ddformat.endSpecific ending date.
Stringordateobject inyyyy-mm-ddformat.
Returns
A data.frame.
Examples
\donttest{
nifty <- Index$new('^NSEI')
nifty$get_history(start = '2022-07-01', interval = '1d')
nifty$get_history(start = '2022-07-01', end = '2022-07-14', interval = '1d')
nifty$get_history(period = '1mo', interval = '1d')
}
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')
## ------------------------------------------------
## Method `Index$get_history`
## ------------------------------------------------
nifty <- Index$new('^NSEI')
nifty$get_history(start = '2022-07-01', interval = '1d')
nifty$get_history(start = '2022-07-01', end = '2022-07-14', interval = '1d')
nifty$get_history(period = '1mo', interval = '1d')
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
symbolSymbol for which data is retrieved.
Active bindings
valuation_measuresRetrieves valuation measures for most recent four quarters
recommendationsRecommended symbols
technical_insightsTechnical indicators for given symbol
currencyCurrency
exchange_nameExchange name
full_exchange_nameFull exchange name
first_trade_dateFirst trade date
regular_market_timeRegular market time
timezoneTime zone
exchange_timezone_nameExchange timezone name
regular_market_priceRegular market price
fifty_two_week_highFifty two week high
fifty_two_week_lowFifty two week low
regular_market_day_highRegular market day high
regular_market_day_lowRegular market day low
regular_market_volumeRegular market volume
previous_closePrevious close
Methods
Public methods
Method new()
Create a new Ticker object.
Usage
Ticker$new(symbol = NA)
Arguments
symbolSymbol.
Returns
A new 'Ticker' object
Examples
aapl <- Ticker$new('aapl')
Method set_symbol()
Set a new symbol.
Usage
Ticker$set_symbol(symbol)
Arguments
symbolNew 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
periodLength of time. Defaults to
'ytd'. Valid values are:-
'1d' -
'5d' -
'1mo' -
'3mo' -
'6mo' -
'1y' -
'2y' -
'5y' -
'10y' -
'ytd' -
'max'
-
intervalTime between data points. Defaults to
'1d'. Valid values are:-
'1m' -
'2m' -
'5m' -
'15m' -
'30m' -
'60m' -
'90m' -
'1h' -
'1d' -
'5d' -
'1wk' -
'1mo' -
'3mo'
-
startSpecific starting date.
Stringordateobject inyyyy-mm-ddformat.endSpecific ending date.
Stringordateobject inyyyy-mm-ddformat.
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
deepWhether 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')
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 = NULL)
Arguments
symbol |
Ticker, index or fund name. |
Examples
validate("aapl")
validate("aapls")