Skip to content
5 min read · Tags: plotting plotly grouping datetime api

BW 150: Kalshi

Get better at: Working with APIs, grouping, dates and times, and plotting with Plotly.

BW 150: Kalshi

Hi, everyone! Before we get started, I've got two administrative announcements:

  1. Pandas 3 will be coming out soon, and as we saw last week, it includes a number of changes. I'm recording videos about the Pandas 3 upgrade on YouTube; you can see them on my Pandas 3 playlist, here: https://www.youtube.com/watch?v=TCSjgvtO714&list=PLbFHh-ZjYFwFWHVT0qeg9Jz1TBD0TlJJT
  2. Like many other online creators and instructors, I've written an end-of-year summary of what I did this year, and what plans I have for 2026. You can read it at: https://lerner.co.il/2025/12/23/reuvens-2025-in-review/

And now...

Over the last few years, I've heard more and more about "prediction markets," online platforms that allow you to make predictions about the future. You can predict who will win an election, or on the value of a particular currency (or cryptocurrency) at a particular time, on whether Netflix will successfully buy Warner-Discovery, or on any number of other events in our world.

But in practice? Many commentators say that Kalshi has effectively become an online gambling platform, and they make a pretty convincing argument. Moreover, I've heard that it has become an online sports gambling platform. Sports gambling, as we saw in BW 100, back in January of this year, is extremely popular, especially among young people. Online sports betting companies are making enormous profits, in no small part because they exclude anyone who actually manages to make money.

Kalshi isn't officially a gambling platform, and certainly not a sports gambling platform, but I read that many people see it that way — including the state of Nevada, which has gone to court to stop Kalshi from allowing its residents from entering into sports markets (https://finance.yahoo.com/news/kalshi-risk-nevada-enforcement-court-173246378.html). Nevada has long allowed for sports betting, but also has strict rules over who runs such platforms, and is trying to stop Kalshi from joining.

Kyla Scanlon argues that the spread of gambling reflects other issues in modern society, and specifically mentions Kalshi in one of her latest essays, at https://kyla.substack.com/p/everyone-is-gambling-and-no-one-is .

I'm sure that Kalshi has a different take on things. Just yesterday, in fact, they announced Kalshi Research, which will look at prediction markets as a new and different way to predict trends (https://research.kalshi.com/).

This week, I thought it would be interesting to look at Kalshi: What sorts of questions are people trying to ask? Is it really being used for sports betting? And do we see the number of predictions on Kalshi growing over time?

Data and five questions

The good news is that Kalshi offers an API to retrieve information about just about any part of the system. The better news is that if you're looking to get information about their events and markets, rather than your personal predictions, then the API is totally open and free to use. And even better than that? There's a package on PyPI (https://pypi.org/project/kalshi-python/) that packages the Kalshi API into an easy-to-use format.

The bad news? That PyPI project crashed on me pretty consistently, apparently because of a validation error. The Kalshi server is returning values that are considered invalid by the client program.

I thus, with some help from Claude, pieced together a program that retrieves Kalshi event and market information using the Python requests module, and then rewrites things into a Pandas data frame. It took me a while to get this to work, and it would be unfair to ask you to do this — so I'm providing the Python program here:

FYI, it took about 15 minutes for this program to run on my computer.

In case you aren't a Kalshi guru, here are a few basics that you should know:

Learning goals for this week include: Working with APIs, dates and times, grouping, and plotting.

Paid subscribers, including members of my LernerPython.com membership program, get the data files provided to them, as well as all of the questions and answers each week, downloadable notebooks, and participation in monthly office hours.

Here are my five questions for this week. I'll be back tomorrow with solutions and full explanations: