From c666126661ccfa918f098c63062f8a72da0d538d Mon Sep 17 00:00:00 2001 From: Pietro Rodolfo Masera Date: Sat, 13 May 2023 16:52:31 +0200 Subject: [PATCH] Indexer finished with the last index, on monday we will discuss the implementation of the main dashboard with these indexes --- indexer/indexer.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/indexer/indexer.py b/indexer/indexer.py index 059042a..167a03f 100644 --- a/indexer/indexer.py +++ b/indexer/indexer.py @@ -1,7 +1,6 @@ import pandas as pd def get_peg(ticker: str): - # Read current ratios .csv current_ratios = pd.read_csv(f'Companies_Data/{ticker}_Data/{ticker}_current_ratios.csv', index_col=[0]) @@ -20,7 +19,6 @@ def get_peg(ticker: str): return peg_ratio.values[0] def get_financial_health(ticker: str): - # Read balance sheet .csv balance_sheet = pd.read_csv(f'Companies_Data/{ticker}_Data/{ticker}_balance_sheet_4Y+4Q.csv', index_col=[0]) @@ -42,14 +40,23 @@ def get_financial_health(ticker: str): return financial_health.values[0] def estimated_growth(ticker: str): - - # Read 5 years growth estimates + # Read 5 years growth estimates growth_estimated = pd.read_csv(f'Companies_Data/{ticker}_Data/{ticker}5YGrowthEstimates.csv', index_col=[0])['5Y Growth estimate'].values[0] return growth_estimated -if __name__ == '__main__': - print(get_peg('MCD')) # < 1 (GREEN); > 1 (RED); = 1 (ORANGE) - print(get_financial_health('MCD')) # < 1 (GREEN); > 1 (RED); = 1 (ORANGE) - print(estimated_growth('MCD')) # < 0 (RED); 0 < x < 8% (ORANGE); < 8 % (GREEN) +def past_performance_earnings(ticker: str): + # Read earnings csv + earnings = pd.read_csv(f'Companies_Data/{ticker}_Data/{ticker}earnings.csv', index_col=[0]) + + # Performance + performance_index = round((earnings['epsActual'].sum() - earnings['epsEstimate'].sum()) / earnings['epsEstimate'].sum() * 100, 2) + + return performance_index + +if __name__ == '__main__': + print(get_peg('GOOGL')) # < 1 (GREEN); > 1 (RED); = 1 (ORANGE) + print(get_financial_health('GOOGL')) # < 1 (GREEN); > 1 (RED); = 1 (ORANGE) + print(estimated_growth('GOOGL')) # < 0 (RED); 0 < x < 8% (ORANGE); < 8 % (GREEN) + print(past_performance_earnings('GOOGL'), "%") # -100 < x < 0 (RED); = 0 (ORANGE); 0 < x < 100 (GREEN)