AJAY KASU commited on
Commit
38386cc
·
1 Parent(s): 2b62855

Fix: JS ReferenceErrors and add strategy parsing

Browse files
Files changed (1) hide show
  1. api/static/index.html +23 -2
api/static/index.html CHANGED
@@ -461,6 +461,27 @@
461
  }
462
  }
463
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
464
  const payload = {
465
  "client_id": "Web_User",
466
  "excluded_sectors": excluded,
@@ -482,7 +503,7 @@
482
 
483
  // Display Results
484
  const allExclusions = [...excluded, ...excludedTickers];
485
- displayData(data, allExclusions);
486
  loader.style.display = 'none';
487
  results.style.display = 'block';
488
 
@@ -492,7 +513,7 @@
492
  }
493
  }
494
 
495
- function displayData(data, excluded) {
496
  // Metrics
497
  document.getElementById('teMetric').innerText = (data.tracking_error * 100).toFixed(4) + "%";
498
 
 
461
  }
462
  }
463
 
464
+ // Extract Strategy (Smallest/Largest)
465
+ let strategy = null;
466
+ let topN = null; // Default to full universe if null
467
+
468
+ if (lowerInput.includes("smallest")) {
469
+ strategy = "smallest_market_cap";
470
+ } else if (lowerInput.includes("largest")) {
471
+ strategy = "largest_market_cap";
472
+ }
473
+
474
+ // Extract Number for Top N (e.g. "50 smallest")
475
+ // Look for number near strategy keywords or just a number if strategy is present
476
+ if (strategy) {
477
+ const numberMatch = lowerInput.match(/(\d+)\s*(?:smallest|largest|companies|stocks)/);
478
+ if (numberMatch) {
479
+ topN = parseInt(numberMatch[1]);
480
+ } else {
481
+ topN = 50; // Default default
482
+ }
483
+ }
484
+
485
  const payload = {
486
  "client_id": "Web_User",
487
  "excluded_sectors": excluded,
 
503
 
504
  // Display Results
505
  const allExclusions = [...excluded, ...excludedTickers];
506
+ displayData(data, allExclusions, payload); // Pass payload here!
507
  loader.style.display = 'none';
508
  results.style.display = 'block';
509
 
 
513
  }
514
  }
515
 
516
+ function displayData(data, excluded, payload) {
517
  // Metrics
518
  document.getElementById('teMetric').innerText = (data.tracking_error * 100).toFixed(4) + "%";
519