How to Set Specific Probabilities Using the LMSR?
How many shares do you need to buy/sell in the in a prediction market using the Logarithmic Market Scoring Rule (LMSR) to change the price/probability of an asset to a specific value?
This post assumes knowledge about prediction markets and market scoring rules. I think the original paper by Robin Hanson provides a good introduction.
There are basically two approaches to buying/selling the right amount of shares to reach a certain probability. Method #1 is the sledgehammer approach, Method #2 is elegant, but tedious for more complicated price functions.
Method #1
Doing some kind of binary search until the price is “close enough”. I’ve written some example code in Clojure:
(defn set-to-prob [q i prob]
(loop [lower (magically-find-lower-bound q i prob)
upper (magically-find-upper-bound q i prob)]
(let [q_i' (/ (+ upper lower) 2)
q' (assoc q i q_i')
p' (p i q')]
(if (close? 0.1 p' prob)
q'
(if (> p' prob)
(recur lower q_i')
(recur q_i' upper))))))
Other than inelegance, this has the obvious flaw that it’s difficult to find reasonable upper and lower bounds for the number of outstanding shares.
I used a simple implementation for the upper (lower) bound that added (subtracted) a multiple of the liquidity parameter , but it was always possible to force an infinite loop by using an input so that .
Method #2
It’s possible to solve analytically for the number of shares to move the price to a certain probability .
I’ve actually found the solution in this GitHub repository, but there was no hint as to how the solution was arrived at (maybe obvious when you have better math skills 🙁). However, eventually I was able to figure it out 😏. So if you are like me and need to have every baby step laid out, here they are:
We know the price function for the LMSR is
For a specific price/probability for outcome , it must be the case that
where iterates over all indices in except for .
Using some math magic:
Which finally leads to
which is the number of shares that element in the quantity vector needs to be changed to, in order for the price of contract to reach price .
For the number of shares to buy/sell, the current amount of shares needs to be subtracted .
Now somebody needs to do the same for the the liquidity-sensitive LMSR…
where
How hard can it be?