Compare commits

...

11 Commits

Author SHA1 Message Date
ValueRaider
5124059422 Bump version to 0.2.19 2023-06-07 13:28:32 +01:00
ValueRaider
d18cd6f42f Merge pull request #1549 from ranaroussi/dev
dev -> main
2023-06-07 13:23:39 +01:00
ValueRaider
c20211a06c Merge pull request #1547 from bveber/dev 2023-06-06 23:05:40 +01:00
bveber
cdfe7d0d2d add session to download 2023-06-06 01:06:18 -05:00
ValueRaider
d9bfd29113 Delete 'Feature request' issue template - can't have nice things 2023-05-23 17:11:31 +01:00
ValueRaider
4711aab7b3 Merge pull request #1536 from ranaroussi/hotfix/tz-cache-migrate-error-again
Fix corrupt tkr-tz-csv halting code (again)
2023-05-23 16:44:35 +01:00
ValueRaider
30d20c1206 Fix corrupt tkr-tz-csv halting code (again) 2023-05-23 16:34:50 +01:00
ValueRaider
83b177b7fb README.md - note on installing betas 2023-05-12 12:11:14 +01:00
ValueRaider
b96319dd64 Merge pull request #1504 from ranaroussi/hotfix/sql-exception
Fix timezone cache error: IntegrityError('NOT NULL constraint failed: kv.key')
2023-04-26 21:29:33 +01:00
ValueRaider
74b88dc62c Fix IntegrityError in timezone cache 2023-04-26 21:27:31 +01:00
ValueRaider
d30a2a0915 README.md: update 'News' 2023-04-16 21:29:57 +01:00
7 changed files with 59 additions and 48 deletions

View File

@@ -1,14 +0,0 @@
---
name: Feature request
about: Request a new feature
title: ''
labels: ''
assignees: ''
---
**Describe the problem**
**Describe the solution**
**Additional context**

View File

@@ -1,20 +1,13 @@
Change Log
===========
0.2.19b4
--------
Fix `download` logging #1541
Fix corrupt tkr-tz-csv halting code #1528
0.2.19b3
-------
Improve logging messages #1522
Price fixes #1523
0.2.19b1 - beta
-------
Optimise Ticker.history #1514
Logging module #1493
0.2.19
------
Switch to `logging` module #1493 #1522 #1541
Price history:
- optimise #1514
- fixes #1523
- fix TZ-cache corruption #1528
0.2.18
------

View File

@@ -42,10 +42,19 @@ Yahoo! finance API is intended for personal use only.**
---
## News [2023-01-27]
Since December 2022 Yahoo has been encrypting the web data that `yfinance` scrapes for non-market data. Fortunately the decryption keys are available, although Yahoo moved/changed them several times hence `yfinance` breaking several times. `yfinance` is now better prepared for any future changes by Yahoo.
## News
Why is Yahoo doing this? We don't know. Is it to stop scrapers? Maybe, so we've implemented changes to reduce load on Yahoo. In December we rolled out version 0.2 with optimised scraping. ~Then in 0.2.6 introduced `Ticker.fast_info`, providing much faster access to some `info` elements wherever possible e.g. price stats and forcing users to switch (sorry but we think necessary). `info` will continue to exist for as long as there are elements without a fast alternative.~ `info` now fixed and much faster than before.
### 2023-01-27
Since December 2022 Yahoo has been encrypting the web data that `yfinance` scrapes for non-price data. Price data still works. Fortunately the decryption keys are available, although Yahoo moved/changed them several times hence `yfinance` breaking several times. `yfinance` is now better prepared for any future changes by Yahoo.
Why is Yahoo doing this? We don't know. Is it to stop scrapers? Maybe, so we've implemented changes to reduce load on Yahoo. In December we rolled out version 0.2 with optimised scraping. Then in 0.2.6 introduced `Ticker.fast_info`, providing much faster access to some `Ticker.info` elements wherever possible e.g. price stats and forcing users to switch (sorry but we think necessary).
### 2023-02-07
Yahoo is now regularly changing their decryption key, breaking `yfinance` decryption. Is technically possible to extract this from their webpage but not implemented because difficult, see [discussion in the issue thread](https://github.com/ranaroussi/yfinance/issues/1407).
### 2023-04-09
Fixed `Ticker.info`
## Quick Start
@@ -282,6 +291,11 @@ Install `yfinance` using `pip`:
$ pip install yfinance --upgrade --no-cache-dir
```
Test new features by installing betas, provide feedback in [corresponding Discussion](https://github.com/ranaroussi/yfinance/discussions):
``` {.sourceCode .bash}
$ pip install yfinance --upgrade --no-cache-dir --pre
```
To install `yfinance` using `conda`, see
[this](https://anaconda.org/ranaroussi/yfinance).

View File

@@ -1,5 +1,5 @@
{% set name = "yfinance" %}
{% set version = "0.2.19b4" %}
{% set version = "0.2.19" %}
package:
name: "{{ name|lower }}"

View File

@@ -33,7 +33,7 @@ from . import shared
def download(tickers, start=None, end=None, actions=False, threads=True, ignore_tz=None,
group_by='column', auto_adjust=False, back_adjust=False, repair=False, keepna=False,
progress=True, period="max", show_errors=None, interval="1d", prepost=False,
proxy=None, rounding=False, timeout=10):
proxy=None, rounding=False, timeout=10, session=None):
"""Download yahoo tickers
:Parameters:
tickers : str, list
@@ -82,6 +82,8 @@ def download(tickers, start=None, end=None, actions=False, threads=True, ignore_
timeout: None or float
If not None stops waiting for a response after given number of
seconds. (Can also be a fraction of a second e.g. 0.01)
session: None or Session
Optional. Pass your own session object to be used for all requests
"""
if show_errors is not None:
@@ -110,7 +112,7 @@ def download(tickers, start=None, end=None, actions=False, threads=True, ignore_
for ticker in tickers:
if utils.is_isin(ticker):
isin = ticker
ticker = utils.get_ticker_by_isin(ticker, proxy)
ticker = utils.get_ticker_by_isin(ticker, proxy, session=session)
shared._ISINS[ticker] = isin
_tickers_.append(ticker)
@@ -137,10 +139,9 @@ def download(tickers, start=None, end=None, actions=False, threads=True, ignore_
actions=actions, auto_adjust=auto_adjust,
back_adjust=back_adjust, repair=repair, keepna=keepna,
progress=(progress and i > 0), proxy=proxy,
rounding=rounding, timeout=timeout)
rounding=rounding, timeout=timeout, session=session)
while len(shared._DFS) < len(tickers):
_time.sleep(0.01)
# download synchronously
else:
for i, ticker in enumerate(tickers):
@@ -149,10 +150,10 @@ def download(tickers, start=None, end=None, actions=False, threads=True, ignore_
actions=actions, auto_adjust=auto_adjust,
back_adjust=back_adjust, repair=repair, keepna=keepna,
proxy=proxy,
rounding=rounding, timeout=timeout)
rounding=rounding, timeout=timeout, session=session)
if progress:
shared._PROGRESS_BAR.animate()
if progress:
shared._PROGRESS_BAR.completed()
@@ -239,10 +240,10 @@ def _download_one_threaded(ticker, start=None, end=None,
auto_adjust=False, back_adjust=False, repair=False,
actions=False, progress=True, period="max",
interval="1d", prepost=False, proxy=None,
keepna=False, rounding=False, timeout=10):
keepna=False, rounding=False, timeout=10, session=None):
data = _download_one(ticker, start, end, auto_adjust, back_adjust, repair,
actions, period, interval, prepost, proxy, rounding,
keepna, timeout)
keepna, timeout, session)
if progress:
shared._PROGRESS_BAR.animate()
@@ -251,10 +252,10 @@ def _download_one(ticker, start=None, end=None,
auto_adjust=False, back_adjust=False, repair=False,
actions=False, period="max", interval="1d",
prepost=False, proxy=None, rounding=False,
keepna=False, timeout=10):
keepna=False, timeout=10, session=None):
data = None
try:
data = Ticker(ticker).history(
data = Ticker(ticker, session=session).history(
period=period, interval=interval,
start=start, end=end, prepost=prepost,
actions=actions, auto_adjust=auto_adjust,

View File

@@ -867,14 +867,21 @@ class _KVStore:
def get(self, key: str) -> Union[str, None]:
"""Get value for key if it exists else returns None"""
item = self.conn.execute('select value from "kv" where key=?', (key,))
try:
item = self.conn.execute('select value from "kv" where key=?', (key,))
except _sqlite3.IntegrityError as e:
self.delete(key)
return None
if item:
return next(item, (None,))[0]
def set(self, key: str, value: str) -> None:
with self._cache_mutex:
self.conn.execute('replace into "kv" (key, value) values (?,?)', (key, value))
self.conn.commit()
if value is None:
self.delete(key)
else:
with self._cache_mutex:
self.conn.execute('replace into "kv" (key, value) values (?,?)', (key, value))
self.conn.commit()
def bulk_set(self, kvdata: Dict[str, str]):
records = tuple(i for i in kvdata.items())
@@ -946,7 +953,17 @@ class _TzCache:
except TypeError:
_os.remove(old_cache_file_path)
else:
self.tz_db.bulk_set(df.to_dict()['Tz'])
# Discard corrupt data:
df = df[~df["Tz"].isna().to_numpy()]
df = df[~(df["Tz"]=='').to_numpy()]
df = df[~df.index.isna()]
if not df.empty:
try:
self.tz_db.bulk_set(df.to_dict()['Tz'])
except Exception as e:
# Ignore
pass
_os.remove(old_cache_file_path)

View File

@@ -1 +1 @@
version = "0.2.19b4"
version = "0.2.19"