JECSand / yahoofinancials

A powerful financial data module used for pulling data from Yahoo Finance. This module can pull fundamental and technical data for stocks, indexes, currencies, cryptos, ETFs, Mutual Funds, U.S. Treasuries, and commodity futures.
https://pypi.python.org/pypi/yahoofinancials
MIT License
899 stars 214 forks source link

Cash Flow Statement : Some data cannot retrieve (e.g. Free cash flow) #67

Open jimmylai-hk opened 4 years ago

jimmylai-hk commented 4 years ago

Hi,

It seems that the function get_financial_stmts get not get some of the data such as Free cash flow from the cash flow statement.

Any clue?

cgbeas commented 3 years ago

You can actually use the following formula and some of the fields that are provided to calculate Free Cash Flow: 𝐹𝐢𝐹=π‘‚π‘π‘’π‘Ÿπ‘Žπ‘‘π‘–π‘›π‘”πΆπ‘Žπ‘ β„ŽπΉπ‘™π‘œπ‘€βˆ’πΆπ‘Žπ‘π‘–π‘‘π‘Žπ‘™πΈπ‘₯π‘π‘’π‘›π‘‘π‘–π‘‘π‘’π‘Ÿπ‘’π‘ 

Here is an example of how I'm doing this:

from yahoofinancials import YahooFinancials

ticker = 'AAPL'
yahoo_financials = YahooFinancials(ticker)
cashflow_statement_data_yr = yahoo_financials.get_financial_stmts('annual', 'cash')
operating_cashflow = cashflow_statement_data_yr['cashflowStatementHistory']['AAPL'][0]['2020-09-26']['totalCashFromOperatingActivities']
capital_expenditures = cashflow_statement_data_yr['cashflowStatementHistory']['AAPL'][0]['2020-09-26']['capitalExpenditures']
free_cash_flow = operating_cashflow + capital_expenditures  # Addition since capEx is negative...
print('Free Cash Flow: {}'.format(free_cash_flow))

Hope this helps.