First of all – thank you to everyone who has contacted me regarding the yahoo_fin package! Due to some changes in Yahoo Finance’s website, I’ve updated the source code of yahoo_fin. To upgrade to the latest version (0.8.4), you can use pip:
pip install yahoo_fin --upgrade
The most recent version includes all functionality from the previous version, but now also includes the ability to pull weekly and monthly historical stock prices in the get_data method.
from yahoo_fin import stock_info as si # default daily data daily_data = si.get_data("amzn") # get weekly data weekly_data = si.get_data("amzn", interval = "1wk") # get monthly data monthly_data = si.get_data("amzn", interval = "1mo")
The options module includes an update behind the get_expiration_dates function. The functionality is the same, but the code was slightly modified to make it run faster.
from yahoo_fin import options # get expiration dates for AAPL option chain options.get_expiration_dates("aapl")
As a reminder for anyone new to, or less familiar with, yahoo_fin, the package has two modules – stock_info for collecting stock price and fundamentals data, and options for extracting option prices. Here’s a few more examples.
# get AAPL balance sheet si.get_balance_sheet("aapl") # get AAPL cash flow info si.get_cash_flow("aapl") # get AAPL income statement si.get_income_statement("aapl")
si.get_stats("aapl")
si.get_day_gainers() si.get_day_losers()
For more details on the options functionality, check out this post, or here for getting real-time stock prices.
For full documentation, check out this link.
If you have any questions or find any issues regarding yahoo_fin, please feel free to contact me here.
Very excited to announce the early-access preview (MEAP) of my upcoming book, Software Engineering for…
Ever had long-running code that you don't know when it's going to finish running? If…
Background If you've done any type of data analysis in Python, chances are you've probably…
In this post, we will investigate the pandas_profiling and sweetviz packages, which can be used…
In this post, we're going to cover how to plot XGBoost trees in R. XGBoost…
In this post, we'll discuss the underrated Python collections package, which is part of the…