DEV Community

What Happens to My Polymarket Bot When a BTC Market Resolves Unexpectedly

This one caught me off guard. I was running my bot on BTC 5 minute and 15 minute markets on Polymarket. These are fast markets. A new one opens every few minutes. Price goes above or below a level, market resolves, next one starts. The cycle is constant and at first it felt perfect for a market maker. High frequency, steady volume, predictable structure.

Then I learned the hard way that fast markets resolve fast. Faster than I expected. And my bot was not ready for it.

What Happened

I had open orders on both sides of a 5 minute BTC market. The market was still showing time remaining on my dashboard. But BTC moved hard in one direction, the resolution condition was met, and the market closed early. My buy side had already filled. My sell side had not. The market resolved before I could balance the position.

The bot kept trying to repost orders on a closed market. The logs started throwing errors I had never seen before. The filled position was now locked at resolution value. The hedge I thought I had was gone.

The damage on that single market was small. But these markets run back to back all day. If this happens once it will happen again. I had to fix it fast.

What I Changed

First I added a resolution time buffer. On 5 minute markets I now stop posting new orders in the last 60 seconds before expected resolution. On 15 minute markets I stop in the last 90 seconds. The spread in those final moments gets weird anyway as the probability collapses toward zero or one. Not worth the risk.

Second I added a pre-order status check. Before every order cycle the bot now calls the API and confirms the market is still active and accepting orders. If anything looks off it skips that market and waits for the next one to open. This added maybe 20 milliseconds to each cycle. Worth it.

Third I added inventory tracking per market expiry. The bot now knows when each market is expected to close and will not let inventory accumulate beyond a certain level as that time approaches. If it is holding tokens and resolution is coming soon it backs off and lets existing positions settle rather than adding more.

Fourth I added automatic market rotation. When a 5 minute market closes the bot now waits for the next one to open and validates it before jumping in. It used to try to switch immediately and sometimes caught the edge of a closing market by mistake. The small delay fixed that.

Final Thoughts

BTC 5 minute and 15 minute markets are genuinely good for market making when the bot handles the lifecycle correctly. The volume is there. The fills come in. The spreads are workable. But the speed that makes them attractive is the same speed that will burn you if your order management does not account for how quickly they turn over.

My bot runs these markets cleanly now. It took one bad resolution to get there. All my code is open source at github.com/casatrick if you want to follow along.

Comments

No comments yet. Start the discussion.