Skip to content

Commit c92867a

Browse files
committed
Add Balance Sheet Overview table
1 parent ad2661f commit c92867a

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

src/infra/yahoo.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99

1010
class YahooFinance:
11+
NUMBER_ROWS = 4
12+
1113
@staticmethod
1214
def is_valid_ticker(ticker: str) -> bool:
1315
stock = yf.Ticker(ticker)
@@ -46,23 +48,9 @@ def get_balance_sheet(
4648
)
4749

4850
try:
49-
fields = [
50-
"Current Assets",
51-
"Current Liabilities",
52-
"Total Assets",
53-
"Total Liabilities Net Minority Interest",
54-
"Total Capitalization",
55-
"Working Capital",
56-
"Invested Capital",
57-
"Total Debt",
58-
"Net Debt",
59-
"Stockholders Equity",
60-
]
61-
6251
df_balance_sheet = balance_sheet.transpose()
63-
df_balance_sheet = df_balance_sheet.reindex(columns=fields, fill_value=0)
6452

65-
return df_balance_sheet.sort_index().tail(4)
53+
return df_balance_sheet.sort_index().tail(YahooFinance.NUMBER_ROWS)
6654
except Exception as e:
6755
logging.error(f"Error fetching balance sheet for {stock}: {e}")
6856

@@ -96,7 +84,7 @@ def get_income_statement(
9684
df_income_stmt = income_statement.transpose()
9785
df_income_stmt = df_income_stmt.reindex(columns=fields, fill_value=0)
9886

99-
return df_income_stmt.sort_index().tail(4)
87+
return df_income_stmt.sort_index().tail(YahooFinance.NUMBER_ROWS)
10088

10189
except Exception as e:
10290
logging.error(f"Error fetching income statement for {stock}: {e}")
@@ -122,7 +110,7 @@ def get_cashflow(
122110
df_cashflow = cashflow.transpose()
123111
df_cashflow = df_cashflow.reindex(columns=fields, fill_value=0)
124112

125-
return df_cashflow.sort_index().tail(4)
113+
return df_cashflow.sort_index().tail(YahooFinance.NUMBER_ROWS)
126114

127115
except Exception as e:
128116
logging.error(f"Error fetching cash flow for {stock}: {e}")

src/ui/layout.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,13 @@ def render_balance_sheet(financial_data, financial_calculations):
377377
)
378378
st.plotly_chart(fig, use_container_width=True)
379379

380+
st.divider()
381+
382+
with st.container():
383+
st.markdown("#### Balance Sheet Overview")
384+
st.write("Hover over the table to download it as a CSV file")
385+
st.dataframe(balance_sheet)
386+
380387

381388
def render_income_stmt(financial_data, *kwargs):
382389
income_stmt = financial_data.get_income_statement(

0 commit comments

Comments
 (0)