rapidoddsapi-mcp 0.2.0__tar.gz → 0.3.0__tar.gz

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.
@@ -0,0 +1,75 @@
1
+ # Changelog
2
+
3
+ Notable changes to this package. Versions follow [semantic versioning](https://semver.org).
4
+
5
+ ## 0.3.0
6
+
7
+ Needs the SDK at 0.3.0 or later.
8
+
9
+ - `find_arbitrage` and `find_value_bets` work on totals, handicaps, team totals
10
+ and player props, not only two-way markets with no line. Their descriptions
11
+ said otherwise, so the model was turning down markets that now work. Only
12
+ three-way markets are still refused
13
+ - `find_value_bets` takes `devig` in place of `sharp`. The default, `"all"`,
14
+ de-vigs every bookmaker fetched and averages the result, which needs no view
15
+ on which book is sharp and works on markets Pinnacle does not price. Naming
16
+ a book measures the others against it, as before. The description explains
17
+ the trade-off so the model can put it to the user rather than pick silently
18
+ - Nothing is seeded into the bookmaker list under `"all"`, since a consensus
19
+ needs enough books rather than any particular one. Naming a book still seeds
20
+ it, or the request is paid for and cannot be de-vigged
21
+ - An empty consensus says four bookmakers have to price the same line, and
22
+ suggests naming a book. Fewer books quote each line of a totals or player
23
+ prop market than quote the game, so a thin market otherwise reads as no value
24
+ - Arbitrage legs and value bets show the line and the player or team, so two
25
+ sides of a totals bet no longer both read "Over". Handicaps are signed,
26
+ totals are not, since "Over +8.5" implies the line itself is positive
27
+ - An empty result from `find_arbitrage` or `find_value_bets` says when no games
28
+ came back at all, rather than reporting that it looked and found nothing. A
29
+ sport out of season read as "no arbitrage", which is a conclusion that was
30
+ never tested
31
+ - A near miss prints as `-0.90%` rather than `+-0.90%`
32
+ - `list_sports(sport)` returns every bookmaker rather than only the sport's
33
+ region. Feeds price across regions, so an American book quoting the AFL is
34
+ normal and hiding it removed a real option for line shopping
35
+ - An empty `get_odds` now says whether the market types are wrong for the
36
+ sport. The API returns nothing for a market it does not recognise, which was
37
+ indistinguishable from the season being over
38
+
39
+ ## 0.2.0
40
+
41
+ - `list_sports(sport)` now returns every bookmaker that can be requested for
42
+ that sport, alongside its market types. There was no way to discover a
43
+ bookmaker name: the API has no endpoint for them and does not reject unknown
44
+ ones, it just returns no prices. A model asked which bookmakers were covered
45
+ would therefore guess names and pay for each attempt, and a casing slip such
46
+ as `Palmerbet` for `PalmerBet` looked identical to the book not existing
47
+ - Tool descriptions say not to guess bookmaker or market names, and where the
48
+ valid ones come from
49
+ - Soccer and tennis now list every feed rather than only the European ones,
50
+ since Australian and American books price them too
51
+
52
+ ## 0.1.2
53
+
54
+ - Certificates are verified against the operating system's trust store. On
55
+ networks that inspect HTTPS, and with antivirus that does the same, every
56
+ request previously failed with CERTIFICATE_VERIFY_FAILED because the bundled
57
+ store does not know the intercepting certificate the machine itself trusts
58
+
59
+ ## 0.1.1
60
+
61
+ - Tool descriptions now say these tools are RapidOddsAPI itself. Asked what
62
+ RapidOddsAPI covered, a model would search the web instead of calling
63
+ `list_sports`, because nothing connected the name to the tools
64
+
65
+ ## 0.1.0
66
+
67
+ First release.
68
+
69
+ - Five tools: `list_sports`, `get_odds`, `get_results`, `find_arbitrage`,
70
+ `find_value_bets`
71
+ - Every response reports what it cost and the credits remaining
72
+ - A sport is always required, and bookmakers default to five, so a vague
73
+ question costs 1 credit rather than tens
74
+ - Built on the `rapidoddsapi` SDK, which needs the API at v1.1.0 or later for
75
+ the sport directory and balance lookups
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rapidoddsapi-mcp
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: MCP server for RapidOddsAPI: bookmaker odds, live scores, arbitrage and value bets.
5
5
  Project-URL: Homepage, https://rapidoddsapi.com
6
6
  Project-URL: Documentation, https://rapidoddsapi.com/docs
@@ -20,7 +20,7 @@ Classifier: Programming Language :: Python :: 3.13
20
20
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
21
  Requires-Python: >=3.10
22
22
  Requires-Dist: mcp>=2.0.0
23
- Requires-Dist: rapidoddsapi>=0.2.0
23
+ Requires-Dist: rapidoddsapi>=0.3.0
24
24
  Requires-Dist: truststore>=0.10
25
25
  Provides-Extra: dev
26
26
  Requires-Dist: mypy>=1.11; extra == 'dev'
@@ -78,7 +78,7 @@ It speaks stdio.
78
78
  | `get_odds(sport, market_types=, bookmakers=)` | `market_types x ceil(bookmakers / 5)` |
79
79
  | `get_results(sport, status=, include=)` | 1 |
80
80
  | `find_arbitrage(sport, market=, bookmakers=, min_profit=, stake=)` | `ceil(bookmakers / 5)` |
81
- | `find_value_bets(sport, market=, bookmakers=, min_edge=, sharp=)` | `ceil(bookmakers / 5)` |
81
+ | `find_value_bets(sport, market=, bookmakers=, min_edge=, devig=)` | `ceil(bookmakers / 5)` |
82
82
 
83
83
  Credits are charged only when games come back, so a query that matches nothing
84
84
  is free. Every response ends with what it cost and what is left.
@@ -101,11 +101,20 @@ because both need books that disagree and five rarely spread far enough.
101
101
 
102
102
  ## Markets
103
103
 
104
- `find_arbitrage` and `find_value_bets` handle two-way markets with no line:
105
- `head_to_head`, its period variants, and soccer's `draw_no_bet`. Totals,
106
- spreads, player props and three-way markets return an error explaining why
107
- rather than an empty list, since "nothing found" would read as "no
108
- opportunities".
104
+ `find_arbitrage` and `find_value_bets` handle any market whose bets have two
105
+ sides: `head_to_head` and its period variants, soccer's `draw_no_bet`, totals,
106
+ handicaps, team totals and player props. Each line is its own bet, so a totals
107
+ market can return several results for one game.
108
+
109
+ Three-way markets return an error explaining why rather than an empty list,
110
+ since "nothing found" would read as "no opportunities".
111
+
112
+ `find_value_bets` takes `devig` for where the fair price comes from. The
113
+ default, `"all"`, de-vigs every bookmaker fetched and averages the result,
114
+ which needs no view on which book is sharp. Naming one, `devig="Pinnacle"`,
115
+ measures every other book against that one instead: tighter, but only on
116
+ markets that book prices. A consensus needs four bookmakers on the same line,
117
+ so on thin markets naming a book finds bets that averaging cannot.
109
118
 
110
119
  Market keys vary by sport. `list_sports(sport)` returns the valid ones and
111
120
  costs nothing.
@@ -48,7 +48,7 @@ It speaks stdio.
48
48
  | `get_odds(sport, market_types=, bookmakers=)` | `market_types x ceil(bookmakers / 5)` |
49
49
  | `get_results(sport, status=, include=)` | 1 |
50
50
  | `find_arbitrage(sport, market=, bookmakers=, min_profit=, stake=)` | `ceil(bookmakers / 5)` |
51
- | `find_value_bets(sport, market=, bookmakers=, min_edge=, sharp=)` | `ceil(bookmakers / 5)` |
51
+ | `find_value_bets(sport, market=, bookmakers=, min_edge=, devig=)` | `ceil(bookmakers / 5)` |
52
52
 
53
53
  Credits are charged only when games come back, so a query that matches nothing
54
54
  is free. Every response ends with what it cost and what is left.
@@ -71,11 +71,20 @@ because both need books that disagree and five rarely spread far enough.
71
71
 
72
72
  ## Markets
73
73
 
74
- `find_arbitrage` and `find_value_bets` handle two-way markets with no line:
75
- `head_to_head`, its period variants, and soccer's `draw_no_bet`. Totals,
76
- spreads, player props and three-way markets return an error explaining why
77
- rather than an empty list, since "nothing found" would read as "no
78
- opportunities".
74
+ `find_arbitrage` and `find_value_bets` handle any market whose bets have two
75
+ sides: `head_to_head` and its period variants, soccer's `draw_no_bet`, totals,
76
+ handicaps, team totals and player props. Each line is its own bet, so a totals
77
+ market can return several results for one game.
78
+
79
+ Three-way markets return an error explaining why rather than an empty list,
80
+ since "nothing found" would read as "no opportunities".
81
+
82
+ `find_value_bets` takes `devig` for where the fair price comes from. The
83
+ default, `"all"`, de-vigs every bookmaker fetched and averages the result,
84
+ which needs no view on which book is sharp. Naming one, `devig="Pinnacle"`,
85
+ measures every other book against that one instead: tighter, but only on
86
+ markets that book prices. A consensus needs four bookmakers on the same line,
87
+ so on thin markets naming a book finds bets that averaging cannot.
79
88
 
80
89
  Market keys vary by sport. `list_sports(sport)` returns the valid ones and
81
90
  costs nothing.
@@ -24,7 +24,7 @@ classifiers = [
24
24
  ]
25
25
  dependencies = [
26
26
  "mcp>=2.0.0",
27
- "rapidoddsapi>=0.2.0",
27
+ "rapidoddsapi>=0.3.0",
28
28
  "truststore>=0.10",
29
29
  ]
30
30
 
@@ -4,6 +4,6 @@ Exposes bookmaker odds, live scores, arbitrage and value bets as MCP tools,
4
4
  backed by the official `rapidoddsapi` SDK.
5
5
  """
6
6
 
7
- __version__ = "0.2.0"
7
+ __version__ = "0.3.0"
8
8
 
9
9
  __all__ = ["__version__"]
@@ -42,25 +42,21 @@ def default_bookmakers(sport: str) -> tuple[str, ...]:
42
42
  return _REGIONS.get(sport.upper(), _FALLBACK)
43
43
 
44
44
 
45
- def region_bookmakers(sport: str) -> Sequence[str]:
46
- """Every feed in this sport's region.
45
+ def all_bookmakers() -> Sequence[str]:
46
+ """Every feed, for every sport.
47
+
48
+ Not filtered by region. Feeds price across regions, so an American book
49
+ quoting the AFL is normal, and hiding it would remove a real option for
50
+ line shopping.
47
51
 
48
52
  The API has no bookmaker endpoint and does not validate the names, so a
49
53
  name that is not a feed returns an empty result rather than an error.
50
54
  Without this list the only way to discover a feed is to guess and pay for
51
55
  the attempt, so it has to be handed over up front.
52
56
  """
53
- from rapidoddsapi import AU_BOOKMAKERS, BOOKMAKERS, US_BOOKMAKERS
57
+ from rapidoddsapi import BOOKMAKERS
54
58
 
55
- # Soccer and tennis are priced everywhere, by Australian and American books
56
- # as much as European ones, so the honest answer for them is every feed.
57
- # Only the domestic codes are genuinely regional.
58
- pools: dict[tuple[str, ...], Sequence[str]] = {
59
- AU_DEFAULT: AU_BOOKMAKERS,
60
- US_DEFAULT: US_BOOKMAKERS,
61
- EU_DEFAULT: BOOKMAKERS,
62
- }
63
- return pools[default_bookmakers(sport)]
59
+ return BOOKMAKERS
64
60
 
65
61
 
66
62
  def wide_bookmakers(
@@ -99,8 +95,12 @@ def wide_bookmakers(
99
95
  return picked
100
96
 
101
97
 
102
- def with_sharp(bookmakers: Sequence[str]) -> Sequence[str]:
103
- """Guarantee the sharp book is in the list, since value is measured off it."""
104
- if SHARP_BOOKMAKER in bookmakers:
98
+ def with_sharp(bookmakers: Sequence[str], book: str = SHARP_BOOKMAKER) -> Sequence[str]:
99
+ """Guarantee the book value is measured against is in the list.
100
+
101
+ Without it there is nothing to de-vig, so the request would be paid for and
102
+ return nothing.
103
+ """
104
+ if book in bookmakers:
105
105
  return bookmakers
106
- return [SHARP_BOOKMAKER, *bookmakers]
106
+ return [book, *bookmakers]
@@ -71,6 +71,25 @@ def format_odds(response: OddsResponse, bookmakers: Sequence[str]) -> str:
71
71
  return "\n".join(lines).rstrip()
72
72
 
73
73
 
74
+ def selection_label(bet: Mapping[str, Any]) -> str:
75
+ """Name a bet in full, so two sides of one line cannot be confused.
76
+
77
+ On a market with a line both sides are called "Over" and "Under", and on
78
+ props and team totals several bets share those names, so the subject and
79
+ the line have to be shown or the legs read as duplicates. Only a handicap
80
+ is signed: "Over +8.5" implies the line itself is positive, where on a
81
+ handicap the sign is the whole meaning.
82
+ """
83
+ name = str(bet.get("team") or bet.get("selection", ""))
84
+ parts = [bet.get("player_name"), bet.get("team_name"), name]
85
+
86
+ point = bet.get("point")
87
+ if point is not None:
88
+ parts.append(f"{point:g}" if name in ("Over", "Under") else f"{point:+g}")
89
+
90
+ return " ".join(str(part) for part in parts if part)
91
+
92
+
74
93
  def format_arbitrage(found: list[Arbitrage], stake: float) -> str:
75
94
  if not found:
76
95
  return ""
@@ -78,12 +97,12 @@ def format_arbitrage(found: list[Arbitrage], stake: float) -> str:
78
97
  lines = [f"{len(found)} arbitrage opportunit{'y' if len(found) == 1 else 'ies'}:", ""]
79
98
  for arb in found:
80
99
  lines.append(
81
- f"{arb['away_team']} at {arb['home_team']} +{arb['profit_percent']:.2f}% "
100
+ f"{arb['away_team']} at {arb['home_team']} {arb['profit_percent']:+.2f}% "
82
101
  f"on a {stake:g} stake"
83
102
  )
84
103
  for leg in arb["legs"]:
85
104
  lines.append(
86
- f" {leg['team']:<28} {leg['price']} @ {leg['bookmaker']} "
105
+ f" {selection_label(leg):<34} {leg['price']} @ {leg['bookmaker']} "
87
106
  f"stake {leg['stake']:g}"
88
107
  )
89
108
  lines.append("")
@@ -95,14 +114,16 @@ def format_arbitrage(found: list[Arbitrage], stake: float) -> str:
95
114
  return "\n".join(lines)
96
115
 
97
116
 
98
- def format_value_bets(found: list[ValueBet], sharp: str) -> str:
117
+ def format_value_bets(found: list[ValueBet], devig: str) -> str:
99
118
  if not found:
100
119
  return ""
101
120
 
102
- lines = [f"{len(found)} value bet(s), priced against {sharp}:", ""]
121
+ against = "every bookmaker" if devig == "all" else devig
122
+ lines = [f"{len(found)} value bet(s), priced against {against}:", ""]
103
123
  for bet in found:
104
124
  lines.append(
105
- f"+{bet['edge_percent']:.2f}% {bet['selection']} {bet['price']} @ {bet['bookmaker']}"
125
+ f"+{bet['edge_percent']:.2f}% {selection_label(bet)} "
126
+ f"{bet['price']} @ {bet['bookmaker']}"
106
127
  )
107
128
  lines.append(
108
129
  f" {bet['away_team']} at {bet['home_team']} "
@@ -111,7 +132,7 @@ def format_value_bets(found: list[ValueBet], sharp: str) -> str:
111
132
  )
112
133
  lines.append("")
113
134
  lines.append(
114
- f"Edge is measured off {sharp} with its margin removed. It is an estimate of "
135
+ f"Edge is measured off {against} with the margin removed. It is an estimate of "
115
136
  "value, not a guaranteed win."
116
137
  )
117
138
  return "\n".join(lines)
@@ -27,9 +27,8 @@ from rapidoddsapi.types import OddsResponse, Usage
27
27
 
28
28
  from . import __version__
29
29
  from .defaults import (
30
- SHARP_BOOKMAKER,
30
+ all_bookmakers,
31
31
  default_bookmakers,
32
- region_bookmakers,
33
32
  wide_bookmakers,
34
33
  with_sharp,
35
34
  )
@@ -132,6 +131,46 @@ def _explain(exc: Exception) -> str:
132
131
  return f"Request failed: {exc}"
133
132
 
134
133
 
134
+ def unsupported_markets(sport: str, requested: Sequence[str]) -> list[str]:
135
+ """Which of these market types the sport does not carry.
136
+
137
+ Only worth asking once a response comes back empty. The API accepts any
138
+ market string and returns nothing for one it does not recognise, so a
139
+ misspelled or wrong-sport key is indistinguishable from a sport simply
140
+ having no fixtures. Checking costs nothing.
141
+ """
142
+ try:
143
+ markets = get_client().get_sport(sport).get("markets")
144
+ except RapidOddsAPIError:
145
+ return []
146
+ if markets is None:
147
+ return []
148
+
149
+ valid = {*markets["game"], *markets["team"], *markets["player_props"]}
150
+ return [key for key in requested if key not in valid]
151
+
152
+
153
+ def _no_games(sport: str, market: str) -> str:
154
+ """Nothing came back at all, which is not the same as nothing being found.
155
+
156
+ "No arbitrage" reads as having looked and found none, so a sport out of
157
+ season or a market type this sport does not carry has to say so, or the
158
+ model reports a conclusion it never tested.
159
+ """
160
+ wrong = unsupported_markets(sport, [market])
161
+ if wrong:
162
+ return (
163
+ f"{sport} does not have '{market}', so there was nothing to look "
164
+ f"at. Call list_sports({sport!r}) for the market types it carries "
165
+ f"and retry with one of those."
166
+ )
167
+ return (
168
+ f"No games priced for {sport} on {market}, so there was nothing to "
169
+ f"look at. The season may be over or the fixtures not yet posted. "
170
+ f"This is not the same as finding no opportunities."
171
+ )
172
+
173
+
135
174
  def _fetch_odds(
136
175
  sport: str, market_types: Sequence[str], bookmakers: Sequence[str]
137
176
  ) -> tuple[OddsResponse, int]:
@@ -190,14 +229,15 @@ def list_sports(sport: str | None = None) -> str:
190
229
  lines.append(f"{group} ({len(keys)}):")
191
230
  lines.extend(f" {key}" for key in keys)
192
231
  lines.append("")
193
- feeds = region_bookmakers(sport)
194
- lines.append(f"bookmakers you can request for {info['id']} ({len(feeds)}):")
232
+ feeds = all_bookmakers()
233
+ lines.append(f"bookmakers you can request ({len(feeds)}):")
195
234
  lines.extend(f" {feed}" for feed in feeds)
196
235
  lines += [
197
236
  "",
198
- "That is the complete list of feeds for this region. A name "
199
- "not on it returns no prices, so do not try other bookmaker "
200
- "names to see what happens, each attempt can cost credits.",
237
+ "That is every feed, and they are not split by region: an "
238
+ "American book pricing the AFL is normal. A name not on the "
239
+ "list returns no prices, so do not try other bookmaker names "
240
+ "to see what happens, each attempt can cost credits.",
201
241
  "These are feeds, not brands. One feed often carries several "
202
242
  "brands at identical prices, so the number of betting sites "
203
243
  "behind them is larger than the number of names here.",
@@ -267,14 +307,30 @@ def get_odds(
267
307
 
268
308
  body = format_odds(response, books)
269
309
  if not body:
270
- return (
271
- f"No games for {sport} from {', '.join(books)} "
272
- f"on {', '.join(markets)}.\n"
273
- f"Nothing was charged, since empty responses are free. The season "
274
- f"may be over, or these bookmakers may not price this market. "
275
- f"Check list_sports({sport!r}) for valid market types before "
276
- f"retrying.\n" + credit_line(cost, _usage())
277
- )
310
+ lines = [
311
+ f"No games for {sport} from {', '.join(books)} on "
312
+ f"{', '.join(markets)}. Nothing was charged, since empty responses "
313
+ f"are free."
314
+ ]
315
+
316
+ wrong = unsupported_markets(sport, markets)
317
+ if wrong:
318
+ lines.append(
319
+ f"{sport} does not have {', '.join(repr(k) for k in wrong)}. "
320
+ f"That is why the result is empty, and it would be empty "
321
+ f"whatever the fixtures are, so do not read it as the season "
322
+ f"being over. Call list_sports({sport!r}) for the market types "
323
+ f"this sport actually carries and retry with one of those."
324
+ )
325
+ else:
326
+ lines.append(
327
+ f"The market types are valid for {sport}, so there are simply "
328
+ f"no fixtures priced right now, whether out of season or not "
329
+ f"yet posted. Retrying the same request will not change that."
330
+ )
331
+
332
+ lines.append(credit_line(cost, _usage()))
333
+ return "\n".join(lines)
278
334
 
279
335
  return f"{body}\n\n{credit_line(cost, _usage())}"
280
336
 
@@ -338,13 +394,18 @@ def find_arbitrage(
338
394
  to ten bookmakers, 2 credits, because an arbitrage only exists when books
339
395
  disagree and five rarely spread far enough.
340
396
 
341
- Only two-way markets with no line work: head_to_head, its period variants
342
- such as head_to_head_1st_half, and soccer's draw_no_bet. Totals, spreads,
343
- player props and three-way markets are rejected with an explanation rather
344
- than silently returning nothing.
397
+ Works on any market whose bets have two sides: head_to_head and its period
398
+ variants, soccer's draw_no_bet, totals, handicaps, team totals and player
399
+ props. Only three-way markets are rejected, with an explanation rather than
400
+ silently returning nothing.
401
+
402
+ On a market with a line each line is a separate bet, so a totals market can
403
+ return several results for one game. Over 8.5 is never paired with Under
404
+ 9.5, and a handicap of -1.5 only ever with +1.5.
345
405
 
346
406
  min_profit is a percentage, default 1.0. Below roughly 1 percent an edge
347
- usually disappears while the second leg is being placed.
407
+ usually disappears while the second leg is being placed. Set it negative to
408
+ see near misses.
348
409
  """
349
410
  books = bookmakers or wide_bookmakers(sport)
350
411
 
@@ -356,6 +417,8 @@ def find_arbitrage(
356
417
 
357
418
  body = format_arbitrage(found, stake)
358
419
  if not body:
420
+ if not response.get("games"):
421
+ return _no_games(sport, market) + "\n" + credit_line(cost, _usage())
359
422
  return (
360
423
  f"No arbitrage on {market} for {sport} above {min_profit}% "
361
424
  f"across {len(books)} bookmakers.\n"
@@ -372,49 +435,77 @@ def find_value_bets(
372
435
  market: str = "head_to_head",
373
436
  bookmakers: list[str] | None = None,
374
437
  min_edge: float = 2.0,
375
- sharp: str = SHARP_BOOKMAKER,
438
+ devig: str = "all",
376
439
  ) -> str:
377
- """Find prices that beat a sharp bookmaker's fair value.
440
+ """Find prices that beat fair value.
441
+
442
+ Bookmakers price in a margin, so their odds sum to more than certainty.
443
+ Removing it leaves a fair price, and any book paying more than that is
444
+ positive expected value.
445
+
446
+ devig says where the fair price comes from, and is worth explaining to the
447
+ user rather than just picking:
378
448
 
379
- A sharp book runs thin margins and moves fast, so its prices track true
380
- probability. Stripping its margin gives a fair price, and any book paying
381
- more than that is positive expected value.
449
+ "all" the default. Every bookmaker fetched is de-vigged on its
450
+ own and the results averaged. Needs no view on which book
451
+ is sharp, works on markets Pinnacle does not price, and is
452
+ the one to use unless there is a reason not to.
453
+ a book name "Pinnacle" measures every other book against that one. A
454
+ sharp book runs thin margins and moves fast, so its prices
455
+ track true probability more closely than an average does.
456
+ Tighter, but only where that book prices the market, and it
457
+ cannot itself appear in the results.
382
458
 
383
459
  Fetches odds first, so it costs the same as get_odds:
384
460
  ceil(number of bookmakers / 5) credits for the single market. Defaults to
385
- ten bookmakers, 2 credits. The sharp book is added automatically if it is
386
- not in the list, since the calculation is impossible without it.
461
+ ten bookmakers, 2 credits. Naming a book puts it in the request
462
+ automatically, since the calculation is impossible without it.
387
463
 
388
- Same market limits as find_arbitrage: two-way, no line. head_to_head, its
389
- period variants, and soccer's draw_no_bet.
464
+ Same markets as find_arbitrage: head_to_head and its period variants,
465
+ draw_no_bet, totals, handicaps, team totals and player props.
390
466
 
391
467
  min_edge is a percentage, default 2.0. Smaller edges are usually inside the
392
468
  error of the fair price rather than real value.
393
469
  """
394
- # Seeded into the default spread so it stays at ten books and two credits.
395
- # An explicit list is respected as given, with the sharp book appended only
396
- # because the edge cannot be worked out without it.
397
- books = (
398
- list(with_sharp(bookmakers))
399
- if bookmakers
400
- else list(wide_bookmakers(sport, must_include=(sharp,)))
401
- )
470
+ consensus = devig == "all"
471
+
472
+ # The named book is seeded into the default spread rather than appended, so
473
+ # it stays at ten books and two credits. A consensus needs no particular
474
+ # book, only enough of them.
475
+ if bookmakers:
476
+ books = list(bookmakers) if consensus else list(with_sharp(bookmakers, devig))
477
+ else:
478
+ books = list(wide_bookmakers(sport, must_include=() if consensus else (devig,)))
402
479
 
403
480
  try:
404
481
  response, cost = _fetch_odds(sport, [market], books)
405
- found = value(response, sharp=sharp, market=market, min_edge=min_edge)
482
+ found = value(response, devig=devig, market=market, min_edge=min_edge)
406
483
  except Exception as exc:
407
484
  return _explain(exc)
408
485
 
409
- body = format_value_bets(found, sharp)
486
+ body = format_value_bets(found, devig)
410
487
  if not body:
411
- return (
412
- f"No value on {market} for {sport} above {min_edge}% against "
413
- f"{sharp}.\n"
414
- f"If {sharp} does not price this sport there is nothing to compare "
415
- f"against, which looks the same as finding nothing.\n"
416
- + credit_line(cost, _usage())
417
- )
488
+ if not response.get("games"):
489
+ return _no_games(sport, market) + "\n" + credit_line(cost, _usage())
490
+
491
+ lines = [f"No value on {market} for {sport} above {min_edge}%."]
492
+ if consensus:
493
+ lines.append(
494
+ "A consensus needs four bookmakers pricing the same bet, and on "
495
+ "markets with a line that means the same line. Fewer books "
496
+ "quote each line of a totals, handicap or player prop market "
497
+ "than quote the game itself, so this can mean too few prices "
498
+ "rather than no value. Naming one book, devig='Pinnacle', "
499
+ "needs only that book and is worth trying here."
500
+ )
501
+ else:
502
+ lines.append(
503
+ f"If {devig} does not price this market there is nothing to "
504
+ f"compare against, which looks the same as finding nothing. "
505
+ f"devig='all' prices against the other books instead."
506
+ )
507
+ lines.append(credit_line(cost, _usage()))
508
+ return "\n".join(lines)
418
509
 
419
510
  return f"{body}\n{credit_line(cost, _usage())}"
420
511
 
@@ -78,6 +78,17 @@ class FakeClient:
78
78
  def get_usage(self):
79
79
  return self._usage
80
80
 
81
+ def get_sport(self, sport, markets=True):
82
+ return {
83
+ "id": sport,
84
+ "name": sport,
85
+ "markets": {
86
+ "game": ["head_to_head_3_way", "draw_no_bet"],
87
+ "team": [],
88
+ "player_props": [],
89
+ },
90
+ }
91
+
81
92
 
82
93
  @pytest.fixture
83
94
  def fake(monkeypatch):
@@ -108,21 +119,26 @@ class TestDefaults:
108
119
  def test_wide_starts_from_the_region(self):
109
120
  assert list(defaults.wide_bookmakers("AFL"))[:5] == list(defaults.AU_DEFAULT)
110
121
 
111
- def test_region_bookmakers_is_the_full_regional_list(self):
122
+ def test_all_bookmakers_is_every_feed(self):
112
123
  """The API has no bookmaker endpoint and does not reject bad names, so
113
124
  without a list to hand the only way to find a feed is to guess and pay
114
125
  for each attempt."""
115
- from rapidoddsapi import AU_BOOKMAKERS, BOOKMAKERS, US_BOOKMAKERS
126
+ from rapidoddsapi import BOOKMAKERS
116
127
 
117
- assert defaults.region_bookmakers("AFL") == AU_BOOKMAKERS
118
- assert defaults.region_bookmakers("NFL") == US_BOOKMAKERS
119
- # Soccer and tennis are priced in every region, not just Europe.
120
- assert defaults.region_bookmakers("EPL") == BOOKMAKERS
128
+ assert defaults.all_bookmakers() == BOOKMAKERS
121
129
 
122
- def test_region_list_is_a_superset_of_the_default(self):
130
+ def test_the_list_is_not_filtered_by_region(self):
131
+ """Feeds price across regions, so an American book on the AFL is
132
+ normal and must not be hidden."""
133
+ from rapidoddsapi import AU_BOOKMAKERS, US_BOOKMAKERS
134
+
135
+ feeds = set(defaults.all_bookmakers())
136
+ assert set(AU_BOOKMAKERS) <= feeds
137
+ assert set(US_BOOKMAKERS) <= feeds
138
+
139
+ def test_every_default_is_a_real_feed(self):
123
140
  for sport in ("AFL", "NFL", "EPL"):
124
- region = set(defaults.region_bookmakers(sport))
125
- assert set(defaults.default_bookmakers(sport)) <= region
141
+ assert set(defaults.default_bookmakers(sport)) <= set(defaults.all_bookmakers())
126
142
 
127
143
  def test_with_sharp_adds_it_once(self):
128
144
  assert defaults.SHARP_BOOKMAKER in defaults.with_sharp(["Sportsbet"])
@@ -268,6 +284,26 @@ class TestGetOdds:
268
284
  assert "Cost: 0 credits." in text
269
285
  assert "Nothing was charged" in text
270
286
 
287
+ def test_empty_on_a_wrong_market_blames_the_market(self, fake):
288
+ """Soccer has no head_to_head because of the draw. Left unexplained,
289
+ the empty result reads as the season being over, which is a wrong
290
+ conclusion a user would act on."""
291
+ text = server.get_odds("EPL", market_types=["head_to_head"])
292
+
293
+ assert "does not have 'head_to_head'" in text
294
+ assert "do not read it as the season being over" in text
295
+
296
+ def test_empty_on_a_valid_market_blames_the_fixtures(self, fake):
297
+ text = server.get_odds("EPL", market_types=["draw_no_bet"])
298
+
299
+ assert "market types are valid" in text
300
+ assert "no fixtures priced right now" in text
301
+
302
+ def test_unsupported_markets_only_flags_the_bad_ones(self, fake):
303
+ wrong = server.unsupported_markets("EPL", ["draw_no_bet", "head_to_head"])
304
+
305
+ assert wrong == ["head_to_head"]
306
+
271
307
  def test_explicit_bookmakers_are_respected(self, fake):
272
308
  server.get_odds("AFL", bookmakers=["Pinnacle"])
273
309
 
@@ -283,21 +319,60 @@ class TestGetOdds:
283
319
 
284
320
 
285
321
  class TestValueBets:
286
- def test_sharp_book_is_always_requested(self, fake):
287
- server.find_value_bets("AFL", bookmakers=["Sportsbet", "TAB"])
322
+ def test_a_named_book_is_always_requested(self, fake):
323
+ """Without it there is nothing to de-vig, so the request would be paid
324
+ for and return nothing."""
325
+ server.find_value_bets("AFL", bookmakers=["Sportsbet", "TAB"], devig="Pinnacle")
288
326
 
289
- assert defaults.SHARP_BOOKMAKER in fake.calls[0][2]
327
+ assert "Pinnacle" in fake.calls[0][2]
290
328
 
291
- def test_sharp_does_not_push_the_default_over_a_credit_group(self, fake):
292
- """Appending the sharp book to ten would make eleven, and
293
- ceil(11 / 5) is 3 credits where the description promises 2."""
294
- server.find_value_bets("AFL")
329
+ def test_a_named_book_does_not_push_the_default_over_a_credit_group(self, fake):
330
+ """Appending it to ten would make eleven, and ceil(11 / 5) is 3 credits
331
+ where the description promises 2."""
332
+ server.find_value_bets("AFL", devig="Pinnacle")
295
333
 
296
334
  books = fake.calls[0][2]
297
- assert defaults.SHARP_BOOKMAKER in books
335
+ assert "Pinnacle" in books
298
336
  assert len(books) == defaults.ARBITRAGE_DEFAULT_COUNT
299
337
  assert -(-len(books) // 5) == 2
300
338
 
339
+ def test_a_consensus_forces_no_particular_book(self, fake):
340
+ """The default needs enough books, not any one of them, so nothing is
341
+ seeded and the caller's list is requested as given."""
342
+ server.find_value_bets("AFL", bookmakers=["Sportsbet", "TAB"])
343
+
344
+ assert list(fake.calls[0][2]) == ["Sportsbet", "TAB"]
345
+
346
+ def test_the_sdk_is_actually_called(self, fake):
347
+ """Every tool turns an exception into text, so calling the SDK wrongly
348
+ reads exactly like a failed request. This asserts the call went
349
+ through, which is what an argument renamed in the SDK would break."""
350
+ for devig in ("all", "Pinnacle"):
351
+ assert not server.find_value_bets("AFL", devig=devig).startswith("Request failed")
352
+
353
+ def test_an_empty_consensus_blames_the_book_count(self, fake):
354
+ """Two books priced the game, and a consensus needs four. Left
355
+ unexplained, a thin market reads as no value, which is a different
356
+ conclusion."""
357
+ fake._odds = ONE_GAME
358
+
359
+ text = server.find_value_bets("AFL", market="head_to_head")
360
+
361
+ assert "four bookmakers" in text
362
+ assert "devig='Pinnacle'" in text
363
+
364
+ def test_no_games_is_not_no_value(self, fake):
365
+ """Nothing came back at all, so nothing was tested."""
366
+ text = server.find_value_bets("AFL", market="draw_no_bet")
367
+
368
+ assert "nothing to look at" in text
369
+ assert "not the same as finding no opportunities" in text
370
+
371
+ def test_no_games_on_a_wrong_market_blames_the_market(self, fake):
372
+ text = server.find_arbitrage("AFL", market="head_to_head")
373
+
374
+ assert "does not have 'head_to_head'" in text
375
+
301
376
 
302
377
  class TestProtocol:
303
378
  """What the MCP client actually sees. No API key needed to inspect this."""
@@ -1,41 +0,0 @@
1
- # Changelog
2
-
3
- Notable changes to this package. Versions follow [semantic versioning](https://semver.org).
4
-
5
- ## 0.2.0
6
-
7
- - `list_sports(sport)` now returns every bookmaker that can be requested for
8
- that sport, alongside its market types. There was no way to discover a
9
- bookmaker name: the API has no endpoint for them and does not reject unknown
10
- ones, it just returns no prices. A model asked which bookmakers were covered
11
- would therefore guess names and pay for each attempt, and a casing slip such
12
- as `Palmerbet` for `PalmerBet` looked identical to the book not existing
13
- - Tool descriptions say not to guess bookmaker or market names, and where the
14
- valid ones come from
15
- - Soccer and tennis now list every feed rather than only the European ones,
16
- since Australian and American books price them too
17
-
18
- ## 0.1.2
19
-
20
- - Certificates are verified against the operating system's trust store. On
21
- networks that inspect HTTPS, and with antivirus that does the same, every
22
- request previously failed with CERTIFICATE_VERIFY_FAILED because the bundled
23
- store does not know the intercepting certificate the machine itself trusts
24
-
25
- ## 0.1.1
26
-
27
- - Tool descriptions now say these tools are RapidOddsAPI itself. Asked what
28
- RapidOddsAPI covered, a model would search the web instead of calling
29
- `list_sports`, because nothing connected the name to the tools
30
-
31
- ## 0.1.0
32
-
33
- First release.
34
-
35
- - Five tools: `list_sports`, `get_odds`, `get_results`, `find_arbitrage`,
36
- `find_value_bets`
37
- - Every response reports what it cost and the credits remaining
38
- - A sport is always required, and bookmakers default to five, so a vague
39
- question costs 1 credit rather than tens
40
- - Built on the `rapidoddsapi` SDK, which needs the API at v1.1.0 or later for
41
- the sport directory and balance lookups