How I used ChatGPT to get live BetMGM Odds into Excel | Free Download
Added 2024-07-14 05:22:57 +0000 UTCG’day lads! In this article I’ll explain how I used ChatGPT to generate blank power query code. This allowed me to import BetMGM’s live MLB Odds, as featured on Yahoo Sport, into the Excel LADZ - 2024 MLB Model. Now, after generating the probabilities for each market, you can compare them to BetMGM’s live odds to find value!
Attached is a file containing the connection to the live odds. Over the coming days, Patrons will be able to access a video with instructions on how to best use the file in conjunction with the MLB Model. The live odds will also be included in the updated ‘Excel LADZ - 2024 MLB Model’, which Patrons can re-download below.
To refresh the file and update the odds, select the "Refresh All" icon in the 'Data' tab 🔥
DOWNLOAD the ‘Excel LADZ - 2024 MLB Model’ and become a Patron here: https://www.patreon.com/posts/how-to-use-excel-106190197
Finding a Data Source
My goal was to update the ‘Excel LADZ - 2024 MLB Model’ with live odds, so that the probabilities generated by the model can be compared to the market. By doing this, “undervalued” bets can be identified.
For example, consider a game between Arizona and Toronto. Taking into account that Diaz and Berrios were the Starting Pitchers respectively, the model produced a Win % of 60% for Arizona - equivalent to $1.67 decimal odds. Pregame though, BetMGM were offering odds of $1.75. This has a positive expected value of 5%, meaning that in the long term, a trader can expect to make a profit of 5%.
My first step is always to find a website offering the information I’m looking for. Then, I can scrape the website’s data and bring it into my Excel file using a Power Query. This way, whenever the website updates, so will the data in my spreadsheet.
After a long search though, I couldn’t find a website offering odds for each upcoming MLB game in a clean format. Because of this, I realised a regular Power Query wasn’t sufficient. As a result, I shifted my focus from finding a website to finding an API.
An API allows you to programmatically access and retrieve data from a particular service or source - in this case, live odds for upcoming MLB games. I often like to think of an API as “large, hidden data”. All the stats you see on a sports website are usually powered by an API that contains a huge amount of stats. It is then “cleaned up” so it is presented nicely on the website.
Most API’s are behind a paywall - probably because they’re so valuable! However, large websites often include a free-to-access API in the website’s code. You can find the url to these APIs by “Inspecting” the website. I work on a MacBook, so this process involves pressing “Inspect Element”, which will then reveal all the APIs the website is using.
I found a reliable and free API on Yahoo Sport’s website. As you can see, Yahoo displays live BetMGM odds for upcoming MLB games.
To find the link to this API, I’ve right-clicked and selected “Inspect Element” on my MacBook. This process may be different for other computers. I’ve then located the XHR/Fetch section, which contains the API requests and responses exchanged between the browser and the server, revealing the endpoints used to fetch live odds data for MLB Games.
Now I’ve gotten a URL for this BetMGM MLB Odds API. I can copy and paste this link into the internet, and it returns a bunch of hard-coded data.
However, the data isn’t really useful here. It’s messy and pretty much unreadable. Now, I have to be able to bring this data into Excel so that it can be presented neatly.
ChatGPT - Blank Power Query Code
I can do this by creating a Blank Query in Excel. A Blank Query is a starting point within Power Query where you can define custom data retrieval operations. To bring in live MLB odds, I can use a Blank Query to input the API endpoint URL provided by the Yahoo Sport website, configure any necessary parameters or authentication details, and transform the returned JSON data into a structured format suitable for analysis in Excel.
The only problem is, Blank Query code is like a separate coding language. It’s tough to work out by yourself, especially with complex and multi-layered datasets. That’s why using ChatGPT makes life so much easier!
Firstly, I asked ChatGPT to write the code necessary to bring the URL into Excel. This returns the starting point of the dataset. The most difficult thing about API’s is that they are multi-layered. To unravel the layers properly requires careful and diligent coding. This was my initial prompt to ChatGPT.
ChatGPT was then able to produce the following code. As stated in the machine’s last sentence, we need to further manipulate the data so as to return the odds for each game.
My next prompt was to ask for more information; digging further into the dataset.
I like to do things a step at a time. This is so that I can test each part of the code, meaning an error can be identified quickly. My next prompt goes further into the dataset, returning all the played, live and upcoming matches.
Next to these matches, I want to return a list of all the available bets on that game.
I want to be able to make this dataset as tidy as possible, so I’m going to add columns to the left of the ‘bets’ column.
In expanding the ‘bets’ column, I can return all the important information for someone looking to place a bet on the game.
In the Power Query Editor, which is where I can create/view my Blank Query code, the final product is just copied and pasted from ChatGPT’s last response.
Once I press OK, Excel will load this data into the spreadsheet. This will be in the form of a table, so I can filter the results. Below, I’ve filtered all the bets so that only those on Live games are shown.
Now I’m able to compare the market’s odds with the model’s!
Note: Excel's Power Query Editor is only available for users of Excel 2016 and later 🔥
Thanks for reading lads, become a member today and take advantage of the community’s sports modelling skills!
Comments
What would be useful is to be able to pull Pinnacle odds
absolute -
2024-07-29 00:34:16 +0000 UTCHi lad, welcome! 🔥 You can message me through Patreon or Discord. You can also send me an email at: ladz.excel@gmail.com 😃
Excel LADZ
2024-07-26 12:52:21 +0000 UTCHello. How can I contact you? I have a couple of ideas for you
Мінтенко Андрій
2024-07-24 14:47:50 +0000 UTCThere is oddsapi under paywall to check. Never used it https://the-odds-api.com/
Vasilis
2024-07-21 22:35:39 +0000 UTCHi lad, not particularly. Right now I'm investigating different API's, and seeing which one's can offer the most utility in terms of live odds, stats, lineups & news. I'll keep the Patreon posted with what I'm able to find 😉
Excel LADZ
2024-07-21 22:26:04 +0000 UTCHave you tried anything similar with other books?
Vasilis
2024-07-21 09:24:18 +0000 UTC