A Python package to access historical stock data for NASDAQ and NYSE.
Project description
Stocks Historical Library 📊
A Python library for accessing historical stock data from major stock exchanges and equity markets. This library simplifies the process of fetching and formatting stock data using the Stocks Historical API, making it easy to retrieve and analyze stock data programmatically. Currently, it supports data for top 100 stocks from NYSE and NASDAQ markets, with plans to include data from additional markets in the future.
Library inspired by Yahoo Historical.
Features
- Retrieve historical stock data for NASDAQ and NYSE.
- Supports specifying date ranges with start and optional end dates.
- Formats data into Pandas DataFrames for easy analysis.
- Fetch Open, High, Low, and Close data.
Installation
Install the library via pip:
pip install stocks-historical
Usage
Import and Initialize
You can use the Nasdaq or Nyse classes to fetch stock data:
from stocks_historical import Nasdaq, Nyse
# Fetch NASDAQ data
nasdaq_data = Nasdaq(symbol="AAPL", start="2023-01-03", end="2023-01-09") # Start and end are dates (YYYY-MM-DD)
data = nasdaq_data.get_data()
print(data.head())
# Fetch NYSE data
nyse_data = Nyse(symbol="GE", start="2023-01-03") # End is optional
data = nyse_data.get_data()
print(data.head())
Output: The data is returned as a Pandas DataFrame with columns:
Date:Timestamp of the record (in human-readable format).Open:Opening price of the stock.High:Highest price of the stock.Low:Lowest price of the stock.Close:Closing price of the stock.
Example DataFrame:
Fetched Data:
Date Open High Low Close
0 2023-01-03 01:00:00 130.280 130.900 124.17 125.07
1 2023-01-04 01:00:00 126.890 128.656 125.08 126.36
2 2023-01-05 01:00:00 127.130 127.770 124.76 125.02
3 2023-01-06 01:00:00 126.010 130.290 124.89 129.62
4 2023-01-09 01:00:00 130.465 133.410 129.89 130.15
API Reference
This library is built on top of the Stocks Historical API. If you prefer to work directly with the API, refer to the API repository for documentation: Stocks Historical API
Credits
The stock data used in this library is sourced from Kaggle Datasets:
-
Top 100 NYSE Daily Stock Prices by Steven Van Ingelgem
-
Top 100 NASDAQ daily stock prices by Steven Van Ingelgem
All credits goes to the Kaggle community for providing these datasets!
Contributions
Contributions are welcome 🤗! If you'd like to improve this library, feel free to fork the repository and submit a pull request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stocks_historical-1.0.1.tar.gz.
File metadata
- Download URL: stocks_historical-1.0.1.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6ccf3fedc3343ae073a2a4fc4510b4e69bb03969dfa30224b00d0d72bb39a11
|
|
| MD5 |
4d76330a16450d0a9b7496450421aef1
|
|
| BLAKE2b-256 |
dfebb825fb42e55cd2f4a6cea8080ea46b2bf5191664176d9809fd78d25af016
|
File details
Details for the file stocks_historical-1.0.1-py3-none-any.whl.
File metadata
- Download URL: stocks_historical-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ee1b5d5de2407f0314ca3ae026f8c3cb02ee4e268b0ade548919ef2039723da
|
|
| MD5 |
acae09ea6c58287b056a1c631a2c3da5
|
|
| BLAKE2b-256 |
c0e51e640acc1043ef26c8a2042652a9a763213d56f1adf2c48a64004986b8cc
|