overtime-live-trading-utils 1.1.37 → 2.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.
@@ -1,202 +1,4 @@
1
- export enum Sport {
2
- SOCCER = 'Soccer',
3
- FOOTBALL = 'Football',
4
- BASKETBALL = 'Basketball',
5
- BASEBALL = 'Baseball',
6
- HOCKEY = 'Hockey',
7
- FIGHTING = 'Fighting',
8
- TENNIS = 'Tennis',
9
- ESPORTS = 'eSports',
10
- RUGBY = 'Rugby',
11
- VOLLEYBALL = 'Volleyball',
12
- HANDBALL = 'Handball',
13
- WATERPOLO = 'Waterpolo',
14
- CRICKET = 'Cricket',
15
- MOTOSPORT = 'Motosport',
16
- GOLF = 'Golf',
17
- TABLE_TENNIS = 'TableTennis',
18
- POLITICS = 'Politics',
19
- FUTURES = 'Futures',
20
- EMPTY = '',
21
- }
22
-
23
- export enum League {
24
- NCAAF = 1,
25
- NFL = 2,
26
- MLB = 3,
27
- NBA = 4,
28
- NCAAB = 5,
29
- NHL = 6,
30
- UFC = 7,
31
- WNBA = 8,
32
- MLS = 10,
33
- EPL = 11,
34
- LIGUE_ONE = 12,
35
- BUNDESLIGA = 13,
36
- LA_LIGA = 14,
37
- SERIE_A = 15,
38
- UEFA_CL = 16,
39
- UEFA_EL = 17,
40
- FIFA_WC = 18,
41
- J1_LEAGUE = 19,
42
- IPL = 20,
43
- T20_BLAST = 21,
44
- IIHF_WORLD_CHAMPIONSHIP = 33,
45
- COPA_AMERICA = 44,
46
- COPA_LIBERTADORES = 45,
47
- UEFA_EURO = 50,
48
- EREDIVISIE = 57,
49
- PRIMEIRA_LIGA = 61,
50
- SUMMER_OLYMPICS_SOCCER_WOMEN = 65,
51
- SUMMER_OLYMPICS_SOCCER = 66,
52
- FIFA_WC_WOMEN = 76,
53
- ENGLAND_FA_CUP = 132,
54
- FRANCE_CUP = 134,
55
- SPAIN_CUP = 138,
56
- ITALY_CUP = 141,
57
- TENNIS_WTA = 152,
58
- TENNIS_GS = 153,
59
- TENNIS_MASTERS = 156,
60
- SUMMER_OLYMPICS_TENNIS = 158,
61
- GERMANY_CUP = 209,
62
- LIGA_MX = 230,
63
- BRAZIL_1 = 268,
64
- UEFA_EURO_U21 = 288,
65
- FIFA_WORLD_CUP_U20 = 296,
66
- NPB = 301,
67
- KBO = 302,
68
- COLLEGE_BASEBALL = 303,
69
- CPBL = 304,
70
- CZECH_REPUBLIC_EXTRALIGA = 310,
71
- FINLAND_SM_LIIGA = 319,
72
- RUSSIA_KHL = 321,
73
- GERMANY_DEL = 322,
74
- AUSTRIA_ICE_HOCKEY_LEAGUE = 323,
75
- SWEDEN_SHL = 324,
76
- SWITZETLAND_NATIONAL_LEAGUE = 327,
77
- USA_AHL = 328,
78
- SUMMER_OLYMPICS_HANDBALL_WOMEN = 380,
79
- SUMMER_OLYMPICS_HANDBALL = 381,
80
- EUROLEAGUE = 399,
81
- SUMMER_OLYMPICS_BASKETBALL = 406,
82
- SUMMER_OLYMPICS_BASKETBALL_WOMEN = 407,
83
- FIBA_WORLD_CUP = 409,
84
- FORMULA1 = 445,
85
- SUMMER_OLYMPICS_BEACH_VOLEYBALL_WOMEN = 453,
86
- SUMMER_OLYMPICS_BEACH_VOLEYBALL = 454,
87
- MOTOGP = 497,
88
- SAUDI_PROFESSIONAL_LEAGUE = 536,
89
- SUMMER_OLYMPICS_WATERPOLO = 8881,
90
- SUMMER_OLYMPICS_VOLEYBALL_WOMEN = 8893,
91
- SUMMER_OLYMPICS_VOLEYBALL = 8894,
92
- SUMMER_OLYMPICS_TABLE_TENNIS = 8910,
93
- BOXING = 9196,
94
- AUSTRALIA_NRL = 9500,
95
- ENGLAND_SUPER_LEAGUE = 9501,
96
- SUMMER_OLYMPICS_RUGBY = 9578,
97
- SUMMER_OLYMPICS_RUGBY_WOMEN = 9588,
98
- SUMMER_OLYMPICS_HOCKEY_WOMEN = 9698,
99
- SUMMER_OLYMPICS_HOCKEY = 9699,
100
- UEFA_NATIONS_LEAGUE = 9806,
101
- CONCACAF_NATIONS_LEAGUE = 9821,
102
- CSGO = 9977,
103
- DOTA2 = 9983,
104
- SUMMER_OLYMPICS_BASKETBALL_3X3 = 10071,
105
- SUMMER_OLYMPICS_BASKETBALL_3X3_WOMEN = 10072,
106
- LOL = 10138,
107
- SUMMER_OLYMPICS_QUALIFICATION = 10502,
108
- CONMEBOL_WC_QUALIFICATIONS = 10199,
109
- UEFA_CONFERENCE_LEAGUE = 10216,
110
- NON_TITLE_BOXING = 10595,
111
- UEFA_CHAMPIONS_LEAGUE_QUALIFICATION = 10611,
112
- UEFA_EUROPA_LEAGUE_QUALIFICATION = 10613,
113
- UEFA_CONFERENCE_LEAGUE_QUALIFICATION = 10615,
114
- US_ELECTION = 20000,
115
- UEFA_SUPER_CUP = 20001,
116
- BRAZIL_CUP = 20002,
117
- ENGLAND_CHAMPIONSHIP = 20011,
118
- SCOTLAND_PREMIERSHIP = 20101,
119
- BELGIUM_LEAGUE = 20102,
120
- CZECH_LEAGUE = 20103,
121
- CHILE_PRIMERA = 20104,
122
- FINLAND_LEAGUE = 20105,
123
- ARGENTINA_PRIMERA = 20106,
124
- RUSSIA_PREMIER = 20107,
125
- TURKEY_SUPER_LEAGUE = 20108,
126
- SERBIA_SUPER_LEAGUE = 20109,
127
- GREECE_SUPER_LEAGUE = 20110,
128
- INDIA_PREMIER = 20111,
129
- CHINA_SUPER_LEAGUE = 20112,
130
- AUSTRALIA_A_LEAGUE = 20113,
131
- SWITZERLAND_SUPER_LEAGUE = 20114,
132
- BUNDESLIGA_2 = 20115,
133
- LA_LIGA_2 = 20116,
134
- SERIE_B = 20117,
135
- INDIA_SUPER_LEAGUE = 20118,
136
- LIGUE_2 = 20119,
137
- AUSTRIA_BUNDESLIGA = 20120,
138
- DENMARK_SUPER_LEAGUE = 20121,
139
- POLAND_LEAGUE = 20122,
140
- SWEDEN_LEAGUE = 20123,
141
- COLOMBIA_PRIMERA_A = 20124,
142
- ENGLAND_EFL_CUP = 20125,
143
- ENGLAND_LEGAUE_1 = 20126,
144
- URUGUAY_PRIMERA_DIVISION = 20127,
145
- AFC_CHAMPIONS_LEAGUE = 20128,
146
- ITALY_SUPER_CUP = 20129,
147
- FRANCE_SUPER_CUP = 20130,
148
- SPAIN_SUPER_CUP = 20131,
149
- GERMANY_SUPER_CUP = 20132,
150
- PORTUGAL_LEAGUE_CUP = 20133,
151
- THAILAND_LEAGUE_1 = 20134,
152
- NETHERLANDS_CUP = 20135,
153
- PORTUGAL_CUP = 20136,
154
- ENGLAND_SUPER_LEAGUE_WOMEN = 20137,
155
- ITALY_SERIE_A_WOMEN = 20138,
156
- FRANCE_PREMIERE_LIGUE_WOMEN = 20139,
157
- GERMANY_BUNDESLIGA_WOMEN = 20140,
158
- SPAIN_LIGA_F_WOMEN = 20141,
159
- NETHERLANDS_EREDIVISIE_WOMEN = 20142,
160
- BELGIUM_SUPER_LEAGUE_WOMEN = 20143,
161
- UEFA_CHAMPIONS_LEAGUE_WOMEN = 20144,
162
- USA_NWSL = 20145,
163
- AUSTRALIA_A_LEAGUE_WOMEN = 20146,
164
- CONCACAF_CHAMPIONS_CUP = 20147,
165
- UEFA_NATIONS_LEAGUE_WOMEN = 20148,
166
- CANADA_PREMIER_LEAGUE = 20149,
167
- EUROCUP = 20200,
168
- SPAIN_LIGA_ACB = 20201,
169
- ITALY_LEGA_BASKET_SERIE_A = 20202,
170
- GERMANY_BBL = 20203,
171
- FRANCE_LNB_PRO_A = 20204,
172
- CHINA_CBA = 20205,
173
- AUSTRALIA_NBL = 20206,
174
- NCAAW = 20211,
175
- FIBA_AMERICUP_QUALIFIERS = 20212,
176
- FIBA_ASIA_CUP_QUALIFIERS = 20213,
177
- FIBA_EUROBASKET_QUALIFIERS = 20214,
178
- FIBA_WORLD_CUP_QUALIFIERS = 20215,
179
- FIBA_AFRO_BASKET_QUALIFIERS = 20216,
180
- GREECE_A1_LEAGUE = 20217,
181
- FIBA_CHAMPIONS_LEAGUE = 20218,
182
- ROCKET_LEAGUE = 20297,
183
- CALL_OF_DUTY = 20298,
184
- STARCRAFT = 20299,
185
- VALORANT = 20300,
186
- NFL_FUTURES = 30002,
187
- NBA_FUTURES = 30004,
188
- NCAAB_FUTURES = 30005,
189
- NHL_FUTURES = 30006,
190
- EPL_FUTURES = 30011,
191
- LIGUE_ONE_FUTURES = 30012,
192
- BUNDESLIGA_FUTURES = 30013,
193
- LA_LIGA_FUTURES = 30014,
194
- SERIE_A_FUTURES = 30015,
195
- UEFA_CHAMPIONS_LEAGUE_FUTURES = 30016,
196
- ATP_FUTURES = 30156,
197
- EUROLEAGUE_FUTURES = 30399,
198
- GOLF_H2H = 100021,
199
- GOLF_WINNER = 100121,
1
+ export const enum TennisSubLeague {
200
2
  TENNIS_ATP_GRAND_SLAM_LIVE_MAPPING_V2_0 = 15611,
201
3
  TENNIS_ATP_GRAND_SLAM_LIVE_MAPPING_V2_1 = 15612,
202
4
  TENNIS_ATP_GRAND_SLAM_LIVE_MAPPING_V2_2 = 15613,
@@ -305,11 +107,3 @@ export enum PeriodType {
305
107
  MAP = 'map',
306
108
  EMPTY = '',
307
109
  }
308
-
309
- export enum Provider {
310
- RUNDOWN = 'rundown',
311
- ENETPULSE = 'enetpulse',
312
- JSONODDS = 'jsonOdds',
313
- OPTICODDS = 'opticOdds',
314
- EMPTY = '',
315
- }
@@ -1,6 +1,6 @@
1
- import { LeagueInfo } from '../../types/sports';
1
+ import { LeagueConfigInfo } from '../../types/sports';
2
2
 
3
- const baseLeagueInfo: LeagueInfo = {
3
+ const baseLeagueInfo: LeagueConfigInfo = {
4
4
  sportId: 9806,
5
5
  enabled: 'true',
6
6
  marketName: 'Moneyline',
@@ -10,7 +10,7 @@ const baseLeagueInfo: LeagueInfo = {
10
10
  minOdds: 0.75,
11
11
  };
12
12
 
13
- const spreadMock: LeagueInfo = {
13
+ const spreadMock: LeagueConfigInfo = {
14
14
  sportId: 9806,
15
15
  enabled: 'true',
16
16
  marketName: 'Goal Spread',
@@ -20,7 +20,7 @@ const spreadMock: LeagueInfo = {
20
20
  minOdds: 0.75,
21
21
  };
22
22
 
23
- const totalMock: LeagueInfo = {
23
+ const totalMock: LeagueConfigInfo = {
24
24
  sportId: 9806,
25
25
  enabled: 'true',
26
26
  marketName: 'Total Goals',
@@ -30,7 +30,7 @@ const totalMock: LeagueInfo = {
30
30
  minOdds: 0.75,
31
31
  };
32
32
 
33
- const childMoneylineMock: LeagueInfo = {
33
+ const childMoneylineMock: LeagueConfigInfo = {
34
34
  sportId: 9806,
35
35
  enabled: 'true',
36
36
  marketName: '1st Half Moneyline',
@@ -40,30 +40,30 @@ const childMoneylineMock: LeagueInfo = {
40
40
  minOdds: 0.75,
41
41
  };
42
42
 
43
- const baseDiffSportId: LeagueInfo = {
43
+ const baseDiffSportId: LeagueConfigInfo = {
44
44
  ...baseLeagueInfo,
45
45
  sportId: 4,
46
46
  };
47
47
 
48
48
  // Mock Variants
49
- const leagueInfoOnlyParent: LeagueInfo[] = [baseLeagueInfo];
50
- const leagueInfoOnlyParentWithSpreadAdded: LeagueInfo[] = [{ ...baseLeagueInfo, addedSpread: 3 }];
51
- const leagueInfoOnlyParentDiffSportId: LeagueInfo[] = [baseDiffSportId];
49
+ const leagueInfoOnlyParent: LeagueConfigInfo[] = [baseLeagueInfo];
50
+ const leagueInfoOnlyParentWithSpreadAdded: LeagueConfigInfo[] = [{ ...baseLeagueInfo, addedSpread: 3 }];
51
+ const leagueInfoOnlyParentDiffSportId: LeagueConfigInfo[] = [baseDiffSportId];
52
52
 
53
- const leagueInfoMockDisabledChilds: LeagueInfo[] = [
53
+ const leagueInfoMockDisabledChilds: LeagueConfigInfo[] = [
54
54
  baseLeagueInfo,
55
55
  { ...spreadMock, enabled: 'false' },
56
56
  { ...totalMock, enabled: 'false' },
57
57
  ];
58
58
 
59
- const leagueInfoEnabledSpreadDisabledTotals: LeagueInfo[] = [
59
+ const leagueInfoEnabledSpreadDisabledTotals: LeagueConfigInfo[] = [
60
60
  baseLeagueInfo,
61
61
  spreadMock,
62
62
  { ...totalMock, enabled: 'false' },
63
63
  ];
64
64
 
65
- const leagueInfoEnabledSpeadAndTotals: LeagueInfo[] = [baseLeagueInfo, spreadMock, totalMock];
66
- const leagueInfoEnabledAll: LeagueInfo[] = [baseLeagueInfo, spreadMock, totalMock, childMoneylineMock];
65
+ const leagueInfoEnabledSpeadAndTotals: LeagueConfigInfo[] = [baseLeagueInfo, spreadMock, totalMock];
66
+ const leagueInfoEnabledAll: LeagueConfigInfo[] = [baseLeagueInfo, spreadMock, totalMock, childMoneylineMock];
67
67
 
68
68
  // Grouped Exports
69
69
  export const LeagueMocks = {
@@ -21,7 +21,7 @@ describe('Bookmakers', () => {
21
21
  );
22
22
 
23
23
  const hasOdds = market.odds.some(
24
- (odd) => odd.american !== 0 || odd.decimal !== 0 || odd.normalizedImplied !== 0
24
+ (odd: any) => odd.american !== 0 || odd.decimal !== 0 || odd.normalizedImplied !== 0
25
25
  );
26
26
 
27
27
  expect(hasOdds).toBe(false);
@@ -44,7 +44,7 @@ describe('Bookmakers', () => {
44
44
  );
45
45
 
46
46
  const hasOdds = market.odds.some(
47
- (odd) => odd.american !== 0 || odd.decimal !== 0 || odd.normalizedImplied !== 0
47
+ (odd: any) => odd.american !== 0 || odd.decimal !== 0 || odd.normalizedImplied !== 0
48
48
  );
49
49
 
50
50
  expect(hasOdds).toBe(false);
@@ -67,7 +67,7 @@ describe('Bookmakers', () => {
67
67
  );
68
68
 
69
69
  const hasOdds = market.odds.some(
70
- (odd) => odd.american !== 0 || odd.decimal !== 0 || odd.normalizedImplied !== 0
70
+ (odd: any) => odd.american !== 0 || odd.decimal !== 0 || odd.normalizedImplied !== 0
71
71
  );
72
72
 
73
73
  expect(hasOdds).toBe(false);
@@ -1,9 +1,9 @@
1
+ import { NO_MARKETS_FOR_LEAGUE_ID } from '../../constants/errors';
1
2
  import { processMarket } from '../../utils/markets';
2
- import { mockSoccer } from '../mock/MockSoccerRedis';
3
- import { MockOnlyMoneyline, MockOpticSoccer } from '../mock/MockOpticSoccer';
4
3
  import { mapOpticOddsApiFixtureOdds } from '../../utils/opticOdds';
5
4
  import { LeagueMocks } from '../mock/MockLeagueMap';
6
- import { NO_MARKETS_FOR_LEAGUE_ID } from '../../constants/errors';
5
+ import { MockOnlyMoneyline, MockOpticSoccer } from '../mock/MockOpticSoccer';
6
+ import { mockSoccer } from '../mock/MockSoccerRedis';
7
7
 
8
8
  describe('Markets', () => {
9
9
  describe('LeagueMap configuration', () => {
@@ -56,8 +56,8 @@ describe('Markets', () => {
56
56
  LeagueMocks.leagueInfoEnabledSpreadDisabledTotals
57
57
  );
58
58
 
59
- const containsSpread = market.childMarkets.some((child) => child.type === 'spread');
60
- const containsTotal = market.childMarkets.some((child) => child.type === 'total');
59
+ const containsSpread = market.childMarkets.some((child: any) => child.type === 'spread');
60
+ const containsTotal = market.childMarkets.some((child: any) => child.type === 'total');
61
61
 
62
62
  expect(containsSpread).toBe(true);
63
63
  expect(containsTotal).toBe(false);
@@ -77,8 +77,8 @@ describe('Markets', () => {
77
77
  LeagueMocks.leagueInfoEnabledSpeadAndTotals
78
78
  );
79
79
 
80
- const containsSpread = market.childMarkets.some((child) => child.type === 'spread');
81
- const containsTotal = market.childMarkets.some((child) => child.type === 'total');
80
+ const containsSpread = market.childMarkets.some((child: any) => child.type === 'spread');
81
+ const containsTotal = market.childMarkets.some((child: any) => child.type === 'total');
82
82
 
83
83
  expect(containsSpread).toBe(true);
84
84
  expect(containsTotal).toBe(true);
@@ -98,9 +98,9 @@ describe('Markets', () => {
98
98
  LeagueMocks.leagueInfoEnabledAll
99
99
  );
100
100
 
101
- const containsSpread = market.childMarkets.some((child) => child.type === 'spread');
102
- const containsTotal = market.childMarkets.some((child) => child.type === 'total');
103
- const containsChildMoneyline = market.childMarkets.some((child) => child.type === 'moneyline');
101
+ const containsSpread = market.childMarkets.some((child: any) => child.type === 'spread');
102
+ const containsTotal = market.childMarkets.some((child: any) => child.type === 'total');
103
+ const containsChildMoneyline = market.childMarkets.some((child: any) => child.type === 'moneyline');
104
104
 
105
105
  expect(containsSpread).toBe(true);
106
106
  expect(containsTotal).toBe(true);
@@ -3,10 +3,10 @@ import { processMarket } from '../../utils/markets';
3
3
  import { mapOpticOddsApiFixtureOdds } from '../../utils/opticOdds';
4
4
  import { LeagueMocks } from '../mock/MockLeagueMap';
5
5
  import {
6
- MockOnlyMoneyline,
7
- MockZeroOdds,
8
6
  MockOddsChildMarketsGoodOdds,
9
7
  MockOddsChildMarketsOddsCut,
8
+ MockOnlyMoneyline,
9
+ MockZeroOdds,
10
10
  } from '../mock/MockOpticSoccer';
11
11
  import { mockSoccer } from '../mock/MockSoccerRedis';
12
12
 
@@ -26,7 +26,7 @@ describe('Odds', () => {
26
26
  );
27
27
 
28
28
  const hasOdds = market.odds.some(
29
- (odd) => odd.american !== 0 || odd.decimal !== 0 || odd.normalizedImplied !== 0
29
+ (odd: any) => odd.american !== 0 || odd.decimal !== 0 || odd.normalizedImplied !== 0
30
30
  );
31
31
 
32
32
  expect(hasOdds).toBe(true);
@@ -47,7 +47,7 @@ describe('Odds', () => {
47
47
  );
48
48
 
49
49
  const hasOdds = market.odds.some(
50
- (odd) => odd.american !== 0 || odd.decimal !== 0 || odd.normalizedImplied !== 0
50
+ (odd: any) => odd.american !== 0 || odd.decimal !== 0 || odd.normalizedImplied !== 0
51
51
  );
52
52
 
53
53
  expect(hasOdds).toBe(false);
@@ -21,7 +21,7 @@ describe('Spread configuration', () => {
21
21
  );
22
22
 
23
23
  const hasOdds = market.odds.some(
24
- (odd) => odd.american !== 0 || odd.decimal !== 0 || odd.normalizedImplied !== 0
24
+ (odd: any) => odd.american !== 0 || odd.decimal !== 0 || odd.normalizedImplied !== 0
25
25
  );
26
26
 
27
27
  expect(hasOdds).toBe(false);
@@ -0,0 +1,2 @@
1
+ declare module 'oddslib';
2
+ declare module 'bytes32';
package/src/types/odds.ts CHANGED
@@ -1,3 +1,27 @@
1
+ export type Fixture = {
2
+ gameId: string;
3
+ startDate: number;
4
+ homeTeam: string;
5
+ awayTeam: string;
6
+ };
7
+
8
+ export type Odds = [
9
+ {
10
+ id: string;
11
+ sportsBookName: string;
12
+ name: string;
13
+ price: number;
14
+ timestamp: number;
15
+ points: number;
16
+ isMain: boolean;
17
+ isLive: boolean;
18
+ marketName: string;
19
+ playerId: string;
20
+ selection: string;
21
+ selectionLine: string;
22
+ }
23
+ ];
24
+
1
25
  export type OddsObject = {
2
26
  gameId: string;
3
27
  startDate: number;
@@ -7,22 +31,7 @@ export type OddsObject = {
7
31
  status: string;
8
32
  sport: string;
9
33
  league: string;
10
- odds: [
11
- {
12
- id: string;
13
- sportsBookName: string;
14
- name: string;
15
- price: number;
16
- timestamp: number;
17
- points: number;
18
- isMain: boolean;
19
- isLive: boolean;
20
- marketName: string;
21
- playerId: string;
22
- selection: string;
23
- selectionLine: string;
24
- }
25
- ];
34
+ odds: Odds;
26
35
  };
27
36
 
28
37
  export type ScoresObject = {
@@ -48,3 +57,5 @@ export type ScoresObject = {
48
57
  homePeriod5: string;
49
58
  awayPeriod5: string;
50
59
  };
60
+
61
+ export type HomeAwayTeams = { homeTeam: string; awayTeam: string };
@@ -1,4 +1,5 @@
1
- export type LeagueInfo = {
1
+
2
+ export type LeagueConfigInfo = {
2
3
  sportId: number;
3
4
  typeId: number;
4
5
  marketName: string;
@@ -1,6 +1,6 @@
1
1
  import * as oddslib from 'oddslib';
2
2
 
3
- export const getBookmakersArray = (bookmakersData, sportId, backupLiveOddsProviders) => {
3
+ export const getBookmakersArray = (bookmakersData: any[], sportId: any, backupLiveOddsProviders: string[]) => {
4
4
  const sportBookmakersData = bookmakersData.find((data) => Number(data.sportId) === Number(sportId));
5
5
  if (sportBookmakersData) {
6
6
  if (sportBookmakersData.primaryBookmaker == '') {
@@ -1,8 +1,12 @@
1
- import { League, Sport } from '../enums/sports';
1
+ import { League, Sport } from 'overtime-utils';
2
2
  import { ScoresObject } from '../types/odds';
3
3
  import { getLeagueSport } from './sports';
4
4
 
5
- export const checkGameContraints = (opticOddsScoresApiResponse: ScoresObject, marketLeague: League, constraintsMap) => {
5
+ export const checkGameContraints = (
6
+ opticOddsScoresApiResponse: ScoresObject,
7
+ marketLeague: League,
8
+ constraintsMap: Map<Sport, number>
9
+ ) => {
6
10
  const marketSport = getLeagueSport(marketLeague);
7
11
  const homeTeam = opticOddsScoresApiResponse.homeTeam;
8
12
  const awayTeam = opticOddsScoresApiResponse.awayTeam;
@@ -28,7 +32,12 @@ export const checkGameContraints = (opticOddsScoresApiResponse: ScoresObject, ma
28
32
  };
29
33
  };
30
34
 
31
- export const allowGameSportWithPeriodConstraint = (homeTeam, awayTeam, currentPeriod, periodLimitForLiveTrade) => {
35
+ export const allowGameSportWithPeriodConstraint = (
36
+ homeTeam: string,
37
+ awayTeam: string,
38
+ currentPeriod: number,
39
+ periodLimitForLiveTrade: number
40
+ ) => {
32
41
  if (!Number.isNaN(currentPeriod) && currentPeriod >= periodLimitForLiveTrade) {
33
42
  return {
34
43
  allow: false,
@@ -38,10 +47,18 @@ export const allowGameSportWithPeriodConstraint = (homeTeam, awayTeam, currentPe
38
47
  return { allow: true, message: '' };
39
48
  };
40
49
 
41
- export const allowSoccerGame = (homeTeam, awayTeam, currentClock, currentPeriod, soccerMinuteLimitForLiveTrading) => {
50
+ export const allowSoccerGame = (
51
+ homeTeam: string,
52
+ awayTeam: string,
53
+ currentClock: string,
54
+ currentPeriod: string,
55
+ soccerMinuteLimitForLiveTrading: number | undefined
56
+ ) => {
42
57
  const currentClockNumber = Number(currentClock);
43
58
  if (
44
- (!Number.isNaN(currentClockNumber) && currentClockNumber >= soccerMinuteLimitForLiveTrading) ||
59
+ (!Number.isNaN(currentClockNumber) &&
60
+ soccerMinuteLimitForLiveTrading !== undefined &&
61
+ currentClockNumber >= soccerMinuteLimitForLiveTrading) ||
45
62
  (Number.isNaN(currentClockNumber) && currentPeriod.toLowerCase() != 'half')
46
63
  ) {
47
64
  return { allow: false, message: `Blocking game ${homeTeam} - ${awayTeam} due to clock: ${currentClock}min` };
@@ -52,13 +69,13 @@ export const allowSoccerGame = (homeTeam, awayTeam, currentClock, currentPeriod,
52
69
 
53
70
  export const allowGameSportWithResultConstraint = (
54
71
  opticOddsScoresApiResponse: ScoresObject,
55
- homeTeam,
56
- awayTeam,
57
- currentPeriod,
58
- currentScoreHome,
59
- currentScoreAway,
60
- marketLeague,
61
- marketSport
72
+ homeTeam: string,
73
+ awayTeam: string,
74
+ currentPeriod: string,
75
+ currentScoreHome: number,
76
+ currentScoreAway: number,
77
+ marketLeague: League,
78
+ marketSport: Sport
62
79
  ) => {
63
80
  const setInProgress = Number(currentPeriod);
64
81
  const currentResultInSet = fetchResultInCurrentSet(setInProgress, opticOddsScoresApiResponse);
@@ -87,7 +104,7 @@ export const allowGameSportWithResultConstraint = (
87
104
  }
88
105
  }
89
106
 
90
- if (marketLeague.toString().startsWith(League.TENNIS_GS) && atpGrandSlamMatch) {
107
+ if (marketLeague.toString().startsWith(League.TENNIS_GS.toString()) && atpGrandSlamMatch) {
91
108
  return checkResultConstraint(
92
109
  homeTeam,
93
110
  awayTeam,
@@ -99,10 +116,10 @@ export const allowGameSportWithResultConstraint = (
99
116
  }
100
117
 
101
118
  if (
102
- (marketLeague.toString().startsWith(League.TENNIS_GS) && !atpGrandSlamMatch) ||
103
- marketLeague.toString().startsWith(League.TENNIS_MASTERS) ||
104
- marketLeague.toString().startsWith(League.SUMMER_OLYMPICS_TENNIS) ||
105
- marketLeague.toString().startsWith(League.TENNIS_WTA)
119
+ (marketLeague.toString().startsWith(League.TENNIS_GS.toString()) && !atpGrandSlamMatch) ||
120
+ marketLeague.toString().startsWith(League.TENNIS_MASTERS.toString()) ||
121
+ marketLeague.toString().startsWith(League.SUMMER_OLYMPICS_TENNIS.toString()) ||
122
+ marketLeague.toString().startsWith(League.TENNIS_WTA.toString())
106
123
  ) {
107
124
  return checkResultConstraint(
108
125
  homeTeam,
@@ -148,7 +165,14 @@ export const fetchResultInCurrentSet = (currentSet: number, opticOddsScoresApiRe
148
165
  return { home: currentHomeGameScore, away: currentAwayGameScore };
149
166
  };
150
167
 
151
- const checkResultConstraint = (homeTeam, awayTeam, currentResultInSet, currentSetsWon, setThreshold, resultLimit) => {
168
+ const checkResultConstraint = (
169
+ homeTeam: string,
170
+ awayTeam: string,
171
+ currentResultInSet: { home: number; away: number },
172
+ currentSetsWon: { home: number; away: number },
173
+ setThreshold: number,
174
+ resultLimit: number
175
+ ) => {
152
176
  if (Number(currentSetsWon.home) == setThreshold || Number(currentSetsWon.away) == setThreshold) {
153
177
  if (Number(currentSetsWon.home) == setThreshold && currentResultInSet.home >= resultLimit) {
154
178
  return {
@@ -1,5 +1,5 @@
1
+ import { Sport } from 'overtime-utils';
1
2
  import { LEAGUES_NO_FORMAL_HOME_AWAY } from '../constants/sports';
2
- import { Sport } from '../enums/sports';
3
3
  import { getLeagueSport } from './sports';
4
4
 
5
5
  export const teamNamesMatching = (
@@ -1,6 +1,6 @@
1
1
  import * as oddslib from 'oddslib';
2
- import { createChildMarkets, getParentOdds } from './odds';
3
2
  import { OddsObject } from '../types/odds';
3
+ import { createChildMarkets, getParentOdds } from './odds';
4
4
  import { getLeagueInfo } from './sports';
5
5
  import { adjustAddedSpread } from './spread';
6
6
  /**
@@ -28,7 +28,7 @@ export const processMarket = (
28
28
  maxPercentageDiffBetwenOdds: any,
29
29
  leagueMap: any
30
30
  ) => {
31
- const sportSpreadData = spreadData.filter((data) => data.sportId === String(market.leagueId));
31
+ const sportSpreadData = spreadData.filter((data: any) => data.sportId === String(market.leagueId));
32
32
  const leagueInfo = getLeagueInfo(market.leagueId, leagueMap);
33
33
 
34
34
  const moneylineOdds = getParentOdds(