overtime-live-trading-utils 2.1.33 → 2.1.35
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/CLAUDE.md +26 -19
- package/main.js +1 -1
- package/package.json +1 -1
- package/resolution_live_markets.md +93 -88
- package/src/tests/mock/MockOpticOddsEvents.ts +144 -0
- package/src/tests/unit/resolution.test.ts +471 -71
- package/src/types/resolution.ts +25 -25
- package/src/utils/resolution.ts +43 -22
- package/src/utils/sportPeriodMapping.ts +36 -0
- package/tsconfig.json +3 -7
package/CLAUDE.md
CHANGED
|
@@ -9,15 +9,18 @@ This is a TypeScript utility library for live sports betting/trading. It process
|
|
|
9
9
|
## Commands
|
|
10
10
|
|
|
11
11
|
### Build & Compile
|
|
12
|
-
|
|
13
|
-
-
|
|
12
|
+
|
|
13
|
+
- `npm run compile` - Compile TypeScript to JavaScript
|
|
14
|
+
- `npm run pack` - Build production bundle with webpack
|
|
14
15
|
|
|
15
16
|
### Testing
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
17
|
+
|
|
18
|
+
- `npm test` - Run all Jest tests
|
|
19
|
+
- `npm test -- --coverage` - Run tests with coverage report
|
|
20
|
+
- `npm test -- src/tests/unit/odds.test.ts` - Run a specific test file
|
|
19
21
|
|
|
20
22
|
### Development
|
|
23
|
+
|
|
21
24
|
The library is published to npm. Run `npm run prepublish` to pack before publishing (runs automatically on npm publish).
|
|
22
25
|
|
|
23
26
|
## Architecture
|
|
@@ -25,6 +28,7 @@ The library is published to npm. Run `npm run prepublish` to pack before publish
|
|
|
25
28
|
### Core Processing Flow
|
|
26
29
|
|
|
27
30
|
The main processing pipeline:
|
|
31
|
+
|
|
28
32
|
1. **Bookmaker Selection** (`src/utils/bookmakers.ts`) - Selects primary/secondary/tertiary bookmakers for a sport, validates odds consistency across providers
|
|
29
33
|
2. **Odds Processing** (`src/utils/odds.ts`) - Converts odds formats (decimal ↔ implied probability), filters by market type and bookmaker, creates parent moneyline odds
|
|
30
34
|
3. **Spread Adjustment** (`src/utils/spread.ts`) - Applies spread data to odds, handles Asian handicap, game/point/goal spreads, run/puck lines
|
|
@@ -44,11 +48,12 @@ The main processing pipeline:
|
|
|
44
48
|
### Type System
|
|
45
49
|
|
|
46
50
|
Key types in `src/types/`:
|
|
47
|
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
51
|
+
|
|
52
|
+
- `OddsObject` - Complete game data with odds array from API
|
|
53
|
+
- `Odds` - Array of individual odds entries with bookmaker, price, market name
|
|
54
|
+
- `LeagueConfigInfo` - League/market configuration (enabled status, min/max odds, spread)
|
|
55
|
+
- `ChildMarket` - Generated derivative market with line and odds
|
|
56
|
+
- `Fixture` & `ScoresObject` - Game metadata and live scores
|
|
52
57
|
|
|
53
58
|
### Sports-Specific Logic
|
|
54
59
|
|
|
@@ -57,21 +62,23 @@ Key types in `src/types/`:
|
|
|
57
62
|
### Error Handling
|
|
58
63
|
|
|
59
64
|
Error messages in `src/constants/errors.ts`:
|
|
60
|
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
65
|
+
|
|
66
|
+
- `NO_MATCHING_BOOKMAKERS_MESSAGE` - None of the specified bookmakers have odds
|
|
67
|
+
- `DIFF_BETWEEN_BOOKMAKERS_MESSAGE` - Bookmaker odds diverge beyond threshold
|
|
68
|
+
- `ZERO_ODDS_MESSAGE` - Zero odds detected (invalid)
|
|
69
|
+
- `ZERO_ODDS_AFTER_SPREAD_ADJUSTMENT` - Spread adjustment resulted in zero odds
|
|
64
70
|
|
|
65
71
|
## Testing Notes
|
|
66
72
|
|
|
67
73
|
Tests use mock data from `src/tests/mock/`:
|
|
68
|
-
|
|
69
|
-
-
|
|
70
|
-
-
|
|
74
|
+
|
|
75
|
+
- `MockLeagueMap.ts` - League configuration fixtures
|
|
76
|
+
- `MockOpticSoccer.ts` - Sample OpticOdds API responses
|
|
77
|
+
- `MockSoccerRedis.ts` - Redis-cached odds data
|
|
71
78
|
|
|
72
79
|
Test files are organized by utility module: `odds.test.ts`, `sports.test.ts`, `spread.test.ts`, `markets.test.ts`, `bookmakers.test.ts`.
|
|
73
80
|
|
|
74
81
|
## Dependencies
|
|
75
82
|
|
|
76
|
-
-
|
|
77
|
-
-
|
|
83
|
+
- `oddslib` - Odds format conversion (decimal, moneyline, implied probability)
|
|
84
|
+
- `overtime-utils` - Shared types and enums for the Overtime platform (League enum, MarketType)
|