Skip to content

Commit f32097e

Browse files
authored
Merge pull request #1771 from JuliaLWang8/feat/extra-dependencies
Feat/adding extra dependencies
2 parents f718db6 + 469037b commit f32097e

File tree

2 files changed

+29
-39
lines changed

2 files changed

+29
-39
lines changed

README.md

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,26 @@ Yahoo! finance API is intended for personal use only.**
4242

4343
---
4444

45+
## Installation
46+
47+
Install `yfinance` using `pip`:
48+
49+
``` {.sourceCode .bash}
50+
$ pip install yfinance --upgrade --no-cache-dir
51+
```
52+
53+
[With Conda](https://anaconda.org/ranaroussi/yfinance).
54+
55+
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:
56+
57+
``` {.sourceCode .bash}
58+
$ pip install yfinance[optional]
59+
```
60+
61+
[Required dependencies](./requirements.txt) , [all dependencies](./setup.py#L62).
62+
63+
---
64+
4565
## Quick Start
4666

4767
### The Ticker module
@@ -155,9 +175,10 @@ data = yf.download("SPY AAPL", period="1mo")
155175

156176
### Smarter scraping
157177

158-
To use a custom `requests` session (for example to cache calls to the
159-
API or customize the `User-agent` header), pass a `session=` argument to
160-
the Ticker constructor.
178+
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.
179+
180+
To use a custom `requests` session, pass a `session=` argument to
181+
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.
161182

162183
```python
163184
import requests_cache
@@ -168,7 +189,7 @@ ticker = yf.Ticker('msft', session=session)
168189
ticker.actions
169190
```
170191

171-
Combine a `requests_cache` with rate-limiting to avoid triggering Yahoo's rate-limiter/blocker that can corrupt data.
192+
Combine `requests_cache` with rate-limiting to avoid triggering Yahoo's rate-limiter/blocker that can corrupt data.
172193
```python
173194
from requests import Session
174195
from requests_cache import CacheMixin, SQLiteCache
@@ -230,41 +251,6 @@ yf.set_tz_cache_location("custom/cache/location")
230251

231252
---
232253

233-
## Installation
234-
235-
Install `yfinance` using `pip`:
236-
237-
``` {.sourceCode .bash}
238-
$ pip install yfinance --upgrade --no-cache-dir
239-
```
240-
241-
Test new features by installing betas, provide feedback in [corresponding Discussion](https://github.com/ranaroussi/yfinance/discussions):
242-
``` {.sourceCode .bash}
243-
$ pip install yfinance --upgrade --no-cache-dir --pre
244-
```
245-
246-
To install `yfinance` using `conda`, see
247-
[this](https://anaconda.org/ranaroussi/yfinance).
248-
249-
### Requirements
250-
251-
- [Python](https://www.python.org) \>= 2.7, 3.4+
252-
- [Pandas](https://github.com/pydata/pandas) \>= 1.3.0
253-
- [Numpy](http://www.numpy.org) \>= 1.16.5
254-
- [requests](http://docs.python-requests.org/en/master) \>= 2.31
255-
- [lxml](https://pypi.org/project/lxml) \>= 4.9.1
256-
- [appdirs](https://pypi.org/project/appdirs) \>= 1.4.4
257-
- [pytz](https://pypi.org/project/pytz) \>=2022.5
258-
- [frozendict](https://pypi.org/project/frozendict) \>= 2.3.4
259-
- [beautifulsoup4](https://pypi.org/project/beautifulsoup4) \>= 4.11.1
260-
- [html5lib](https://pypi.org/project/html5lib) \>= 1.1
261-
- [peewee](https://pypi.org/project/peewee) \>= 3.16.2
262-
263-
#### Optional (if you want to use `pandas_datareader`)
264-
265-
- [pandas\_datareader](https://github.com/pydata/pandas-datareader)
266-
\>= 0.4.0
267-
268254
## Developers: want to contribute?
269255

270256
`yfinance` relies on community to investigate bugs and contribute code. Developer guide: https://github.com/ranaroussi/yfinance/discussions/1084

setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@
6464
'lxml>=4.9.1', 'appdirs>=1.4.4', 'pytz>=2022.5',
6565
'frozendict>=2.3.4', 'peewee>=3.16.2',
6666
'beautifulsoup4>=4.11.1', 'html5lib>=1.1'],
67+
extras_require={
68+
'nospam': ['requests_cache>=1.1.1', 'requests_ratelimiter>=0.4.2'],
69+
'repair': ['scipy>=1.6.3'],
70+
},
6771
# Note: Pandas.read_html() needs html5lib & beautifulsoup4
6872
entry_points={
6973
'console_scripts': [

0 commit comments

Comments
 (0)