dhruv575 commited on
Commit
66544a8
·
1 Parent(s): febf196

Add summary stat

Browse files
Files changed (3) hide show
  1. static/index.html +10 -10
  2. static/script.js +8 -2
  3. static/styles.css +38 -0
static/index.html CHANGED
@@ -151,7 +151,7 @@
151
  <div class="param-group">
152
  <label class="param-label">
153
  Simulations
154
- <span class="param-hint" title="Number of Monte Carlo runs">?</span>
155
  </label>
156
  <div class="param-input-wrap">
157
  <input type="number" id="numSimulations" class="param-input" value="100" min="10" max="100" step="10">
@@ -162,7 +162,7 @@
162
  <div class="param-group">
163
  <label class="param-label">
164
  Days Before
165
- <span class="param-hint" title="Days before market closes to invest">?</span>
166
  </label>
167
  <div class="param-input-wrap">
168
  <input type="number" id="daysBefore" class="param-input" value="1" min="1" max="7" step="1">
@@ -173,7 +173,7 @@
173
  <div class="param-group">
174
  <label class="param-label">
175
  Min Prob @ 7d
176
- <span class="param-hint" title="Minimum probability 7 days before resolution">?</span>
177
  </label>
178
  <div class="param-input-wrap">
179
  <input type="number" id="minProb7d" class="param-input" value="90" min="50" max="99" step="1">
@@ -184,7 +184,7 @@
184
  <div class="param-group">
185
  <label class="param-label">
186
  Min Prob @ Entry
187
- <span class="param-hint" title="Minimum probability at investment time">?</span>
188
  </label>
189
  <div class="param-input-wrap">
190
  <input type="number" id="minProbCurrent" class="param-input" value="90" min="50" max="99" step="1">
@@ -195,7 +195,7 @@
195
  <div class="param-group">
196
  <label class="param-label">
197
  Trading Frequency
198
- <span class="param-hint" title="How often to trade when opportunities exist">?</span>
199
  </label>
200
  <select id="investmentProbability" class="param-input param-select">
201
  <option value="0.02">Conservative</option>
@@ -208,7 +208,7 @@
208
  <div class="param-group threshold-only">
209
  <label class="param-label">
210
  Target Return
211
- <span class="param-hint" title="Stop trading when this return is reached">?</span>
212
  </label>
213
  <select id="targetReturn" class="param-input param-select">
214
  <option value="4.14">4.14% (Treasury)</option>
@@ -222,7 +222,7 @@
222
  <div class="param-group multi-only">
223
  <label class="param-label">
224
  Number of Funds
225
- <span class="param-hint" title="Split capital across independent funds">?</span>
226
  </label>
227
  <div class="param-input-wrap">
228
  <input type="number" id="numFunds" class="param-input" value="5" min="2" max="10" step="1">
@@ -265,9 +265,9 @@
265
  <div class="metric-label">Average Return</div>
266
  <div class="metric-value" id="avgReturn">--</div>
267
  </div>
268
- <div class="metric-card">
269
- <div class="metric-label">Median Return</div>
270
- <div class="metric-value" id="medianReturn">--</div>
271
  </div>
272
  <div class="metric-card">
273
  <div class="metric-label">Success Rate</div>
 
151
  <div class="param-group">
152
  <label class="param-label">
153
  Simulations
154
+ <span class="param-hint" data-tooltip="Number of Monte Carlo simulation runs">?</span>
155
  </label>
156
  <div class="param-input-wrap">
157
  <input type="number" id="numSimulations" class="param-input" value="100" min="10" max="100" step="10">
 
162
  <div class="param-group">
163
  <label class="param-label">
164
  Days Before
165
+ <span class="param-hint" data-tooltip="Days before market resolution to invest">?</span>
166
  </label>
167
  <div class="param-input-wrap">
168
  <input type="number" id="daysBefore" class="param-input" value="1" min="1" max="7" step="1">
 
173
  <div class="param-group">
174
  <label class="param-label">
175
  Min Prob @ 7d
176
+ <span class="param-hint" data-tooltip="Minimum probability 7 days before resolution">?</span>
177
  </label>
178
  <div class="param-input-wrap">
179
  <input type="number" id="minProb7d" class="param-input" value="90" min="50" max="99" step="1">
 
184
  <div class="param-group">
185
  <label class="param-label">
186
  Min Prob @ Entry
187
+ <span class="param-hint" data-tooltip="Minimum probability at time of investment">?</span>
188
  </label>
189
  <div class="param-input-wrap">
190
  <input type="number" id="minProbCurrent" class="param-input" value="90" min="50" max="99" step="1">
 
195
  <div class="param-group">
196
  <label class="param-label">
197
  Trading Frequency
198
+ <span class="param-hint" data-tooltip="How often to trade when opportunities exist">?</span>
199
  </label>
200
  <select id="investmentProbability" class="param-input param-select">
201
  <option value="0.02">Conservative</option>
 
208
  <div class="param-group threshold-only">
209
  <label class="param-label">
210
  Target Return
211
+ <span class="param-hint" data-tooltip="Stop trading when this return is reached">?</span>
212
  </label>
213
  <select id="targetReturn" class="param-input param-select">
214
  <option value="4.14">4.14% (Treasury)</option>
 
222
  <div class="param-group multi-only">
223
  <label class="param-label">
224
  Number of Funds
225
+ <span class="param-hint" data-tooltip="Split capital across independent funds">?</span>
226
  </label>
227
  <div class="param-input-wrap">
228
  <input type="number" id="numFunds" class="param-input" value="5" min="2" max="10" step="1">
 
265
  <div class="metric-label">Average Return</div>
266
  <div class="metric-value" id="avgReturn">--</div>
267
  </div>
268
+ <div class="metric-card metric-survivors">
269
+ <div class="metric-label">Avg Return (Survivors)</div>
270
+ <div class="metric-value" id="avgReturnSurvivors">--</div>
271
  </div>
272
  <div class="metric-card">
273
  <div class="metric-label">Success Rate</div>
static/script.js CHANGED
@@ -243,16 +243,22 @@ async function callSimulationAPI(params) {
243
 
244
  // ===== RESULTS DISPLAY =====
245
  function displayResults(results) {
246
- const { summary, parameters } = results;
247
 
248
  // Show results section
249
  const resultsSection = document.getElementById('resultsSection');
250
  resultsSection.classList.add('visible');
251
  resultsSection.scrollIntoView({ behavior: 'smooth', block: 'start' });
252
 
 
 
 
 
 
 
253
  // Primary metrics
254
  updateMetric('avgReturn', summary.avgReturn, true);
255
- updateMetric('medianReturn', summary.medianReturn, true);
256
  updateMetric('successRate', summary.positiveReturnRate);
257
  updateMetric('bustRate', summary.bustRate, false, true);
258
 
 
243
 
244
  // ===== RESULTS DISPLAY =====
245
  function displayResults(results) {
246
+ const { summary, parameters, runs } = results;
247
 
248
  // Show results section
249
  const resultsSection = document.getElementById('resultsSection');
250
  resultsSection.classList.add('visible');
251
  resultsSection.scrollIntoView({ behavior: 'smooth', block: 'start' });
252
 
253
+ // Calculate average return of survivors
254
+ const survivors = runs.filter(r => !r.wentBust);
255
+ const avgReturnSurvivors = survivors.length > 0
256
+ ? survivors.reduce((sum, r) => sum + r.totalReturn, 0) / survivors.length
257
+ : null;
258
+
259
  // Primary metrics
260
  updateMetric('avgReturn', summary.avgReturn, true);
261
+ updateMetric('avgReturnSurvivors', avgReturnSurvivors, true);
262
  updateMetric('successRate', summary.positiveReturnRate);
263
  updateMetric('bustRate', summary.bustRate, false, true);
264
 
static/styles.css CHANGED
@@ -367,6 +367,7 @@ body {
367
  }
368
 
369
  .param-hint {
 
370
  width: 14px;
371
  height: 14px;
372
  background: var(--bg-elevated);
@@ -378,6 +379,38 @@ body {
378
  align-items: center;
379
  justify-content: center;
380
  cursor: help;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
381
  }
382
 
383
  .param-input-wrap {
@@ -595,6 +628,11 @@ body {
595
  border-color: var(--border-accent);
596
  }
597
 
 
 
 
 
 
598
  .metric-card.metric-risk .metric-value.high-risk {
599
  color: var(--danger);
600
  }
 
367
  }
368
 
369
  .param-hint {
370
+ position: relative;
371
  width: 14px;
372
  height: 14px;
373
  background: var(--bg-elevated);
 
379
  align-items: center;
380
  justify-content: center;
381
  cursor: help;
382
+ transition: all 0.2s;
383
+ }
384
+
385
+ .param-hint:hover {
386
+ background: var(--accent);
387
+ color: white;
388
+ }
389
+
390
+ .param-hint::after {
391
+ content: attr(data-tooltip);
392
+ position: absolute;
393
+ bottom: calc(100% + 8px);
394
+ left: 50%;
395
+ transform: translateX(-50%);
396
+ padding: 8px 12px;
397
+ background: var(--bg-elevated);
398
+ border: 1px solid var(--border);
399
+ border-radius: var(--radius-sm);
400
+ font-size: 12px;
401
+ font-weight: 400;
402
+ color: var(--text-primary);
403
+ white-space: nowrap;
404
+ opacity: 0;
405
+ visibility: hidden;
406
+ transition: all 0.2s;
407
+ z-index: 100;
408
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
409
+ }
410
+
411
+ .param-hint:hover::after {
412
+ opacity: 1;
413
+ visibility: visible;
414
  }
415
 
416
  .param-input-wrap {
 
628
  border-color: var(--border-accent);
629
  }
630
 
631
+ .metric-card.metric-survivors {
632
+ background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
633
+ border-color: rgba(16, 185, 129, 0.3);
634
+ }
635
+
636
  .metric-card.metric-risk .metric-value.high-risk {
637
  color: var(--danger);
638
  }