CCockrum commited on
Commit
52c8526
·
verified ·
1 Parent(s): 7ddb64a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -111,16 +111,28 @@ def compare_to_sector(sector, ratios):
111
  "Sector Average": [],
112
  "Difference": []
113
  }
 
114
  for key in averages:
115
  stock_value = ratios.get(key, 0)
116
  sector_value = averages.get(key, 0)
117
  diff = stock_value - sector_value
 
 
 
 
 
 
 
 
 
118
  data["Ratio"].append(key)
119
  data["Stock Value"].append(round(stock_value, 2))
120
  data["Sector Average"].append(round(sector_value, 2))
121
- data["Difference"].append(round(diff, 2))
 
122
  return pd.DataFrame(data)
123
 
 
124
  def generate_summary(info, ratios):
125
  recommendation = "Hold"
126
  if ratios['P/E Ratio'] < 15 and ratios['P/B Ratio'] < 2 and ratios['PEG Ratio'] < 1.0 and ratios['Dividend Yield'] > 2:
 
111
  "Sector Average": [],
112
  "Difference": []
113
  }
114
+
115
  for key in averages:
116
  stock_value = ratios.get(key, 0)
117
  sector_value = averages.get(key, 0)
118
  diff = stock_value - sector_value
119
+
120
+ # Add emoji based on difference
121
+ if diff < 0:
122
+ diff_display = f"{diff:.2f} 🟢"
123
+ elif diff > 0:
124
+ diff_display = f"{diff:.2f} 🔴"
125
+ else:
126
+ diff_display = f"{diff:.2f} ⚪"
127
+
128
  data["Ratio"].append(key)
129
  data["Stock Value"].append(round(stock_value, 2))
130
  data["Sector Average"].append(round(sector_value, 2))
131
+ data["Difference"].append(diff_display)
132
+
133
  return pd.DataFrame(data)
134
 
135
+
136
  def generate_summary(info, ratios):
137
  recommendation = "Hold"
138
  if ratios['P/E Ratio'] < 15 and ratios['P/B Ratio'] < 2 and ratios['PEG Ratio'] < 1.0 and ratios['Dividend Yield'] > 2: