overtime-live-trading-utils 4.0.3-rc.0 → 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,8 +29,7 @@ export const processMarket = (
29
29
  leagueMap: any,
30
30
  lastPolledData: LastPolledArray,
31
31
  maxAllowedProviderDataStaleDelay: number,
32
- playersMap: Map<string, number>,
33
- maxPercentageDiffForPPLines: number
32
+ playersMap: Map<string, number>
34
33
  ) => {
35
34
  const leagueInfo = getLeagueInfo(market.leagueId, leagueMap);
36
35
 
@@ -84,8 +83,7 @@ export const processMarket = (
84
83
  lastPolledData,
85
84
  maxAllowedProviderDataStaleDelay,
86
85
  anchors,
87
- playersMap,
88
- maxPercentageDiffForPPLines
86
+ playersMap
89
87
  );
90
88
 
91
89
  const packedChildMarkets = childMarkets.map((childMarket: any) => {
package/src/utils/odds.ts CHANGED
@@ -198,8 +198,7 @@ export const createChildMarkets: (
198
198
  lastPolledData: LastPolledArray,
199
199
  maxAllowedProviderDataStaleDelay: number,
200
200
  anchors: Anchor[],
201
- playersMap: Map<string, number>,
202
- maxPercentageDiffForPPLines: number
201
+ playersMap: Map<string, number>
203
202
  ) => ChildMarket[] = (
204
203
  apiResponseWithOdds,
205
204
  leagueId,
@@ -208,8 +207,7 @@ export const createChildMarkets: (
208
207
  lastPolledData,
209
208
  maxAllowedProviderDataStaleDelay,
210
209
  anchors,
211
- playersMap,
212
- maxPercentageDiffForPPLines
210
+ playersMap
213
211
  ) => {
214
212
  const [spreadOdds, totalOdds, moneylineOdds, correctScoreOdds, doubleChanceOdds, ggOdds, childMarkets]: any[] = [
215
213
  [],
@@ -234,8 +232,7 @@ export const createChildMarkets: (
234
232
  liveOddsProviders,
235
233
  lastPolledData,
236
234
  maxAllowedProviderDataStaleDelay,
237
- anchors,
238
- maxPercentageDiffForPPLines
235
+ anchors
239
236
  );
240
237
  checkedChildOdds.forEach((odd) => {
241
238
  if (odd.type === 'Total') {
@@ -354,8 +351,8 @@ export const filterOdds = (oddsArray: Odds, leagueInfos: LeagueConfigInfo[], pla
354
351
  .map((leagueInfo) => leagueInfo.marketName.toLowerCase());
355
352
  return oddsArray.reduce((acc: any, odd: any) => {
356
353
  if (allChildMarketsTypes.includes(odd.marketName.toLowerCase())) {
357
- const { points, marketName, selection, selectionLine, sportsBookName, playerId } = odd;
358
- if (playerId && !playersMap.has(playerId)) {
354
+ const { points, marketName, selection, selectionLine, sportsBookName, playerId, isMain } = odd;
355
+ if (playerId && (!playersMap.has(playerId) || !isMain)) {
359
356
  return acc;
360
357
  }
361
358
  const key = `${sportsBookName.toLowerCase()}_${marketName.toLowerCase()}_${points}_${selection}_${selectionLine}`;
@@ -1,476 +0,0 @@
1
- // Mock data for testing player props point adjustment logic
2
- // This mock simulates a scenario where the primary bookmaker (Superbet) has certain lines
3
- // but the secondary bookmaker (DraftKings) has slightly different point values
4
-
5
- const MockBaseEvent = {
6
- id: '20251118019C916F',
7
- numerical_id: 402468,
8
- game_id: '27843-48840-2025-11-17',
9
- start_date: '2025-11-18T00:00:00Z',
10
- home_competitors: [
11
- {
12
- id: 'EDF03AD3C346',
13
- name: 'Philadelphia 76ers',
14
- numerical_id: 21814,
15
- base_id: 14370,
16
- abbreviation: 'PHI',
17
- logo: 'https://cdn.opticodds.com/team-logos/basketball/14370.png',
18
- },
19
- ],
20
- away_competitors: [
21
- {
22
- id: '3E1EA77686B9',
23
- name: 'Los Angeles Clippers',
24
- numerical_id: 21804,
25
- base_id: 14360,
26
- abbreviation: 'LAC',
27
- logo: 'https://cdn.opticodds.com/team-logos/basketball/14360.png',
28
- },
29
- ],
30
- home_team_display: 'Philadelphia 76ers',
31
- away_team_display: 'Los Angeles Clippers',
32
- status: 'unplayed',
33
- is_live: false,
34
- season_type: 'Regular Season',
35
- season_year: '2025',
36
- season_week: '47',
37
- venue_name: 'Xfinity Mobile Arena',
38
- venue_location: 'Philadelphia, PA, USA',
39
- venue_neutral: false,
40
- sport: {
41
- id: 'basketball',
42
- name: 'Basketball',
43
- numerical_id: 4,
44
- },
45
- league: {
46
- id: 'nba',
47
- name: 'NBA',
48
- numerical_id: 355,
49
- },
50
- tournament: null,
51
- };
52
-
53
- // Scenario 1: Primary bookmaker has 25.5 points, secondary has 26.5 points (1 point difference)
54
- export const MockPlayerPropsWithOnePointDiff = {
55
- ...MockBaseEvent,
56
- odds: [
57
- // Superbet (Primary) - 25.5 points
58
- {
59
- id: '27843-48840-2025-11-17:superbet:player_assists:james_harden_over_25_5',
60
- sportsbook: 'Superbet',
61
- market: 'Player Assists',
62
- name: 'James Harden Over 25.5',
63
- is_main: true,
64
- selection: 'James Harden',
65
- normalized_selection: 'james_harden',
66
- market_id: 'player_assists',
67
- selection_line: 'over',
68
- player_id: 'CC707B1EADE5',
69
- team_id: null,
70
- price: 1.95,
71
- timestamp: 1763376721.4084241,
72
- grouping_key: 'james_harden:25.5',
73
- points: 25.5,
74
- deep_link: null,
75
- limits: null,
76
- },
77
- {
78
- id: '27843-48840-2025-11-17:superbet:player_assists:james_harden_under_25_5',
79
- sportsbook: 'Superbet',
80
- market: 'Player Assists',
81
- name: 'James Harden Under 25.5',
82
- is_main: true,
83
- selection: 'James Harden',
84
- normalized_selection: 'james_harden',
85
- market_id: 'player_assists',
86
- selection_line: 'under',
87
- player_id: 'CC707B1EADE5',
88
- team_id: null,
89
- price: 1.85,
90
- timestamp: 1763376496.8200307,
91
- grouping_key: 'james_harden:25.5',
92
- points: 25.5,
93
- deep_link: null,
94
- limits: null,
95
- },
96
- // DraftKings (Secondary) - 26.5 points (1 point difference, should be found by adjustment logic)
97
- {
98
- id: '27843-48840-2025-11-17:draftkings:player_assists:james_harden_over_26_5',
99
- sportsbook: 'DraftKings',
100
- market: 'Player Assists',
101
- name: 'James Harden Over 26.5',
102
- is_main: true,
103
- selection: 'James Harden',
104
- normalized_selection: 'james_harden',
105
- market_id: 'player_assists',
106
- selection_line: 'over',
107
- player_id: 'CC707B1EADE5',
108
- team_id: null,
109
- price: 1.9,
110
- timestamp: 1763376721.4084241,
111
- grouping_key: 'james_harden:26.5',
112
- points: 26.5,
113
- deep_link: null,
114
- limits: null,
115
- },
116
- {
117
- id: '27843-48840-2025-11-17:draftkings:player_assists:james_harden_under_26_5',
118
- sportsbook: 'DraftKings',
119
- market: 'Player Assists',
120
- name: 'James Harden Under 26.5',
121
- is_main: true,
122
- selection: 'James Harden',
123
- normalized_selection: 'james_harden',
124
- market_id: 'player_assists',
125
- selection_line: 'under',
126
- player_id: 'CC707B1EADE5',
127
- team_id: null,
128
- price: 1.88,
129
- timestamp: 1763376496.8200307,
130
- grouping_key: 'james_harden:26.5',
131
- points: 26.5,
132
- deep_link: null,
133
- limits: null,
134
- },
135
- ],
136
- };
137
-
138
- // Scenario 2: Primary bookmaker has 25.5 points, secondary has 24.5 points (-1 point difference)
139
- export const MockPlayerPropsWithNegativeOnePointDiff = {
140
- ...MockBaseEvent,
141
- odds: [
142
- // Superbet (Primary) - 25.5 points
143
- {
144
- id: '27843-48840-2025-11-17:superbet:player_assists:lebron_james_over_25_5',
145
- sportsbook: 'Superbet',
146
- market: 'Player Assists',
147
- name: 'LeBron James Over 25.5',
148
- is_main: true,
149
- selection: 'LeBron James',
150
- normalized_selection: 'lebron_james',
151
- market_id: 'player_assists',
152
- selection_line: 'over',
153
- player_id: 'ABC123',
154
- team_id: null,
155
- price: 1.95,
156
- timestamp: 1763376721.4084241,
157
- grouping_key: 'lebron_james:25.5',
158
- points: 25.5,
159
- deep_link: null,
160
- limits: null,
161
- },
162
- {
163
- id: '27843-48840-2025-11-17:superbet:player_assists:lebron_james_under_25_5',
164
- sportsbook: 'Superbet',
165
- market: 'Player Assists',
166
- name: 'LeBron James Under 25.5',
167
- is_main: true,
168
- selection: 'LeBron James',
169
- normalized_selection: 'lebron_james',
170
- market_id: 'player_assists',
171
- selection_line: 'under',
172
- player_id: 'ABC123',
173
- team_id: null,
174
- price: 1.85,
175
- timestamp: 1763376496.8200307,
176
- grouping_key: 'lebron_james:25.5',
177
- points: 25.5,
178
- deep_link: null,
179
- limits: null,
180
- },
181
- // DraftKings (Secondary) - 24.5 points (-1 point difference, should be found by adjustment logic)
182
- {
183
- id: '27843-48840-2025-11-17:draftkings:player_assists:lebron_james_over_24_5',
184
- sportsbook: 'DraftKings',
185
- market: 'Player Assists',
186
- name: 'LeBron James Over 24.5',
187
- is_main: true,
188
- selection: 'LeBron James',
189
- normalized_selection: 'lebron_james',
190
- market_id: 'player_assists',
191
- selection_line: 'over',
192
- player_id: 'ABC123',
193
- team_id: null,
194
- price: 1.9,
195
- timestamp: 1763376721.4084241,
196
- grouping_key: 'lebron_james:24.5',
197
- points: 24.5,
198
- deep_link: null,
199
- limits: null,
200
- },
201
- {
202
- id: '27843-48840-2025-11-17:draftkings:player_assists:lebron_james_under_24_5',
203
- sportsbook: 'DraftKings',
204
- market: 'Player Assists',
205
- name: 'LeBron James Under 24.5',
206
- is_main: true,
207
- selection: 'LeBron James',
208
- normalized_selection: 'lebron_james',
209
- market_id: 'player_assists',
210
- selection_line: 'under',
211
- player_id: 'ABC123',
212
- team_id: null,
213
- price: 1.88,
214
- timestamp: 1763376496.8200307,
215
- grouping_key: 'lebron_james:24.5',
216
- points: 24.5,
217
- deep_link: null,
218
- limits: null,
219
- },
220
- ],
221
- };
222
-
223
- // Scenario 3: Primary bookmaker has 25.5 points, secondary has 27.5 points (2 points difference)
224
- export const MockPlayerPropsWithTwoPointDiff = {
225
- ...MockBaseEvent,
226
- odds: [
227
- // Superbet (Primary) - 25.5 points
228
- {
229
- id: '27843-48840-2025-11-17:superbet:player_assists:stephen_curry_over_25_5',
230
- sportsbook: 'Superbet',
231
- market: 'Player Assists',
232
- name: 'Stephen Curry Over 25.5',
233
- is_main: true,
234
- selection: 'Stephen Curry',
235
- normalized_selection: 'stephen_curry',
236
- market_id: 'player_assists',
237
- selection_line: 'over',
238
- player_id: 'DEF456',
239
- team_id: null,
240
- price: 1.95,
241
- timestamp: 1763376721.4084241,
242
- grouping_key: 'stephen_curry:25.5',
243
- points: 25.5,
244
- deep_link: null,
245
- limits: null,
246
- },
247
- {
248
- id: '27843-48840-2025-11-17:superbet:player_assists:stephen_curry_under_25_5',
249
- sportsbook: 'Superbet',
250
- market: 'Player Assists',
251
- name: 'Stephen Curry Under 25.5',
252
- is_main: true,
253
- selection: 'Stephen Curry',
254
- normalized_selection: 'stephen_curry',
255
- market_id: 'player_assists',
256
- selection_line: 'under',
257
- player_id: 'DEF456',
258
- team_id: null,
259
- price: 1.85,
260
- timestamp: 1763376496.8200307,
261
- grouping_key: 'stephen_curry:25.5',
262
- points: 25.5,
263
- deep_link: null,
264
- limits: null,
265
- },
266
- // DraftKings (Secondary) - 27.5 points (2 points difference, should be found by adjustment logic)
267
- {
268
- id: '27843-48840-2025-11-17:draftkings:player_assists:stephen_curry_over_27_5',
269
- sportsbook: 'DraftKings',
270
- market: 'Player Assists',
271
- name: 'Stephen Curry Over 27.5',
272
- is_main: true,
273
- selection: 'Stephen Curry',
274
- normalized_selection: 'stephen_curry',
275
- market_id: 'player_assists',
276
- selection_line: 'over',
277
- player_id: 'DEF456',
278
- team_id: null,
279
- price: 1.9,
280
- timestamp: 1763376721.4084241,
281
- grouping_key: 'stephen_curry:27.5',
282
- points: 27.5,
283
- deep_link: null,
284
- limits: null,
285
- },
286
- {
287
- id: '27843-48840-2025-11-17:draftkings:player_assists:stephen_curry_under_27_5',
288
- sportsbook: 'DraftKings',
289
- market: 'Player Assists',
290
- name: 'Stephen Curry Under 27.5',
291
- is_main: true,
292
- selection: 'Stephen Curry',
293
- normalized_selection: 'stephen_curry',
294
- market_id: 'player_assists',
295
- selection_line: 'under',
296
- player_id: 'DEF456',
297
- team_id: null,
298
- price: 1.88,
299
- timestamp: 1763376496.8200307,
300
- grouping_key: 'stephen_curry:27.5',
301
- points: 27.5,
302
- deep_link: null,
303
- limits: null,
304
- },
305
- ],
306
- };
307
-
308
- // Scenario 4: Primary bookmaker has 25.5 points, secondary has no matching line (should be filtered out)
309
- export const MockPlayerPropsWithNoMatchingLine = {
310
- ...MockBaseEvent,
311
- odds: [
312
- // Superbet (Primary) - 25.5 points
313
- {
314
- id: '27843-48840-2025-11-17:superbet:player_assists:kevin_durant_over_25_5',
315
- sportsbook: 'Superbet',
316
- market: 'Player Assists',
317
- name: 'Kevin Durant Over 25.5',
318
- is_main: true,
319
- selection: 'Kevin Durant',
320
- normalized_selection: 'kevin_durant',
321
- market_id: 'player_assists',
322
- selection_line: 'over',
323
- player_id: 'GHI789',
324
- team_id: null,
325
- price: 1.95,
326
- timestamp: 1763376721.4084241,
327
- grouping_key: 'kevin_durant:25.5',
328
- points: 25.5,
329
- deep_link: null,
330
- limits: null,
331
- },
332
- {
333
- id: '27843-48840-2025-11-17:superbet:player_assists:kevin_durant_under_25_5',
334
- sportsbook: 'Superbet',
335
- market: 'Player Assists',
336
- name: 'Kevin Durant Under 25.5',
337
- is_main: true,
338
- selection: 'Kevin Durant',
339
- normalized_selection: 'kevin_durant',
340
- market_id: 'player_assists',
341
- selection_line: 'under',
342
- player_id: 'GHI789',
343
- team_id: null,
344
- price: 1.85,
345
- timestamp: 1763376496.8200307,
346
- grouping_key: 'kevin_durant:25.5',
347
- points: 25.5,
348
- deep_link: null,
349
- limits: null,
350
- },
351
- // DraftKings (Secondary) - 30.5 points (5 points difference, too far to be found)
352
- {
353
- id: '27843-48840-2025-11-17:draftkings:player_assists:kevin_durant_over_30_5',
354
- sportsbook: 'DraftKings',
355
- market: 'Player Assists',
356
- name: 'Kevin Durant Over 30.5',
357
- is_main: true,
358
- selection: 'Kevin Durant',
359
- normalized_selection: 'kevin_durant',
360
- market_id: 'player_assists',
361
- selection_line: 'over',
362
- player_id: 'GHI789',
363
- team_id: null,
364
- price: 1.9,
365
- timestamp: 1763376721.4084241,
366
- grouping_key: 'kevin_durant:30.5',
367
- points: 30.5,
368
- deep_link: null,
369
- limits: null,
370
- },
371
- {
372
- id: '27843-48840-2025-11-17:draftkings:player_assists:kevin_durant_under_30_5',
373
- sportsbook: 'DraftKings',
374
- market: 'Player Assists',
375
- name: 'Kevin Durant Under 30.5',
376
- is_main: true,
377
- selection: 'Kevin Durant',
378
- normalized_selection: 'kevin_durant',
379
- market_id: 'player_assists',
380
- selection_line: 'under',
381
- player_id: 'GHI789',
382
- team_id: null,
383
- price: 1.88,
384
- timestamp: 1763376496.8200307,
385
- grouping_key: 'kevin_durant:30.5',
386
- points: 30.5,
387
- deep_link: null,
388
- limits: null,
389
- },
390
- ],
391
- };
392
-
393
- // Scenario 5: Low point values (10.5) where step calculation is different
394
- export const MockPlayerPropsWithLowPoints = {
395
- ...MockBaseEvent,
396
- odds: [
397
- // Superbet (Primary) - 10.5 points
398
- {
399
- id: '27843-48840-2025-11-17:superbet:player_assists:anthony_davis_over_10_5',
400
- sportsbook: 'Superbet',
401
- market: 'Player Assists',
402
- name: 'Anthony Davis Over 10.5',
403
- is_main: true,
404
- selection: 'Anthony Davis',
405
- normalized_selection: 'anthony_davis',
406
- market_id: 'player_assists',
407
- selection_line: 'over',
408
- player_id: 'JKL012',
409
- team_id: null,
410
- price: 1.95,
411
- timestamp: 1763376721.4084241,
412
- grouping_key: 'anthony_davis:10.5',
413
- points: 10.5,
414
- deep_link: null,
415
- limits: null,
416
- },
417
- {
418
- id: '27843-48840-2025-11-17:superbet:player_assists:anthony_davis_under_10_5',
419
- sportsbook: 'Superbet',
420
- market: 'Player Assists',
421
- name: 'Anthony Davis Under 10.5',
422
- is_main: true,
423
- selection: 'Anthony Davis',
424
- normalized_selection: 'anthony_davis',
425
- market_id: 'player_assists',
426
- selection_line: 'under',
427
- player_id: 'JKL012',
428
- team_id: null,
429
- price: 1.85,
430
- timestamp: 1763376496.8200307,
431
- grouping_key: 'anthony_davis:10.5',
432
- points: 10.5,
433
- deep_link: null,
434
- limits: null,
435
- },
436
- // DraftKings (Secondary) - 11.5 points (1 point difference, should be found)
437
- {
438
- id: '27843-48840-2025-11-17:draftkings:player_assists:anthony_davis_over_11_5',
439
- sportsbook: 'DraftKings',
440
- market: 'Player Assists',
441
- name: 'Anthony Davis Over 11.5',
442
- is_main: true,
443
- selection: 'Anthony Davis',
444
- normalized_selection: 'anthony_davis',
445
- market_id: 'player_assists',
446
- selection_line: 'over',
447
- player_id: 'JKL012',
448
- team_id: null,
449
- price: 1.9,
450
- timestamp: 1763376721.4084241,
451
- grouping_key: 'anthony_davis:11.5',
452
- points: 11.5,
453
- deep_link: null,
454
- limits: null,
455
- },
456
- {
457
- id: '27843-48840-2025-11-17:draftkings:player_assists:anthony_davis_under_11_5',
458
- sportsbook: 'DraftKings',
459
- market: 'Player Assists',
460
- name: 'Anthony Davis Under 11.5',
461
- is_main: true,
462
- selection: 'Anthony Davis',
463
- normalized_selection: 'anthony_davis',
464
- market_id: 'player_assists',
465
- selection_line: 'under',
466
- player_id: 'JKL012',
467
- team_id: null,
468
- price: 1.88,
469
- timestamp: 1763376496.8200307,
470
- grouping_key: 'anthony_davis:11.5',
471
- points: 11.5,
472
- deep_link: null,
473
- limits: null,
474
- },
475
- ],
476
- };
@@ -1,22 +0,0 @@
1
- // Redis mock data for player props adjustment tests
2
- export const MockRedisNbaPlayerPropsAdjustment = {
3
- leagueId: 4,
4
- typeId: 0,
5
- odds: [
6
- {
7
- american: -140.056022408986,
8
- decimal: 1.71399999999988,
9
- normalizedImplied: 0.583430571762,
10
- },
11
- {
12
- american: 450.00000000055,
13
- decimal: 5.5000000000055,
14
- normalizedImplied: 0.181818181818,
15
- },
16
- {
17
- american: 234.999999999514,
18
- decimal: 3.34999999999514,
19
- normalizedImplied: 0.298507462687,
20
- },
21
- ],
22
- };