overtime-live-trading-utils 3.0.2-rc.1 → 3.0.2
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 +1 -1
- package/src/tests/unit/bookmakers.test.ts +7 -18
- package/src/tests/unit/markets.test.ts +7 -44
- package/src/tests/unit/odds.test.ts +5 -14
- package/src/tests/unit/spread.test.ts +6 -16
- package/src/tests/utils/helper.ts +0 -8
- package/src/utils/bookmakers.ts +5 -16
- package/src/utils/markets.ts +2 -4
- package/src/utils/odds.ts +8 -32
package/package.json
CHANGED
|
@@ -10,14 +10,9 @@ import {
|
|
|
10
10
|
MockOnlyMoneylineWithDifferentSportsbook,
|
|
11
11
|
} from '../mock/MockOpticSoccer';
|
|
12
12
|
import { mockSoccer } from '../mock/MockSoccerRedis';
|
|
13
|
-
import {
|
|
14
|
-
getLastPolledDataForBookmakers,
|
|
15
|
-
getPlayersMap,
|
|
16
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST,
|
|
17
|
-
} from '../utils/helper';
|
|
13
|
+
import { getLastPolledDataForBookmakers, MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST } from '../utils/helper';
|
|
18
14
|
|
|
19
15
|
const lastPolledData = getLastPolledDataForBookmakers();
|
|
20
|
-
const playersMap = getPlayersMap();
|
|
21
16
|
|
|
22
17
|
describe('Bookmakers', () => {
|
|
23
18
|
it('Should return zero odds for moneyline when one of the bookmakers has no odds', () => {
|
|
@@ -33,8 +28,7 @@ describe('Bookmakers', () => {
|
|
|
33
28
|
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
34
29
|
LeagueMocks.leagueInfoEnabledSpeadAndTotals,
|
|
35
30
|
lastPolledData,
|
|
36
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
37
|
-
playersMap
|
|
31
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
38
32
|
);
|
|
39
33
|
|
|
40
34
|
const hasOdds = market.odds.some(
|
|
@@ -59,8 +53,7 @@ describe('Bookmakers', () => {
|
|
|
59
53
|
5,
|
|
60
54
|
LeagueMocks.leagueInfoOnlyParent,
|
|
61
55
|
lastPolledData,
|
|
62
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
63
|
-
playersMap
|
|
56
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
64
57
|
);
|
|
65
58
|
|
|
66
59
|
const hasOdds = market.odds.some(
|
|
@@ -85,8 +78,7 @@ describe('Bookmakers', () => {
|
|
|
85
78
|
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
86
79
|
LeagueMocks.leagueInfoEnabledSpeadAndTotals,
|
|
87
80
|
lastPolledData,
|
|
88
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
89
|
-
playersMap
|
|
81
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
90
82
|
);
|
|
91
83
|
|
|
92
84
|
const hasOdds = market.odds.some(
|
|
@@ -111,8 +103,7 @@ describe('Bookmakers', () => {
|
|
|
111
103
|
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
112
104
|
LeagueMocks.leagueInfoEnabledSpeadAndTotals,
|
|
113
105
|
lastPolledData,
|
|
114
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
115
|
-
playersMap
|
|
106
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
116
107
|
);
|
|
117
108
|
|
|
118
109
|
expect(market.childMarkets.length).toBe(2);
|
|
@@ -131,8 +122,7 @@ describe('Bookmakers', () => {
|
|
|
131
122
|
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
132
123
|
LeagueMocks.leaguInfoDifferentPrimaryBookmaker,
|
|
133
124
|
lastPolledData,
|
|
134
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
135
|
-
playersMap
|
|
125
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
136
126
|
);
|
|
137
127
|
|
|
138
128
|
expect(market.childMarkets.length).toBe(3);
|
|
@@ -151,8 +141,7 @@ describe('Bookmakers', () => {
|
|
|
151
141
|
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
152
142
|
LeagueMocks.leagueInfoEnabledSpeadAndTotals,
|
|
153
143
|
lastPolledData,
|
|
154
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
155
|
-
playersMap
|
|
144
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
156
145
|
);
|
|
157
146
|
|
|
158
147
|
expect(market.childMarkets.length).toBe(1);
|
|
@@ -5,16 +5,9 @@ import { mapOpticOddsApiFixtureOdds } from '../../utils/opticOdds';
|
|
|
5
5
|
import { LeagueMocks } from '../mock/MockLeagueMap';
|
|
6
6
|
import { MockOnlyMoneyline, MockOpticSoccer } from '../mock/MockOpticSoccer';
|
|
7
7
|
import { mockSoccer } from '../mock/MockSoccerRedis';
|
|
8
|
-
import {
|
|
9
|
-
import { MockRedisNba } from '../mock/OpticOddsMock/MockRedisNba';
|
|
10
|
-
import {
|
|
11
|
-
getLastPolledDataForBookmakers,
|
|
12
|
-
getPlayersMap,
|
|
13
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST,
|
|
14
|
-
} from '../utils/helper';
|
|
8
|
+
import { getLastPolledDataForBookmakers, MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST } from '../utils/helper';
|
|
15
9
|
|
|
16
10
|
const lastPolledData = getLastPolledDataForBookmakers();
|
|
17
|
-
const playersMap = getPlayersMap();
|
|
18
11
|
|
|
19
12
|
describe('Markets', () => {
|
|
20
13
|
describe('LeagueMap configuration', () => {
|
|
@@ -32,8 +25,7 @@ describe('Markets', () => {
|
|
|
32
25
|
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
33
26
|
LeagueMocks.leagueInfoOnlyParent,
|
|
34
27
|
lastPolledData,
|
|
35
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
36
|
-
playersMap
|
|
28
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
37
29
|
);
|
|
38
30
|
|
|
39
31
|
expect(market.childMarkets).toHaveLength(0);
|
|
@@ -52,8 +44,7 @@ describe('Markets', () => {
|
|
|
52
44
|
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
53
45
|
LeagueMocks.leagueInfoMockDisabledChilds,
|
|
54
46
|
lastPolledData,
|
|
55
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
56
|
-
playersMap
|
|
47
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
57
48
|
);
|
|
58
49
|
|
|
59
50
|
expect(market.childMarkets).toHaveLength(0);
|
|
@@ -72,8 +63,7 @@ describe('Markets', () => {
|
|
|
72
63
|
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
73
64
|
LeagueMocks.leagueInfoEnabledSpreadDisabledTotals,
|
|
74
65
|
lastPolledData,
|
|
75
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
76
|
-
playersMap
|
|
66
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
77
67
|
);
|
|
78
68
|
|
|
79
69
|
const containsSpread = market.childMarkets.some((child: any) => child.type === 'spread');
|
|
@@ -96,8 +86,7 @@ describe('Markets', () => {
|
|
|
96
86
|
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
97
87
|
LeagueMocks.leagueInfoEnabledSpeadAndTotals,
|
|
98
88
|
lastPolledData,
|
|
99
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
100
|
-
playersMap
|
|
89
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
101
90
|
);
|
|
102
91
|
|
|
103
92
|
const containsSpread = market.childMarkets.some((child: any) => child.type === 'spread');
|
|
@@ -120,8 +109,7 @@ describe('Markets', () => {
|
|
|
120
109
|
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
121
110
|
LeagueMocks.leagueInfoEnabledAll,
|
|
122
111
|
lastPolledData,
|
|
123
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
124
|
-
playersMap
|
|
112
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
125
113
|
);
|
|
126
114
|
|
|
127
115
|
const containsSpread = market.childMarkets.some((child: any) => child.type === 'spread');
|
|
@@ -176,8 +164,7 @@ describe('Markets', () => {
|
|
|
176
164
|
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
177
165
|
LeagueMocks.leagueInfoOnlyParentDiffSportId,
|
|
178
166
|
lastPolledData,
|
|
179
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
180
|
-
playersMap
|
|
167
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
181
168
|
);
|
|
182
169
|
|
|
183
170
|
expect(warnSpy).toHaveBeenCalled();
|
|
@@ -186,29 +173,5 @@ describe('Markets', () => {
|
|
|
186
173
|
// Restore the original implementation
|
|
187
174
|
warnSpy.mockRestore();
|
|
188
175
|
});
|
|
189
|
-
|
|
190
|
-
it('Should return child markets with player props', () => {
|
|
191
|
-
const freshMockSoccer = JSON.parse(JSON.stringify(MockRedisNba));
|
|
192
|
-
const freshMockOpticSoccer = JSON.parse(JSON.stringify(MockNbaData));
|
|
193
|
-
const market = processMarket(
|
|
194
|
-
freshMockSoccer,
|
|
195
|
-
mapOpticOddsApiFixtureOdds([freshMockOpticSoccer])[0],
|
|
196
|
-
['bovada', 'draftkings'], // this will be ignored as primaryBookmaker is defined in LeagueMap
|
|
197
|
-
[],
|
|
198
|
-
true,
|
|
199
|
-
undefined,
|
|
200
|
-
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
201
|
-
LeagueMocks.PlayerAssist, // league map with player props configured
|
|
202
|
-
lastPolledData,
|
|
203
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST,
|
|
204
|
-
playersMap
|
|
205
|
-
);
|
|
206
|
-
|
|
207
|
-
market.childMarkets.forEach((child: any) => {
|
|
208
|
-
expect(child.playerProps).toBeDefined();
|
|
209
|
-
expect(child.playerProps.playerId).toBeDefined();
|
|
210
|
-
expect(child.playerProps.playerName).toBeDefined();
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
176
|
});
|
|
214
177
|
});
|
|
@@ -10,14 +10,9 @@ import {
|
|
|
10
10
|
MockZeroOdds,
|
|
11
11
|
} from '../mock/MockOpticSoccer';
|
|
12
12
|
import { mockSoccer } from '../mock/MockSoccerRedis';
|
|
13
|
-
import {
|
|
14
|
-
getLastPolledDataForBookmakers,
|
|
15
|
-
getPlayersMap,
|
|
16
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST,
|
|
17
|
-
} from '../utils/helper';
|
|
13
|
+
import { getLastPolledDataForBookmakers, MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST } from '../utils/helper';
|
|
18
14
|
|
|
19
15
|
const lastPolledData = getLastPolledDataForBookmakers();
|
|
20
|
-
const playersMap = getPlayersMap();
|
|
21
16
|
|
|
22
17
|
describe('Odds', () => {
|
|
23
18
|
it('Should return odds for moneyline', () => {
|
|
@@ -33,8 +28,7 @@ describe('Odds', () => {
|
|
|
33
28
|
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
34
29
|
LeagueMocks.leagueInfoOnlyParent,
|
|
35
30
|
lastPolledData,
|
|
36
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
37
|
-
playersMap
|
|
31
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
38
32
|
);
|
|
39
33
|
|
|
40
34
|
const hasOdds = market.odds.some(
|
|
@@ -57,8 +51,7 @@ describe('Odds', () => {
|
|
|
57
51
|
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
58
52
|
LeagueMocks.leagueInfoEnabledSpeadAndTotals,
|
|
59
53
|
lastPolledData,
|
|
60
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
61
|
-
playersMap
|
|
54
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
62
55
|
);
|
|
63
56
|
|
|
64
57
|
const hasOdds = market.odds.some(
|
|
@@ -83,8 +76,7 @@ describe('Odds', () => {
|
|
|
83
76
|
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
84
77
|
LeagueMocks.leagueInfoEnabledSpeadAndTotals,
|
|
85
78
|
lastPolledData,
|
|
86
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
87
|
-
playersMap
|
|
79
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
88
80
|
);
|
|
89
81
|
|
|
90
82
|
const hasChildMarkets = market.childMarkets.length > 0;
|
|
@@ -104,8 +96,7 @@ describe('Odds', () => {
|
|
|
104
96
|
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
105
97
|
LeagueMocks.leagueInfoEnabledSpeadAndTotals,
|
|
106
98
|
lastPolledData,
|
|
107
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
108
|
-
playersMap
|
|
99
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
109
100
|
);
|
|
110
101
|
|
|
111
102
|
expect(market.childMarkets).toHaveLength(0);
|
|
@@ -5,14 +5,9 @@ import { mapOpticOddsApiFixtureOdds } from '../../utils/opticOdds';
|
|
|
5
5
|
import { LeagueMocks } from '../mock/MockLeagueMap';
|
|
6
6
|
import { MockAfterSpreadZeroOdds1, MockOnlyMoneylineFavorite, MockOpticSoccer } from '../mock/MockOpticSoccer';
|
|
7
7
|
import { mockSoccer } from '../mock/MockSoccerRedis';
|
|
8
|
-
import {
|
|
9
|
-
getLastPolledDataForBookmakers,
|
|
10
|
-
getPlayersMap,
|
|
11
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST,
|
|
12
|
-
} from '../utils/helper';
|
|
8
|
+
import { getLastPolledDataForBookmakers, MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST } from '../utils/helper';
|
|
13
9
|
|
|
14
10
|
const lastPolledData = getLastPolledDataForBookmakers();
|
|
15
|
-
const playersMap = getPlayersMap();
|
|
16
11
|
|
|
17
12
|
describe('Spread configuration', () => {
|
|
18
13
|
it('Should return zero odds for quotes that sum up total probability above 1', () => {
|
|
@@ -28,8 +23,7 @@ describe('Spread configuration', () => {
|
|
|
28
23
|
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
29
24
|
LeagueMocks.leagueInfoEnabledSpeadAndTotals,
|
|
30
25
|
lastPolledData,
|
|
31
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
32
|
-
playersMap
|
|
26
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
33
27
|
);
|
|
34
28
|
|
|
35
29
|
const hasOdds = market.odds.some(
|
|
@@ -56,8 +50,7 @@ describe('Spread configuration', () => {
|
|
|
56
50
|
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
57
51
|
LeagueMocks.leagueInfoOnlyParent,
|
|
58
52
|
lastPolledData,
|
|
59
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
60
|
-
playersMap
|
|
53
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
61
54
|
)
|
|
62
55
|
)
|
|
63
56
|
);
|
|
@@ -74,8 +67,7 @@ describe('Spread configuration', () => {
|
|
|
74
67
|
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
75
68
|
LeagueMocks.leagueInfoOnlyParentWithSpreadAdded,
|
|
76
69
|
lastPolledData,
|
|
77
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
78
|
-
playersMap
|
|
70
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
79
71
|
)
|
|
80
72
|
)
|
|
81
73
|
);
|
|
@@ -112,8 +104,7 @@ describe('Spread configuration', () => {
|
|
|
112
104
|
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
113
105
|
LeagueMocks.leagueInfoOnlyParent,
|
|
114
106
|
lastPolledData,
|
|
115
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
116
|
-
playersMap
|
|
107
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
117
108
|
)
|
|
118
109
|
)
|
|
119
110
|
);
|
|
@@ -130,8 +121,7 @@ describe('Spread configuration', () => {
|
|
|
130
121
|
MAX_IMPLIED_PERCENTAGE_DIFF,
|
|
131
122
|
LeagueMocks.leagueInfoOnlyParentWithSpreadAdded,
|
|
132
123
|
lastPolledData,
|
|
133
|
-
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
134
|
-
playersMap
|
|
124
|
+
MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST
|
|
135
125
|
)
|
|
136
126
|
)
|
|
137
127
|
);
|
|
@@ -8,12 +8,4 @@ export const getLastPolledDataForBookmakers = () => {
|
|
|
8
8
|
return lastPolledData;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
export const getPlayersMap = () => {
|
|
12
|
-
const playersMap: Map<string, number> = new Map<string, number>();
|
|
13
|
-
playersMap.set('0C07D14CC5DC', 13234);
|
|
14
|
-
playersMap.set('AD91EA260284', 56789);
|
|
15
|
-
playersMap.set('674851E026BC', 98765);
|
|
16
|
-
return playersMap;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
11
|
export const MAX_ALLOWED_PROVIDER_DATA_STALE_DELAY_TEST = 30000; // 30 seconds
|
package/src/utils/bookmakers.ts
CHANGED
|
@@ -32,23 +32,12 @@ export const getBookmakersArray = (
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export const getBookmakersFromLeagueConfig = (sportId: string | number, leagueInfoArray: LeagueConfigInfo[]) => {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const primary = leagueInfo.primaryBookmaker?.toLowerCase();
|
|
40
|
-
const secondary = leagueInfo.secondaryBookmaker?.toLowerCase();
|
|
41
|
-
if (primary) {
|
|
42
|
-
uniqueBookmakers.push(primary);
|
|
43
|
-
}
|
|
44
|
-
if (secondary && secondary !== primary) {
|
|
45
|
-
uniqueBookmakers.push(secondary);
|
|
46
|
-
}
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
35
|
+
const leagueInfoArrayFiltered: string[] = leagueInfoArray
|
|
36
|
+
.filter((leagueInfo) => Number(leagueInfo.sportId) === Number(sportId) && leagueInfo.enabled === 'true')
|
|
37
|
+
.flatMap((item) => [item.primaryBookmaker?.toLowerCase(), item.secondaryBookmaker?.toLowerCase()])
|
|
38
|
+
.filter((item): item is string => !!item && item.length > 0);
|
|
50
39
|
|
|
51
|
-
return
|
|
40
|
+
return [...new Set(leagueInfoArrayFiltered)];
|
|
52
41
|
};
|
|
53
42
|
|
|
54
43
|
export const getBookmakersForLeague = (
|
package/src/utils/markets.ts
CHANGED
|
@@ -30,8 +30,7 @@ export const processMarket = (
|
|
|
30
30
|
maxPercentageDiffBetwenOdds: number,
|
|
31
31
|
leagueMap: any,
|
|
32
32
|
lastPolledData: LastPolledArray,
|
|
33
|
-
maxAllowedProviderDataStaleDelay: number
|
|
34
|
-
playersMap: Map<string, number>
|
|
33
|
+
maxAllowedProviderDataStaleDelay: number
|
|
35
34
|
) => {
|
|
36
35
|
const sportSpreadData = spreadData.filter((data: any) => data.sportId === String(market.leagueId));
|
|
37
36
|
const leagueInfo = getLeagueInfo(market.leagueId, leagueMap);
|
|
@@ -90,8 +89,7 @@ export const processMarket = (
|
|
|
90
89
|
leagueMap,
|
|
91
90
|
lastPolledData,
|
|
92
91
|
maxAllowedProviderDataStaleDelay,
|
|
93
|
-
maxPercentageDiffBetwenOdds
|
|
94
|
-
playersMap
|
|
92
|
+
maxPercentageDiffBetwenOdds
|
|
95
93
|
);
|
|
96
94
|
|
|
97
95
|
const packedChildMarkets = childMarkets.map((childMarket: any) => {
|
package/src/utils/odds.ts
CHANGED
|
@@ -214,8 +214,7 @@ export const createChildMarkets: (
|
|
|
214
214
|
leagueMap: any,
|
|
215
215
|
lastPolledData: LastPolledArray,
|
|
216
216
|
maxAllowedProviderDataStaleDelay: number,
|
|
217
|
-
maxImpliedPercentageDifference: number
|
|
218
|
-
playersMap: Map<string, number>
|
|
217
|
+
maxImpliedPercentageDifference: number
|
|
219
218
|
) => ChildMarket[] = (
|
|
220
219
|
apiResponseWithOdds,
|
|
221
220
|
spreadDataForSport,
|
|
@@ -225,8 +224,7 @@ export const createChildMarkets: (
|
|
|
225
224
|
leagueMap,
|
|
226
225
|
lastPolledData,
|
|
227
226
|
maxAllowedProviderDataStaleDelay,
|
|
228
|
-
maxImpliedPercentageDifference
|
|
229
|
-
playersMap
|
|
227
|
+
maxImpliedPercentageDifference
|
|
230
228
|
) => {
|
|
231
229
|
const [spreadOdds, totalOdds, moneylineOdds, correctScoreOdds, doubleChanceOdds, ggOdds, childMarkets]: any[] = [
|
|
232
230
|
[],
|
|
@@ -244,7 +242,7 @@ export const createChildMarkets: (
|
|
|
244
242
|
};
|
|
245
243
|
|
|
246
244
|
if (leagueInfo.length > 0) {
|
|
247
|
-
const allChildOdds =
|
|
245
|
+
const allChildOdds = filterOddsByMarketNameBookmaker(apiResponseWithOdds.odds, leagueInfo);
|
|
248
246
|
const checkedChildOdds = checkOddsFromBookmakersForChildMarkets(
|
|
249
247
|
allChildOdds,
|
|
250
248
|
leagueInfo,
|
|
@@ -271,7 +269,7 @@ export const createChildMarkets: (
|
|
|
271
269
|
|
|
272
270
|
const homeAwayFormattedOdds = [
|
|
273
271
|
...groupAndFormatSpreadOdds(spreadOdds, commonData),
|
|
274
|
-
...groupAndFormatTotalOdds(totalOdds, commonData),
|
|
272
|
+
...groupAndFormatTotalOdds(totalOdds, commonData),
|
|
275
273
|
...groupAndFormatMoneylineOdds(moneylineOdds, commonData),
|
|
276
274
|
...groupAndFormatGGOdds(ggOdds),
|
|
277
275
|
...groupAndFormatDoubleChanceOdds(doubleChanceOdds, commonData),
|
|
@@ -286,23 +284,12 @@ export const createChildMarkets: (
|
|
|
286
284
|
);
|
|
287
285
|
|
|
288
286
|
homeAwayOddsWithSpreadAdjusted.forEach((data) => {
|
|
289
|
-
let playerProps = {
|
|
290
|
-
playerId: 0,
|
|
291
|
-
playerName: '',
|
|
292
|
-
};
|
|
293
|
-
if (data.playerProps) {
|
|
294
|
-
playerProps = {
|
|
295
|
-
playerId: playersMap.get(data.playerProps.playerId.toString()) || 0, // convert from opticOdds playerId to our internal playerId
|
|
296
|
-
playerName: data.playerProps.playerName,
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
287
|
const childMarket = {
|
|
300
288
|
leagueId: Number(data.sportId),
|
|
301
289
|
typeId: Number(data.typeId),
|
|
302
290
|
type: MarketTypeMap[data.typeId as MarketType]?.key || '',
|
|
303
291
|
line: Number(data.line || 0),
|
|
304
292
|
odds: data.odds,
|
|
305
|
-
playerProps,
|
|
306
293
|
};
|
|
307
294
|
const leagueInfoByTypeId = leagueInfo.find((league) => Number(league.typeId) === Number(data.typeId));
|
|
308
295
|
const minOdds = leagueInfoByTypeId?.minOdds; // minimum odds configured for child market (e.g. 0.95 implied probability)
|
|
@@ -356,7 +343,7 @@ export const createChildMarkets: (
|
|
|
356
343
|
* @param {string} oddsProvider - The main odds provider to filter by.
|
|
357
344
|
* @returns {Array} The filtered odds array.
|
|
358
345
|
*/
|
|
359
|
-
export const
|
|
346
|
+
export const filterOddsByMarketNameBookmaker = (oddsArray: Odds, leagueInfos: LeagueConfigInfo[]): any => {
|
|
360
347
|
const allChildMarketsTypes = leagueInfos
|
|
361
348
|
.filter(
|
|
362
349
|
(leagueInfo) =>
|
|
@@ -366,10 +353,7 @@ export const filterOdds = (oddsArray: Odds, leagueInfos: LeagueConfigInfo[], pla
|
|
|
366
353
|
.map((leagueInfo) => leagueInfo.marketName.toLowerCase());
|
|
367
354
|
return oddsArray.reduce((acc: any, odd: any) => {
|
|
368
355
|
if (allChildMarketsTypes.includes(odd.marketName.toLowerCase())) {
|
|
369
|
-
const { points, marketName, selection, selectionLine, sportsBookName
|
|
370
|
-
if (playerId && !playersMap.has(playerId)) {
|
|
371
|
-
return acc;
|
|
372
|
-
}
|
|
356
|
+
const { points, marketName, selection, selectionLine, sportsBookName } = odd;
|
|
373
357
|
const key = `${sportsBookName.toLowerCase()}_${marketName.toLowerCase()}_${points}_${selection}_${selectionLine}`;
|
|
374
358
|
acc[key] = {
|
|
375
359
|
...odd,
|
|
@@ -456,13 +440,6 @@ export const groupAndFormatTotalOdds = (oddsArray: any[], commonData: HomeAwayTe
|
|
|
456
440
|
acc[key].typeId = odd.typeId;
|
|
457
441
|
acc[key].type = odd.type;
|
|
458
442
|
acc[key].sportId = odd.sportId;
|
|
459
|
-
|
|
460
|
-
if (odd.playerId) {
|
|
461
|
-
acc[key].playerProps = {
|
|
462
|
-
playerId: odd.playerId, // Player ID from OpticOdds, this will be converted to our internal playerId later
|
|
463
|
-
playerName: odd.selection,
|
|
464
|
-
};
|
|
465
|
-
}
|
|
466
443
|
}
|
|
467
444
|
|
|
468
445
|
return acc;
|
|
@@ -470,8 +447,8 @@ export const groupAndFormatTotalOdds = (oddsArray: any[], commonData: HomeAwayTe
|
|
|
470
447
|
|
|
471
448
|
// Format the grouped odds into the desired output
|
|
472
449
|
const formattedOdds = Object.entries(groupedOdds as any).reduce((acc: any, [key, value]) => {
|
|
473
|
-
const [_marketName, selection,
|
|
474
|
-
const line = parseFloat(
|
|
450
|
+
const [_marketName, selection, selectionLine] = key.split('_');
|
|
451
|
+
const line = parseFloat(selectionLine);
|
|
475
452
|
|
|
476
453
|
// if we have away team in total odds we know the market is team total and we need to increase typeId by one.
|
|
477
454
|
// if this is false typeId is already mapped correctly
|
|
@@ -483,7 +460,6 @@ export const groupAndFormatTotalOdds = (oddsArray: any[], commonData: HomeAwayTe
|
|
|
483
460
|
typeId: !isAwayTeam ? (value as any).typeId : Number((value as any).typeId) + 1,
|
|
484
461
|
sportId: (value as any).sportId,
|
|
485
462
|
type: (value as any).type,
|
|
486
|
-
playerProps: (value as any).playerProps,
|
|
487
463
|
});
|
|
488
464
|
}
|
|
489
465
|
return acc;
|