overtime-live-trading-utils 4.0.0-rc.0 → 4.0.0-rc.10
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/mock/OpticOddsMock/MockNBA.ts +5 -0
- package/src/tests/unit/bookmakers.test.ts +32 -13
- package/src/tests/unit/markets.test.ts +40 -16
- package/src/tests/unit/odds.test.ts +9 -9
- package/src/tests/unit/spread.test.ts +9 -11
- package/src/types/sports.ts +6 -0
- package/src/utils/bookmakers.ts +4 -1
- package/src/utils/markets.ts +0 -10
- package/src/utils/odds.ts +30 -66
- package/src/utils/spread.ts +2 -39
- /package/src/{constants/odds.ts → tests/mock/MockAnchors.ts} +0 -0
package/src/utils/spread.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LeagueConfigInfo } from '../types/sports';
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const sanityCheckForOdds = (impliedProbs: number[]) => {
|
|
4
4
|
// Step 1: Check if any implied probability is zero
|
|
5
5
|
if (impliedProbs.some((prob) => prob === 0)) {
|
|
6
6
|
return impliedProbs;
|
|
@@ -14,44 +14,7 @@ export const adjustSpreadOnOdds = (impliedProbs: number[], minSpread: number, ta
|
|
|
14
14
|
return Array(impliedProbs.length).fill(0);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
if (targetSpread === 0) {
|
|
19
|
-
const currentSpread = (totalImpliedProbs - 1) * 100;
|
|
20
|
-
// If minSpread is set and greater than current spread, use minSpread
|
|
21
|
-
if (minSpread > currentSpread) {
|
|
22
|
-
targetSpread = minSpread;
|
|
23
|
-
} else {
|
|
24
|
-
// If minSpread is less than current spread, return odds as they are
|
|
25
|
-
return impliedProbs;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Step 5: Calculate the target total implied probabilities
|
|
30
|
-
const targetTotalImpliedProbs = 1 + targetSpread / 100;
|
|
31
|
-
|
|
32
|
-
// Step 6: Calculate the adjustment factor
|
|
33
|
-
const adjustmentFactor = targetTotalImpliedProbs / totalImpliedProbs;
|
|
34
|
-
|
|
35
|
-
// Step 7: Adjust the probabilities to reflect the target spread
|
|
36
|
-
let adjustedImpliedProbs = impliedProbs.map((prob) => prob * adjustmentFactor);
|
|
37
|
-
|
|
38
|
-
// Step 8: Check if any adjusted probability equals or exceeds 1
|
|
39
|
-
if (adjustedImpliedProbs.some((prob) => prob >= 1)) {
|
|
40
|
-
return Array(impliedProbs.length).fill(0);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Step 9: Ensure the sum of the adjusted probabilities equals the target total implied probabilities
|
|
44
|
-
const sumAdjustedProbs = adjustedImpliedProbs.reduce((sum, prob) => sum + prob, 0);
|
|
45
|
-
|
|
46
|
-
// Step 10: If the sum of the adjusted probabilities is less than 1, return zeros
|
|
47
|
-
if (sumAdjustedProbs < 1) {
|
|
48
|
-
return Array(impliedProbs.length).fill(0);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const normalizationFactor = targetTotalImpliedProbs / sumAdjustedProbs;
|
|
52
|
-
adjustedImpliedProbs = adjustedImpliedProbs.map((prob) => prob * normalizationFactor);
|
|
53
|
-
|
|
54
|
-
return adjustedImpliedProbs;
|
|
17
|
+
return impliedProbs;
|
|
55
18
|
};
|
|
56
19
|
|
|
57
20
|
export const getSpreadData = (
|
|
File without changes
|