overtime-live-trading-utils 4.0.0-rc.8 → 4.0.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "overtime-live-trading-utils",
3
- "version": "4.0.0-rc.8",
3
+ "version": "4.0.0",
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.59",
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';
@@ -291,12 +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
- let conditionToAddChildMarket = true;
295
- data.odds.forEach((odd: number) => {
296
- if (odd >= minOdds || odd <= maxOdds) {
297
- conditionToAddChildMarket = false;
298
- }
299
- });
294
+ const allowZeroOdds = ['Total'].includes(data.type);
295
+ const conditionToAddChildMarket = data.odds.every(
296
+ (odd: number) => (odd < minOdds && odd > maxOdds) || (allowZeroOdds && odd === ZERO)
297
+ );
300
298
  if (conditionToAddChildMarket) {
301
299
  childMarkets.push(childMarket);
302
300
  }
@@ -459,9 +457,16 @@ export const groupAndFormatTotalOdds = (oddsArray: any[], commonData: HomeAwayTe
459
457
  // if this is false typeId is already mapped correctly
460
458
  const shouldIncreaseTypeId = selection === commonData.awayTeam && !(value as any).playerProps;
461
459
 
460
+ const odds = [(value as any).over, (value as any).under];
461
+ const hasOdds = odds.some((odd) => odd !== null);
462
+
462
463
  acc.push({
463
464
  line: line as any,
464
- odds: [(value as any).over, (value as any).under].map((odd) => odd || ZERO),
465
+ odds: hasOdds
466
+ ? isOneSideExtendedPlayerPropsMarket(Number((value as any).typeId))
467
+ ? odds.filter((odd) => odd !== null)
468
+ : odds.map((odd) => odd || ZERO)
469
+ : [],
465
470
  typeId: !shouldIncreaseTypeId ? (value as any).typeId : Number((value as any).typeId) + 1,
466
471
  sportId: (value as any).sportId,
467
472
  type: (value as any).type,