Inspiration

There is no shying away from the fact that prediction markets have had a massive impact on society, now often being quoted as the most accurate odds for any event. A fairly recent addition to these markets has been binary options; one can make predictions on whether or not crypto price will go up or down in the next 15 minutes. These markets have gained massive traction, now having $40 million + of volume per asset traded daily, and so we thought this was an untapped opportunity to test some novel algorithms.

What it does

Our trading algorithm performs market making on 15 minute to expiry bitcoin contracts on Polymarkets, taking into account aspects such as inventory skew (accounting for correlation between ETH and BTC), and queue position (which updates deterministically under market trade exchange messages, and probabilistically under limit trade exchange messages). It then plots out our bot's performance live against streamed data from Polymarkets websockets API under different queue position updating functions to illustrate how the algorithm would perform under different ratios of limit cancels to limit adds to the orderbook.

How we built it

The first stage of building involved getting data for testing, this was done through the polymarkets API, and the data is now stored online in an adjusted format. We compressed order book data for two days worth of trades, keeping the entire orderbook.

The next stage was to create some strategies. We created metrics based off the order book, some common such as microprice, and some which we invented, for example depth momentum; which is the log ratio of the total bid depth to total ask depth, among others in order to help us predict if the next price would be an uptick or downtick. The reason we had to predict change in price as opposed to just keeping a tighter market was because the spread was almost always 1 cent - the most granular possible spread, therefore the only reasonable way to make a profit was from predicting where the next market will be placed at. We also created a sentiment analysis metric by scraping off data from tweets about bitcoin and checking keywords to see if there was any indication of direction. This would allow us to improve our estimate on whether or not we would see an uptick or downtick. Picking out the best of these metrics, implementing sentiment analysis and also adding some inventory management we created a strategy.

We then backtested our strategy, ensuring that drawdowns were minimised and that inventory was managed well - we didn't want to be exposed too much at expiry as that could cancel all profits made from market making. A key insight here was to combine the holdings of the 'up' and 'down' contract, as they are stored on separate books, but correspond to the same underlying contract, and also both favour being bought by design of polymarket. So we were happy to hold a larger short position for both of them, as long as their difference between the two was close to zero.

Finally we deployed the strategy on live data, allowing us to see how we performed on the current market. We again looked at similar analytics to the backtest (screenshots provided), and found our strategy to be consistently profitable, regardless of queue position.

Challenges we ran into

When backtesting a major difficulty was factoring in queue position. Due to polymarkets not providing a way to differentiate between limit order additions and limit order cancellations, we needed to update our estimated queue position probabilistically based on a strictly increasing function.

Another major difficulty was retrieving the tick-by-tick data required to backtest our algorithms. This required coordinating multiple websocket connections, updating a tabular files live (which then get emptied at the end of every 15 minute cycle), then compressing them to store into a google drive for ease of access via notebooks.

Accomplishments that we're proud of

We managed to consistently provide a market for the options contract, and were also profitable.

What's next for Polymarket Market Making

Currently we restrict trades occurring in the last minute before settlement, as often when the direction of settlement is uncertain, large orders of bitcoins can sway the outcome of the contract, which happens fairly often as polymarket is unregulated. Focusing on obtaining a better estimate of fair value could be a way for us to include this extra trading time.

Another improvement would be to expand to more markets, as the tight spread and limited rate of orders occurring means that even if we were to fill all orders, we would still only be making a small amount of money per asset.

Built With

Share this project:

Updates