It is difficult to find a free stock financial data interface now. Extracting financial data from Yahoo Finance may be the easiest method in the free solution. Since yahoo Finance canceled API support, you can only write your own crawler or use a third-party library, but yahoo occasionally Page changes and regional restrictions also cause great trouble for crawling data.
This article introduces the yahoo_financials_stmt package I recently submitted to get stock financial data Project address:https://github.com/luckfu/yahoo_financials_stmt
Usage:
Install yahoo_financials_stmt
pip install git+https://github.com/luckfu/yahoo_financials_stmt.git
Get Financials data
import datetime
from yahoo_financials_stmt import YahooFinancialsStmt
yfs = YahooFinancialsStmt()
finances=yfs.get_financials('box')
View Financials data
import datetime
from yahoo_financials_stmt import YahooFinancialsStmt
yfs = YahooFinancialsStmt()
finances.keys()
返回:
dict_keys(['balance_annual', 'balance_quarterly', 'earnings_annual', 'earnings_quarterly', 'income_annual', 'income_quarterly', 'cashflow_annual', 'cashflow_quarterly'])
balance annual
finances['balance_annual']