overtime-live-trading-utils 4.0.0-rc.9 → 4.0.1
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.
- package/main.js +1 -1
- package/package.json +2 -2
- package/src/utils/odds.ts +20 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "overtime-live-trading-utils",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "main.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@types/node": "^20.8.10",
|
|
16
16
|
"oddslib": "^2.1.1",
|
|
17
|
-
"overtime-utils": "^0.1.
|
|
17
|
+
"overtime-utils": "^0.1.66",
|
|
18
18
|
"react": "^17.0.1"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
package/src/utils/odds.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as oddslib from 'oddslib';
|
|
2
|
-
import { MarketType, MarketTypeMap } from 'overtime-utils';
|
|
2
|
+
import { isOneSideExtendedPlayerPropsMarket, MarketType, MarketTypeMap } from 'overtime-utils';
|
|
3
3
|
import { DRAW, ZERO } from '../constants/common';
|
|
4
4
|
import { LAST_POLLED_TOO_OLD, NO_MARKETS_FOR_LEAGUE_ID } from '../constants/errors';
|
|
5
5
|
import { MoneylineTypes } from '../enums/sports';
|
|
@@ -263,7 +263,7 @@ export const createChildMarkets: (
|
|
|
263
263
|
const homeAwayOddsWithSpreadAdjusted = adjustSpreadOnChildOdds(homeAwayFormattedOdds);
|
|
264
264
|
|
|
265
265
|
homeAwayOddsWithSpreadAdjusted.forEach((data) => {
|
|
266
|
-
let childMarket = {
|
|
266
|
+
let childMarket: ChildMarket = {
|
|
267
267
|
leagueId: Number(data.sportId),
|
|
268
268
|
typeId: Number(data.typeId),
|
|
269
269
|
type: MarketTypeMap[data.typeId as MarketType]?.key || '',
|
|
@@ -291,10 +291,10 @@ export const createChildMarkets: (
|
|
|
291
291
|
const maxOdds = leagueInfoByTypeId?.maxOdds; // maximum odds configured for child market (e.g. 0.05 implied probability)
|
|
292
292
|
|
|
293
293
|
if (minOdds && maxOdds) {
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
294
|
+
const allowZeroOdds = ['Total'].includes(data.type);
|
|
295
|
+
const conditionToAddChildMarket = data.odds.every(
|
|
296
|
+
(odd: number) => (odd < minOdds && odd > maxOdds) || (allowZeroOdds && odd === ZERO)
|
|
297
|
+
);
|
|
298
298
|
if (conditionToAddChildMarket) {
|
|
299
299
|
childMarkets.push(childMarket);
|
|
300
300
|
}
|
|
@@ -308,7 +308,7 @@ export const createChildMarkets: (
|
|
|
308
308
|
const minOdds = leagueInfoByTypeId?.minOdds;
|
|
309
309
|
const maxOdds = leagueInfoByTypeId?.maxOdds;
|
|
310
310
|
|
|
311
|
-
const childMarket = {
|
|
311
|
+
const childMarket: ChildMarket = {
|
|
312
312
|
leagueId: Number(data.sportId),
|
|
313
313
|
typeId: Number(data.typeId),
|
|
314
314
|
type: MarketTypeMap[data.typeId as MarketType]?.key || '',
|
|
@@ -318,6 +318,11 @@ export const createChildMarkets: (
|
|
|
318
318
|
return !minOdds || !maxOdds || impliedOdds >= minOdds || impliedOdds <= maxOdds ? 0 : impliedOdds;
|
|
319
319
|
}),
|
|
320
320
|
positionNames: data.positionNames,
|
|
321
|
+
playerProps: {
|
|
322
|
+
playerId: 0,
|
|
323
|
+
playerName: '',
|
|
324
|
+
},
|
|
325
|
+
isPlayerPropsMarket: false,
|
|
321
326
|
};
|
|
322
327
|
childMarkets.push(childMarket);
|
|
323
328
|
});
|
|
@@ -457,9 +462,16 @@ export const groupAndFormatTotalOdds = (oddsArray: any[], commonData: HomeAwayTe
|
|
|
457
462
|
// if this is false typeId is already mapped correctly
|
|
458
463
|
const shouldIncreaseTypeId = selection === commonData.awayTeam && !(value as any).playerProps;
|
|
459
464
|
|
|
465
|
+
const odds = [(value as any).over, (value as any).under];
|
|
466
|
+
const hasOdds = odds.some((odd) => odd !== null);
|
|
467
|
+
|
|
460
468
|
acc.push({
|
|
461
469
|
line: line as any,
|
|
462
|
-
odds:
|
|
470
|
+
odds: hasOdds
|
|
471
|
+
? isOneSideExtendedPlayerPropsMarket(Number((value as any).typeId))
|
|
472
|
+
? odds.filter((odd) => odd !== null)
|
|
473
|
+
: odds.map((odd) => odd || ZERO)
|
|
474
|
+
: [],
|
|
463
475
|
typeId: !shouldIncreaseTypeId ? (value as any).typeId : Number((value as any).typeId) + 1,
|
|
464
476
|
sportId: (value as any).sportId,
|
|
465
477
|
type: (value as any).type,
|