Codex commited on
Commit
9a1982f
·
1 Parent(s): e829b62

Filter impossible Circa binary prices

Browse files
src/market-scanner.js CHANGED
@@ -1402,6 +1402,30 @@ function isLikelyValidCircaEntry(entry) {
1402
  }
1403
  }
1404
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1405
  if (entry.lineValue !== null && entry.lineValue !== undefined) {
1406
  if (entry.lineValue < 0 || entry.lineValue > 20) {
1407
  return false;
 
1402
  }
1403
  }
1404
 
1405
+ if (['hits', 'rbis', 'runs'].includes(entry.marketType)) {
1406
+ if (entry.side === 'yes' && (oddsValue < -400 || oddsValue > 600)) {
1407
+ return false;
1408
+ }
1409
+ if (entry.side === 'no' && (oddsValue > 400 || oddsValue < -1200)) {
1410
+ return false;
1411
+ }
1412
+ }
1413
+
1414
+ if (entry.marketType === 'steals') {
1415
+ if (entry.side === 'yes' && (oddsValue < 120 || oddsValue > 1200)) {
1416
+ return false;
1417
+ }
1418
+ if (entry.side === 'no' && (oddsValue > -120 || oddsValue < -2500)) {
1419
+ return false;
1420
+ }
1421
+ }
1422
+
1423
+ if (['total_bases', 'pitcher_strikeouts_generic', 'hits_runs_rbis'].includes(entry.marketType)) {
1424
+ if (oddsValue < -400 || oddsValue > 400) {
1425
+ return false;
1426
+ }
1427
+ }
1428
+
1429
  if (entry.lineValue !== null && entry.lineValue !== undefined) {
1430
  if (entry.lineValue < 0 || entry.lineValue > 20) {
1431
  return false;
test/market-scanner.test.js CHANGED
@@ -129,6 +129,15 @@ test('parses side-by-side binary circa sections without mixing markets', () => {
129
  assert.ok(!entries.some((entry) => entry.marketType === 'hits' && entry.playerName === 'BOBBY WITT JR' && entry.oddsInput === '+185'));
130
  });
131
 
 
 
 
 
 
 
 
 
 
132
  test('parses steals binary section', () => {
133
  const entries = parseCircaOcrText([
134
  'WILL [PLAYER] STEAL A BASE?',
 
129
  assert.ok(!entries.some((entry) => entry.marketType === 'hits' && entry.playerName === 'BOBBY WITT JR' && entry.oddsInput === '+185'));
130
  });
131
 
132
+ test('filters impossible binary hit prices caused by OCR corruption', () => {
133
+ const entries = parseCircaOcrText([
134
+ 'WILL [PLAYER] RECORD A HIT?',
135
+ 'BOBBY WITT JR (KC) 85801 +1858 85802 -230',
136
+ ].join('\n'));
137
+
138
+ assert.ok(!entries.some((entry) => entry.marketType === 'hits' && entry.playerName === 'BOBBY WITT JR' && entry.side === 'yes'));
139
+ });
140
+
141
  test('parses steals binary section', () => {
142
  const entries = parseCircaOcrText([
143
  'WILL [PLAYER] STEAL A BASE?',