Compare commits

...

101 Commits

Author SHA1 Message Date
github-actions[bot]
b656a8ab39 Update documentation 2024-11-06 09:28:16 +00:00
ValueRaider
1e15302414 Merge pull request #2115 from ericpien/docs
Adding Sphinx Documentation
2024-11-06 09:27:21 +00:00
Eric Pien
3e647a8e29 Merge branch 'docs_markdown' into docs 2024-11-05 20:02:32 -08:00
Eric Pien
d20923551d Add Sphinx Documentation
- Initial draft of Sphinx documentation using rst
    - update docstrings
    - add deploy_doc.yml for automated deployment through GitHub Actions
2024-11-05 19:56:34 -08:00
ValueRaider
664a4b4b59 Manually restore docs/ & mkdocs.yml changes lost during rebase 2024-11-03 11:34:47 +00:00
Ran Aroussi
43f311d695 Delete CNAME 2024-11-03 11:29:14 +00:00
Ran Aroussi
2c43de5f92 Create CNAME 2024-11-03 11:29:14 +00:00
silvavn
d324fde012 Documented util.py 2024-11-03 11:29:13 +00:00
silvavn
ad2f17fffa added advanced usage 2024-11-03 11:22:16 +00:00
silvavn
977d3144c5 fixing documentation 2024-11-03 11:21:54 +00:00
ValueRaider
0bc22f82bb Merge pull request #2108 from ranaroussi/main
sync main -> dev
2024-11-02 12:38:00 +00:00
Ran Aroussi
5e942fdec4 Refactor multi.py to handle single tickers and rename columns 2024-10-25 19:02:07 +01:00
Ran Aroussi
16072e87df Bump version to 0.2.48 2024-10-25 18:59:19 +01:00
Ran Aroussi
6946f99e30 Refactor multi.py to handle single tickers and rename columns 2024-10-25 18:59:03 +01:00
Ran Aroussi
1397dcc4bc Update version.py 2024-10-25 11:34:13 +01:00
Ran Aroussi
7fee3039f4 Delete .DS_Store 2024-10-25 11:33:08 +01:00
Ran Aroussi
4beb489f82 Refactor multi.py to handle single tickers and rename columns 2024-10-25 11:31:20 +01:00
ValueRaider
0f570c4684 Merge pull request #2097 from eltociear/patch-1
docs: update README.md
2024-10-22 18:55:03 +01:00
Ikko Eltociear Ashimine
b32e57fcfe docs: update README.md
minor fix
2024-10-22 17:19:56 +09:00
ValueRaider
0ec5151ff3 Version 0.2.46 2024-10-21 18:37:53 +01:00
ValueRaider
b88a0a6bf5 Merge pull request #2094 from FX196/patch-1
Fix malformed f-string in release `0.2.45`
2024-10-21 18:36:49 +01:00
Yuhong Chen
c218848a69 Fix malformed f-string 2024-10-20 17:36:22 -07:00
ValueRaider
f19dff247e Version 0.2.45 2024-10-20 22:59:16 +01:00
ValueRaider
1de113eccd Merge pull request #2091 from ranaroussi/dev
sync dev -> main
2024-10-20 22:56:26 +01:00
ValueRaider
8daa477167 Merge pull request #2090 from ranaroussi/feature/divident-repair-improve
Feature/dividend repair improve
2024-10-20 22:55:52 +01:00
ValueRaider
3152715d45 Improve divident repair
Dividend repair tweaks:
- handle coincident split missing from dividend
- avoid 100x price changes confusing detection of div too-big/small
- improve detecting div-date-wrong
2024-10-20 21:50:08 +01:00
ValueRaider
ee657b24d5 Merge pull request #2087 from ranaroussi/fix/debug-msg
Fix IndexError in some history() debug messages
2024-10-20 16:31:33 +01:00
ValueRaider
4672715a86 Merge pull request #2066 from ericpien/screener
Implement Screener Feature
2024-10-19 22:13:46 +01:00
Eric Pien
4a70b59db9 Simplify README for Screener
- Reduce the information provided in README with the expectation of migrating to separate documentation.
2024-10-19 09:27:32 -07:00
Ran Aroussi
12e815d977 Update README.md 2024-10-17 21:51:59 +01:00
ValueRaider
e282d1b59c Fix IndexError in some history() debug messages 2024-10-12 11:48:11 +01:00
ValueRaider
7e0946ed37 Merge pull request #2080 from ranaroussi/main
sync main -> dev
2024-10-07 21:30:03 +01:00
ValueRaider
a21fc073b8 Merge pull request #2059 from marco-carvalho/patch-1
Add Pyright type checking
2024-10-07 19:50:24 +01:00
ValueRaider
a9e3cf0780 Merge pull request #2072 from algonell/main
Fix typos
2024-10-05 20:08:10 +01:00
ValueRaider
0f63ecc2bd Merge pull request #2068 from antoniouaa/fix_tickers_single
fix keyerror with single element list passed to Tickers
2024-10-03 20:09:52 +01:00
Andrew Kreimer
10800a1070 Fix typos 2024-10-03 22:01:53 +03:00
Andrew Kreimer
db39b3fca4 Fix a typo 2024-10-03 22:00:57 +03:00
Andrew Kreimer
10d6221718 Fix typos 2024-10-03 22:00:29 +03:00
ValueRaider
17f07e08ef Merge pull request #2069 from ranaroussi/main
sync main -> dev
2024-10-02 20:12:48 +01:00
ValueRaider
f82823c624 Merge pull request #2067 from ranaroussi/fix/tests-context
Fix unit tests contextual imports
2024-10-02 20:11:30 +01:00
antoniouaa
ebc4e200c1 fix keyerror with single element list passed to Tickers 2024-10-01 23:15:54 +01:00
ValueRaider
a8df88b2d2 Fix unit tests contextual imports 2024-10-01 21:24:51 +01:00
Eric Pien
048378ea20 Implement Screener
- Add a new class Screener, Query, and EquityQuery
- Refactor YfData.get() to enable YfData.post() to all of get's implementations
- Add test for the Screener
- Add new set and map to const

Screener can be used to filter yahoo finance. This can be used to get the top gainers of the day, and more customized queries that a user may want to automate.
2024-09-30 18:01:11 -07:00
ValueRaider
9e2252e451 Version 0.2.44 2024-09-30 19:57:57 +01:00
ValueRaider
4c3c228724 Merge pull request #2063 from ranaroussi/dev
sync dev -> main
2024-09-30 19:55:01 +01:00
ValueRaider
3535fb9ed7 Fix test fails in _fix_prices_sudden_change 2024-09-29 23:03:44 +01:00
ValueRaider
dd663a404a Merge pull request #2062 from ranaroussi/feature/improve-div-repair
Improve dividend repair
2024-09-29 20:32:54 +01:00
ValueRaider
ce530b0855 Improve dividend repair
Improve dividend repair:
- detect wrong date
- detect split missing from coincident dividend
- improve detecting adjust contradicting price action
- improve detecting when Close has adjustment
  (remove phantoms before, then use AdjClose -> AdjLow deltas)

Stop negative 'Adj Close' triggering a 'sudden change' repair.
2024-09-29 16:44:23 +01:00
ValueRaider
1890ff2b6d Merge pull request #2058 from ericpien/sectors
Feature Proposal: Support Sector and Industry data from Markets Tab
2024-09-22 17:53:39 +01:00
Eric Pien
3a0b6c2315 Implement Sector and Industry
Sector and Industry class to query the data available on: https://finance.yahoo.com/sectors/:
- sector / industry overview
- sector / industry top companies
- sector / industry research reports
- sector top ETFs
- sector top Mutual Funds
- industries within sector
- industry's sector
- industry's top performing companies
- industry's top growth companies
2024-09-22 08:35:12 -07:00
ValueRaider
676500854c Bug template: clarify 'bad data proof' 2024-09-21 11:56:54 +01:00
Marco Carvalho
f1d5c1d06f Update pyright.yml 2024-09-19 16:08:40 -03:00
Marco Carvalho
d65bf2d761 Update requirements.txt 2024-09-19 15:57:55 -03:00
Marco Carvalho
81deec0d6c Update pyrightconfig.json 2024-09-19 11:32:57 -03:00
Marco Carvalho
74f44a4e1e Update pyright.yml 2024-09-19 11:14:09 -03:00
Marco Carvalho
691904202b Create pyright.yml 2024-09-19 11:09:13 -03:00
Marco Carvalho
3fc54ab249 Create pyrightconfig.json 2024-09-19 11:08:56 -03:00
Marco Carvalho
d7c6f5f320 Update requirements.txt 2024-09-19 11:08:08 -03:00
ValueRaider
6b7a511765 Merge pull request #2041 from ericpien/funds
implement support for funds data
2024-09-08 12:53:20 +01:00
Eric Pien
f584b0c7d0 implementing support for funds data
- adding to scraper a new class FundsData.
- Ticker can now reference the data via ticker.funds_data when appropriate.
- Add unit tests in test_ticker.py for the funds data
2024-09-07 13:49:54 -07:00
ValueRaider
8cadad2cbb Merge pull request #2048 from ranaroussi/main
sync main -> dev
2024-09-04 21:44:28 +01:00
ValueRaider
3fe87cb132 Merge pull request #2039 from joncokisler/main
Fix typo in README.md #2038
2024-08-26 19:27:55 +01:00
Jon Cokisler
72684b1784 fix typo in README 2024-08-26 13:51:45 -04:00
ValueRaider
ed43f6fc09 Version 0.2.43 2024-08-24 21:37:58 +01:00
ValueRaider
f87a9affb3 Merge pull request #2036 from ranaroussi/fix/price-repair-currency-bug
Fix price-repair-currency, logic was inverted
2024-08-24 21:36:36 +01:00
ValueRaider
e329f267b2 Fix price-repair-currency, logic was inverted 2024-08-24 19:04:15 +01:00
ValueRaider
bd1a597a0c Version 0.2.42 2024-08-22 16:59:11 +01:00
ValueRaider
0193cec8bf Merge pull request #2034 from ranaroussi/dev
sync dev -> main
2024-08-22 16:53:14 +01:00
ValueRaider
a2b5d6bea9 Fix 2x old tests 2024-08-22 16:29:07 +01:00
ValueRaider
ce9becddbb Merge branch 'main' into dev 2024-08-22 16:12:15 +01:00
ValueRaider
7e12f2029f Merge pull request #2031 from ranaroussi/feature/price-repair-div-adjust
New: repair bad dividends and div-adjusts. Plus other repair fixes.
2024-08-22 16:03:13 +01:00
ValueRaider
a74ad474d9 Repair dividends: fine-tune logic + unit tests
Fix detecting div_adj_exceeds_prices.
Fine-tune fixing div_too_big.
Unit tests.
2024-08-22 15:47:10 +01:00
ValueRaider
2f5203d677 New: repair bad dividends and div-adjusts. Plus other repair fixes.
The new dividend repair logic looks for too big/small dividends/adjusts.
Because it analyses prices, it needs prices to be consistent - this means
for some exchanges, prices are converted to major currency e.g. pence -> £.
These exchanges are: .L, .TA, .JO
Also, multiday intervals are created by resampling adjusted 1d intervals.

Related change:
- _fix_prices_sudden_change() now fixes dividends with prices

Other repair fixes:
- add basic repair function to fix_Yahoo_returning_live_separate() to handle simple 100x price errors within same week/month
- fix _fix_prices_sudden_change() false positive on real massive price drop (clue = massive volume spike)
- price reconstruct fixes:
  - calibration: stop NaNs breaking, and detect currency unit mixup
  - fix a Pandas warning
2024-08-22 11:08:31 +01:00
ValueRaider
7c66bc374c Merge pull request #2032 from ranaroussi/revert/PR-2027-30m-resampling
Revert PR #2027, breaks with prepost=True
2024-08-22 11:08:07 +01:00
ValueRaider
a0dc25229b Update python-publish.yml to v4 for node20 2024-08-21 22:35:27 +01:00
ValueRaider
1baecc9d5b Revert PR #2027, breaks with prepost=True 2024-08-21 21:11:52 +01:00
ValueRaider
8b8db167f5 Update bug_report.yaml 2024-08-19 10:10:57 +01:00
ValueRaider
4941c619f4 Merge pull request #2023 from Fidasek009/feature/analysis
Implement Analysis (no scraping)
2024-08-16 19:25:48 +01:00
Filip Krása
9cf62894e8 Fix ruff complaining 2024-08-16 20:14:02 +02:00
Filip Krása
0c447d56d1 Update README.md with analysis attributes 2024-08-16 18:37:31 +02:00
Filip Krása
bc719627d1 Implement tests for Analysis 2024-08-16 17:40:40 +02:00
Filip Krása
408d0659e5 Implement Analysis 2024-08-16 17:37:55 +02:00
ValueRaider
67d6859384 Merge pull request #2027 from aleksfasting/fix/NSEI-quarter-offset
Solves #2026
2024-08-16 14:27:14 +01:00
Aleks Fasting
1037ec5b05 solves #2026
Solution that checks the offset of the opening time of the stock exchange (mod 30 minutes) and adds it to the quotes
2024-08-15 17:11:57 +02:00
ValueRaider
459d5f69c2 Merge pull request #2016 from mreiche/bugfix/mixed-tz-conversion
Fix datetime conversion with mixed timezones when ignore_tz is False
2024-08-12 20:29:54 +01:00
Mike Reiche
f13ff4bb4c Fix datetime conversion with mixed timezones when ignore_tz is False 2024-08-12 07:39:55 +02:00
ValueRaider
2b8716c72f Merge pull request #2021 from ericpien/address_issue_2015
Handle faulty response object when getting news.
2024-08-10 12:38:09 +01:00
Eric Pien
447ec68eff add try except for when requests.response.json() fails
- return empty set rather than raising an exception
2024-08-10 03:50:27 -07:00
ValueRaider
602fe2abe6 Merge pull request #2000 from ranaroussi/feature/prices-adjust-errors-and-logging
Prices: improve exceptions and logging
2024-08-10 11:42:43 +01:00
ValueRaider
ffe364268c Prices: improve exceptions & logging
Tidy messages sent to logging.INFO
Use logging's 'extra' argument to make YF log formatting programmatic.
Reclassify some YF price-repair log messages, so that repairs (or repair fails) are level INFO.
2024-08-10 11:40:36 +01:00
ValueRaider
cd18947284 Merge pull request #2020 from ericpien/dev
Fix minor typo
2024-08-10 11:26:03 +01:00
Eric Pien
76062dda22 fixing minor typo
%% -> %
2024-08-10 00:29:07 -07:00
ValueRaider
07329dbfd7 Merge pull request #2013 from ericpien/dev
use dict.get() to safely access key in Holders
2024-08-07 21:02:25 +01:00
ValueRaider
89e61bb118 Merge pull request #2009 from ranaroussi/feature/sec-filings
Implement fetch sec-filings
2024-08-06 22:36:34 +01:00
ThetisLake
d490fa3163 use dict.get() to safely access key
using .get() is safer than [key] and allows effective way to return non-None variable
2024-08-05 17:37:31 -07:00
ValueRaider
614906cc50 Implement fetch sec-filings 2024-08-03 15:16:45 +01:00
ValueRaider
fa3779896b Merge pull request #1995 from stevenbischoff/dev
Fix error on empty options chain
2024-07-24 22:21:52 +01:00
ValueRaider
59178f4402 Merge pull request #1998 from aaron-jencks/patch-1
Remove erroneous print statement
2024-07-22 18:47:14 +01:00
Aaron Jencks
ce6bf9378c Remove erroneous print statement 2024-07-22 11:29:31 -05:00
Steven Bischoff
d70c99ccfa Fix error on empty options chain
Signed-off-by: Steven Bischoff <61480100+stevenbischoff@users.noreply.github.com>
2024-07-19 15:12:43 -05:00
ValueRaider
2594eef3a3 Merge pull request #1994 from ranaroussi/main
main -> dev
2024-07-19 16:07:02 +01:00
489 changed files with 155355 additions and 1195 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -55,7 +55,7 @@ body:
id: debug-log
attributes:
label: "Debug log"
description: "Run code with debug logging enabled and post the full output. IMPORTANT INSTRUCTIONS: https://github.com/ranaroussi/yfinance/tree/main#logging"
description: "Run code with debug logging enabled - `yf.enable_debug_mode()` - and post the full output. Context: https://github.com/ranaroussi/yfinance/tree/main#logging"
validations:
required: true
@@ -63,7 +63,7 @@ body:
id: bad-data-proof
attributes:
label: "Bad data proof"
description: "If you think `yfinance` returning bad data, provide your proof here."
description: "If `yfinance` returning bad data, show proof here. Best is screenshot of finance.yahoo.com"
validations:
required: false

53
.github/workflows/deploy_doc.yml vendored Normal file
View File

@@ -0,0 +1,53 @@
name: Build and Deploy Sphinx Docs
on:
push:
branches:
- docs_markdown
jobs:
build:
runs-on: ubuntu-latest
env:
BUILD_DIR: "doc/_build/html"
DEPLOY_BRANCH: "docs_markdown"
DEPLOY_DIR: "docs"
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install Sphinx==8.0.2 pydata-sphinx-theme==0.15.4 Jinja2==3.1.4 sphinx-copybutton==0.5.2
- name: Build Sphinx documentation
run: |
sphinx-build -b html doc/source ${{ env.BUILD_DIR }} -v
- name: List generated HTML files
run: |
ls -l -R ${{ env.BUILD_DIR }}
- name: Publish to the Deploy Branch
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git checkout ${{ env.DEPLOY_BRANCH }}
mkdir -p ${{ env.DEPLOY_DIR }}
rm -rf ${{ env.DEPLOY_DIR }}/*
cp -r ${{ env.BUILD_DIR }}/* ${{ env.DEPLOY_DIR }}/
touch ${{ env.DEPLOY_DIR }}/.nojekyll
git add -f ${{ env.DEPLOY_DIR }}
git commit -m "Update documentation"
git push origin ${{ env.DEPLOY_BRANCH }}

27
.github/workflows/pyright.yml vendored Normal file
View File

@@ -0,0 +1,27 @@
name: Pyright
on:
pull_request:
branches:
- master
- main
- dev
jobs:
pyright:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyright
- name: Run Pyright
run: pyright . --level error

View File

@@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:

7
.gitignore vendored
View File

@@ -18,3 +18,10 @@ test.ipynb
env/
venv/
ENV/
# Documentation
/doc/build/
/doc/_build/
/doc/source/reference/api
!yfinance.css
!/doc/source/development/assets/branches.png

View File

@@ -1,6 +1,49 @@
Change Log
===========
0.2.46
------
Fix regression in 0.2.45 #2094
0.2.45
------
Features:
- Screener #2066 @ericpien
Fixes
- Tickers keyerror #2068 @antoniouaa
- IndexError in some history() debug messages #2087
- improve dividend repair #2090
Maintenance
- fix unit tests contextual imports #2067
- fix typos #2072 @algonell
- add Pyright type checking #2059 @marco-carvalho
0.2.44
------
Features:
- fetch funds #2041
- fetch sector & industry #2058
Fixes:
- improve dividend repair #2062
0.2.43
------
Fix price-repair bug introduced in 0.2.42 #2036
0.2.42
------
Features:
- fetch SEC filings #2009
- fetch analysis #2023 @Fidasek009
- price repair extended to dividends & adjust #2031
Fixes:
- fix error on empty options chain #1995 @stevenbischoff
- use dict.get() to safely access key in Holders #2013 @ericpien
- fix datetime conversion with mixed timezones when ignore_tz is False #2016 @mreiche
- handle faulty response object when getting news. #2021 @ericpien
Maintenance:
- prices: improve exceptions and logging #2000
0.2.41
------
Improvements:
@@ -333,7 +376,7 @@ Jumping to 0.2 for this big update. 0.1.* will continue to receive bug-fixes
- Fix timezone handling
- Fix handling of missing data
- Clean&format earnings_dates table
- Add ``.get_earnings_dates()`` to retreive earnings calendar
- Add ``.get_earnings_dates()`` to retrieve earnings calendar
- Added ``.get_earnings_history()`` to fetch earnings data
0.1.70
@@ -645,7 +688,7 @@ Jumping to 0.2 for this big update. 0.1.* will continue to receive bug-fixes
- Removed 5 second wait for every failed fetch
- Reduced TTL for Yahoo!'s cookie
- Keeps track of failed downloads and tries to re-download all failed downloads one more time before giving up
- Added progress bar (can be turned off useing ``progress=False``)
- Added progress bar (can be turned off using ``progress=False``)
0.0.7
-------

212
README.md
View File

@@ -28,7 +28,6 @@ Yahoo! finance API is intended for personal use only.**
<a target="new" href="https://pypi.python.org/pypi/yfinance"><img border=0 src="https://img.shields.io/pypi/v/yfinance.svg?maxAge=60%" alt="PyPi version"></a>
<a target="new" href="https://pypi.python.org/pypi/yfinance"><img border=0 src="https://img.shields.io/pypi/status/yfinance.svg?maxAge=60" alt="PyPi status"></a>
<a target="new" href="https://pypi.python.org/pypi/yfinance"><img border=0 src="https://img.shields.io/pypi/dm/yfinance.svg?maxAge=2592000&label=installs&color=%2327B1FF" alt="PyPi downloads"></a>
<a target="new" href="https://travis-ci.com/github/ranaroussi/yfinance"><img border=0 src="https://img.shields.io/travis/ranaroussi/yfinance/main.svg?maxAge=1" alt="Travis-CI build status"></a>
<a target="new" href="https://www.codefactor.io/repository/github/ranaroussi/yfinance"><img border=0 src="https://www.codefactor.io/repository/github/ranaroussi/yfinance/badge" alt="CodeFactor"></a>
<a target="new" href="https://github.com/ranaroussi/yfinance"><img border=0 src="https://img.shields.io/github/stars/ranaroussi/yfinance.svg?style=social&label=Star&maxAge=60" alt="Star this repo"></a>
<a target="new" href="https://twitter.com/aroussi"><img border=0 src="https://img.shields.io/twitter/follow/aroussi.svg?style=social&label=Follow&maxAge=60" alt="Follow me on twitter"></a>
@@ -36,19 +35,16 @@ Yahoo! finance API is intended for personal use only.**
**yfinance** offers a threaded and Pythonic way to download market data from [Yahoo!Ⓡ finance](https://finance.yahoo.com).
→ Check out this [Blog post](https://aroussi.com/#post/python-yahoo-finance) for a detailed tutorial with code examples.
## Main Features
- `Ticker` module: Class for accessing single ticker data.
- `Tickers` module: Class for handling multiple tickers.
- `download` Efficiently download market data for multiple tickers.
- `Sector` and `Industry` modules : Classes for accessing sector and industry information.
- Market Screening: `EquityQuery` and `Screener` to build query and screen the market.
- Caching and Smart Scraping
[Changelog »](https://github.com/ranaroussi/yfinance/blob/main/CHANGELOG.rst)
---
- [Installation](#installation)
- [Quick start](#quick-start)
- [Advanced](#logging)
- [Wiki](https://github.com/ranaroussi/yfinance/wiki)
- [Contribute](#developers-want-to-contribute)
---
## Documentation
The official documentation is available on [ranaroussi.github.io/yfinance](https://ranaroussi.github.io/yfinance/index.html)
## Installation
@@ -68,196 +64,10 @@ $ pip install "yfinance[optional]"
[Required dependencies](./requirements.txt) , [all dependencies](./setup.py#L62).
---
The list of changes can be found in the [changelog](https://github.com/ranaroussi/yfinance/blob/main/CHANGELOG.rst)
## Quick Start
### The Ticker module
The `Ticker` module, which allows you to access ticker data in a more Pythonic way:
```python
import yfinance as yf
msft = yf.Ticker("MSFT")
# get all stock info
msft.info
# get historical market data
hist = msft.history(period="1mo")
# show meta information about the history (requires history() to be called first)
msft.history_metadata
# show actions (dividends, splits, capital gains)
msft.actions
msft.dividends
msft.splits
msft.capital_gains # only for mutual funds & etfs
# show share count
msft.get_shares_full(start="2022-01-01", end=None)
# show financials:
# - income statement
msft.income_stmt
msft.quarterly_income_stmt
# - balance sheet
msft.balance_sheet
msft.quarterly_balance_sheet
# - cash flow statement
msft.cashflow
msft.quarterly_cashflow
# see `Ticker.get_income_stmt()` for more options
# show holders
msft.major_holders
msft.institutional_holders
msft.mutualfund_holders
msft.insider_transactions
msft.insider_purchases
msft.insider_roster_holders
msfs.sustainability
# show recommendations
msft.recommendations
msft.recommendations_summary
msft.upgrades_downgrades
# Show future and historic earnings dates, returns at most next 4 quarters and last 8 quarters by default.
# Note: If more are needed use msft.get_earnings_dates(limit=XX) with increased limit argument.
msft.earnings_dates
# show ISIN code - *experimental*
# ISIN = International Securities Identification Number
msft.isin
# show options expirations
msft.options
# show news
msft.news
# get option chain for specific expiration
opt = msft.option_chain('YYYY-MM-DD')
# data available via: opt.calls, opt.puts
```
If you want to use a proxy server for downloading data, use:
```python
import yfinance as yf
msft = yf.Ticker("MSFT")
msft.history(..., proxy="PROXY_SERVER")
msft.get_actions(proxy="PROXY_SERVER")
msft.get_dividends(proxy="PROXY_SERVER")
msft.get_splits(proxy="PROXY_SERVER")
msft.get_capital_gains(proxy="PROXY_SERVER")
msft.get_balance_sheet(proxy="PROXY_SERVER")
msft.get_cashflow(proxy="PROXY_SERVER")
msft.option_chain(..., proxy="PROXY_SERVER")
...
```
### Multiple tickers
To initialize multiple `Ticker` objects, use
```python
import yfinance as yf
tickers = yf.Tickers('msft aapl goog')
# access each ticker using (example)
tickers.tickers['MSFT'].info
tickers.tickers['AAPL'].history(period="1mo")
tickers.tickers['GOOG'].actions
```
To download price history into one table:
```python
import yfinance as yf
data = yf.download("SPY AAPL", period="1mo")
```
#### `yf.download()` and `Ticker.history()` have many options for configuring fetching and processing. [Review the Wiki](https://github.com/ranaroussi/yfinance/wiki) for more options and detail.
### Logging
`yfinance` now uses the `logging` module to handle messages, default behaviour is only print errors. If debugging, use `yf.enable_debug_mode()` to switch logging to debug with custom formatting.
### Smarter scraping
Install the `nospam` packages for smarter scraping using `pip` (see [Installation](#installation)). These packages help cache calls such that Yahoo is not spammed with requests.
To use a custom `requests` session, pass a `session=` argument to
the Ticker constructor. This allows for caching calls to the API as well as a custom way to modify requests via the `User-agent` header.
```python
import requests_cache
session = requests_cache.CachedSession('yfinance.cache')
session.headers['User-agent'] = 'my-program/1.0'
ticker = yf.Ticker('msft', session=session)
# The scraped response will be stored in the cache
ticker.actions
```
Combine `requests_cache` with rate-limiting to avoid triggering Yahoo's rate-limiter/blocker that can corrupt data.
```python
from requests import Session
from requests_cache import CacheMixin, SQLiteCache
from requests_ratelimiter import LimiterMixin, MemoryQueueBucket
from pyrate_limiter import Duration, RequestRate, Limiter
class CachedLimiterSession(CacheMixin, LimiterMixin, Session):
pass
session = CachedLimiterSession(
limiter=Limiter(RequestRate(2, Duration.SECOND*5)), # max 2 requests per 5 seconds
bucket_class=MemoryQueueBucket,
backend=SQLiteCache("yfinance.cache"),
)
```
### Managing Multi-Level Columns
The following answer on Stack Overflow is for [How to deal with
multi-level column names downloaded with
yfinance?](https://stackoverflow.com/questions/63107801)
- `yfinance` returns a `pandas.DataFrame` with multi-level column
names, with a level for the ticker and a level for the stock price
data
- The answer discusses:
- How to correctly read the the multi-level columns after
saving the dataframe to a csv with `pandas.DataFrame.to_csv`
- How to download single or multiple tickers into a single
dataframe with single level column names and a ticker column
### Persistent cache store
To reduce Yahoo, yfinance store some data locally: timezones to localize dates, and cookie. Cache location is:
- Windows = C:/Users/\<USER\>/AppData/Local/py-yfinance
- Linux = /home/\<USER\>/.cache/py-yfinance
- MacOS = /Users/\<USER\>/Library/Caches/py-yfinance
You can direct cache to use a different location with `set_tz_cache_location()`:
```python
import yfinance as yf
yf.set_tz_cache_location("custom/cache/location")
...
```
---
## Developers: want to contribute?
`yfinance` relies on community to investigate bugs and contribute code. Developer guide: https://github.com/ranaroussi/yfinance/discussions/1084
---
@@ -280,6 +90,6 @@ details on your rights to use the actual data downloaded.
### P.S.
Please drop me an note with any feedback you have.
Please drop me a note with any feedback you have.
**Ran Aroussi**

20
doc/Makefile Normal file
View File

@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

35
doc/make.bat Normal file
View File

@@ -0,0 +1,35 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)
if "%1" == "" goto help
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd

View File

@@ -0,0 +1,4 @@
/* Hide the "Section Navigation" title */
p.bd-links__title {
display: none;
}

View File

@@ -0,0 +1,30 @@
{{ fullname | escape | underline}}
.. currentmodule:: {{ module }}
.. autoclass:: {{ objname }}
{% block attributes %}
{% if attributes %}
.. rubric:: Attributes
.. autosummary::
:toctree: attributes
{% for item in attributes %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{% block methods %}
{% if methods %}
.. rubric:: Methods
.. autosummary::
:toctree: methods
{% for item in methods %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

45
doc/source/conf.py Normal file
View File

@@ -0,0 +1,45 @@
import os
import sys
sys.path.insert(0, os.path.abspath('../..'))
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = 'yfinance - market data downloader'
copyright = '2017-2019 Ran Aroussi'
author = 'Ran Aroussi'
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.napoleon',
"sphinx.ext.githubpages",
"sphinx.ext.autosectionlabel",
"sphinx.ext.autosummary",
"sphinx_copybutton"]
templates_path = ['_templates']
exclude_patterns = []
autoclass_content = 'both'
autosummary_generate = True
autodoc_default_options = {
'exclude-members': '__init__'
}
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_title = 'yfinance'
html_theme = 'pydata_sphinx_theme'
html_theme_options = {
"github_url": "https://github.com/ranaroussi/yfinance",
"navbar_align": "left"
}
html_static_path = ['_static']
html_css_files = ['yfinance.css']

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View File

@@ -0,0 +1,109 @@
********************************
Contributiong to yfinance
********************************
`yfinance` relies on the community to investigate bugs and contribute code. Heres how you can help:
Contributing
------------
1. Fork the repository on GitHub.
2. Clone your forked repository:
.. code-block:: bash
git clone https://github.com/your-username/yfinance.git
3. Create a new branch for your feature or bug fix:
.. code-block:: bash
git checkout -b feature-branch-name
4. Make your changes, commit them, and push your branch to GitHub. To keep the commit history and `network graph <https://github.com/ranaroussi/yfinance/network>`_ compact:
Use short summaries for commits
.. code-block:: shell
git commit -m "short summary" -m "full commit message"
**Squash** tiny or negligible commits with meaningful ones.
.. code-block:: shell
git rebase -i HEAD~2
git push --force-with-lease origin <branch-name>
5. Open a pull request on the `yfinance` GitHub page.
For more information, see the `Developer Guide <https://github.com/ranaroussi/yfinance/discussions/1084>`_.
Branches
---------
To support rapid development without breaking stable versions, this project uses a two-layer branch model:
.. image:: assets/branches.png
:alt: Branching Model
`Inspiration <https://miro.medium.com/max/700/1*2YagIpX6LuauC3ASpwHekg.png>`_
- **dev**: New features and some bug fixes are merged here. This branch allows collective testing, conflict resolution, and further stabilization before merging into the stable branch.
- **main**: Stable branch where PIP releases are created.
By default, branches target **main**, but most contributions should target **dev**.
**Exceptions**:
Direct merges to **main** are allowed if:
- `yfinance` is massively broken
- Part of `yfinance` is broken, and the fix is simple and isolated
Unit Tests
----------
Tests are written using Pythons `unittest` module. Here are some ways to run tests:
- **Run all price tests**:
.. code-block:: shell
python -m unittest tests.test_prices
- **Run a subset of price tests**:
.. code-block:: shell
python -m unittest tests.test_prices.TestPriceRepair
- **Run a specific test**:
.. code-block:: shell
python -m unittest tests.test_prices.TestPriceRepair.test_ticker_missing
- **Run all tests**:
.. code-block:: shell
python -m unittest discover -s tests
Rebasing
--------------
If asked to move your branch from **main** to **dev**:
1. Ensure all relevant branches are pulled.
2. Run:
.. code-block:: shell
git checkout <your-branch>
git rebase --onto dev main <branch-name>
git push --force-with-lease origin <branch-name>
Running the GitHub Version of yfinance
--------------------------------------
To download and run a GitHub version of `yfinance`, refer to `GitHub discussion <https://github.com/ranaroussi/yfinance/discussions/1080>`_

View File

@@ -0,0 +1,46 @@
*************************************
Contribution to the documentation
*************************************
.. contents:: Documentation:
:local:
About documentation
------------------------
* yfinance documentation is written in reStructuredText (rst) and built using Sphinx.
* The documentation file is in `doc/source/..`.
* Most of the notes under API References read from class and methods docstrings. These documentations, found in `doc/source/reference/api` is autogenerated by Sphinx and not included in git.
Building documentation locally
-------------------------------
To build the documentation locally, follow these steps:
1. **Install Required Dependencies**:
* Make sure `Sphinx` and any other dependencies are installed. If a `requirements.txt` file is available, you can install dependencies by running:
.. code-block:: console
pip install -r requirements.txt
2. **Build with Sphinx**:
* After dependencies are installed, use the sphinx-build command to generate HTML documentation.
* Go to `doc/` directory Run:
.. code-block:: console
make clean && make html
3. **View Documentation Locally**:
* Open `doc/build/html/index.html` in the browser to view the generated documentation.
Building documentation on main
-------------------------------
The documentation updates are built on merge to `main` branch. This is done via GitHub Actions workflow based on `/yfinance/.github/workflows/deploy_doc.yml`.
1. Reivew the changes locally and push to `dev`.
2. When `dev` gets merged to `main`, GitHub Actions workflow is automated to build documentation.

View File

@@ -0,0 +1,9 @@
Development
===============================
.. toctree::
:maxdepth: 1
contributing
documentation
reporting_bug

View File

@@ -0,0 +1,5 @@
********************************
Reporting a Bug
********************************
Open a new issue on our `GitHub <https://github.com/ranaroussi/yfinance/issues>`_.

View File

@@ -0,0 +1,9 @@
Getting Started
===============
.. toctree::
:maxdepth: 1
installation
quick_start
legal

View File

@@ -0,0 +1,17 @@
********************
Installation Guide
********************
Install `yfinance` using `pip`:
.. code-block:: bash
$ pip install yfinance --upgrade --no-cache-dir
To install with optional dependencies, replace `optional` with: `nospam` for `caching-requests <https://github.com/ranaroussi/yfinance?tab=readme-ov-file#smarter-scraping>`_, `repair` for `price repair <https://github.com/ranaroussi/yfinance/wiki/Price-repair>`_, or `nospam`, `repair` for both:
.. code-block:: bash
$ pip install "yfinance[optional]"
For required dependencies, check out the `requirements file <./requirements.txt>`_, and for all dependencies, see the `setup.py file <./setup.py#L62>`_.

View File

@@ -0,0 +1,12 @@
********************
Legal Information
********************
yfinance is distributed under the Apache Software License. See the `LICENSE.txt <../../../../LICENSE.txt>`_ file for details.
Again, yfinance 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.
Refer to Yahoo!'s terms of use:
- `API Terms <https://policies.yahoo.com/us/en/yahoo/terms/product-atos/apiforydn/index.htm>`_
- `Yahoo Terms <https://legal.yahoo.com/us/en/yahoo/terms/otos/index.html>`_

View File

@@ -0,0 +1,30 @@
********************
Quick Start
********************
The Ticker module allows you to access ticker data in a more Pythonic way:
.. code-block:: python
import yfinance as yf
msft = yf.Ticker("MSFT")
# get all stock info
msft.info
# get historical market data
hist = msft.history(period="1mo")
# show actions (dividends, splits, capital gains)
msft.actions
msft.dividends
msft.splits
To work with multiple tickers, use:
.. code-block:: python
tickers = yf.Tickers('msft aapl goog')
tickers.tickers['MSFT'].info
tickers.tickers['AAPL'].history(period="1mo")

30
doc/source/index.rst Normal file
View File

@@ -0,0 +1,30 @@
yfinance documentation
==============================================
Download Market Data from Yahoo! Finance's API
------------------------------------------------
.. admonition:: IMPORTANT LEGAL DISCLAIMER
**Yahoo!, Y!Finance, and Yahoo! finance are registered trademarks of Yahoo, Inc.**
yfinance 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.
.. toctree::
:maxdepth: 3
:hidden:
:titlesonly:
getting_started/index
user_guide/index
reference/index
development/index

View File

@@ -0,0 +1,2 @@
import yfinance as yf
data = yf.download("SPY AAPL", period="1mo")

View File

@@ -0,0 +1,18 @@
import yfinance as yf
spy = yf.Ticker('SPY')
data = spy.funds_data
# show fund description
data.description
# show operational information
data.fund_overview
data.fund_operations
# show holdings related information
data.asset_classes
data.top_holdings
data.equity_holdings
data.bond_holdings
data.bond_ratings
data.sector_weightings

View File

@@ -0,0 +1,13 @@
import yfinance as yf
msft = yf.Ticker("MSFT")
msft.history(..., proxy="PROXY_SERVER")
msft.get_actions(proxy="PROXY_SERVER")
msft.get_dividends(proxy="PROXY_SERVER")
msft.get_splits(proxy="PROXY_SERVER")
msft.get_capital_gains(proxy="PROXY_SERVER")
msft.get_balance_sheet(proxy="PROXY_SERVER")
msft.get_cashflow(proxy="PROXY_SERVER")
msft.option_chain(..., proxy="PROXY_SERVER")
...

View File

@@ -0,0 +1,25 @@
import yfinance as yf
tech = yf.Sector('technology')
software = yf.Industry('software-infrastructure')
# Common information
tech.key
tech.name
tech.symbol
tech.ticker
tech.overview
tech.top_companies
tech.research_reports
# Sector information
tech.top_etfs
tech.top_mutual_funds
tech.industries
# Industry information
software.sector_key
software.sector_name
software.top_performing_companies
software.top_growth_companies

View File

@@ -0,0 +1,11 @@
import yfinance as yf
# Ticker to Sector and Industry
msft = yf.Ticker('MSFT')
tech = yf.Sector(msft.info.get('sectorKey'))
software = yf.Industry(msft.info.get('industryKey'))
# Sector and Industry to Ticker
tech_ticker = tech.ticker
tech_ticker.info
software_ticker = software.ticker
software_ticker.history()

View File

@@ -0,0 +1,77 @@
import yfinance as yf
msft = yf.Ticker("MSFT")
# get all stock info
msft.info
# get historical market data
hist = msft.history(period="1mo")
# show meta information about the history (requires history() to be called first)
msft.history_metadata
# show actions (dividends, splits, capital gains)
msft.actions
msft.dividends
msft.splits
msft.capital_gains # only for mutual funds & etfs
# show share count
msft.get_shares_full(start="2022-01-01", end=None)
# show financials:
msft.calendar
msft.sec_filings
# - income statement
msft.income_stmt
msft.quarterly_income_stmt
# - balance sheet
msft.balance_sheet
msft.quarterly_balance_sheet
# - cash flow statement
msft.cashflow
msft.quarterly_cashflow
# see `Ticker.get_income_stmt()` for more options
# show holders
msft.major_holders
msft.institutional_holders
msft.mutualfund_holders
msft.insider_transactions
msft.insider_purchases
msft.insider_roster_holders
msft.sustainability
# show recommendations
msft.recommendations
msft.recommendations_summary
msft.upgrades_downgrades
# show analysts data
msft.analyst_price_targets
msft.earnings_estimate
msft.revenue_estimate
msft.earnings_history
msft.eps_trend
msft.eps_revisions
msft.growth_estimates
# Show future and historic earnings dates, returns at most next 4 quarters and last 8 quarters by default.
# Note: If more are needed use msft.get_earnings_dates(limit=XX) with increased limit argument.
msft.earnings_dates
# show ISIN code - *experimental*
# ISIN = International Securities Identification Number
msft.isin
# show options expirations
msft.options
# show news
msft.news
# get option chain for specific expiration
opt = msft.option_chain('YYYY-MM-DD')
# data available via: opt.calls, opt.puts

View File

@@ -0,0 +1,8 @@
import yfinance as yf
tickers = yf.Tickers('msft aapl goog')
# access each ticker using (example)
tickers.tickers['MSFT'].info
tickers.tickers['AAPL'].history(period="1mo")
tickers.tickers['GOOG'].actions

View File

@@ -0,0 +1,33 @@
=======================
API Reference
=======================
Overview
--------
The `yfinance` package provides easy access to Yahoo! Finance's API to retrieve market data. It includes classes and functions for downloading historical market data, accessing ticker information, managing cache, and more.
Public API
==========
The following are the publicly available classes, and functions exposed by the `yfinance` package:
- :attr:`Ticker <yfinance.Ticker>`: Class for accessing single ticker data.
- :attr:`Tickers <yfinance.Tickers>`: Class for handling multiple tickers.
- :attr:`Sector <yfinance.Sector>`: Domain class for accessing sector information.
- :attr:`Industry <yfinance.Industry>`: Domain class for accessing industry information.
- :attr:`download <yfinance.download>`: Function to download market data for multiple tickers.
- :attr:`EquityQuery <yfinance.EquityQuery>`: Class to build equity market query.
- :attr:`Screener <yfinance.Screener>`: Class to screen the market using defined query.
- :attr:`enable_debug_mode <yfinance.enable_debug_mode>`: Function to enable debug mode for logging.
- :attr:`set_tz_cache_location <yfinance.set_tz_cache_location>`: Function to set the timezone cache location.
.. toctree::
:maxdepth: 1
:hidden:
yfinance.ticker_tickers
yfinance.sector_industry
yfinance.functions

View File

@@ -0,0 +1,51 @@
=========================
Functions and Utilities
=========================
.. currentmodule:: yfinance
Download Market Data
~~~~~~~~~~~~~~~~~~~~~
The `download` function allows you to retrieve market data for multiple tickers at once.
.. autosummary::
:toctree: api/
download
Query Market Data
~~~~~~~~~~~~~~~~~~~~~
The `Sector` and `Industry` modules allow you to access the sector and industry information.
.. autosummary::
:toctree: api/
EquityQuery
Screener
.. seealso::
:attr:`EquityQuery.valid_operand_fields <yfinance.EquityQuery.valid_operand_fields>`
supported operand values for query
:attr:`EquityQuery.valid_eq_operand_map <yfinance.EquityQuery.valid_eq_operand_map>`
supported `EQ query operand parameters`
:attr:`Screener.predefined_bodies <yfinance.Screener.predefined_bodies>`
supported predefined screens
Enable Debug Mode
~~~~~~~~~~~~~~~~~
Enables logging of debug information for the `yfinance` package.
.. autosummary::
:toctree: api/
enable_debug_mode
Set Timezone Cache Location
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets the cache location for timezone data.
.. autosummary::
:toctree: api/
set_tz_cache_location

View File

@@ -0,0 +1,32 @@
=======================
Sector and Industry
=======================
.. currentmodule:: yfinance
Class
------------
The `Sector` and `Industry` modules provide access to the Sector and Industry information.
.. autosummary::
:toctree: api/
:recursive:
Sector
Industry
.. seealso::
:attr:`Sector.industries <yfinance.Sector.industries>`
Map of sector and industry
Sample Code
------------
To initialize, use the relevant sector or industry key as below.
.. literalinclude:: examples/sector_industry.py
:language: python
The modules can be chained with Ticker as below.
.. literalinclude:: examples/sector_industry_ticker.py
:language: python

View File

@@ -0,0 +1,46 @@
=====================
Ticker and Tickers
=====================
.. currentmodule:: yfinance
Class
------------
The `Ticker` module, allows you to access ticker data in a Pythonic way.
.. autosummary::
:toctree: api/
Ticker
Tickers
Sample Code
------------
The `Ticker` module, allows you to access ticker data in a Pythonic way.
.. literalinclude:: examples/ticker.py
:language: python
To initialize multiple `Ticker` objects, use
.. literalinclude:: examples/tickers.py
:language: python
For tickers that are ETFs/Mutual Funds, `Ticker.funds_data` provides access to fund related data.
Funds' Top Holdings and other data with category average is returned as `pd.DataFrame`.
.. literalinclude:: examples/funds_data.py
:language: python
If you want to use a proxy server for downloading data, use:
.. literalinclude:: examples/proxy.py
:language: python
To initialize multiple `Ticker` objects, use `Tickers` module
.. literalinclude:: examples/tickers.py
:language: python

View File

@@ -0,0 +1,11 @@
User Guide
==========
.. toctree::
:maxdepth: 1
logging
proxy
smart_scraping
persistent_cache
multi_level_columns

View File

@@ -0,0 +1,11 @@
Logging in yfinance
===================
`yfinance` uses the `logging` module to handle messages. By default, only errors are logged.
If debugging, you can switch to debug mode with custom formatting using:
.. code-block:: python
import yfinance as yf
yf.enable_debug_mode()

View File

@@ -0,0 +1,13 @@
******************************
Managing Multi-Level Columns
******************************
The following answer on Stack Overflow is for `How to deal with
multi-level column names downloaded with yfinance? <https://stackoverflow.com/questions/63107801>`_
- `yfinance` returns a `pandas.DataFrame` with multi-level column names, with a level for the ticker and a level for the stock price data
The answer discusses:
- How to correctly read the the multi-level columns after saving the dataframe to a csv with `pandas.DataFrame.to_csv`
- How to download single or multiple tickers into a singledataframe with single level column names and a ticker column

View File

@@ -0,0 +1,16 @@
******************************
Persistent Cache Store
******************************
To reduce Yahoo, yfinance store some data locally: timezones to localize dates, and cookie. Cache location is:
- Windows = C:/Users/\<USER\>/AppData/Local/py-yfinance
- Linux = /home/\<USER\>/.cache/py-yfinance
- MacOS = /Users/\<USER\>/Library/Caches/py-yfinance
You can direct cache to use a different location with `set_tz_cache_location()`:
.. code-block:: python
import yfinance as yf
yf.set_tz_cache_location("custom/cache/location")

View File

@@ -0,0 +1,11 @@
*********************
Using a Proxy Server
*********************
You can download data via a proxy:
.. code-block:: python
msft = yf.Ticker("MSFT")
msft.history(..., proxy="PROXY_SERVER")

View File

@@ -0,0 +1,41 @@
******************************
Smarter Scraping with Caching
******************************
Install the `nospam` package to cache API calls and reduce spam to Yahoo:
.. code-block:: bash
pip install yfinance[nospam]
To use a custom `requests` session, pass a `session=` argument to
the Ticker constructor. This allows for caching calls to the API as well as a custom way to modify requests via the `User-agent` header.
.. code-block:: python
import requests_cache
session = requests_cache.CachedSession('yfinance.cache')
session.headers['User-agent'] = 'my-program/1.0'
ticker = yf.Ticker('MSFT', session=session)
# The scraped response will be stored in the cache
ticker.actions
Combine `requests_cache` with rate-limiting to avoid triggering Yahoo's rate-limiter/blocker that can corrupt data.
.. code-block:: python
from requests import Session
from requests_cache import CacheMixin, SQLiteCache
from requests_ratelimiter import LimiterMixin, MemoryQueueBucket
from pyrate_limiter import Duration, RequestRate, Limiter
class CachedLimiterSession(CacheMixin, LimiterMixin, Session):
pass
session = CachedLimiterSession(
limiter=Limiter(RequestRate(2, Duration.SECOND*5)), # max 2 requests per 5 seconds
bucket_class=MemoryQueueBucket,
backend=SQLiteCache("yfinance.cache"),
)

0
docs/.nojekyll Normal file
View File

BIN
docs/_images/branches.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View File

@@ -0,0 +1,109 @@
********************************
Contributiong to yfinance
********************************
`yfinance` relies on the community to investigate bugs and contribute code. Heres how you can help:
Contributing
------------
1. Fork the repository on GitHub.
2. Clone your forked repository:
.. code-block:: bash
git clone https://github.com/your-username/yfinance.git
3. Create a new branch for your feature or bug fix:
.. code-block:: bash
git checkout -b feature-branch-name
4. Make your changes, commit them, and push your branch to GitHub. To keep the commit history and `network graph <https://github.com/ranaroussi/yfinance/network>`_ compact:
Use short summaries for commits
.. code-block:: shell
git commit -m "short summary" -m "full commit message"
**Squash** tiny or negligible commits with meaningful ones.
.. code-block:: shell
git rebase -i HEAD~2
git push --force-with-lease origin <branch-name>
5. Open a pull request on the `yfinance` GitHub page.
For more information, see the `Developer Guide <https://github.com/ranaroussi/yfinance/discussions/1084>`_.
Branches
---------
To support rapid development without breaking stable versions, this project uses a two-layer branch model:
.. image:: assets/branches.png
:alt: Branching Model
`Inspiration <https://miro.medium.com/max/700/1*2YagIpX6LuauC3ASpwHekg.png>`_
- **dev**: New features and some bug fixes are merged here. This branch allows collective testing, conflict resolution, and further stabilization before merging into the stable branch.
- **main**: Stable branch where PIP releases are created.
By default, branches target **main**, but most contributions should target **dev**.
**Exceptions**:
Direct merges to **main** are allowed if:
- `yfinance` is massively broken
- Part of `yfinance` is broken, and the fix is simple and isolated
Unit Tests
----------
Tests are written using Pythons `unittest` module. Here are some ways to run tests:
- **Run all price tests**:
.. code-block:: shell
python -m unittest tests.test_prices
- **Run a subset of price tests**:
.. code-block:: shell
python -m unittest tests.test_prices.TestPriceRepair
- **Run a specific test**:
.. code-block:: shell
python -m unittest tests.test_prices.TestPriceRepair.test_ticker_missing
- **Run all tests**:
.. code-block:: shell
python -m unittest discover -s tests
Rebasing
--------------
If asked to move your branch from **main** to **dev**:
1. Ensure all relevant branches are pulled.
2. Run:
.. code-block:: shell
git checkout <your-branch>
git rebase --onto dev main <branch-name>
git push --force-with-lease origin <branch-name>
Running the GitHub Version of yfinance
--------------------------------------
To download and run a GitHub version of `yfinance`, refer to `GitHub discussion <https://github.com/ranaroussi/yfinance/discussions/1080>`_

View File

@@ -0,0 +1,46 @@
*************************************
Contribution to the documentation
*************************************
.. contents:: Documentation:
:local:
About documentation
------------------------
* yfinance documentation is written in reStructuredText (rst) and built using Sphinx.
* The documentation file is in `doc/source/..`.
* Most of the notes under API References read from class and methods docstrings. These documentations, found in `doc/source/reference/api` is autogenerated by Sphinx and not included in git.
Building documentation locally
-------------------------------
To build the documentation locally, follow these steps:
1. **Install Required Dependencies**:
* Make sure `Sphinx` and any other dependencies are installed. If a `requirements.txt` file is available, you can install dependencies by running:
.. code-block:: console
pip install -r requirements.txt
2. **Build with Sphinx**:
* After dependencies are installed, use the sphinx-build command to generate HTML documentation.
* Go to `doc/` directory Run:
.. code-block:: console
make clean && make html
3. **View Documentation Locally**:
* Open `doc/build/html/index.html` in the browser to view the generated documentation.
Building documentation on main
-------------------------------
The documentation updates are built on merge to `main` branch. This is done via GitHub Actions workflow based on `/yfinance/.github/workflows/deploy_doc.yml`.
1. Reivew the changes locally and push to `dev`.
2. When `dev` gets merged to `main`, GitHub Actions workflow is automated to build documentation.

View File

@@ -0,0 +1,9 @@
Development
===============================
.. toctree::
:maxdepth: 1
contributing
documentation
reporting_bug

View File

@@ -0,0 +1,5 @@
********************************
Reporting a Bug
********************************
Open a new issue on our `GitHub <https://github.com/ranaroussi/yfinance/issues>`_.

View File

@@ -0,0 +1,9 @@
Getting Started
===============
.. toctree::
:maxdepth: 1
installation
quick_start
legal

View File

@@ -0,0 +1,17 @@
********************
Installation Guide
********************
Install `yfinance` using `pip`:
.. code-block:: bash
$ pip install yfinance --upgrade --no-cache-dir
To install with optional dependencies, replace `optional` with: `nospam` for `caching-requests <https://github.com/ranaroussi/yfinance?tab=readme-ov-file#smarter-scraping>`_, `repair` for `price repair <https://github.com/ranaroussi/yfinance/wiki/Price-repair>`_, or `nospam`, `repair` for both:
.. code-block:: bash
$ pip install "yfinance[optional]"
For required dependencies, check out the `requirements file <./requirements.txt>`_, and for all dependencies, see the `setup.py file <./setup.py#L62>`_.

View File

@@ -0,0 +1,12 @@
********************
Legal Information
********************
yfinance is distributed under the Apache Software License. See the `LICENSE.txt <../../../../LICENSE.txt>`_ file for details.
Again, yfinance 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.
Refer to Yahoo!'s terms of use:
- `API Terms <https://policies.yahoo.com/us/en/yahoo/terms/product-atos/apiforydn/index.htm>`_
- `Yahoo Terms <https://legal.yahoo.com/us/en/yahoo/terms/otos/index.html>`_

View File

@@ -0,0 +1,30 @@
********************
Quick Start
********************
The Ticker module allows you to access ticker data in a more Pythonic way:
.. code-block:: python
import yfinance as yf
msft = yf.Ticker("MSFT")
# get all stock info
msft.info
# get historical market data
hist = msft.history(period="1mo")
# show actions (dividends, splits, capital gains)
msft.actions
msft.dividends
msft.splits
To work with multiple tickers, use:
.. code-block:: python
tickers = yf.Tickers('msft aapl goog')
tickers.tickers['MSFT'].info
tickers.tickers['AAPL'].history(period="1mo")

View File

@@ -0,0 +1,30 @@
yfinance documentation
==============================================
Download Market Data from Yahoo! Finance's API
------------------------------------------------
.. admonition:: IMPORTANT LEGAL DISCLAIMER
**Yahoo!, Y!Finance, and Yahoo! finance are registered trademarks of Yahoo, Inc.**
yfinance 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.
.. toctree::
:maxdepth: 3
:hidden:
:titlesonly:
getting_started/index
user_guide/index
reference/index
development/index

View File

@@ -0,0 +1,6 @@
yfinance.EquityQuery.valid\_eq\_operand\_map
============================================
.. currentmodule:: yfinance
.. autoproperty:: EquityQuery.valid_eq_operand_map

View File

@@ -0,0 +1,6 @@
yfinance.EquityQuery.valid\_operand\_fields
===========================================
.. currentmodule:: yfinance
.. autoproperty:: EquityQuery.valid_operand_fields

View File

@@ -0,0 +1,6 @@
yfinance.Industry.key
=====================
.. currentmodule:: yfinance
.. autoproperty:: Industry.key

View File

@@ -0,0 +1,6 @@
yfinance.Industry.name
======================
.. currentmodule:: yfinance
.. autoproperty:: Industry.name

View File

@@ -0,0 +1,6 @@
yfinance.Industry.overview
==========================
.. currentmodule:: yfinance
.. autoproperty:: Industry.overview

View File

@@ -0,0 +1,6 @@
yfinance.Industry.research\_reports
===================================
.. currentmodule:: yfinance
.. autoproperty:: Industry.research_reports

View File

@@ -0,0 +1,6 @@
yfinance.Industry.sector\_key
=============================
.. currentmodule:: yfinance
.. autoproperty:: Industry.sector_key

View File

@@ -0,0 +1,6 @@
yfinance.Industry.sector\_name
==============================
.. currentmodule:: yfinance
.. autoproperty:: Industry.sector_name

View File

@@ -0,0 +1,6 @@
yfinance.Industry.symbol
========================
.. currentmodule:: yfinance
.. autoproperty:: Industry.symbol

View File

@@ -0,0 +1,6 @@
yfinance.Industry.ticker
========================
.. currentmodule:: yfinance
.. autoproperty:: Industry.ticker

View File

@@ -0,0 +1,6 @@
yfinance.Industry.top\_companies
================================
.. currentmodule:: yfinance
.. autoproperty:: Industry.top_companies

View File

@@ -0,0 +1,6 @@
yfinance.Industry.top\_growth\_companies
========================================
.. currentmodule:: yfinance
.. autoproperty:: Industry.top_growth_companies

View File

@@ -0,0 +1,6 @@
yfinance.Industry.top\_performing\_companies
============================================
.. currentmodule:: yfinance
.. autoproperty:: Industry.top_performing_companies

View File

@@ -0,0 +1,6 @@
yfinance.Screener.body
======================
.. currentmodule:: yfinance
.. autoproperty:: Screener.body

View File

@@ -0,0 +1,6 @@
yfinance.Screener.predefined\_bodies
====================================
.. currentmodule:: yfinance
.. autoproperty:: Screener.predefined_bodies

View File

@@ -0,0 +1,6 @@
yfinance.Screener.response
==========================
.. currentmodule:: yfinance
.. autoproperty:: Screener.response

View File

@@ -0,0 +1,6 @@
yfinance.Sector.industries
==========================
.. currentmodule:: yfinance
.. autoproperty:: Sector.industries

View File

@@ -0,0 +1,6 @@
yfinance.Sector.key
===================
.. currentmodule:: yfinance
.. autoproperty:: Sector.key

View File

@@ -0,0 +1,6 @@
yfinance.Sector.name
====================
.. currentmodule:: yfinance
.. autoproperty:: Sector.name

View File

@@ -0,0 +1,6 @@
yfinance.Sector.overview
========================
.. currentmodule:: yfinance
.. autoproperty:: Sector.overview

View File

@@ -0,0 +1,6 @@
yfinance.Sector.research\_reports
=================================
.. currentmodule:: yfinance
.. autoproperty:: Sector.research_reports

View File

@@ -0,0 +1,6 @@
yfinance.Sector.symbol
======================
.. currentmodule:: yfinance
.. autoproperty:: Sector.symbol

View File

@@ -0,0 +1,6 @@
yfinance.Sector.ticker
======================
.. currentmodule:: yfinance
.. autoproperty:: Sector.ticker

View File

@@ -0,0 +1,6 @@
yfinance.Sector.top\_companies
==============================
.. currentmodule:: yfinance
.. autoproperty:: Sector.top_companies

View File

@@ -0,0 +1,6 @@
yfinance.Sector.top\_etfs
=========================
.. currentmodule:: yfinance
.. autoproperty:: Sector.top_etfs

View File

@@ -0,0 +1,6 @@
yfinance.Sector.top\_mutual\_funds
==================================
.. currentmodule:: yfinance
.. autoproperty:: Sector.top_mutual_funds

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.actions
=======================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.actions

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.analyst\_price\_targets
=======================================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.analyst_price_targets

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.balance\_sheet
==============================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.balance_sheet

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.balancesheet
============================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.balancesheet

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.basic\_info
===========================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.basic_info

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.calendar
========================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.calendar

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.capital\_gains
==============================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.capital_gains

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.cash\_flow
==========================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.cash_flow

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.cashflow
========================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.cashflow

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.dividends
=========================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.dividends

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.earnings
========================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.earnings

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.earnings\_dates
===============================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.earnings_dates

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.earnings\_estimate
==================================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.earnings_estimate

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.earnings\_history
=================================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.earnings_history

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.eps\_revisions
==============================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.eps_revisions

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.eps\_trend
==========================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.eps_trend

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.fast\_info
==========================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.fast_info

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.financials
==========================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.financials

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.funds\_data
===========================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.funds_data

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.growth\_estimates
=================================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.growth_estimates

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.history\_metadata
=================================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.history_metadata

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.income\_stmt
============================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.income_stmt

View File

@@ -0,0 +1,6 @@
yfinance.Ticker.incomestmt
==========================
.. currentmodule:: yfinance
.. autoproperty:: Ticker.incomestmt

Some files were not shown because too many files have changed in this diff Show More