Giter VIP home page Giter VIP logo

yfinance-extended's Introduction

yfinance Package with Wide-Form Data Support and Data Export

yfinance-extended extends yfinance package by Ran Aroussi and make it easier to:

  1. Retrieve multiple-ticker intraday price data in a wide-form pandas dataframe;
  2. Read options data for all available expiration dates;
  3. Retrieve top-of-the-book bid-ask prices and sizes; and,
  4. 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")

yfinance-extended's People

Contributors

zhaohan-dong avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.