overtime-live-trading-utils 4.0.0-rc.7 → 4.0.0-rc.9
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/tests/unit/bookmakers.test.ts +28 -1
- package/src/tests/unit/markets.test.ts +1 -1
- package/src/tests/unit/odds.test.ts +1 -1
- package/src/tests/unit/spread.test.ts +1 -1
- package/src/utils/bookmakers.ts +3 -0
- package/src/utils/odds.ts +5 -7
- /package/src/{constants/odds.ts → tests/mock/MockAnchors.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "overtime-live-trading-utils",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.9",
|
|
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.59",
|
|
18
18
|
"react": "^17.0.1"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { DIFF_BETWEEN_BOOKMAKERS_MESSAGE, ZERO_ODDS_MESSAGE } from '../../constants/errors';
|
|
2
|
-
import {
|
|
2
|
+
import { __test__ } from '../../utils/bookmakers';
|
|
3
3
|
import { processMarket } from '../../utils/markets';
|
|
4
4
|
import { mapOpticOddsApiFixtureOdds } from '../../utils/opticOdds';
|
|
5
|
+
import { ODDS_THRESHOLD_ANCHORS } from '../mock/MockAnchors';
|
|
5
6
|
import { LeagueMocks } from '../mock/MockLeagueMap';
|
|
6
7
|
import {
|
|
7
8
|
MockOddsChildMarketsDifferentBookmakers,
|
|
@@ -150,3 +151,29 @@ describe('Bookmakers', () => {
|
|
|
150
151
|
expect(market.childMarkets.length).toBe(1);
|
|
151
152
|
});
|
|
152
153
|
});
|
|
154
|
+
|
|
155
|
+
describe('Bookmakers', () => {
|
|
156
|
+
it('Should export test only functions', () => {
|
|
157
|
+
const OUR_ODDS = 1.943;
|
|
158
|
+
const OTHER_ODDS = 1.847;
|
|
159
|
+
|
|
160
|
+
const THRESHOLDS = [
|
|
161
|
+
{ our: 1.02, otherMin: 1.01 },
|
|
162
|
+
{ our: 1.05, otherMin: 1.04 },
|
|
163
|
+
{ our: 1.1, otherMin: 1.09 },
|
|
164
|
+
{ our: 1.2, otherMin: 1.19 },
|
|
165
|
+
{ our: 1.3, otherMin: 1.29 },
|
|
166
|
+
{ our: 1.4, otherMin: 1.39 },
|
|
167
|
+
{ our: 1.5, otherMin: 1.48 },
|
|
168
|
+
{ our: 2.0, otherMin: 1.95 },
|
|
169
|
+
{ our: 2.5, otherMin: 2.25 },
|
|
170
|
+
{ our: 3.0, otherMin: 2.5 },
|
|
171
|
+
{ our: 4.0, otherMin: 3.5 },
|
|
172
|
+
{ our: 8.0, otherMin: 6.5 },
|
|
173
|
+
{ our: 10.0, otherMin: 8.0 },
|
|
174
|
+
{ our: 100.0, otherMin: 70.0 },
|
|
175
|
+
];
|
|
176
|
+
|
|
177
|
+
expect(__test__.shouldBlockOdds(OUR_ODDS, OTHER_ODDS, THRESHOLDS)).toBe(true);
|
|
178
|
+
});
|
|
179
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NO_MARKETS_FOR_LEAGUE_ID } from '../../constants/errors';
|
|
2
|
-
import { ODDS_THRESHOLD_ANCHORS } from '../../constants/odds';
|
|
3
2
|
import { processMarket } from '../../utils/markets';
|
|
4
3
|
import { mapOpticOddsApiFixtureOdds } from '../../utils/opticOdds';
|
|
4
|
+
import { ODDS_THRESHOLD_ANCHORS } from '../mock/MockAnchors';
|
|
5
5
|
import { LeagueMocks } from '../mock/MockLeagueMap';
|
|
6
6
|
import { MockOnlyMoneyline, MockOpticSoccer } from '../mock/MockOpticSoccer';
|
|
7
7
|
import { mockSoccer } from '../mock/MockSoccerRedis';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ZERO_ODDS_MESSAGE_SINGLE_BOOKMAKER } from '../../constants/errors';
|
|
2
|
-
import { ODDS_THRESHOLD_ANCHORS } from '../../constants/odds';
|
|
3
2
|
import { processMarket } from '../../utils/markets';
|
|
4
3
|
import { mapOpticOddsApiFixtureOdds } from '../../utils/opticOdds';
|
|
4
|
+
import { ODDS_THRESHOLD_ANCHORS } from '../mock/MockAnchors';
|
|
5
5
|
import { LeagueMocks } from '../mock/MockLeagueMap';
|
|
6
6
|
import {
|
|
7
7
|
MockOddsChildMarketsGoodOdds,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ZERO_ODDS_AFTER_SPREAD_ADJUSTMENT } from '../../constants/errors';
|
|
2
|
-
import { ODDS_THRESHOLD_ANCHORS } from '../../constants/odds';
|
|
3
2
|
import { processMarket } from '../../utils/markets';
|
|
4
3
|
import { mapOpticOddsApiFixtureOdds } from '../../utils/opticOdds';
|
|
4
|
+
import { ODDS_THRESHOLD_ANCHORS } from '../mock/MockAnchors';
|
|
5
5
|
import { LeagueMocks } from '../mock/MockLeagueMap';
|
|
6
6
|
import { MockAfterSpreadZeroOdds1, MockOnlyMoneylineFavorite, MockOpticSoccer } from '../mock/MockOpticSoccer';
|
|
7
7
|
import { mockSoccer } from '../mock/MockSoccerRedis';
|
package/src/utils/bookmakers.ts
CHANGED
|
@@ -295,3 +295,6 @@ const shouldBlockOdds = (ourOdds: number, otherOdds: number, anchors: Anchor[])
|
|
|
295
295
|
// Block if the other book is below the required threshold
|
|
296
296
|
return otherOdds < requiredOther;
|
|
297
297
|
};
|
|
298
|
+
|
|
299
|
+
// Export only when running tests
|
|
300
|
+
export const __test__ = { getRequiredOtherOdds, shouldBlockOdds };
|
package/src/utils/odds.ts
CHANGED
|
@@ -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
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
});
|
|
294
|
+
const conditionToAddChildMarket =
|
|
295
|
+
data.type === 'Total'
|
|
296
|
+
? data.odds.some((odd: number) => odd < minOdds && odd > maxOdds)
|
|
297
|
+
: data.odds.every((odd: number) => odd < minOdds && odd > maxOdds);
|
|
300
298
|
if (conditionToAddChildMarket) {
|
|
301
299
|
childMarkets.push(childMarket);
|
|
302
300
|
}
|
|
@@ -461,7 +459,7 @@ export const groupAndFormatTotalOdds = (oddsArray: any[], commonData: HomeAwayTe
|
|
|
461
459
|
|
|
462
460
|
acc.push({
|
|
463
461
|
line: line as any,
|
|
464
|
-
odds: [(value as any).over, (value as any).under].
|
|
462
|
+
odds: [(value as any).over, (value as any).under].map((odd) => odd || ZERO),
|
|
465
463
|
typeId: !shouldIncreaseTypeId ? (value as any).typeId : Number((value as any).typeId) + 1,
|
|
466
464
|
sportId: (value as any).sportId,
|
|
467
465
|
type: (value as any).type,
|
|
File without changes
|