Skip to content

Commit

Permalink
clean up balance and cash flow sheets
Browse files Browse the repository at this point in the history
  • Loading branch information
cortisiko committed Jun 25, 2024
1 parent 9883721 commit ae071a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
19 changes: 11 additions & 8 deletions app/financials/balance_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ def get_balance_sheet_data(ticker_symbol, frequency):
DataFrame: A DataFrame containing the balance sheet data.
"""
try:
balanceSheetData = ticker_symbol.balance_sheet(frequency)
return balanceSheetData
except Exception as e:
print(e)
balance_sheet_data = ticker_symbol.balance_sheet(frequency)
return balance_sheet_data

except (AttributeError, KeyError, TypeError, ValueError) as e:
print(e)
return None

def get_long_term_debt(long_term_debt_data):
"""
Expand All @@ -47,9 +48,9 @@ def get_long_term_debt(long_term_debt_data):
long_term_debt = long_term_debt / 1e3

return long_term_debt
except KeyError:
print(ERROR_MESSAGE)

except (AttributeError, KeyError, TypeError, ValueError) as e:
print(ERROR_MESSAGE,e)
return None

def get_cash_and_expenses(balance_sheet_data, ticker_symbol):
"""
Expand All @@ -68,5 +69,7 @@ def get_cash_and_expenses(balance_sheet_data, ticker_symbol):
] ## getting the data for the most recent year
cash_and_cash_equivalents = cash_and_cash_equivalents / 1e3
return cash_and_cash_equivalents
except Exception as e:
except (AttributeError, KeyError, TypeError, ValueError) as e:
print(f"I do not see anything on the balance sheet for {ticker_symbol}")
print(f"KeyError: {e}")
return None
3 changes: 2 additions & 1 deletion app/financials/cash_flow_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ def get_most_recent_cash_flow_total(cash_flow_data, position):
] ## takes the most recent cashflow
most_recent_cash_flow = most_recent_cash_flow / 1e3
return most_recent_cash_flow
except Exception as e:
except (AttributeError, KeyError, TypeError, ValueError) as e:
print(e)
return None


def calculate_cash_burn(cash_and_cash_equivalents, free_cash_flow):
Expand Down

0 comments on commit ae071a0

Please sign in to comment.