pull down to refresh

@mega_dreamer is Predyx a LMSR-based AMM model?
seeing the current percentages for this market do you think this would be a cheat script?
import numpy as np
import matplotlib.pyplot as plt

# LMSR Cost function: C(q) = b * ln(sum(exp(q_i / b)))
# Here, we track two outcomes: Pacers and Thunder

def lmsr_cost(q1, q2, b):
    return b * np.log(np.exp(q1 / b) + np.exp(q2 / b))

# Marginal price of outcome 1 (Pacers)
def lmsr_price(q1, q2, b):
    return np.exp(q1 / b) / (np.exp(q1 / b) + np.exp(q2 / b))

# Simulate cost of buying shares
def simulate_lmsr_buy(initial_q1, initial_q2, b, buy_shares, outcome='q1'):
    # Determine which quantity we are increasing
    q1, q2 = initial_q1, initial_q2
    new_q1 = q1 + buy_shares if outcome == 'q1' else q1
    new_q2 = q2 + buy_shares if outcome == 'q2' else q2

    # Initial and final cost
    initial_cost = lmsr_cost(q1, q2, b)
    final_cost = lmsr_cost(new_q1, new_q2, b)

    # Total cost to buy `buy_shares` of the selected outcome
    cost = final_cost - initial_cost

    # Final probability (price)
    final_price = lmsr_price(new_q1, new_q2, b)

    return cost, final_price

# Parameters
b = 10000  # liquidity parameter (higher b = more stable market)
initial_q1 = 0
initial_q2 = 0
buy_shares = 50000

# Simulate buying 50K shares for Pacers (q1)
cost_pacers, final_price_pacers = simulate_lmsr_buy(initial_q1, initial_q2, b, buy_shares, 'q1')

# Now simulate how many shares of Thunder (q2) are needed to bring the price back to 0.50
# We'll iterate to find that point
def find_thunder_shares_to_balance(q1, initial_q2, b, target_price=0.5):
    for shares in range(1000, 100000, 100):
        q2 = initial_q2 + shares
        price = lmsr_price(q1, q2, b)
        if abs(price - target_price) < 0.001:
            cost = lmsr_cost(q1, q2, b) - lmsr_cost(q1, initial_q2, b)
            return shares, cost, price
    return None, None, None

thunder_shares, cost_thunder, final_price_thunder = find_thunder_shares_to_balance(buy_shares, 0, b)

(cost_pacers, final_price_pacers), (thunder_shares, cost_thunder, final_price_thunder)
Result ((43135.68167929173, 0.9933071490757152), (50000, 6864.318320708269, 0.5))
I just mean to ask if it works, I won't be using it real time, I was thinking of incorporating something of this sort in one of my projects
Yes - Predyx is LMSR based at this time, but eventually we'll upgrade to Continuous Double Auction (CDA) as we gain more trading traction.
I don't understand python much - but from first glance I can tell LMSR cost and price function looks correct.
initial_q1 = 0, initial_q2 = 0 I'm assuming this is number of shares in each option (OKC = 0, IND = 0)
Let me know if you're able to make this work correctly: find_thunder_shares_to_balance On Predyx - I don't think you can see the exact numbers of shares on each options in GUI(we'll make it available soon), but I can get you the exact number from the database so that you validate your code against it.
People like @Undisciplined would love to get their hands on a clean executable of this code. If you throw in a minimal GUI - I'm sure people would happily give you some πŸ’°fat bounty for it.
reply
42 sats \ 1 reply \ @noknees 7h
People like @Undisciplined would love to get their hands on a clean executable of this code. If you throw in a minimal GUI - I'm sure people would happily give you some πŸ’°fat bounty for it.
On it cap!
reply
Indeed and then I need the time to play around with it.
reply
0 sats \ 0 replies \ @noknees 7h
we'll upgrade to Continuous Double Auction (CDA)
That's will make the market more accessible to both sellers and buyers!
reply