Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch keyError in #2027 #2029

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f13ff4b
Fix datetime conversion with mixed timezones when ignore_tz is False
mreiche Aug 7, 2024
459d5f6
Merge pull request #2016 from mreiche/bugfix/mixed-tz-conversion
ValueRaider Aug 12, 2024
8b8db16
Update bug_report.yaml
ValueRaider Aug 19, 2024
f67f747
add try/except for keyerror
aleksfasting Aug 19, 2024
683bb0d
changed metadata that time is fetched from
aleksfasting Aug 20, 2024
8c7b671
Merge branch 'ranaroussi:main' into fix/keyerror-30min-resample
aleksfasting Aug 20, 2024
1baecc9
Revert PR #2027, breaks with prepost=True
ValueRaider Aug 21, 2024
a0dc252
Update python-publish.yml to v4 for node20
ValueRaider Aug 21, 2024
7c66bc3
Merge pull request #2032 from ranaroussi/revert/PR-2027-30m-resampling
ValueRaider Aug 22, 2024
2f5203d
New: repair bad dividends and div-adjusts. Plus other repair fixes.
ValueRaider Aug 21, 2024
a74ad47
Repair dividends: fine-tune logic + unit tests
ValueRaider Aug 22, 2024
7e12f20
Merge pull request #2031 from ranaroussi/feature/price-repair-div-adjust
ValueRaider Aug 22, 2024
ce9becd
Merge branch 'main' into dev
ValueRaider Aug 22, 2024
a2b5d6b
Fix 2x old tests
ValueRaider Aug 22, 2024
0193cec
Merge pull request #2034 from ranaroussi/dev
ValueRaider Aug 22, 2024
bd1a597
Version 0.2.42
ValueRaider Aug 22, 2024
e329f26
Fix price-repair-currency, logic was inverted
ValueRaider Aug 24, 2024
f87a9af
Merge pull request #2036 from ranaroussi/fix/price-repair-currency-bug
ValueRaider Aug 24, 2024
ed43f6f
Version 0.2.43
ValueRaider Aug 24, 2024
72684b1
fix typo in README
joncokisler Aug 26, 2024
3fe87cb
Merge pull request #2039 from joncokisler/main
ValueRaider Aug 26, 2024
5e5df8f
Merge branch 'dev' of https://github.com/aleksfasting/yfinance into dev
aleksfasting Aug 28, 2024
eca141f
added unittests for prepost true and false
aleksfasting Aug 29, 2024
b141136
fix mistake in imports
aleksfasting Aug 29, 2024
8cadad2
Merge pull request #2048 from ranaroussi/main
ValueRaider Sep 4, 2024
f584b0c
implementing support for funds data
ericpien Sep 1, 2024
6b7a511
Merge pull request #2041 from ericpien/funds
ValueRaider Sep 8, 2024
6765008
Bug template: clarify 'bad data proof'
ValueRaider Sep 21, 2024
3a0b6c2
Implement Sector and Industry
ericpien Sep 18, 2024
1890ff2
Merge pull request #2058 from ericpien/sectors
ValueRaider Sep 22, 2024
ce530b0
Improve dividend repair
ValueRaider Sep 29, 2024
dd663a4
Merge pull request #2062 from ranaroussi/feature/improve-div-repair
ValueRaider Sep 29, 2024
3535fb9
Fix test fails in _fix_prices_sudden_change
ValueRaider Sep 29, 2024
4c3c228
Merge pull request #2063 from ranaroussi/dev
ValueRaider Sep 30, 2024
9e2252e
Version 0.2.44
ValueRaider Sep 30, 2024
a8df88b
Fix unit tests contextual imports
ValueRaider Oct 1, 2024
ebc4e20
fix keyerror with single element list passed to Tickers
antoniouaa Oct 1, 2024
f82823c
Merge pull request #2067 from ranaroussi/fix/tests-context
ValueRaider Oct 2, 2024
17f07e0
Merge pull request #2069 from ranaroussi/main
ValueRaider Oct 2, 2024
0f63ecc
Merge pull request #2068 from antoniouaa/fix_tickers_single
ValueRaider Oct 3, 2024
8e70fbd
chore: rebase from dev
aleksfasting Oct 7, 2024
e1a49ea
added unittests for prepost true and false
aleksfasting Aug 29, 2024
cb51247
fix mistake in imports
aleksfasting Aug 29, 2024
535f557
Merge branch 'fix/keyerror-30min-resample' of https://github.com/alek…
aleksfasting Oct 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ 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

- type: textarea
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

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
26 changes: 26 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
Change Log
===========

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:
Expand Down
76 changes: 75 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ msft.insider_transactions
msft.insider_purchases
msft.insider_roster_holders

msfs.sustainability
msft.sustainability

# show recommendations
msft.recommendations
Expand Down Expand Up @@ -156,6 +156,31 @@ opt = msft.option_chain('YYYY-MM-DD')
# data available via: opt.calls, opt.puts
```

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`.

```python
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
```

If you want to use a proxy server for downloading data, use:

```python
Expand Down Expand Up @@ -198,6 +223,55 @@ 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.

### Sector and Industry

The `Sector` and `Industry` modules allow you to access the US market information.

To initialize, use the relevant sector or industry key as below. (Complete mapping of the keys is available in `const.py`.)

```python
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
```

The modules can be chained with Ticker as below.
```python
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()
```

### 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.
Expand Down
2 changes: 1 addition & 1 deletion meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "yfinance" %}
{% set version = "0.2.41" %}
{% set version = "0.2.44" %}

package:
name: "{{ name|lower }}"
Expand Down
649 changes: 649 additions & 0 deletions tests/data/1398-HK-1d-bad-div-fixed.csv

Large diffs are not rendered by default.

649 changes: 649 additions & 0 deletions tests/data/1398-HK-1d-bad-div.csv

Large diffs are not rendered by default.

649 changes: 649 additions & 0 deletions tests/data/3988-HK-1d-bad-div-fixed.csv

Large diffs are not rendered by default.

649 changes: 649 additions & 0 deletions tests/data/3988-HK-1d-bad-div.csv

Large diffs are not rendered by default.

668 changes: 668 additions & 0 deletions tests/data/4063-T-1d-bad-div-fixed.csv

Large diffs are not rendered by default.

668 changes: 668 additions & 0 deletions tests/data/4063-T-1d-bad-div.csv

Large diffs are not rendered by default.

666 changes: 666 additions & 0 deletions tests/data/ABDP-L-1d-bad-div-fixed.csv

Large diffs are not rendered by default.

666 changes: 666 additions & 0 deletions tests/data/ABDP-L-1d-bad-div.csv

Large diffs are not rendered by default.

666 changes: 666 additions & 0 deletions tests/data/ADIG-L-1d-bad-div-fixed.csv

Large diffs are not rendered by default.

666 changes: 666 additions & 0 deletions tests/data/ADIG-L-1d-bad-div.csv

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions tests/data/AET-L-1d-100x-error-fixed.csv
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
Date,Open,High,Low,Close,Adj Close,Volume,Dividends,Stock Splits
2022-06-06 00:00:00+01:00,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0,0,0
2022-06-01 00:00:00+01:00,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0,0,0
2022-05-31 00:00:00+01:00,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0,0,0
2022-05-30 00:00:00+01:00,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0,0,0
2022-05-27 00:00:00+01:00,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0,0,0
2022-05-26 00:00:00+01:00,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0,0,0
2022-05-25 00:00:00+01:00,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0,0,0
2022-05-24 00:00:00+01:00,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0,0,0
2022-05-23 00:00:00+01:00,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0,0,0
2022-05-20 00:00:00+01:00,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0,0,0
2022-05-19 00:00:00+01:00,0.1455,0.1455,0.1455,0.1455,0.1455,0,0,0
2022-05-18 00:00:00+01:00,0.1455,0.1455,0.1455,0.1455,0.1455,532454,0,0
2022-05-17 00:00:00+01:00,0.1455,0.1455,0.1455,0.1455,0.1455,0,0,0
2022-05-16 00:00:00+01:00,0.1455,0.1455,0.1455,0.1455,0.1455,0,0,0
2022-05-13 00:00:00+01:00,0.1455,0.1455,0.1455,0.1455,0.1455,0,0,0
2022-05-12 00:00:00+01:00,0.1455,0.1455,0.1455,0.1455,0.1455,0,0,0
2022-05-11 00:00:00+01:00,0.1455,0.1455,0.1455,0.1455,0.1455,0,0,0
2022-05-10 00:00:00+01:00,0.1455,0.1455,0.1455,0.1455,0.1455,0,0,0
2022-05-09 00:00:00+01:00,0.1455,0.1455,0.1455,0.1455,0.1455,0,0,0
2022-05-06 00:00:00+01:00,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0,0,0
2022-05-05 00:00:00+01:00,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0,0,0
2022-05-04 00:00:00+01:00,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0,0,0
2022-05-03 00:00:00+01:00,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0.145500004291534,0,0,0
2022-06-06 00:00:00+01:00,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,0,0,0
2022-06-01 00:00:00+01:00,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,0,0,0
2022-05-31 00:00:00+01:00,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,0,0,0
2022-05-30 00:00:00+01:00,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,0,0,0
2022-05-27 00:00:00+01:00,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,0,0,0
2022-05-26 00:00:00+01:00,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,0,0,0
2022-05-25 00:00:00+01:00,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,0,0,0
2022-05-24 00:00:00+01:00,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,0,0,0
2022-05-23 00:00:00+01:00,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,0,0,0
2022-05-20 00:00:00+01:00,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,0,0,0
2022-05-19 00:00:00+01:00,14.5500001907349,14.5500001907349,14.5500001907349,14.5500001907349,14.5500001907349,0,0,0
2022-05-18 00:00:00+01:00,14.5500001907349,14.5500001907349,14.5500001907349,14.5500001907349,14.5500001907349,532454,0,0
2022-05-17 00:00:00+01:00,14.5500001907349,14.5500001907349,14.5500001907349,14.5500001907349,14.5500001907349,0,0,0
2022-05-16 00:00:00+01:00,14.5500001907349,14.5500001907349,14.5500001907349,14.5500001907349,14.5500001907349,0,0,0
2022-05-13 00:00:00+01:00,14.5500001907349,14.5500001907349,14.5500001907349,14.5500001907349,14.5500001907349,0,0,0
2022-05-12 00:00:00+01:00,14.5500001907349,14.5500001907349,14.5500001907349,14.5500001907349,14.5500001907349,0,0,0
2022-05-11 00:00:00+01:00,14.5500001907349,14.5500001907349,14.5500001907349,14.5500001907349,14.5500001907349,0,0,0
2022-05-10 00:00:00+01:00,14.5500001907349,14.5500001907349,14.5500001907349,14.5500001907349,14.5500001907349,0,0,0
2022-05-09 00:00:00+01:00,14.5500001907349,14.5500001907349,14.5500001907349,14.5500001907349,14.5500001907349,0,0,0
2022-05-06 00:00:00+01:00,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,0,0,0
2022-05-05 00:00:00+01:00,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,0,0,0
2022-05-04 00:00:00+01:00,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,0,0,0
2022-05-03 00:00:00+01:00,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,14.5500004291534,0,0,0
25 changes: 0 additions & 25 deletions tests/data/AET-L-1wk-100x-error-fixed.csv.old

This file was deleted.

25 changes: 0 additions & 25 deletions tests/data/AET-L-1wk-100x-error.csv.old

This file was deleted.

Loading
Loading