Package updates
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
Get weekly and monthly stock prices
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")
Speed-up in functions
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")
Other functionality
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.
Download balance sheets, cash flows, and income statements
# 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")
Get company stats
si.get_stats("aapl")
Get top gainers and losers of the day
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.