https://github.com/rsquaredacademy/yahoofinancer
Obtain historical and near real time data from Yahoo Finance
https://github.com/rsquaredacademy/yahoofinancer
api api-wrapper finance market-data rstats stock-market yahoo-finance yahoo-finance-api
Last synced: 6 months ago
JSON representation
Obtain historical and near real time data from Yahoo Finance
- Host: GitHub
- URL: https://github.com/rsquaredacademy/yahoofinancer
- Owner: rsquaredacademy
- License: other
- Created: 2021-01-20T07:28:08.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-01-27T05:45:09.000Z (over 1 year ago)
- Last Synced: 2025-12-09T08:55:07.181Z (7 months ago)
- Topics: api, api-wrapper, finance, market-data, rstats, stock-market, yahoo-finance, yahoo-finance-api
- Language: HTML
- Homepage: https://yahoofinancer.rsquaredacademy.com
- Size: 30 MB
- Stars: 17
- Watchers: 3
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# yahoofinancer
[](https://CRAN.R-project.org/package=yahoofinancer)
[](https://github.com/rsquaredacademy/yahoofinancer/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/rsquaredacademy/yahoofinancer?branch=master)
Obtain historical and near real time data related to stocks, index and currencies from the Yahoo Finance API.
## Installation
```{r gh-installation, eval = FALSE}
# Install rfm from CRAN
install.packages("yahoofinancer")
# Or the development version from GitHub
# install.packages("pak")
pak::pak("rsquaredacademy/yahoofinancer")
```
## Quick Start
```{r load_yfr, echo=FALSE, message=FALSE, warning=FALSE}
library(yahoofinancer)
```
### Ticker
To retrieve data from Yahoo Finance for a single stock, create an instance of the `Ticker` class by passing the company's ticker symbol as an argument:
```{r ticker}
aapl <- Ticker$new('aapl')
# get historical market data
head(aapl$get_history(start = '2024-10-20', interval = '1d'))
# meta info
# regular market price
aapl$regular_market_price
# 52 week high
aapl$fifty_two_week_high
# previous close
aapl$previous_close
```
### Index
To retrieve data from Yahoo Finance for an index, create an instance of the `Index` class by passing the index symbol as an argument:
```{r index}
nifty_50 <- Index$new('^NSEI')
# get historical data
head(nifty_50$get_history(start = '2024-01-20', interval = '1d'))
```
### Currency
```{r currency}
head(currency_converter('GBP', 'USD', '2024-01-20', '2024-01-30'))
```
## IMPORTANT LEGAL DISCLAIMER
**Yahoo!, Y!Finance, and Yahoo! finance are registered trademarks of
Yahoo, Inc.**
yahoofinancer is **not** affiliated, endorsed, or vetted by Yahoo, Inc. It's
an open-source tool that uses Yahoo's publicly available APIs, and is
intended for research and educational purposes.
**You should refer to Yahoo!'s terms of use**
([here](https://policies.yahoo.com/us/en/yahoo/terms/product-atos/apiforydn/index.htm),
[here](https://legal.yahoo.com/us/en/yahoo/terms/otos/index.html), and
[here](https://policies.yahoo.com/us/en/yahoo/terms/index.htm)) **for
details on your rights to use the actual data downloaded. Remember - the
Yahoo! finance API is intended for personal use only.**
## Code of Conduct
Please note that the yahoofinancer project is released with a [Contributor Code of Conduct](https://yahoofinancer.rsquaredacademy.com/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.