closing line value / pinnacle closing odds / clv
Closing line value calculator against Pinnacle's close
import os
import time
from datetime import datetime, timezone
import requests
BASE = os.environ["ODDS_BASE_URL"]
KEY = os.environ["ODDS_API_KEY"]
URL = BASE + "/kit/v1/markets"
HDR = {"x-portal-apikey": KEY}
seen = {} # event_id: (starts, prices)
def utc(stamp):
return datetime.fromisoformat(
stamp.replace("Z", "+00:00"))
def tick(sport_id):
q = {"sport_id": sport_id,
"event_type": "prematch"}
r = requests.get(URL, params=q,
headers=HDR,
timeout=10)
r.raise_for_status()
for ev in r.json()["events"]:
per = ev["periods"]
ml = per.get("num_0", {}).get(
"money_line")
if ml:
seen[ev["event_id"]] = (
ev["starts"], ml)
def settle():
now = datetime.now(timezone.utc)
for eid, (starts, ml) in list(
seen.items()):
if utc(starts) <= now:
print(eid, "closed at", ml)
del seen[eid]
while True:
tick(sport_id=1) # soccer
settle()
time.sleep(60)
Select the code to copy it.
Record Pinnacle's closing prices yourself with the odds API
The script reads the Pinnacle odds API's prematch soccer board every minute and keeps each match's latest money line. When a match's start time passes, the last price it saw is the close, and it prints it; write it to your own table instead.
Sixty seconds between calls puts the recorded close within a minute of the start, at 1,440 calls a day, which needs a paid REST plan. The free key's 100 calls a day allow one call every 15 minutes: enough to test the script, too coarse for a real close.
- Create a key and export it with the base URL from the docs.
- Run the script before the matches you bet on start.
- Put each recorded close into the calculator above, or into your own CLV column.
- Fast feedbackProfit takes thousands of bets to separate skill from luck. The close says something about every bet the moment the market shuts.
- Against the sharpest closePinnacle's closing price has absorbed the most money and information of any line on the match, which makes it the hardest benchmark to beat.
- Margin removedComparing with the raw close counts Pinnacle's margin as your edge. The fair close does not.
Why the close is the benchmark
If you keep getting prices better than where Pinnacle closes, you are usually ahead of the market's final judgement. Bettors track CLV because it points the right way long before a balance does.
taken 2.20 · fair close 2.11 · CLV +4.36%
Keep a close for every bet, and the calculator becomes a column in your sheet