Spaces:
Sleeping
Sleeping
Feature: IPO Discount, Greenshoe, & Ownership Logic
Browse files- static/script.js +67 -30
static/script.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
| 1 |
async function runAnalysis() {
|
| 2 |
const query = document.getElementById('query').value;
|
| 3 |
const lastPrivate = document.getElementById('last-private').value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
const loader = document.getElementById('loader');
|
| 5 |
const dashboard = document.getElementById('dashboard');
|
| 6 |
|
|
@@ -11,10 +17,12 @@ async function runAnalysis() {
|
|
| 11 |
// Prepare form data
|
| 12 |
const formData = new FormData();
|
| 13 |
formData.append('query', query);
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
|
| 19 |
try {
|
| 20 |
const response = await fetch('/analyze', {
|
|
@@ -38,18 +46,18 @@ async function runAnalysis() {
|
|
| 38 |
|
| 39 |
// UI State: Done
|
| 40 |
loader.style.display = 'none';
|
| 41 |
-
dashboard.style.display = 'flex'; //
|
| 42 |
|
| 43 |
} catch (e) {
|
| 44 |
console.error(e);
|
| 45 |
-
alert("System Error:
|
| 46 |
loader.style.display = 'none';
|
| 47 |
}
|
| 48 |
}
|
| 49 |
|
| 50 |
function updateDashboard(data) {
|
| 51 |
// 1. Executive Commentary
|
| 52 |
-
if (data.advisory
|
| 53 |
document.getElementById('exec-summary-content').innerHTML = data.advisory.commentary;
|
| 54 |
document.getElementById('m-price').textContent = `$${data.advisory.low} - $${data.advisory.high}`;
|
| 55 |
|
|
@@ -57,37 +65,67 @@ function updateDashboard(data) {
|
|
| 57 |
statusEl.textContent = data.advisory.sentiment;
|
| 58 |
statusEl.style.color = data.advisory.color;
|
| 59 |
|
| 60 |
-
// --- METRICS
|
| 61 |
-
|
| 62 |
-
// Row 1: Classics
|
| 63 |
document.getElementById('m-momentum').textContent = (data.metrics.avg_momentum ? data.metrics.avg_momentum.toFixed(1) + "%" : "--");
|
| 64 |
document.getElementById('m-beta').textContent = (data.metrics.avg_beta ? data.metrics.avg_beta.toFixed(2) : "--");
|
| 65 |
-
|
| 66 |
-
// Row 2: V2 Intelligence
|
| 67 |
document.getElementById('m-rule-40').textContent = (data.metrics.avg_rule_40 ? data.metrics.avg_rule_40.toFixed(0) : "--");
|
| 68 |
document.getElementById('m-vix').textContent = (data.macro ? data.macro.vix.toFixed(2) : "--");
|
| 69 |
|
| 70 |
-
// --- RISK CHECKLIST
|
| 71 |
const riskBody = document.querySelector('#risk-table tbody');
|
| 72 |
-
if (riskBody) {
|
| 73 |
-
riskBody.innerHTML = '';
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
<
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
});
|
| 85 |
-
}
|
| 86 |
}
|
| 87 |
}
|
| 88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
-
// 3. Chart
|
| 91 |
const layout = {
|
| 92 |
plot_bgcolor: '#0E1117',
|
| 93 |
paper_bgcolor: '#1E1E1E',
|
|
@@ -100,8 +138,7 @@ function updateDashboard(data) {
|
|
| 100 |
legend: { orientation: 'h', y: 1.1 }
|
| 101 |
};
|
| 102 |
|
| 103 |
-
|
| 104 |
-
Plotly.newPlot('main-chart', data.chart_json, layout, config);
|
| 105 |
|
| 106 |
// 4. Table
|
| 107 |
const tbody = document.querySelector('#comps-table tbody');
|
|
|
|
| 1 |
async function runAnalysis() {
|
| 2 |
const query = document.getElementById('query').value;
|
| 3 |
const lastPrivate = document.getElementById('last-private').value;
|
| 4 |
+
|
| 5 |
+
// NEW STRUCTURING INPUTS
|
| 6 |
+
const ipoDiscount = document.getElementById('ipo-discount').value;
|
| 7 |
+
const greenshoe = document.getElementById('greenshoe').checked;
|
| 8 |
+
const primaryShares = document.getElementById('primary-shares').value;
|
| 9 |
+
|
| 10 |
const loader = document.getElementById('loader');
|
| 11 |
const dashboard = document.getElementById('dashboard');
|
| 12 |
|
|
|
|
| 17 |
// Prepare form data
|
| 18 |
const formData = new FormData();
|
| 19 |
formData.append('query', query);
|
| 20 |
+
if (lastPrivate) formData.append('last_private', lastPrivate);
|
| 21 |
+
|
| 22 |
+
// Append Structuring Levers
|
| 23 |
+
formData.append('ipo_discount', ipoDiscount);
|
| 24 |
+
formData.append('greenshoe', greenshoe);
|
| 25 |
+
formData.append('primary_shares', primaryShares);
|
| 26 |
|
| 27 |
try {
|
| 28 |
const response = await fetch('/analyze', {
|
|
|
|
| 46 |
|
| 47 |
// UI State: Done
|
| 48 |
loader.style.display = 'none';
|
| 49 |
+
dashboard.style.display = 'flex'; // Flex layout
|
| 50 |
|
| 51 |
} catch (e) {
|
| 52 |
console.error(e);
|
| 53 |
+
alert("System Error: " + e.message);
|
| 54 |
loader.style.display = 'none';
|
| 55 |
}
|
| 56 |
}
|
| 57 |
|
| 58 |
function updateDashboard(data) {
|
| 59 |
// 1. Executive Commentary
|
| 60 |
+
if (data.advisory) {
|
| 61 |
document.getElementById('exec-summary-content').innerHTML = data.advisory.commentary;
|
| 62 |
document.getElementById('m-price').textContent = `$${data.advisory.low} - $${data.advisory.high}`;
|
| 63 |
|
|
|
|
| 65 |
statusEl.textContent = data.advisory.sentiment;
|
| 66 |
statusEl.style.color = data.advisory.color;
|
| 67 |
|
| 68 |
+
// --- METRICS ---
|
|
|
|
|
|
|
| 69 |
document.getElementById('m-momentum').textContent = (data.metrics.avg_momentum ? data.metrics.avg_momentum.toFixed(1) + "%" : "--");
|
| 70 |
document.getElementById('m-beta').textContent = (data.metrics.avg_beta ? data.metrics.avg_beta.toFixed(2) : "--");
|
|
|
|
|
|
|
| 71 |
document.getElementById('m-rule-40').textContent = (data.metrics.avg_rule_40 ? data.metrics.avg_rule_40.toFixed(0) : "--");
|
| 72 |
document.getElementById('m-vix').textContent = (data.macro ? data.macro.vix.toFixed(2) : "--");
|
| 73 |
|
| 74 |
+
// --- RISK CHECKLIST ---
|
| 75 |
const riskBody = document.querySelector('#risk-table tbody');
|
| 76 |
+
if (riskBody && data.advisory.risk_matrix) {
|
| 77 |
+
riskBody.innerHTML = '';
|
| 78 |
+
data.advisory.risk_matrix.forEach(r => {
|
| 79 |
+
const row = `
|
| 80 |
+
<tr style="border-bottom: 1px solid rgba(255,255,255,0.05);">
|
| 81 |
+
<td style="padding:8px 0; color:#ccc;">${r.factor}</td>
|
| 82 |
+
<td style="padding:8px 0;">${r.status}</td>
|
| 83 |
+
<td style="padding:8px 0; color:var(--text-muted); font-style:italic;">${r.impact}</td>
|
| 84 |
+
</tr>
|
| 85 |
+
`;
|
| 86 |
+
riskBody.innerHTML += row;
|
| 87 |
+
});
|
|
|
|
|
|
|
| 88 |
}
|
| 89 |
}
|
| 90 |
|
| 91 |
+
// 2. IPO STRUCTURING (The Pro Layer)
|
| 92 |
+
if (data.structure) {
|
| 93 |
+
document.getElementById('s-final-price').textContent = `$${data.structure.final_price.toFixed(2)}`;
|
| 94 |
+
document.getElementById('s-dilution').textContent = `${data.structure.dilution}%`;
|
| 95 |
+
|
| 96 |
+
// Down-Round Alert
|
| 97 |
+
const drAlert = document.getElementById('dr-alert');
|
| 98 |
+
if (data.down_round && data.down_round.is_active) {
|
| 99 |
+
drAlert.style.display = 'block';
|
| 100 |
+
drAlert.innerHTML = data.down_round.text;
|
| 101 |
+
} else {
|
| 102 |
+
drAlert.style.display = 'none';
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
// Ownership Pie Chart
|
| 106 |
+
const ownerData = [{
|
| 107 |
+
values: [data.structure.ownership["Existing Shareholders"], data.structure.ownership["New Public Investors"]],
|
| 108 |
+
labels: ['Existing Holders', 'New Public Investors'],
|
| 109 |
+
type: 'pie',
|
| 110 |
+
marker: { colors: ['#333', '#FFD700'] }, // Grey vs Gold
|
| 111 |
+
textinfo: 'label+percent',
|
| 112 |
+
hole: 0.4
|
| 113 |
+
}];
|
| 114 |
+
|
| 115 |
+
const ownerLayout = {
|
| 116 |
+
paper_bgcolor: 'rgba(0,0,0,0)',
|
| 117 |
+
plot_bgcolor: 'rgba(0,0,0,0)',
|
| 118 |
+
font: { color: '#ccc' },
|
| 119 |
+
showlegend: false,
|
| 120 |
+
margin: { t: 10, b: 10, l: 10, r: 10 },
|
| 121 |
+
height: 250
|
| 122 |
+
};
|
| 123 |
+
|
| 124 |
+
Plotly.newPlot('ownership-chart', ownerData, ownerLayout, { responsive: true });
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
|
| 128 |
+
// 3. Main Chart
|
| 129 |
const layout = {
|
| 130 |
plot_bgcolor: '#0E1117',
|
| 131 |
paper_bgcolor: '#1E1E1E',
|
|
|
|
| 138 |
legend: { orientation: 'h', y: 1.1 }
|
| 139 |
};
|
| 140 |
|
| 141 |
+
Plotly.newPlot('main-chart', data.chart_json, layout, { responsive: true });
|
|
|
|
| 142 |
|
| 143 |
// 4. Table
|
| 144 |
const tbody = document.querySelector('#comps-table tbody');
|