eznd commited on
Commit
044efc3
·
1 Parent(s): 3365da7

Force Sniper (1.50-1.85) to select single best CLEAN pick only

Browse files
public/index.html CHANGED
@@ -108,7 +108,7 @@
108
  <label class="field">
109
  <span class="field-label">Risk-veto preset</span>
110
  <select id="scout-preset">
111
- <option value="sniper">Sniper (1.50–1.85, 1–2 CLEAN legs)</option>
112
  <option value="balanced">Balanced (2.00–2.60, up to 3 legs)</option>
113
  <option value="classic3x">Classic 3x (3.05–3.45, up to 3 legs)</option>
114
  </select>
@@ -184,7 +184,7 @@
184
  <label class="field">
185
  <span class="field-label">Evaluate with preset</span>
186
  <select id="manual-preset">
187
- <option value="sniper">Sniper (1.50–1.85, CLEAN only)</option>
188
  <option value="balanced">Balanced (2.00–2.60)</option>
189
  <option value="classic3x">Classic 3x (3.05–3.45)</option>
190
  </select>
 
108
  <label class="field">
109
  <span class="field-label">Risk-veto preset</span>
110
  <select id="scout-preset">
111
+ <option value="sniper">Sniper (1.50–1.85, 1 best CLEAN pick)</option>
112
  <option value="balanced">Balanced (2.00–2.60, up to 3 legs)</option>
113
  <option value="classic3x">Classic 3x (3.05–3.45, up to 3 legs)</option>
114
  </select>
 
184
  <label class="field">
185
  <span class="field-label">Evaluate with preset</span>
186
  <select id="manual-preset">
187
+ <option value="sniper">Sniper (1.50–1.85, 1 best CLEAN pick)</option>
188
  <option value="balanced">Balanced (2.00–2.60)</option>
189
  <option value="classic3x">Classic 3x (3.05–3.45)</option>
190
  </select>
src/engine/optimizer.js CHANGED
@@ -185,13 +185,15 @@ export function optimizeSlips(evaluated, configInput = {}) {
185
  };
186
  }
187
 
 
188
  const primaryMatchIds = new Set(best.legs.map((l) => l.matchId));
189
- const altCandidate =
190
- candidates.find(
191
- (c) =>
192
- c.metrics.adjJointProb >= minSlipProb * 0.94 &&
193
- c.legs.every((l) => !primaryMatchIds.has(l.matchId))
194
- ) || null;
 
195
 
196
  const primaryChecklist = buildLineupChecklist(best.legs);
197
  const alternativeChecklist = altCandidate ? buildLineupChecklist(altCandidate.legs) : [];
@@ -214,9 +216,11 @@ export function optimizeSlips(evaluated, configInput = {}) {
214
  zeroOverlap: true,
215
  }
216
  : null,
217
- alternativeReason: altCandidate
218
- ? 'Zero-overlap alternative shares 0 matches with the Primary Slip.'
219
- : 'No clean zero-overlap alternative exists on this slate without reusing Primary matches.',
 
 
220
  topCleanSingles: evaluated.cleanLegs.slice(0, 5).map(stripInternalRef),
221
  checklist: buildLineupChecklist(combinedLegsForChecklist),
222
  primaryChecklist,
 
185
  };
186
  }
187
 
188
+ const allowAlt = config.includeAlternative !== false;
189
  const primaryMatchIds = new Set(best.legs.map((l) => l.matchId));
190
+ const altCandidate = allowAlt
191
+ ? candidates.find(
192
+ (c) =>
193
+ c.metrics.adjJointProb >= minSlipProb * 0.94 &&
194
+ c.legs.every((l) => !primaryMatchIds.has(l.matchId))
195
+ ) || null
196
+ : null;
197
 
198
  const primaryChecklist = buildLineupChecklist(best.legs);
199
  const alternativeChecklist = altCandidate ? buildLineupChecklist(altCandidate.legs) : [];
 
216
  zeroOverlap: true,
217
  }
218
  : null,
219
+ alternativeReason: !allowAlt
220
+ ? 'Single best option mode enabled (only 1 best pick selected).'
221
+ : altCandidate
222
+ ? 'Zero-overlap alternative shares 0 matches with the Primary Slip.'
223
+ : 'No clean zero-overlap alternative exists on this slate without reusing Primary matches.',
224
  topCleanSingles: evaluated.cleanLegs.slice(0, 5).map(stripInternalRef),
225
  checklist: buildLineupChecklist(combinedLegsForChecklist),
226
  primaryChecklist,
src/engine/riskEngine.js CHANGED
@@ -7,15 +7,16 @@ import { deVigTwoWay, solveImpliedLambda } from './math.js';
7
  export const PRESETS = {
8
  sniper: {
9
  id: 'sniper',
10
- name: 'High-Hit-Rate Sniper (1.50–1.85)',
11
  minOdds: 1.50,
12
  maxOdds: 1.85,
13
- maxLegs: 2,
14
- minFairProb: 0.65,
15
  maxVigPct: 7.0,
16
  strictMode: true,
17
  allowCaution: false,
18
- minSlipAdjProb: 0.56,
 
19
  singlePreferenceGap: 0.015,
20
  retailHaircut: 0.02,
21
  },
 
7
  export const PRESETS = {
8
  sniper: {
9
  id: 'sniper',
10
+ name: 'Single Best Sniper (1.50–1.85, 1 CLEAN pick)',
11
  minOdds: 1.50,
12
  maxOdds: 1.85,
13
+ maxLegs: 1,
14
+ minFairProb: 0.52,
15
  maxVigPct: 7.0,
16
  strictMode: true,
17
  allowCaution: false,
18
+ minSlipAdjProb: 0.54,
19
+ includeAlternative: false,
20
  singlePreferenceGap: 0.015,
21
  retailHaircut: 0.02,
22
  },
test/api.test.js CHANGED
@@ -94,7 +94,7 @@ test('personal-only Express API routes, auth gate, cron secret, and JSON preview
94
  doubts5050: { gk: 0, startingCB: 0, otherDef: 0, topScorer: 0, otherAtt: 0, names: [] },
95
  },
96
  moneyline: { home: 1.55, draw: 4.3, away: 5.5 },
97
- totals: { '1.5': { over: 1.26, under: 3.90, sportybetOver: 1.25 } },
98
  weather: { tempC: 12, windKmh: 8, precipType: 'none' },
99
  },
100
  {
@@ -130,7 +130,7 @@ test('personal-only Express API routes, auth gate, cron secret, and JSON preview
130
  doubts5050: { gk: 0, startingCB: 0, otherDef: 0, topScorer: 0, otherAtt: 0, names: [] },
131
  },
132
  moneyline: { home: 1.48, draw: 4.6, away: 6.2 },
133
- totals: { '1.5': { over: 1.28, under: 3.70, sportybetOver: 1.27 } },
134
  weather: { tempC: 10, windKmh: 7, precipType: 'none' },
135
  },
136
  ],
@@ -140,7 +140,9 @@ test('personal-only Express API routes, auth gate, cron secret, and JSON preview
140
 
141
  assert.equal(preview.matchCount, 2);
142
  assert.equal(preview.optimization.recommendation, 'BET');
143
- assert.equal(preview.optimization.primarySlip.metrics.consensusOdds, 1.61);
 
 
144
 
145
  // 6. History filtering endpoint (week default + bad range validation)
146
  const histWeek = await fetch(`${baseUrl}/api/history?mode=week&date=2026-11-24`, {
 
94
  doubts5050: { gk: 0, startingCB: 0, otherDef: 0, topScorer: 0, otherAtt: 0, names: [] },
95
  },
96
  moneyline: { home: 1.55, draw: 4.3, away: 5.5 },
97
+ totals: { '2.5': { over: 1.56, under: 2.45, sportybetOver: 1.55 } },
98
  weather: { tempC: 12, windKmh: 8, precipType: 'none' },
99
  },
100
  {
 
130
  doubts5050: { gk: 0, startingCB: 0, otherDef: 0, topScorer: 0, otherAtt: 0, names: [] },
131
  },
132
  moneyline: { home: 1.48, draw: 4.6, away: 6.2 },
133
+ totals: { '2.5': { over: 1.72, under: 2.15, sportybetOver: 1.70 } },
134
  weather: { tempC: 10, windKmh: 7, precipType: 'none' },
135
  },
136
  ],
 
140
 
141
  assert.equal(preview.matchCount, 2);
142
  assert.equal(preview.optimization.recommendation, 'BET');
143
+ assert.equal(preview.optimization.primarySlip.legs.length, 1);
144
+ assert.equal(preview.optimization.alternativeSlip, null);
145
+ assert.equal(preview.optimization.primarySlip.metrics.consensusOdds, 1.56);
146
 
147
  // 6. History filtering endpoint (week default + bad range validation)
148
  const histWeek = await fetch(`${baseUrl}/api/history?mode=week&date=2026-11-24`, {
test/engine.test.js CHANGED
@@ -135,19 +135,19 @@ test('symmetric Over and Under risk vetoes catch historical traps', () => {
135
  assert.ok(noNews.hardVetoes.some((v) => v.code === 'NO_VERIFIED_TEAM_NEWS'));
136
  });
137
 
138
- test('optimizer selects highest-survival Sniper slip and returns NO_BET when slate is dirty', () => {
139
  const cleanSlate = parseSlatePayload({
140
  slateDate: '2026-11-24',
141
  matches: [
142
  makeCleanMatch({
143
  id: 'm1',
144
- totals: { '1.5': { over: 1.28, under: 3.80, sportybetOver: 1.27 } },
145
  }),
146
  makeCleanMatch({
147
  id: 'm2',
148
  home: { ...makeCleanMatch().home, name: 'Inter Milan' },
149
  away: { ...makeCleanMatch().away, name: 'Monaco' },
150
- totals: { '1.5': { over: 1.30, under: 3.60, sportybetOver: 1.29 } },
151
  }),
152
  ],
153
  });
@@ -155,9 +155,10 @@ test('optimizer selects highest-survival Sniper slip and returns NO_BET when sla
155
  const evaluated = evaluateSlate(cleanSlate, PRESETS.sniper);
156
  const opt = optimizeSlips(evaluated, PRESETS.sniper);
157
  assert.equal(opt.recommendation, 'BET');
158
- assert.equal(opt.primarySlip.legs.length, 2);
159
- assert.ok(opt.primarySlip.metrics.consensusOdds >= 1.5 && opt.primarySlip.metrics.consensusOdds <= 1.85);
160
- assert.ok(opt.checklist.length === 2);
 
161
 
162
  // Dirty slate -> disciplined NO_BET
163
  const dirtySlate = parseSlatePayload({
@@ -210,13 +211,13 @@ test('cross-competition gf vs xg mismatch (e.g. domestic GF + 4-game UCL xG) doe
210
  assert.equal(leg.hardVetoes.some((v) => v.code === 'ATT_XG_BUBBLE'), false);
211
  });
212
 
213
- test('optimizer separates primaryChecklist and alternativeChecklist per slip', () => {
214
  const mk = (id, h, a) =>
215
  makeCleanMatch({
216
  id,
217
  home: { ...makeCleanMatch().home, name: h },
218
  away: { ...makeCleanMatch().away, name: a },
219
- totals: { '1.5': { over: 1.28, under: 3.80, sportybetOver: 1.27 } },
220
  });
221
 
222
  const slate = parseSlatePayload({
@@ -229,7 +230,7 @@ test('optimizer separates primaryChecklist and alternativeChecklist per slip', (
229
  ],
230
  });
231
 
232
- const opt = optimizeSlips(evaluateSlate(slate, PRESETS.sniper), PRESETS.sniper);
233
  assert.equal(opt.recommendation, 'BET');
234
  assert.ok(opt.alternativeSlip);
235
  assert.equal(opt.primaryChecklist.length, 2);
 
135
  assert.ok(noNews.hardVetoes.some((v) => v.code === 'NO_VERIFIED_TEAM_NEWS'));
136
  });
137
 
138
+ test('optimizer selects single best CLEAN Sniper pick only and returns NO_BET when slate is dirty', () => {
139
  const cleanSlate = parseSlatePayload({
140
  slateDate: '2026-11-24',
141
  matches: [
142
  makeCleanMatch({
143
  id: 'm1',
144
+ totals: { '2.5': { over: 1.56, under: 2.45, sportybetOver: 1.55 } },
145
  }),
146
  makeCleanMatch({
147
  id: 'm2',
148
  home: { ...makeCleanMatch().home, name: 'Inter Milan' },
149
  away: { ...makeCleanMatch().away, name: 'Monaco' },
150
+ totals: { '2.5': { over: 1.72, under: 2.15, sportybetOver: 1.70 } },
151
  }),
152
  ],
153
  });
 
155
  const evaluated = evaluateSlate(cleanSlate, PRESETS.sniper);
156
  const opt = optimizeSlips(evaluated, PRESETS.sniper);
157
  assert.equal(opt.recommendation, 'BET');
158
+ assert.equal(opt.primarySlip.legs.length, 1);
159
+ assert.equal(opt.alternativeSlip, null);
160
+ assert.equal(opt.primarySlip.metrics.consensusOdds, 1.56);
161
+ assert.equal(opt.primaryChecklist.length, 1);
162
 
163
  // Dirty slate -> disciplined NO_BET
164
  const dirtySlate = parseSlatePayload({
 
211
  assert.equal(leg.hardVetoes.some((v) => v.code === 'ATT_XG_BUBBLE'), false);
212
  });
213
 
214
+ test('optimizer separates primaryChecklist and alternativeChecklist per slip on multi-leg preset', () => {
215
  const mk = (id, h, a) =>
216
  makeCleanMatch({
217
  id,
218
  home: { ...makeCleanMatch().home, name: h },
219
  away: { ...makeCleanMatch().away, name: a },
220
+ totals: { '1.5': { over: 1.48, under: 2.75, sportybetOver: 1.46 } },
221
  });
222
 
223
  const slate = parseSlatePayload({
 
230
  ],
231
  });
232
 
233
+ const opt = optimizeSlips(evaluateSlate(slate, PRESETS.balanced), PRESETS.balanced);
234
  assert.equal(opt.recommendation, 'BET');
235
  assert.ok(opt.alternativeSlip);
236
  assert.equal(opt.primaryChecklist.length, 2);