Spaces:
Sleeping
Sleeping
Fix: Force overwrite of V2 Advisor code
Browse files
main.py
CHANGED
|
@@ -8,6 +8,7 @@ import numpy as np
|
|
| 8 |
import json
|
| 9 |
import plotly.utils
|
| 10 |
from datetime import datetime
|
|
|
|
| 11 |
|
| 12 |
# ==============================================================================
|
| 13 |
# CONFIGURATION
|
|
@@ -29,12 +30,6 @@ SECTOR_PROXIES = {
|
|
| 29 |
|
| 30 |
BENCHMARK = '^GSPC'
|
| 31 |
|
| 32 |
-
|
| 33 |
-
# ==============================================================================
|
| 34 |
-
# FINANCIAL LOGIC (Ported from Streamlit App)
|
| 35 |
-
# ==============================================================================
|
| 36 |
-
|
| 37 |
-
|
| 38 |
# ==============================================================================
|
| 39 |
# FINANCIAL LOGIC
|
| 40 |
# ==============================================================================
|
|
@@ -70,6 +65,7 @@ def fetch_macro_data():
|
|
| 70 |
def fetch_market_data(tickers):
|
| 71 |
try:
|
| 72 |
all_tickers = tickers + [BENCHMARK]
|
|
|
|
| 73 |
data = yf.download(all_tickers, period="6mo", progress=False)
|
| 74 |
|
| 75 |
if data.empty: raise ValueError("Empty data returned")
|
|
@@ -201,7 +197,7 @@ def generate_advisory(signals, macro, fundamentals, last_private_price):
|
|
| 201 |
# Base multiple derived from average peer EV/Rev with a hairut
|
| 202 |
# Rough calc: If market expects x10, IPO discount is usually 10-15%
|
| 203 |
# This is a synthetic range for demo
|
| 204 |
-
base_price = 30.0 # Anchor
|
| 205 |
|
| 206 |
if avg_mom > 5: base_price += 4.0
|
| 207 |
if avg_vol > 40: base_price -= 3.0
|
|
@@ -213,24 +209,28 @@ def generate_advisory(signals, macro, fundamentals, last_private_price):
|
|
| 213 |
|
| 214 |
# 2. MARKET WINDOW LOGIC
|
| 215 |
window_status = "OPEN"
|
| 216 |
-
window_color = "
|
| 217 |
|
| 218 |
if macro['vix'] > 25:
|
| 219 |
window_status = "CLOSED"
|
| 220 |
-
window_color = "
|
| 221 |
advice_text = "Market volatility (VIX > 25) indicates a closed issuance window. Severe price dislocation risk."
|
| 222 |
elif avg_mom < -5 or macro['vix'] > 20:
|
| 223 |
window_status = "CAUTION"
|
| 224 |
-
window_color = "
|
| 225 |
advice_text = "Headwinds present. Buy-side demand is highly selective. Recommend widening the price talk."
|
| 226 |
else:
|
| 227 |
advice_text = "Constructive backdrop. Strong peer momentum and stable volatility support a premium valuation."
|
| 228 |
|
| 229 |
# 3. DOWN-ROUND DETECTOR
|
| 230 |
down_round_alert = False
|
| 231 |
-
if last_private_price
|
| 232 |
-
|
| 233 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
|
| 235 |
return {
|
| 236 |
'low': round(low_px, 2),
|
|
|
|
| 8 |
import json
|
| 9 |
import plotly.utils
|
| 10 |
from datetime import datetime
|
| 11 |
+
import contextlib
|
| 12 |
|
| 13 |
# ==============================================================================
|
| 14 |
# CONFIGURATION
|
|
|
|
| 30 |
|
| 31 |
BENCHMARK = '^GSPC'
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
# ==============================================================================
|
| 34 |
# FINANCIAL LOGIC
|
| 35 |
# ==============================================================================
|
|
|
|
| 65 |
def fetch_market_data(tickers):
|
| 66 |
try:
|
| 67 |
all_tickers = tickers + [BENCHMARK]
|
| 68 |
+
# Bulk download
|
| 69 |
data = yf.download(all_tickers, period="6mo", progress=False)
|
| 70 |
|
| 71 |
if data.empty: raise ValueError("Empty data returned")
|
|
|
|
| 197 |
# Base multiple derived from average peer EV/Rev with a hairut
|
| 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 |
if avg_mom > 5: base_price += 4.0
|
| 203 |
if avg_vol > 40: base_price -= 3.0
|
|
|
|
| 209 |
|
| 210 |
# 2. MARKET WINDOW LOGIC
|
| 211 |
window_status = "OPEN"
|
| 212 |
+
window_color = "#4ade80" # Green
|
| 213 |
|
| 214 |
if macro['vix'] > 25:
|
| 215 |
window_status = "CLOSED"
|
| 216 |
+
window_color = "#ef4444" # Red
|
| 217 |
advice_text = "Market volatility (VIX > 25) indicates a closed issuance window. Severe price dislocation risk."
|
| 218 |
elif avg_mom < -5 or macro['vix'] > 20:
|
| 219 |
window_status = "CAUTION"
|
| 220 |
+
window_color = "#facc15" # Yellow/Orange
|
| 221 |
advice_text = "Headwinds present. Buy-side demand is highly selective. Recommend widening the price talk."
|
| 222 |
else:
|
| 223 |
advice_text = "Constructive backdrop. Strong peer momentum and stable volatility support a premium valuation."
|
| 224 |
|
| 225 |
# 3. DOWN-ROUND DETECTOR
|
| 226 |
down_round_alert = False
|
| 227 |
+
if last_private_price:
|
| 228 |
+
try:
|
| 229 |
+
lpp = float(last_private_price)
|
| 230 |
+
if lpp > high_px:
|
| 231 |
+
advice_text += f"<br><br><b>⚠️ DOWN-ROUND RISK:</b> Implied range (${low_px:.2f}-${high_px:.2f}) is below last private mark (${lpp:.2f}). Expect significant cap table friction."
|
| 232 |
+
except:
|
| 233 |
+
pass
|
| 234 |
|
| 235 |
return {
|
| 236 |
'low': round(low_px, 2),
|