https://github.com/andrewrporter/yahoo-historical
Downloads historical EOD (end of day) prices from yahoo finance
https://github.com/andrewrporter/yahoo-historical
finance historical-data pandas pandas-dataframe yahoo yahoo-api yahoo-finance
Last synced: 6 days ago
JSON representation
Downloads historical EOD (end of day) prices from yahoo finance
- Host: GitHub
- URL: https://github.com/andrewrporter/yahoo-historical
- Owner: AndrewRPorter
- License: mit
- Created: 2017-07-05T22:49:43.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-05-05T18:32:52.000Z (about 2 years ago)
- Last Synced: 2025-04-09T16:06:37.247Z (2 months ago)
- Topics: finance, historical-data, pandas, pandas-dataframe, yahoo, yahoo-api, yahoo-finance
- Language: Python
- Size: 57.6 KB
- Stars: 100
- Watchers: 14
- Forks: 41
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[](https://badge.fury.io/py/yahoo-historical) [](https://pepy.tech/project/yahoo_historical) [](https://app.circleci.com/pipelines/github/AndrewRPorter/yahoo-historical)
# yahoo-historical
## Installation
```
pip install --user yahoo-historical
```## Methods
- get_historical()
- get_dividends()
- get_splits()## Example Usage
Below details the available method params for creating a Fetcher object.
### Arguments
- ticker: The ticker symbol to download historical data for
- start: Start date as Unix timestamp### Optional Arguments
- end: End date as Unix timestamp (defaults to `time.time()`)
- interval: Interval to fetch historical data (can be 1d, 1wk, 1mo, defaults to 1d)```python
from yahoo_historical import Fetcher
import datetime
import time# create unix timestamp representing January 1st, 2007
timestamp = time.mktime(datetime.datetime(2007, 1, 1).timetuple())data = Fetcher("AAPL", timestamp)
print(data.get_historical())
``````
Date Open High Low Close Adj Close Volume
0 2007-01-03 12.327143 12.368571 11.700000 10.812462 11.971429 309579900
1 2007-01-04 12.007143 12.278571 11.974286 11.052453 12.237143 211815100
2 2007-01-05 12.252857 12.314285 12.057143 10.973743 12.150000 208685400
3 2007-01-08 12.280000 12.361428 12.182858 11.027935 12.210000 199276700
```Note that you can return a dictionary instead of a DataFrame by setting the `as_dataframe` flag to `False`.
```python
from yahoo_historical import Fetcherimport datetime
import time# create unix timestamp representing January 1st, 2007
timestamp = time.mktime(datetime.datetime(2007, 1, 1).timetuple())data = Fetcher("AAPL", timestamp)
print(data.get_historical(as_dataframe=False))
```