AJAYKASU commited on
Commit
1af5e94
·
verified ·
1 Parent(s): 38e7618

Fix: Force overwrite of V2 Advisor code

Browse files
Files changed (1) hide show
  1. static/script.js +48 -31
static/script.js CHANGED
@@ -1,5 +1,6 @@
1
  async function runAnalysis() {
2
  const query = document.getElementById('query').value;
 
3
  const loader = document.getElementById('loader');
4
  const dashboard = document.getElementById('dashboard');
5
 
@@ -10,6 +11,10 @@ async function runAnalysis() {
10
  // Prepare form data
11
  const formData = new FormData();
12
  formData.append('query', query);
 
 
 
 
13
 
14
  try {
15
  const response = await fetch('/analyze', {
@@ -17,6 +22,12 @@ async function runAnalysis() {
17
  body: formData
18
  });
19
 
 
 
 
 
 
 
20
  const data = await response.json();
21
 
22
  if (data.error) {
@@ -32,30 +43,30 @@ async function runAnalysis() {
32
 
33
  } catch (e) {
34
  console.error(e);
35
- alert("System Error: Could not reach quantitative engine.");
36
  loader.style.display = 'none';
37
  }
38
  }
39
 
40
  function updateDashboard(data) {
41
- // 1. Executive Summary
42
- const summaryHTML = `
43
- <p>
44
- Current market conditions for <b>${data.sector}</b> issuance remain <b style="color:var(--primary-gold)">${data.recommendation.sentiment}</b>.
45
- Sector comparables demonstrate robust momentum relative to the S&P 500 benchmark.
46
- </p>
47
- <p style="margin-top:10px; border-top:1px solid #333; padding-top:10px;">
48
- <b>Strategic Recommendation:</b> Based on current implied volatility and peer multiples,
49
- we recommend an initial pricing range of <b style="color:#fff; font-size:1.1rem">$${data.recommendation.low.toFixed(2)} - $${data.recommendation.high.toFixed(2)}</b> per share.
50
- </p>
51
- `;
52
- document.getElementById('exec-summary-content').innerHTML = summaryHTML;
53
-
54
- // 2. Metrics
55
- document.getElementById('m-momentum').textContent = data.metrics.avg_momentum.toFixed(1) + "%";
56
- document.getElementById('m-beta').textContent = data.metrics.avg_beta.toFixed(2);
57
- document.getElementById('m-vol').textContent = data.metrics.avg_vol.toFixed(1) + "%";
58
- document.getElementById('m-price').textContent = `$${data.recommendation.low.toFixed(0)} - ${data.recommendation.high.toFixed(0)}`;
59
 
60
  // 3. Chart
61
  const layout = {
@@ -77,16 +88,22 @@ function updateDashboard(data) {
77
  const tbody = document.querySelector('#comps-table tbody');
78
  tbody.innerHTML = '';
79
 
80
- data.comparables.forEach(c => {
81
- const row = `
82
- <tr>
83
- <td style="font-weight:bold; color:var(--primary-gold)">${c.ticker}</td>
84
- <td>$${(c.market_cap / 1e9).toFixed(2)}</td>
85
- <td>${c.pe ? c.pe.toFixed(1) + 'x' : 'N/A'}</td>
86
- <td>${c.growth ? (c.growth * 100).toFixed(1) + '%' : 'N/A'}</td>
87
- <td>${c.beta ? c.beta.toFixed(2) : '1.00'}</td>
88
- </tr>
89
- `;
90
- tbody.innerHTML += row;
91
- });
 
 
 
 
 
 
92
  }
 
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
  // Prepare form data
12
  const formData = new FormData();
13
  formData.append('query', query);
14
+ // Only append if value exists
15
+ if (lastPrivate) {
16
+ formData.append('last_private', lastPrivate);
17
+ }
18
 
19
  try {
20
  const response = await fetch('/analyze', {
 
22
  body: formData
23
  });
24
 
25
+ // Check for HTTP errors (like 500)
26
+ if (!response.ok) {
27
+ const errorText = await response.text();
28
+ throw new Error(`Server Error (${response.status}): ${errorText}`);
29
+ }
30
+
31
  const data = await response.json();
32
 
33
  if (data.error) {
 
43
 
44
  } catch (e) {
45
  console.error(e);
46
+ alert("System Error: Could not reach quantitative engine. \nDetail: " + e.message);
47
  loader.style.display = 'none';
48
  }
49
  }
50
 
51
  function updateDashboard(data) {
52
+ // 1. Executive Commentary (The "Advisor")
53
+ // Safe check if advisory exists
54
+ if (data.advisory && data.advisory.commentary) {
55
+ document.getElementById('exec-summary-content').innerHTML = data.advisory.commentary;
56
+ document.getElementById('m-price').textContent = `$${data.advisory.low} - $${data.advisory.high}`;
57
+
58
+ const statusEl = document.getElementById('m-status');
59
+ statusEl.textContent = data.advisory.sentiment;
60
+ statusEl.style.color = data.advisory.color;
61
+
62
+ // Helper
63
+ const formatNum = (num) => (num ? num.toFixed(1) + "x" : "--");
64
+
65
+ document.getElementById('m-ev-rev').textContent = formatNum(data.metrics.avg_ev_rev);
66
+ document.getElementById('m-rule-40').textContent = data.metrics.avg_rule_40 ? data.metrics.avg_rule_40.toFixed(0) : "--";
67
+ document.getElementById('m-vix').textContent = data.macro ? data.macro.vix.toFixed(2) : "--";
68
+ }
69
+
70
 
71
  // 3. Chart
72
  const layout = {
 
88
  const tbody = document.querySelector('#comps-table tbody');
89
  tbody.innerHTML = '';
90
 
91
+ if (data.comparables) {
92
+ data.comparables.forEach(c => {
93
+ // Colors for Rule of 40
94
+ const r40Color = c.rule_40 < 40 ? '#fa5c5c' : '#5cfa85';
95
+
96
+ const row = `
97
+ <tr>
98
+ <td style="font-weight:bold; color:var(--primary-gold)">${c.ticker}</td>
99
+ <td>$${(c.market_cap / 1e9).toFixed(2)}B</td>
100
+ <td>${c.ev_rev ? c.ev_rev.toFixed(1) + 'x' : 'N/A'}</td>
101
+ <td style="color:${r40Color}">${c.rule_40 ? c.rule_40.toFixed(0) : '--'}</td>
102
+ <td>${c.growth ? (c.growth * 100).toFixed(0) + '%' : 'N/A'}</td>
103
+ <td>${c.beta ? c.beta.toFixed(2) : '1.00'}</td>
104
+ </tr>
105
+ `;
106
+ tbody.innerHTML += row;
107
+ });
108
+ }
109
  }