CCockrum commited on
Commit
c018938
·
verified ·
1 Parent(s): ceb643e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -20
app.py CHANGED
@@ -49,6 +49,10 @@ def calculate_ratios(market_cap, total_revenue, price, dividend_amount, eps=5.0,
49
  roe = np.random.uniform(5, 25)
50
  free_cash_flow = np.random.uniform(50000000, 500000000)
51
  beta = np.random.uniform(0.8, 1.5)
 
 
 
 
52
  return {
53
  'P/E Ratio': pe,
54
  'P/S Ratio': ps,
@@ -58,7 +62,11 @@ def calculate_ratios(market_cap, total_revenue, price, dividend_amount, eps=5.0,
58
  'Debt/Equity Ratio': debt_equity,
59
  'Return on Equity (%)': roe,
60
  'Free Cash Flow ($)': free_cash_flow,
61
- 'Beta (Volatility)': beta
 
 
 
 
62
  }
63
 
64
  def stock_research(symbol, eps=5.0, growth=0.1, book=500000000):
@@ -83,7 +91,11 @@ def stock_research(symbol, eps=5.0, growth=0.1, book=500000000):
83
 
84
  info_table = pd.DataFrame(info.items(), columns=["Metric", "Value"])
85
  ratios_table = pd.DataFrame(ratios.items(), columns=["Metric", "Value"])
86
- financial_health = ratios_table[ratios_table["Metric"].isin(["Debt/Equity Ratio", "Return on Equity (%)", "Free Cash Flow ($)", "Beta (Volatility)"])]
 
 
 
 
87
 
88
  recommendation = "Hold"
89
  if ratios['P/E Ratio'] < 15 and ratios['Debt/Equity Ratio'] < 1.0 and ratios['Return on Equity (%)'] > 10 and ratios['Beta (Volatility)'] < 1.2:
@@ -92,22 +104,25 @@ def stock_research(symbol, eps=5.0, growth=0.1, book=500000000):
92
  recommendation = "Sell"
93
 
94
  report = (
95
- f"Company Overview:\n"
96
- f"Name: {info.get('Name', 'N/A')}\n"
97
- f"Industry: {info.get('Industry', 'N/A')}\n"
98
- f"Sector: {info.get('Sector', 'N/A')}\n"
99
- f"Market Cap: ${info.get('Market Cap', 0):,.2f}\n\n"
100
- f"Financial Metrics:\n"
101
- f"P/E Ratio: {ratios.get('P/E Ratio', 'N/A')}\n"
102
- f"P/S Ratio: {ratios.get('P/S Ratio', 'N/A')}\n"
103
- f"P/B Ratio: {ratios.get('P/B Ratio', 'N/A')}\n"
104
- f"PEG Ratio: {ratios.get('PEG Ratio', 'N/A')}\n"
105
- f"Dividend Yield: {ratios.get('Dividend Yield', 'N/A')}%\n"
106
- f"Debt/Equity Ratio: {ratios.get('Debt/Equity Ratio', 'N/A')}\n"
107
- f"Return on Equity: {ratios.get('Return on Equity (%)', 'N/A')}%\n"
108
- f"Free Cash Flow: ${ratios.get('Free Cash Flow ($)', 0):,.2f}\n"
109
- f"Beta (Volatility): {ratios.get('Beta (Volatility)', 'N/A')}\n"
110
-
 
 
 
111
  )
112
 
113
  summary_prompt = f"Summarize this financial report clearly and briefly:\n\n{report}"
@@ -119,8 +134,6 @@ def stock_research(symbol, eps=5.0, growth=0.1, book=500000000):
119
  ], ignore_index=True)
120
 
121
  return ai_summary, info_table, ratios_table, financial_health, sector_comp, fig
122
-
123
-
124
  # Theme Selection
125
  selected_theme = os.getenv("APP_THEME", "light")
126
  if selected_theme == "dark":
 
49
  roe = np.random.uniform(5, 25)
50
  free_cash_flow = np.random.uniform(50000000, 500000000)
51
  beta = np.random.uniform(0.8, 1.5)
52
+ ev_ebitda = np.random.uniform(8, 20) # Placeholder random value
53
+ price_cash_flow = np.random.uniform(10, 25)
54
+ operating_margin = np.random.uniform(10, 30)
55
+ revenue_growth = np.random.uniform(5, 20)
56
  return {
57
  'P/E Ratio': pe,
58
  'P/S Ratio': ps,
 
62
  'Debt/Equity Ratio': debt_equity,
63
  'Return on Equity (%)': roe,
64
  'Free Cash Flow ($)': free_cash_flow,
65
+ 'Beta (Volatility)': beta,
66
+ 'EV/EBITDA': ev_ebitda,
67
+ 'Price/Cash Flow': price_cash_flow,
68
+ 'Operating Margin (%)': operating_margin,
69
+ 'Revenue Growth (%)': revenue_growth
70
  }
71
 
72
  def stock_research(symbol, eps=5.0, growth=0.1, book=500000000):
 
91
 
92
  info_table = pd.DataFrame(info.items(), columns=["Metric", "Value"])
93
  ratios_table = pd.DataFrame(ratios.items(), columns=["Metric", "Value"])
94
+
95
+ financial_health_metrics = [
96
+ "Debt/Equity Ratio", "Return on Equity (%)", "Free Cash Flow ($)", "Beta (Volatility)"
97
+ ]
98
+ financial_health = ratios_table[ratios_table["Metric"].isin(financial_health_metrics)]
99
 
100
  recommendation = "Hold"
101
  if ratios['P/E Ratio'] < 15 and ratios['Debt/Equity Ratio'] < 1.0 and ratios['Return on Equity (%)'] > 10 and ratios['Beta (Volatility)'] < 1.2:
 
104
  recommendation = "Sell"
105
 
106
  report = (
107
+ f"Company Overview:\n"
108
+ f"Name: {info.get('Name', 'N/A')}\n"
109
+ f"Industry: {info.get('Industry', 'N/A')}\n"
110
+ f"Sector: {info.get('Sector', 'N/A')}\n"
111
+ f"Market Cap: ${info.get('Market Cap', 0):,.2f}\n\n"
112
+ f"Financial Metrics:\n"
113
+ f"P/E Ratio: {ratios.get('P/E Ratio', 'N/A')}\n"
114
+ f"P/S Ratio: {ratios.get('P/S Ratio', 'N/A')}\n"
115
+ f"P/B Ratio: {ratios.get('P/B Ratio', 'N/A')}\n"
116
+ f"PEG Ratio: {ratios.get('PEG Ratio', 'N/A')}\n"
117
+ f"Dividend Yield: {ratios.get('Dividend Yield', 'N/A')}%\n"
118
+ f"Debt/Equity Ratio: {ratios.get('Debt/Equity Ratio', 'N/A')}\n"
119
+ f"Return on Equity: {ratios.get('Return on Equity (%)', 'N/A')}%\n"
120
+ f"Free Cash Flow: ${ratios.get('Free Cash Flow ($)', 0):,.2f}\n"
121
+ f"Beta (Volatility): {ratios.get('Beta (Volatility)', 'N/A')}\n"
122
+ f"EV/EBITDA: {ratios.get('EV/EBITDA', 'N/A')}\n"
123
+ f"Price/Cash Flow: {ratios.get('Price/Cash Flow', 'N/A')}\n"
124
+ f"Operating Margin: {ratios.get('Operating Margin (%)', 'N/A')}%\n"
125
+ f"Revenue Growth: {ratios.get('Revenue Growth (%)', 'N/A')}%\n"
126
  )
127
 
128
  summary_prompt = f"Summarize this financial report clearly and briefly:\n\n{report}"
 
134
  ], ignore_index=True)
135
 
136
  return ai_summary, info_table, ratios_table, financial_health, sector_comp, fig
 
 
137
  # Theme Selection
138
  selected_theme = os.getenv("APP_THEME", "light")
139
  if selected_theme == "dark":