atreadw1492 / yahoo_fin

Scrape stock price history from new (Spring 2017) Yahoo Finance layout
MIT License
286 stars 125 forks source link

Request: TTM in addition to Yearly and Quarterly #25

Open daxm opened 3 years ago

daxm commented 3 years ago

Title says it all. Can we get TTM as an option to the yearly/quarterly ranges?

dark7wind commented 3 years ago

same hope here

randomguy4214 commented 2 years ago

use quarterly and sum. I did it in my code:

adding TTM from t0,t1,t2,t3 before selecting t0 only for income and cash flows

df_ttm = fundamentals_table.groupby(['symbol'])[['totalRevenue', 'costOfRevenue' ,'totalCashFromOperatingActivities', 'capitalExpenditures' , 'totalOperatingExpenses', 'totalCashflowsFromInvestingActivities']].sum() df_ttm = df_ttm.reset_index(drop=False) df_ttm['capitalExpenditures'].fillna(df_ttm['totalCashflowsFromInvestingActivities'], inplace=True) df_ttm.rename(columns={'totalRevenue': 'totalRevenueTTM', 'costOfRevenue': 'costOfRevenueTTM' , 'totalCashFromOperatingActivities': 'totalCashFromOperatingActivitiesTTM' , 'totalOperatingExpenses': 'totalOperatingExpensesTTM' , 'capitalExpenditures': 'capitalExpendituresTTM' , 'Total Debt (mrq)': 'Debt'}, inplace=True) print("ttm precalculated")