Spaces:
Sleeping
Sleeping
Logic Upgrade: Dynamic Target Raise + Percentage Pricing
Browse files
main.py
CHANGED
|
@@ -194,18 +194,21 @@ def generate_advisory(signals, macro, fundamentals, last_private_price):
|
|
| 194 |
avg_ev_rev = np.mean([f['ev_rev'] for f in fundamentals if f['ev_rev'] > 0])
|
| 195 |
|
| 196 |
# 1. PRICING LOGIC
|
| 197 |
-
#
|
| 198 |
-
# Rough calc: If market expects x10, IPO discount is usually 10-15%
|
| 199 |
-
# This is a synthetic range for demo
|
| 200 |
base_price = 30.0 # Anchor (Simplified assumption)
|
| 201 |
|
| 202 |
-
|
| 203 |
-
if
|
| 204 |
-
|
| 205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
|
| 207 |
-
low_px = base_price
|
| 208 |
-
high_px = base_price
|
| 209 |
|
| 210 |
# 2. MARKET WINDOW LOGIC
|
| 211 |
window_status = "OPEN"
|
|
@@ -300,12 +303,12 @@ def generate_advisory(signals, macro, fundamentals, last_private_price):
|
|
| 300 |
final_text += " <br><i>Note: Valuation pressured by rising 10yr yields (>4.2%).</i>"
|
| 301 |
|
| 302 |
return {
|
|
|
|
|
|
|
| 303 |
'low': round(low_px, 2),
|
| 304 |
'high': round(high_px, 2),
|
| 305 |
-
'sentiment': window_status,
|
| 306 |
'color': window_color,
|
| 307 |
-
'
|
| 308 |
-
'avg_ev_rev': avg_ev_rev,
|
| 309 |
'risk_matrix': risk_matrix
|
| 310 |
}
|
| 311 |
|
|
@@ -313,12 +316,12 @@ def generate_advisory(signals, macro, fundamentals, last_private_price):
|
|
| 313 |
# IPO STRUCTURING LOGIC (Professional)
|
| 314 |
# ==============================================================================
|
| 315 |
|
| 316 |
-
def calculate_ipo_structure(implied_price, discount_pct, greenshoe_active, existing_shares_m):
|
| 317 |
"""
|
| 318 |
Calculates final deal structure based on banking levers.
|
| 319 |
-
|
| 320 |
"""
|
| 321 |
-
target_raise =
|
| 322 |
|
| 323 |
# 1. Apply Discount
|
| 324 |
discount_factor = (100 - discount_pct) / 100
|
|
@@ -373,7 +376,8 @@ async def analyze(request: Request,
|
|
| 373 |
last_private: str = Form(None),
|
| 374 |
ipo_discount: float = Form(15.0), # Default 15%
|
| 375 |
greenshoe: bool = Form(False), # Default Off
|
| 376 |
-
primary_shares: float = Form(100.0)
|
|
|
|
| 377 |
|
| 378 |
# 1. Determine Sector
|
| 379 |
sector_key = 'SaaS'
|
|
@@ -402,7 +406,7 @@ async def analyze(request: Request,
|
|
| 402 |
# 5. IPO Structuring (The Pro Layer)
|
| 403 |
# We use the midpoint of the implied range as the base for discounting
|
| 404 |
implied_midpoint = (advisory['low'] + advisory['high']) / 2
|
| 405 |
-
structure = calculate_ipo_structure(implied_midpoint, ipo_discount, greenshoe, primary_shares)
|
| 406 |
|
| 407 |
# Update Advisory with Final Price Context
|
| 408 |
final_price = structure['final_price']
|
|
|
|
| 194 |
avg_ev_rev = np.mean([f['ev_rev'] for f in fundamentals if f['ev_rev'] > 0])
|
| 195 |
|
| 196 |
# 1. PRICING LOGIC
|
| 197 |
+
# Revised Logic: Relative Valuation Scaling
|
|
|
|
|
|
|
| 198 |
base_price = 30.0 # Anchor (Simplified assumption)
|
| 199 |
|
| 200 |
+
# NEW: Percentage-based Momentum Premium/Discount
|
| 201 |
+
if avg_mom > 5:
|
| 202 |
+
base_price *= 1.12 # +12% Premium for Hot Sector
|
| 203 |
+
elif avg_mom < -5:
|
| 204 |
+
base_price *= 0.88 # -12% Discount for Cold Sector
|
| 205 |
+
|
| 206 |
+
if avg_vol > 40: base_price *= 0.95 # -5% for High Volatility
|
| 207 |
+
if macro['vix'] > 20: base_price *= 0.90 # -10% for Macro Fear
|
| 208 |
+
if macro['tnx'] > 4.5: base_price *= 0.95 # -5% for Rates
|
| 209 |
|
| 210 |
+
low_px = base_price * 0.93 # +/- 7% Range
|
| 211 |
+
high_px = base_price * 1.07
|
| 212 |
|
| 213 |
# 2. MARKET WINDOW LOGIC
|
| 214 |
window_status = "OPEN"
|
|
|
|
| 303 |
final_text += " <br><i>Note: Valuation pressured by rising 10yr yields (>4.2%).</i>"
|
| 304 |
|
| 305 |
return {
|
| 306 |
+
'commentary': final_text,
|
| 307 |
+
'sentiment': window_status,
|
| 308 |
'low': round(low_px, 2),
|
| 309 |
'high': round(high_px, 2),
|
|
|
|
| 310 |
'color': window_color,
|
| 311 |
+
'avg_ev_rev': round(avg_ev_rev, 1),
|
|
|
|
| 312 |
'risk_matrix': risk_matrix
|
| 313 |
}
|
| 314 |
|
|
|
|
| 316 |
# IPO STRUCTURING LOGIC (Professional)
|
| 317 |
# ==============================================================================
|
| 318 |
|
| 319 |
+
def calculate_ipo_structure(implied_price, discount_pct, greenshoe_active, existing_shares_m, target_raise_m=250.0):
|
| 320 |
"""
|
| 321 |
Calculates final deal structure based on banking levers.
|
| 322 |
+
Target Capital Raise is now dynamic (default $250M)
|
| 323 |
"""
|
| 324 |
+
target_raise = float(target_raise_m)
|
| 325 |
|
| 326 |
# 1. Apply Discount
|
| 327 |
discount_factor = (100 - discount_pct) / 100
|
|
|
|
| 376 |
last_private: str = Form(None),
|
| 377 |
ipo_discount: float = Form(15.0), # Default 15%
|
| 378 |
greenshoe: bool = Form(False), # Default Off
|
| 379 |
+
primary_shares: float = Form(100.0), # Default 100M shares
|
| 380 |
+
target_raise: float = Form(250.0)): # Default $250M
|
| 381 |
|
| 382 |
# 1. Determine Sector
|
| 383 |
sector_key = 'SaaS'
|
|
|
|
| 406 |
# 5. IPO Structuring (The Pro Layer)
|
| 407 |
# We use the midpoint of the implied range as the base for discounting
|
| 408 |
implied_midpoint = (advisory['low'] + advisory['high']) / 2
|
| 409 |
+
structure = calculate_ipo_structure(implied_midpoint, ipo_discount, greenshoe, primary_shares, target_raise)
|
| 410 |
|
| 411 |
# Update Advisory with Final Price Context
|
| 412 |
final_price = structure['final_price']
|