AJAYKASU commited on
Commit
714627e
Β·
verified Β·
1 Parent(s): d0c6c2f

Feature: Added MD Risk Checklist & Yield Sensitivity

Browse files
Files changed (1) hide show
  1. main.py +62 -2
main.py CHANGED
@@ -232,13 +232,72 @@ def generate_advisory(signals, macro, fundamentals, last_private_price):
232
  except:
233
  pass
234
 
235
- # 4. FORMATTING (Restore V1 Style)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  final_text = (
237
  f"<b>Market Conditions:</b> {window_status} ({macro['vix']:.1f} VIX). "
238
  f"{advice_text}<br><br>"
239
  f"<b>Strategic Recommendation:</b> Based on current implied volatility and peer multiples (Avg {avg_ev_rev:.1f}x EV/Rev), "
240
  f"we recommend an initial pricing range of <b>${low_px:.2f} - ${high_px:.2f}</b> per share."
241
  )
 
 
242
 
243
  return {
244
  'low': round(low_px, 2),
@@ -246,7 +305,8 @@ def generate_advisory(signals, macro, fundamentals, last_private_price):
246
  'sentiment': window_status,
247
  'color': window_color,
248
  'commentary': final_text,
249
- 'avg_ev_rev': avg_ev_rev
 
250
  }
251
 
252
  # ==============================================================================
 
232
  except:
233
  pass
234
 
235
+ # 4. YIELD SENSITIVITY (New)
236
+ yield_impact = "Neutral"
237
+ if macro['tnx'] > 4.5:
238
+ yield_impact = "Negative (High Rates)"
239
+ elif macro['tnx'] < 3.5:
240
+ yield_impact = "Positive (Low Rates)"
241
+
242
+ # 5. RISK CHECKLIST GENERATION
243
+ risk_matrix = []
244
+
245
+ # Risk 1: Volatility
246
+ req_vix = "🟒" if macro['vix'] < 20 else ("πŸ”΄" if macro['vix'] > 25 else "🟑")
247
+ risk_matrix.append({
248
+ "factor": "Market Volatility (VIX)",
249
+ "status": f"{req_vix} {macro['vix']:.2f}",
250
+ "impact": "Constructive" if macro['vix'] < 20 else "Dislocated"
251
+ })
252
+
253
+ # Risk 2: Valuation Gap (Down-Round)
254
+ if last_private_price:
255
+ try:
256
+ lpp = float(last_private_price)
257
+ gap_pct = ((high_px - lpp) / lpp) * 100
258
+
259
+ if gap_pct < 0:
260
+ icon = "πŸ”΄"
261
+ impact_text = "Down-Round Risk"
262
+ elif gap_pct < 15:
263
+ icon = "🟑"
264
+ impact_text = "Flat/Small Uplift"
265
+ else:
266
+ icon = "🟒"
267
+ impact_text = "Accretive IPO"
268
+
269
+ risk_matrix.append({
270
+ "factor": "Valuation Step-Up",
271
+ "status": f"{icon} {gap_pct:+.1f}%",
272
+ "impact": impact_text
273
+ })
274
+ except:
275
+ pass
276
+
277
+ # Risk 3: Yield Environment
278
+ risk_matrix.append({
279
+ "factor": "Yield Environment (10Y)",
280
+ "status": f"{'πŸ”΄' if macro['tnx'] > 4.2 else '🟒'} {macro['tnx']:.2f}%",
281
+ "impact": "Valuation Drag" if macro['tnx'] > 4.2 else "Supportive"
282
+ })
283
+
284
+ # Risk 4: Sector Health (Rule of 40)
285
+ avg_r40 = np.mean([f['rule_40'] for f in fundamentals]) if fundamentals else 0
286
+ risk_matrix.append({
287
+ "factor": "Sector Health (Rule of 40)",
288
+ "status": f"{'🟒' if avg_r40 >= 40 else '🟑'} {avg_r40:.0f}",
289
+ "impact": "Premium Multiples" if avg_r40 >= 40 else "Discount Applied"
290
+ })
291
+
292
+ # 6. FORMATTING (Restore V1 Style + Yield Note)
293
  final_text = (
294
  f"<b>Market Conditions:</b> {window_status} ({macro['vix']:.1f} VIX). "
295
  f"{advice_text}<br><br>"
296
  f"<b>Strategic Recommendation:</b> Based on current implied volatility and peer multiples (Avg {avg_ev_rev:.1f}x EV/Rev), "
297
  f"we recommend an initial pricing range of <b>${low_px:.2f} - ${high_px:.2f}</b> per share."
298
  )
299
+ if macro['tnx'] > 4.2:
300
+ final_text += " <br><i>Note: Valuation pressured by rising 10yr yields (>4.2%).</i>"
301
 
302
  return {
303
  'low': round(low_px, 2),
 
305
  'sentiment': window_status,
306
  'color': window_color,
307
  'commentary': final_text,
308
+ 'avg_ev_rev': avg_ev_rev,
309
+ 'risk_matrix': risk_matrix
310
  }
311
 
312
  # ==============================================================================