Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (17.8%) to scientific vocabulary
Last synced: 9 months ago
·
JSON representation
Repository
Repository for R package yf
Basic Info
- Host: GitHub
- Owner: ropensci
- License: other
- Language: HTML
- Default Branch: main
- Homepage: https://docs.ropensci.org/yfR
- Size: 5.16 MB
Statistics
- Stars: 47
- Watchers: 2
- Forks: 7
- Open Issues: 0
- Releases: 0
Created almost 5 years ago
· Last pushed about 1 year ago
Metadata Files
Readme
Changelog
Contributing
Funding
License
Codemeta
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
results = 'hold',
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
[](https://www.repostatus.org/#active)
[](https://app.codecov.io/gh/ropensci/yfR?branch=main)
[](https://github.com/ropensci/yfR/actions)
[](https://github.com/ropensci/software-review/issues/523)
[](https://github.com/ropensci/yfR/actions/workflows/R-CMD-check.yaml)
# Motivation
`yfR` facilitates importing stock prices from Yahoo finance, organizing the data in the `tidy` format and speeding up the process using a cache system and parallel computing. `yfR` is the second and backwards-incompatible version of [BatchGetSymbols](https://CRAN.R-project.org/package=BatchGetSymbols), released in 2016 (see vignette [yfR and BatchGetSymbols](https://docs.ropensci.org/yfR/articles/diff-batchgetsymbols.html) for details).
In a nutshell, [Yahoo Finance (YF)](https://finance.yahoo.com/) provides a vast repository of stock price data around the globe. It covers a significant number of markets and assets, being used extensively in academic research and teaching. In order to import the financial data from YF, all you need is a ticker (id of a stock, e.g. "GM" for [General Motors](https://finance.yahoo.com/quote/GM?p=GM&.tsrc=fin-srch)) and a time period -- first and last date.
# The Data
The main function of the package, `yfR::yf_get`, returns a dataframe with the
financial data. All price data is measured at the unit of the financial
exchange. For example, price data for GM (NASDAQ/US) is measured in dollars,
while price data for PETR3.SA (B3/BR) is measured in Reais (Brazilian currency).
The returned data contains the following columns:
**ticker**: The requested tickers (ids of stocks);
**ref_date**: The reference day (this can also be year/month/week when using argument freq_data);
**price_open**: The opening price of the day/period;
**price_high**: The highest price of the day/period;
**price_close**: The close/last price of the day/period;
**volume**: The financial volume of the day/period, in the unit of the exchange;
**price_adjusted**: The stock price adjusted for corporate events such as
splits, dividends and others -- this is usually what you want/need for studying
stocks as it represents the real financial performance of stockholders;
**ret_adjusted_prices**: The arithmetic or log return (see input type_return) for the adjusted stock
prices;
**ret_adjusted_prices**: The arithmetic or log return (see input type_return) for the closing stock
prices;
**cumret_adjusted_prices**: The accumulated arithmetic/log return for the period (starts at 100%).
# Finding tickers
The easiest way to find the tickers of a company stock is to search for it in [Yahoo Finance's](https://finance.yahoo.com/) website. At the top page you'll find a search bar:

A company can have many different stocks traded at different markets (see picture above). As the example shows, Petrobras is traded at NYQ (New York Exchange), SAO (Sao Paulo/Brazil - B3 exchange) and BUE (Buenos Aires/Argentina Exchange), all with different symbols (tickers).
For market indices, a list of tickers is available [here](https://finance.yahoo.com/world-indices).
## Features of `yfR`
- Fetches daily/weekly/monthly/annual stock prices/returns from yahoo finance and outputs a dataframe (tibble) in the long format (stacked data);
- A new feature called **collections** facilitates download of multiple tickers from a particular market/index. You can, for example, download data for all stocks in the SP500 index with a simple call to `yf_collection_get("SP500")`;
- A session-persistent smart cache system is available by default. This means that the data is saved locally and only missing portions are downloaded, if needed.
- All dates are compared to a benchmark ticker such as SP500 and, whenever an individual asset does not have a sufficient number of dates, the software drops it from the output. This means you can choose to ignore tickers with a high proportion of missing dates.
- A customized function called `yf_convert_to_wide()` can transform the long dataframe into a wide format (tickers as columns), much used in portfolio optimization. The output is a list where each element is a different target variable (prices, returns, volumes).
- Parallel computing with package `furrr` is available, speeding up the data importation process.
## Warnings
- Yahoo finance data is far from perfect or reliable, specially for individual stocks. In my experience, using it for research code with stock **indices** is fine and I can match it with other data sources. But, adjusted stock prices for **individual assets** is messy as stock events such as splits or dividends are not properly registered. I was never able to match it with other data sources, specially for long time periods with lots of corporate events. My advice is to **never use the yahoo finance data of individual stocks in production** (research papers or academic documents -- thesis and dissertations). If adjusted price data of individual stocks is important for your research, **use other data sources** such as [EODHD](https://eodhd.com/), [SimFin](https://www.simfin.com/) or [Economática](https://www.economatica.com/).
## Installation
```
# CRAN (stable)
install.packages('yfR')
# Github (dev version)
devtools::install_github('ropensci/yfR')
# ropensci
install.packages("yfR", repos = "https://ropensci.r-universe.dev")
```
## A simple example of usage
```{r, results='hold'}
library(yfR)
# set options for algorithm
my_ticker <- 'META'
first_date <- Sys.Date() - 30
last_date <- Sys.Date()
# fetch data
df_yf <- yf_get(tickers = my_ticker,
first_date = first_date,
last_date = last_date)
# output is a tibble with data
head(df_yf)
```
# Acknowledgements
Package `yfR` is based on [quantmod](https://www.quantmod.com/) (@joshuaulrich) and uses one of its functions (`quantmod::getSymbols`) for fetching raw data from Yahoo Finance. As with any API, there is significant work in maintaining the code. Joshua was always fast and openminded in implemented required changes, and I'm very grateful for it.
Owner
- Name: rOpenSci
- Login: ropensci
- Kind: organization
- Email: info@ropensci.org
- Location: Berkeley, CA
- Website: https://ropensci.org/
- Twitter: rOpenSci
- Repositories: 307
- Profile: https://github.com/ropensci
CodeMeta (codemeta.json)
{
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"identifier": "yfR",
"description": "Facilitates download of financial data from Yahoo Finance <https://finance.yahoo.com/>, a vast repository of stock price data across multiple financial exchanges. The package offers a local caching system and support for parallel computation.",
"name": "yfR: Downloads and Organizes Financial Data from Yahoo Finance",
"relatedLink": "https://docs.ropensci.org/yfR",
"codeRepository": "https://github.com/ropensci/yfR",
"issueTracker": "https://github.com/msperlin/yfR/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "1.0.0",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 4.2.0 (2022-04-22)",
"author": [
{
"@type": "Person",
"givenName": "Marcelo",
"familyName": "Perlin",
"email": "marceloperlin@gmail.com"
}
],
"maintainer": [
{
"@type": "Person",
"givenName": "Marcelo",
"familyName": "Perlin",
"email": "marceloperlin@gmail.com"
}
],
"softwareSuggestions": [
{
"@type": "SoftwareApplication",
"identifier": "knitr",
"name": "knitr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=knitr"
},
{
"@type": "SoftwareApplication",
"identifier": "rmarkdown",
"name": "rmarkdown",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=rmarkdown"
},
{
"@type": "SoftwareApplication",
"identifier": "testthat",
"name": "testthat",
"version": ">= 3.0.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=testthat"
},
{
"@type": "SoftwareApplication",
"identifier": "ggplot2",
"name": "ggplot2",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=ggplot2"
},
{
"@type": "SoftwareApplication",
"identifier": "covr",
"name": "covr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=covr"
},
{
"@type": "SoftwareApplication",
"identifier": "spelling",
"name": "spelling",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=spelling"
}
],
"softwareRequirements": {
"1": {
"@type": "SoftwareApplication",
"identifier": "R",
"name": "R",
"version": ">= 4.0.0"
},
"2": {
"@type": "SoftwareApplication",
"identifier": "stringr",
"name": "stringr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=stringr"
},
"3": {
"@type": "SoftwareApplication",
"identifier": "curl",
"name": "curl",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=curl"
},
"4": {
"@type": "SoftwareApplication",
"identifier": "tidyr",
"name": "tidyr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=tidyr"
},
"5": {
"@type": "SoftwareApplication",
"identifier": "lubridate",
"name": "lubridate",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=lubridate"
},
"6": {
"@type": "SoftwareApplication",
"identifier": "furrr",
"name": "furrr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=furrr"
},
"7": {
"@type": "SoftwareApplication",
"identifier": "purrr",
"name": "purrr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=purrr"
},
"8": {
"@type": "SoftwareApplication",
"identifier": "future",
"name": "future",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=future"
},
"9": {
"@type": "SoftwareApplication",
"identifier": "tibble",
"name": "tibble",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=tibble"
},
"10": {
"@type": "SoftwareApplication",
"identifier": "zoo",
"name": "zoo",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=zoo"
},
"11": {
"@type": "SoftwareApplication",
"identifier": "cli",
"name": "cli",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=cli"
},
"12": {
"@type": "SoftwareApplication",
"identifier": "readr",
"name": "readr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=readr"
},
"13": {
"@type": "SoftwareApplication",
"identifier": "rvest",
"name": "rvest",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=rvest"
},
"14": {
"@type": "SoftwareApplication",
"identifier": "dplyr",
"name": "dplyr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=dplyr"
},
"15": {
"@type": "SoftwareApplication",
"identifier": "quantmod",
"name": "quantmod",
"version": ">= 0.4.20",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=quantmod"
},
"16": {
"@type": "SoftwareApplication",
"identifier": "magrittr",
"name": "magrittr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=magrittr"
},
"17": {
"@type": "SoftwareApplication",
"identifier": "humanize",
"name": "humanize",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=humanize"
},
"SystemRequirements": null
},
"fileSize": "438.633KB",
"citation": [
{
"@type": "SoftwareSourceCode",
"datePublished": "2021",
"author": [
{
"@type": "Person",
"givenName": "Marcelo",
"familyName": "Perlin"
}
],
"name": "yfR: Downloads and Organizes Financial Data from Yahoo Finance",
"url": "https://github.com/msperlin/yfR",
"description": "R package version 0.0.1"
}
],
"releaseNotes": "https://github.com/ropensci/yfR/blob/master/NEWS.md",
"readme": "https://github.com/ropensci/yfR/blob/main/README.md",
"contIntegration": [
"https://app.codecov.io/gh/ropensci/yfR?branch=main",
"https://github.com/ropensci/yfR/actions"
],
"developmentStatus": "https://www.repostatus.org/#active",
"review": {
"@type": "Review",
"url": "https://github.com/ropensci/software-review/issues/523",
"provider": "https://ropensci.org"
}
}
GitHub Events
Total
- Issues event: 7
- Watch event: 7
- Issue comment event: 10
- Push event: 2
Last Year
- Issues event: 7
- Watch event: 7
- Issue comment event: 10
- Push event: 2
Committers
Last synced: about 3 years ago
All Time
- Total Commits: 109
- Total Committers: 3
- Avg Commits per committer: 36.333
- Development Distribution Score (DDS): 0.037
Top Committers
| Name | Commits | |
|---|---|---|
| msperlin | m****n@g****m | 105 |
| Henrique | h****a@p****r | 3 |
| rpatel15-hue | 8****e@u****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 9 months ago
All Time
- Total issues: 21
- Total pull requests: 9
- Average time to close issues: 26 days
- Average time to close pull requests: 1 day
- Total issue authors: 13
- Total pull request authors: 4
- Average comments per issue: 3.81
- Average comments per pull request: 0.89
- Merged pull requests: 8
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 4
- Pull requests: 0
- Average time to close issues: about 23 hours
- Average time to close pull requests: N/A
- Issue authors: 2
- Pull request authors: 0
- Average comments per issue: 1.75
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- msperlin (7)
- andreltr (2)
- cemal95 (2)
- 3SMMZRjWgS (1)
- rvalieris (1)
- Momo69100 (1)
- jtrecenti (1)
- ccsarapas (1)
- earlcharles1 (1)
- snvv (1)
- thisisnic (1)
- DanielleKarling (1)
- rhamo (1)
Pull Request Authors
- msperlin (5)
- henrique1008 (2)
- jtrecenti (1)
- rpatel15-hue (1)
Top Labels
Issue Labels
bug (3)
good first issue (1)
enhancement (1)
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 955 last-month
- Total dependent packages: 0
- Total dependent repositories: 1
- Total versions: 8
- Total maintainers: 1
cran.r-project.org: yfR
Downloads and Organizes Financial Data from Yahoo Finance
- Homepage: https://github.com/ropensci/yfR
- Documentation: http://cran.r-project.org/web/packages/yfR/yfR.pdf
- License: MIT + file LICENSE
-
Latest release: 1.1.2
published about 1 year ago
Rankings
Stargazers count: 8.4%
Forks count: 8.7%
Downloads: 15.3%
Average: 17.0%
Dependent repos count: 24.0%
Dependent packages count: 28.8%
Maintainers (1)
Last synced:
9 months ago
Dependencies
DESCRIPTION
cran
- R >= 4.0.0 depends
- cli * imports
- curl * imports
- dplyr * imports
- furrr * imports
- future * imports
- humanize * imports
- lubridate * imports
- magrittr * imports
- methods * imports
- purrr * imports
- quantmod >= 0.4.20 imports
- readr * imports
- rvest * imports
- stringr * imports
- tibble * imports
- tidyr * imports
- zoo * imports
- covr * suggests
- ggplot2 * suggests
- knitr * suggests
- rmarkdown * suggests
- spelling * suggests
- testthat >= 3.0.0 suggests
.github/workflows/test-coverage.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/setup-r v1 composite
- r-lib/actions/setup-r-dependencies v1 composite
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v3 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite