Compare commits

...

213 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
ValueRaider
30abd89474 README: add new 'sustainability' attribute 2024-07-19 16:00:52 +01:00
ValueRaider
26697c25de Version 0.2.41 2024-07-19 15:57:45 +01:00
ValueRaider
3e9a77a7f7 Merge pull request #1971 from ranaroussi/dev
dev -> main
2024-07-19 15:50:08 +01:00
ValueRaider
7ca6b10a63 Fix typo in merged branch feature/price-repair-zeroes-improve 2024-07-19 10:39:28 +01:00
ValueRaider
d024dbb012 Merge pull request #1989 from ranaroussi/fix/price-repair-syntax-error-fixes
Fix: price repair syntax errors
2024-07-18 21:33:00 +01:00
ValueRaider
862ef7c78d Merge pull request #1990 from ranaroussi/feature/price-repair-zeroes-improve
Price repair zeroes: improve for 1d+ data
2024-07-18 21:32:24 +01:00
ValueRaider
d948db7344 Price repair zeroes: improve for 1d+ data
If 1d/1wk close changes without volume, tag as bad for repair.
2024-07-18 21:26:01 +01:00
ValueRaider
c894b9e595 Price repair: fix 2x syntax errors 2024-07-18 21:07:55 +01:00
ValueRaider
0681a777b8 Tests small fixes + fix another Pandas warning 2024-07-15 21:33:03 +01:00
ValueRaider
96279b932b Merge pull request #1981 from ranaroussi/fix/pandas-warnings
Prices: fix some Pandas deprecation warnings
2024-07-15 20:55:15 +01:00
ValueRaider
b0e9e917fe Merge pull request #1985 from rhwvu/main
Rebased: Adding various financials to const.py
2024-07-15 20:51:13 +01:00
R. W
d219e841b3 const.py addition 2024-07-15 15:02:43 -04:00
ValueRaider
a73e974d19 Merge pull request #1977 from ranaroussi/fix/earnings
Deprecate Ticker.earnings
2024-07-13 18:46:21 +01:00
ValueRaider
2e48495a9b Fix deprecation warnings not printing. Remove deprecated info code. 2024-07-13 18:45:35 +01:00
ValueRaider
742cc85a0c Prices: fix some Pandas deprecation warnings 2024-07-13 18:30:38 +01:00
ValueRaider
9c89308780 Merge pull request #1967 from SnowCheetos/preiod_max_fix
fixed history fetching when period='max'
2024-07-06 19:55:02 +01:00
ValueRaider
4160fec989 Clarify max period when interval=60m/1h. Tidy. 2024-07-06 19:51:14 +01:00
ValueRaider
57dac67b0e Deprecate 'Ticker.earnings' 2024-07-05 17:40:15 +01:00
SnowCheetos
b1d56ac235 directly subtracted seconds, kept 99 years impl as on main branch 2024-07-03 11:17:03 -05:00
ValueRaider
6be7cc311b Merge pull request #1970 from ranaroussi/fix/history-metadata
history metadata: Fix '1wk is invalid' & repeated calls
2024-06-28 14:01:24 +01:00
ValueRaider
a9f6c3346b history metadata: Fix '1wk is invalid' & repeated calls 2024-06-28 14:00:12 +01:00
zhihaos2
a42a5b75d6 fixed history fetching when period='max' 2024-06-25 13:37:13 -05:00
ValueRaider
2d5978e4d8 Merge pull request #1965 from vittoboa/add-loss-adjustment-expense
Add pull of "Loss Adjustment Expense" as part of Income Statement
2024-06-21 21:58:37 +01:00
vittoboa
17b4518e6a Add pull of Loss Adjustment Expense data in income statement 2024-06-20 23:53:45 +02:00
ValueRaider
2b1dd86c2b Merge pull request #1959 from MohamedAlaa201/mohamed/sustainibillity_implementation
Sustainability Fetching Implementation
2024-06-13 21:13:06 +01:00
Darksinian
ead2b894e4 Implement Sustainibility Fetching 2024-06-13 13:36:29 -04:00
ValueRaider
b27b88caff Merge pull request #1955 from lp177/patch-1 2024-06-04 13:51:06 +01:00
lp177
5d6981346e Fix 'T' is deprecated
site-packages/yfinance/scrapers/history.py:239: FutureWarning: 'T' is deprecated and will be removed in a future version, please use 'min' instead.
2024-06-01 07:57:41 +02:00
ValueRaider
19f9760599 Merge pull request #1946 from ranaroussi/main
sync main -> dev
2024-05-20 19:16:25 +01:00
ValueRaider
930b305327 Version 0.2.40 2024-05-19 17:25:01 +01:00
ValueRaider
7af213dea2 Fix unmatched quotes (0.2.39 regression) 2024-05-19 17:21:59 +01:00
ValueRaider
049337327e Version 0.2.39 2024-05-19 15:14:45 +01:00
ValueRaider
e65ca40d95 Merge pull request #1927 from ranaroussi/dev
sync dev -> main
2024-05-19 15:10:34 +01:00
ValueRaider
fe00fd5152 Ruff fixes 2024-05-19 15:09:57 +01:00
ValueRaider
cb691df586 Merge pull request #1941 from ranaroussi/main
sync main -> dev
2024-05-19 15:07:18 +01:00
ValueRaider
4bc546cb71 Update ci.yml to Node20 2024-05-19 15:05:35 +01:00
ValueRaider
f3c9f9962d Fix tests ; Fine-tune split repair ; Fix UTC warning 2024-05-19 15:01:52 +01:00
ValueRaider
da1c466550 Merge pull request #1931 from ranaroussi/feature/improve-price-repair-bad-splits
Price repair: improve 'sudden change' repair for splits & currency
2024-05-19 11:40:18 +01:00
ValueRaider
97f35b721c Price repair: improve 'sudden change' repair for splits & currency
Original logic for repairing missing split adjustment only checked latest split.
Improved logic checks ALL splits in data, because any can be missing.

Then related changes to 'sudden change detection':
- use prices median not mean, reduce sensitivity to noise.
- handle Kuwait Dinar, which sub-divides into 1000x not 100x.
2024-05-19 11:39:03 +01:00
ValueRaider
7c41434f44 Merge pull request #1930 from ranaroussi/fix/session-switching
Fix switching session from/to requests_cache
2024-05-11 21:40:41 +01:00
ValueRaider
070f13577e Merge pull request #1928 from marcofognog/dev
Add more specific error thowring base on PR 1918
2024-05-11 21:37:35 +01:00
Marcao
7628bec2a6 Adjust and fix according to feedback 2024-05-11 19:20:19 +02:00
ValueRaider
ac4efa3e3d Fix switching session from/to requests_cache
Session switch logic was not recalculating 'self._session_is_caching'.
Also removed message 'help stress-test cookie & crumb & requests_cache', clearly works now.
2024-05-11 09:33:17 +01:00
Elijah Lopez
5a683b916d Add raise missing ticker tests, replace deprecated datetime methods
- renamed test files conform with standards
- replaced utcfromtimestamp
2024-05-10 17:23:14 +02:00
Elijah Lopez
30fdc96157 Fix: PricesMissingError not being raised 2024-05-10 17:15:08 +02:00
Elijah Lopez
ee87a95b8d Rename errors from YFinance to YF 2024-05-10 17:15:08 +02:00
Elijah Lopez
685ef71d9f Add error classes for symbol delisting errors, closes #270 2024-05-10 17:15:08 +02:00
ValueRaider
098e77659c Merge pull request #1922 from ranaroussi/fix/datetime-utc-warning 2024-05-09 10:05:43 +01:00
ValueRaider
dc5c718556 Fix: datetime.datetime.utcnow() is deprecated ...
Python 3.12 deprecates datetime.datetime.utcnow().
Instead of switching to datetime.datetime.now(datetime.UTC), which won't work in Python 3.11,
just switch to Pandas.utcnow().
2024-05-02 22:45:26 +01:00
ValueRaider
84ba6d7d88 Merge pull request #1920 from ranaroussi/feature/price-repair-fx
Don't price-repair FX volume=0, is normal
2024-04-28 12:51:59 +01:00
ValueRaider
e238ac1f95 Merge pull request #1919 from ranaroussi/feature/readme-table-of-contents
Add table-of-contents to README
2024-04-28 12:51:15 +01:00
ValueRaider
efe15e1907 Add table-of-contents to README 2024-04-27 12:50:15 +01:00
ValueRaider
2dcbe34910 Don't price-repair FX volume=0, is normal 2024-04-26 21:32:39 +01:00
ValueRaider
bb47cd4182 Merge pull request #1917 from ranaroussi/main
sync main -> dev
2024-04-24 21:06:43 +01:00
ValueRaider
94e3833e90 Merge pull request #1913 from vittoboa/add_functools_wraps_to_wrapper
Fix help(yf.download) not showing the information about the function
2024-04-22 21:12:22 +01:00
vittoboa
f8e8eecf44 Add functools.wraps to log_indent_decorator's wrapper function 2024-04-22 21:08:10 +02:00
ValueRaider
a1bcb4c351 Version 0.2.38 2024-04-16 22:18:37 +01:00
ValueRaider
18089f451b Merge pull request #1908 from vittoboa/holders_404_error
Fix 404 Error for Holders
2024-04-16 22:14:33 +01:00
vittoboa
3d180fcf2c Move ticker symbol from parameter to URL 2024-04-16 22:37:07 +02:00
ValueRaider
82a3145fdf Merge pull request #1897 from ranaroussi/feature/deprecate-pdr
Deprecate 'pandas_datareader', remove a deprecated argument
2024-04-06 12:42:52 +01:00
ValueRaider
48e9075a2d Deprecate 'pandas_datareader', remove a deprecated argument.
Drop official support for 'pandas_datareader', tag pdr_override() as deprecated.
Also removed deprecated argument 'download(show_errors)'.
2024-04-06 12:42:04 +01:00
ValueRaider
88e8ddb7f5 Merge pull request #1896 from ranaroussi/feature/replace-dead-appdirs
Replace dead 'appdirs' package with 'platformdirs'
2024-04-06 12:22:37 +01:00
ValueRaider
812931ff98 Replace dead 'appdirs' package with 'platformdirs' 2024-04-06 12:19:46 +01:00
ValueRaider
1967e974c1 Merge pull request #1874 from ranaroussi/fix/price-repair-subtle-bug
Fix potential for price repair to discard price=0 rows
2024-03-04 19:46:59 +00:00
Value Raider
942a26fd37 Fix potential for price repair to discard price=0 rows 2024-03-01 22:03:03 +00:00
Value Raider
c2d568367c Version 0.2.37 2024-02-25 13:25:28 +00:00
ValueRaider
d3728d3071 Merge pull request #1869 from ranaroussi/dev
Dev
2024-02-24 23:09:34 +00:00
ValueRaider
915bb1a080 Merge pull request #1866 from ranaroussi/fix/price-repair-confusing-order
Price repair bug-fix
2024-02-24 22:58:20 +00:00
Value Raider
d55c317158 Fix bug: prices order flipping during repair, introducing potential data corruption 2024-02-19 22:17:20 +00:00
ValueRaider
ac1d09049e Merge pull request #1865 from cottrell/fix
Fix some errors.
2024-02-19 22:11:48 +00:00
David Cottrell
afb4e0d5dc Fix some errors. 2024-02-19 21:43:12 +00:00
ValueRaider
1d31e7ca01 Update issue form - more emphasis on following instructions 2024-02-11 13:47:36 +00:00
ValueRaider
683064f9ad Merge pull request #1849 from ranaroussi/refactor/price-history 2024-02-07 23:11:51 +00:00
Value Raider
cdf897f9e6 Move price history+repair logic into new file 2024-02-04 13:09:37 +00:00
ValueRaider
eab6c8dfa7 Update bug_report.yaml because people can't read 2024-02-01 21:28:38 +00:00
ValueRaider
97f93d35ed Merge pull request #1844 from power-edge/dev
adding upgrade for pandas deprecation warning, adding pyarrow>=0.17.0…
2024-01-31 21:51:05 +00:00
Nikolaus Schuetz
5aef8addab removing dev requirements (they are included by extras) 2024-01-29 17:43:12 -05:00
ValueRaider
6b8a4a5608 Merge pull request #1841 from Rogach/pr/dont-disable-global-logging
do not disable app-wide logging in quote.py (fixes #1829)
2024-01-28 16:29:43 +00:00
Platon Pronko
212a7987c3 do not disable app-wide logging in quote.py (fixes #1829) 2024-01-28 20:43:50 +05:00
Nikolaus Schuetz
58a0a57457 adding upgrade for pandas deprecation warning, adding pyarrow>=0.17.0 at minimum requirement as defined in dev requirements for pandas==1.3.0 version 2024-01-26 20:12:58 -05:00
ValueRaider
75297c0eba Merge pull request #1838 from mreiche/bugfix/remove-empty-series
Remove _empty_series leftovers
2024-01-23 19:07:16 +00:00
Mike Reiche
1dc2719368 Remove _empty_series leftovers 2024-01-23 15:32:56 +01:00
Value Raider
ab979e9141 Version 0.2.36 2024-01-21 18:10:41 +00:00
ValueRaider
b837c1ec2a Merge pull request #1834 from ranaroussi/dev
sync dev -> main
2024-01-21 18:08:04 +00:00
ValueRaider
2630c66cd1 Merge pull request #1833 from ange-daumal/json-fix
Fix JSON error handling
2024-01-19 21:56:42 +00:00
ValueRaider
7af789fe9a Merge pull request #1830 from ange-daumal/patch-1
Fix JSON error handling
2024-01-19 21:51:52 +00:00
ValueRaider
73e36688b7 Merge pull request #1827 from ranaroussi/fix/peewee-with-old-sqlite
Handle peewee with old sqlite
2024-01-19 21:51:31 +00:00
ValueRaider
f1264716fc Merge pull request #1824 from ranaroussi/fix/price-keepna-with-repair
Fix history() keepna=False with repair=True
2024-01-19 21:51:10 +00:00
Ange Daumal
06fd35121a Fix JSON access to prevent KeyError 2024-01-19 22:51:02 +01:00
Mike Reiche
91f468e4d3 Fix JSON access to prevent KeyError 2024-01-19 22:42:42 +01:00
ValueRaider
d00c1a976c Merge pull request #1831 from ranaroussi/main
sync main -> dev
2024-01-15 19:28:56 +00:00
ValueRaider
176c3d628b Update ci.yml to Node16 2024-01-15 19:27:37 +00:00
ValueRaider
8f53af1593 Merge pull request #1823 from molpcs/patch-2
Update README.md for better copy-ability
2024-01-14 12:36:17 +00:00
ValueRaider
19188d52d4 Merge pull request #1795 from amanlai/main
explicitly name the column levels
2024-01-14 10:45:04 +00:00
Value Raider
ffaf200562 Handle peewee with old sqlite 2024-01-13 23:00:59 +00:00
Value Raider
6686258e66 Fix history() keepna=False with repair=True 2024-01-13 13:19:44 +00:00
molpcs
47bc46c804 Update README.md
Wrap yfinance[optional] code snippet with quotes to avoid conflict with zsh globbing. Remains compatible with bash.
2024-01-12 11:57:58 -08:00
ValueRaider
f563e51509 Merge pull request #1822 from akshayparopkari/patch-1 2024-01-11 09:30:22 +00:00
Akshay Paropkari
c5404bcd9d Update fundamentals.py
Error in supplying timescale values resulted in misleading ValueError - 

```
ValueError: Illegal argument: timescale must be one of: ['income', 'balance-sheet', 'cash-flow']
```
2024-01-11 05:17:39 +00:00
ValueRaider
006e0a155b Merge pull request #1724 from mreiche/bugfix/data-types-2
Bugfix/data types 2
2024-01-09 20:13:41 +00:00
Mike Reiche
dbc55e5596 Remove unused List import 2024-01-09 21:08:46 +01:00
Mike Reiche
4ce63fe8ca Merge remote-tracking branch 'yfinance/dev' into bugfix/data-types-2 2024-01-09 08:51:33 +01:00
Mike Reiche
223f5337a8 Remove empty static series 2024-01-09 08:50:31 +01:00
Mike Reiche
4c34487149 Revert disabling earnings test 2024-01-09 08:50:00 +01:00
Mike Reiche
ac8a917288 Revert adding explicit requirements 2024-01-09 08:43:54 +01:00
Mike Reiche
15321bd097 Merge remote-tracking branch 'yfinance/main' into bugfix/data-types-2 2024-01-09 08:42:43 +01:00
ValueRaider
10961905b6 Merge pull request #1817 from ranaroussi/main
sync main -> dev
2024-01-07 18:39:10 +00:00
Manlai Amar
a3095d2a40 explicitly name the column levels 2023-12-21 00:02:53 -08:00
Mike Reiche
ba3c1b5ac6 Merge remote-tracking branch 'yfinance/dev' into bugfix/data-types-2
# Conflicts:
#	yfinance/base.py
2023-10-21 12:44:39 +02:00
Mike Reiche
ba977a16a2 Added tests 2023-10-12 08:53:16 +02:00
Mike Reiche
9a3d60105c Minor typing fixes 2023-10-12 08:53:16 +02:00
Mike Reiche
0521428f69 Fixed typing bug when series are empty 2023-10-12 08:53:15 +02:00
497 changed files with 157631 additions and 3312 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -6,23 +6,13 @@ body:
- type: markdown
attributes:
value: |
# IMPORTANT - Read and follow these instructions carefully. Help us help you.
### Does issue already exist?
Use the search tool. Don't annoy everyone by duplicating existing Issues.
# !!! IMPORTANT !!! FOLLOW THESE INSTRUCTIONS CAREFULLY !!!
### Are you up-to-date?
Upgrade to the latest version and confirm the issue/bug is still there.
Upgrade to the latest version: `$ pip install yfinance --upgrade --no-cache-dir`
`$ pip install yfinance --upgrade --no-cache-dir`
Confirm by running:
`import yfinance as yf ; print(yf.__version__)`
and comparing against [PIP](https://pypi.org/project/yfinance/#history).
Confirm latest version by running: `import yfinance as yf ; print(yf.__version__)` and comparing against [PyPI](https://pypi.org/project/yfinance/#history).
### Does Yahoo actually have the data?
@@ -34,6 +24,10 @@ body:
Yahoo Finance free service has rate-limiting https://github.com/ranaroussi/yfinance/discussions/1513. Once limit hit, Yahoo can delay, block, or return bad data -> not a `yfinance` bug.
### Does issue already exist?
Use the search tool. Don't duplicate existing issues.
- type: markdown
attributes:
value: |
@@ -61,7 +55,7 @@ body:
id: debug-log
attributes:
label: "Debug log"
description: "Run code with debug logging enabled and post the full output. 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
@@ -69,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

View File

@@ -8,11 +8,11 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.x
- run: pip install -r requirements.txt
- run: pip install mkdocstrings==0.14.0
- run: pip install mkdocs-material
- run: mkdocs gh-deploy --force
- run: mkdocs gh-deploy --force

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:

8
.gitignore vendored
View File

@@ -10,6 +10,7 @@ build/
*.html
*.css
*.png
test.ipynb
# Environments
.env
@@ -17,3 +18,10 @@ build/
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,104 @@
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:
- add keys to financials #1965 #1985
- fetch Sustainability #1959
- improve price-repair-zeroes #1990
Fixes (prices):
- fetching when period='max' #1967
- metadata: Fix '1wk is invalid' & repeated calls #1970
- Pandas warnings #1955 #1981
- price repair syntax errors #1989
Maintenance:
- deprecate Ticker.earnings #1977
0.2.40
------
Fix typo in 0.2.39 c7af213
0.2.39
------
Fixes:
- Fix switching session from/to requests_cache #1930
Price repair:
- Fix potential for price repair to discard price=0 rows #1874
- Don't price-repair FX volume=0, is normal #1920
- Improve 'sudden change' repair for splits & currency #1931
Information:
- Fix help(yf.download) not showing the information about the function #1913 @vittoboa
- Add more specific error throwing based on PR 1918 #1928 @elibroftw @marcofognog
Maintenance:
- Replace dead 'appdirs' package with 'platformdirs' #1896
- Deprecate 'pandas_datareader', remove a deprecated argument #1897
- Fix: datetime.datetime.utcnow() is deprecated ... #1922
0.2.38
------
Fix holders & insiders #1908
0.2.37
------
Small fixes:
- Fix Pandas warnings #1838 #1844
- Fix price repair bug, typos, refactor #1866 #1865 #1849
- Stop disabling logging #1841
0.2.36
------
Small fixes:
- Update README.md for better copy-ability #1823
- Name download() column levels #1795
- Fix history(keepna=False) when repair=True #1824
- Replace empty list with empty pd.Series #1724
- Handle peewee with old sqlite #1827
- Fix JSON error handling #1830 #1833
0.2.35
------
Internal fixes for 0.2.34
@@ -278,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
@@ -590,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
-------

221
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,11 +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)
---
## Documentation
The official documentation is available on [ranaroussi.github.io/yfinance](https://ranaroussi.github.io/yfinance/index.html)
## Installation
@@ -55,214 +59,15 @@ $ pip install yfinance --upgrade --no-cache-dir
To install with optional dependencies, replace `optional` with: `nospam` for [caching-requests](#smarter-scraping), `repair` for [price repair](https://github.com/ranaroussi/yfinance/wiki/Price-repair), or `nospam,repair` for both:
``` {.sourceCode .bash}
$ pip install yfinance[optional]
$ 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
# 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
### `pandas_datareader` override
If your code uses `pandas_datareader` and you want to download data
faster, you can "hijack" `pandas_datareader.data.get_data_yahoo()`
method to use **yfinance** while making sure the returned data is in the
same format as **pandas\_datareader**'s `get_data_yahoo()`.
```python
from pandas_datareader import data as pdr
import yfinance as yf
yf.pdr_override() # <== that's all it takes :-)
# download dataframe
data = pdr.get_data_yahoo("SPY", start="2017-01-01", end="2017-04-30")
```
### 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
---
@@ -279,12 +84,12 @@ intended for research and educational purposes. You should refer to Yahoo!'s ter
([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
detailes on your rights to use the actual data downloaded.
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

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