Extension of yfinance package to download wide-form stock data from Yahoo! Finance
Project description
yfinance Package with Wide-Form Data Support and Data Export
yfinance-extended
extends yfinance
package by Ran Aroussi and make it easier to:
- Retrieve multiple-ticker intraday price data in a wide-form
pandas
dataframe; - Read options data for all available expiration dates;
- Retrieve top-of-the-book bid-ask prices and sizes; and,
- Store data in the parquet format with the following structure:
./saved_data
├── AAPL
│ ├── AAPL-2023-04-24.parquet
│ ├── AAPL-2023-04-25.parquet
│ ├── AAPL-2023-04-26.parquet
│ ├── AAPL-2023-04-27.parquet
│ └── AAPL-2023-04-28.parquet
└── TSM
└── TSM-2023-04-24.parquet
└── TSM-2023-04-25.parquet
└── TSM-2023-04-26.parquet
└── TSM-2023-04-27.parquet
└── TSM-2023-04-28.parquet
Sample Usage
Get Historical Data
Getting past five days of minute-by-minute prices of Apple, Inc., including pre-/post-market data.
import yfinance-extended as yfe
loader = yfe.YahooBatchLoader()
price_df = get_historical_prices("AAPL", period="5d", interval="1m", prepost=True)
prices_df = get_historical_prices(["AAPL", "GOOGL"], period="5d", interval="1m", prepost=True)
Read all Available Options Information
options_df = loader.options_data("AAPL")
Get Top-of-the-Book Data
live_prices_df = loader.get_prices("AAPL")
live_prices_df = loader.get_prices(["AAPL", "GOOGL"])
Save to and Read Data from Parquet Files
Save files:
prices_df = get_historical_prices(["AAPL", "GOOGL"], period="5d", interval="1m", prepost=True)
yfe.to_parquet(prices_df, root_dir="./data")
Read files:
prices_df = yfe.read_parquet(root_dir="./data")
Alternatively, if you wish to save all data into one file:
# Write to one file
yfe.to_parquet(prices_df, filepath="./data/datafile.parquet")
# Read from the file
prices_df = yfe.read_parquet(filepath="./data/datafile.parquet")
Project details
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
Close
Hashes for yfinance_extended-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d47b96f444a47651e79fda69af34312608d4652ced57c0c3195739e275202bc |
|
MD5 | 6a57611ceb802bc9cb7d6523ff4b688b |
|
BLAKE2b-256 | 94d28c3349d1775b50739c2b09cbb8d6f865d0c1431b82ae89f6e0eacf54abd6 |