overtime-live-trading-utils 1.0.9 → 1.1.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/.circleci/config.yml +30 -0
- package/codecov.yml +20 -0
- package/jest.config.ts +16 -0
- package/main.js +1 -1
- package/package.json +7 -2
- package/src/constants/errors.ts +5 -0
- package/src/tests/mock/MockLeagueMap.ts +75 -0
- package/src/tests/mock/MockOpticSoccer.ts +9267 -0
- package/src/tests/mock/MockSoccerRedis.ts +2309 -0
- package/src/tests/unit/bookmakers.test.ts +77 -0
- package/src/tests/unit/markets.test.ts +133 -0
- package/src/tests/unit/odds.test.ts +92 -0
- package/src/tests/unit/sports.test.ts +47 -0
- package/src/tests/unit/spread.test.ts +31 -0
- package/src/utils/bookmakers.ts +2 -5
- package/src/utils/constraints.ts +1 -1
- package/src/utils/markets.ts +2 -2
- package/src/utils/odds.ts +75 -23
- package/src/utils/sports.ts +14 -11
package/src/utils/sports.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { LeagueMap } from '../constants/sports';
|
|
|
2
2
|
import { League, Sport } from '../enums/sports';
|
|
3
3
|
import { LeagueInfo } from '../types/sports';
|
|
4
4
|
|
|
5
|
+
// Methods that use data from LeagueMap defined in constants in utils
|
|
5
6
|
export const getLeagueSport = (league: League) => {
|
|
6
7
|
const leagueInfo = LeagueMap[league];
|
|
7
8
|
return leagueInfo ? leagueInfo.sport : Sport.EMPTY;
|
|
@@ -22,6 +23,17 @@ export const getLeagueIsDrawAvailable = (league: League) => {
|
|
|
22
23
|
return leagueInfo ? leagueInfo.isDrawAvailable : false;
|
|
23
24
|
};
|
|
24
25
|
|
|
26
|
+
export const getLeaguePeriodType = (league: League) => {
|
|
27
|
+
const leagueInfo = LeagueMap[league];
|
|
28
|
+
return leagueInfo ? leagueInfo.periodType : '';
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const getLeagueOpticOddsName = (league: League) => {
|
|
32
|
+
const leagueInfo = LeagueMap[league];
|
|
33
|
+
return leagueInfo ? leagueInfo.opticOddsName : undefined;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Methods are using data from live-markets-map.csv
|
|
25
37
|
export const getLiveSupportedLeagues = (leagueInfoArray: LeagueInfo[]) => {
|
|
26
38
|
const uniqueId = new Set();
|
|
27
39
|
leagueInfoArray
|
|
@@ -29,13 +41,14 @@ export const getLiveSupportedLeagues = (leagueInfoArray: LeagueInfo[]) => {
|
|
|
29
41
|
.map((league) => uniqueId.add(Number(league.sportId)));
|
|
30
42
|
return Array.from(uniqueId);
|
|
31
43
|
};
|
|
44
|
+
|
|
32
45
|
export const getBetTypesForLeague = (league: League, leagueInfoArray: LeagueInfo[]) => {
|
|
33
46
|
const uniqueMarketNames = new Set();
|
|
34
47
|
leagueInfoArray
|
|
35
48
|
.filter((leagueInfo) => Number(leagueInfo.sportId) === Number(league) && leagueInfo.enabled === 'true')
|
|
36
49
|
.map((leagueInfo) => uniqueMarketNames.add(leagueInfo.marketName));
|
|
37
50
|
|
|
38
|
-
return Array.from(uniqueMarketNames);
|
|
51
|
+
return Array.from(uniqueMarketNames) as string[];
|
|
39
52
|
};
|
|
40
53
|
|
|
41
54
|
export const getLeagueInfo = (league: League, leagueInfoArray: LeagueInfo[]) => {
|
|
@@ -43,16 +56,6 @@ export const getLeagueInfo = (league: League, leagueInfoArray: LeagueInfo[]) =>
|
|
|
43
56
|
return leagueInfos;
|
|
44
57
|
};
|
|
45
58
|
|
|
46
|
-
export const getLeagueOpticOddsName = (league: League) => {
|
|
47
|
-
const leagueInfo = LeagueMap[league];
|
|
48
|
-
return leagueInfo ? leagueInfo.opticOddsName : undefined;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const getLeaguePeriodType = (league: League) => {
|
|
52
|
-
const leagueInfo = LeagueMap[league];
|
|
53
|
-
return leagueInfo ? leagueInfo.periodType : '';
|
|
54
|
-
};
|
|
55
|
-
|
|
56
59
|
export const getLeagueSpreadTypes = (league: League, leagueInfoArray: LeagueInfo[]) => {
|
|
57
60
|
const betTypes = leagueInfoArray
|
|
58
61
|
.filter(
|