CCockrum commited on
Commit
c7fe441
·
verified ·
1 Parent(s): d780f21

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -6
app.py CHANGED
@@ -147,16 +147,28 @@ def calculate_ratios(market_cap, total_revenue, price, dividend_amount, assumed_
147
 
148
  def compare_to_sector(sector, ratios):
149
  if sector.lower() == 'stocks':
150
- sector = 'Technology' # Fallback
151
- averages = sector_averages.get(sector, None)
152
  if not averages:
153
  return pd.DataFrame({"Metric": ["Sector data not available"], "Value": ["N/A"]})
154
- comparison = {}
 
 
 
 
 
 
 
155
  for key in averages:
156
  stock_value = ratios.get(key, 0)
157
- sector_value = averages[key]
158
- comparison[key] = f"{stock_value:.2f} vs Sector Avg {sector_value:.2f}"
159
- return pd.DataFrame({"Ratio": list(comparison.keys()), "Comparison": list(comparison.values())})
 
 
 
 
 
160
 
161
  def stock_research(symbol, assumed_eps=5.0, growth_rate=0.1, book_value=500000000):
162
  info = get_company_info(symbol)
 
147
 
148
  def compare_to_sector(sector, ratios):
149
  if sector.lower() == 'stocks':
150
+ sector = 'Technology'
151
+ averages = sector_averages.get(sector, {})
152
  if not averages:
153
  return pd.DataFrame({"Metric": ["Sector data not available"], "Value": ["N/A"]})
154
+
155
+ data = {
156
+ "Ratio": [],
157
+ "Stock Value": [],
158
+ "Sector Average": [],
159
+ "Difference": []
160
+ }
161
+
162
  for key in averages:
163
  stock_value = ratios.get(key, 0)
164
+ sector_value = averages.get(key, 0)
165
+ diff = stock_value - sector_value
166
+ data["Ratio"].append(key)
167
+ data["Stock Value"].append(round(stock_value, 2))
168
+ data["Sector Average"].append(round(sector_value, 2))
169
+ data["Difference"].append(round(diff, 2))
170
+
171
+ return pd.DataFrame(data)
172
 
173
  def stock_research(symbol, assumed_eps=5.0, growth_rate=0.1, book_value=500000000):
174
  info = get_company_info(symbol)