Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate How Much Market Will Move On Next Bet #185

Closed
pwdel opened this issue Jun 10, 2024 · 4 comments
Closed

Calculate How Much Market Will Move On Next Bet #185

pwdel opened this issue Jun 10, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@pwdel
Copy link
Member

pwdel commented Jun 10, 2024

Currently a sample of MarketDetails looks like the following:

{"market":{"id":3,"questionTitle":"Cool","description":"Whatever","outcomeType":"BINARY","resolutionDateTime":"2024-08-15T09:59:00Z","finalResolutionDateTime":"2024-08-20T03:40:21.947753Z","utcOffset":300,"isResolved":true,"resolutionResult":"YES","initialProbability":0.5,"creatorUsername":"patrick","createdAt":"2024-08-15T04:57:26.476263Z"},"creator":{"username":"patrick","displayname":"Patrick","usertype":"REGULAR","initialAccountBalance":0,"accountBalance":-61,"personalEmoji":"🐺","description":"Stuff","personalink1":"https://www.google.com/"},"probabilityChanges":[{"probability":0.5,"timestamp":"2024-08-15T04:57:26.476263Z"}],"numUsers":0,"totalVolume":0}

In order to calculate the wpam probability we have a simple function:


(P_initial*I_initial + totalYes) / (I_initial + totalYes + totalNo) 

  • totalYes and totalNo values could be added to the MarketDetails function above as an output
  • E.g., these values could be calculated as a part of CalculateMarketProbabilitiesWPAM(), though we will have to change a bunch of functions where this is being used (e.g. the output of totalYes and totalNo is not always needed).
  • So once we include totalYes and totalNo in the output, this can now be reported in MarketDetails easily.
  • Then, we can create a function in React that leverages totalYes and totalNo as well as an inputBet and inputBetDirection to calculate a hypotheticalMarketProbability.

(P_initial*I_initial + totalYes + addedYes) / (I_initial + totalYes + addedYes + totalNo + addedNo)

  • This will tell what the next calculated probability will be at the given bet level and direction.

  • That being said, to get the addedYes and addedNo we have to use specific values within MarketDetails functions that are currently used to handle the bets.

  • Betting is currently accomplished via a layout. We have a, "purchase shares tab" which allows a user to confirm_direction and then enter_amount ... these two functions should trigger either +addedYes or +addedNo ... which then go into the above function to create a new_market_probability which could be displayed at the bottom.

  • If we go over to the, "sell shares," tab, then confirm_direction and enter_amount could be used to trigger either -addedYes or -addedNo ... since they are sales, we're decreasing the amount.

  • There needs to be some kind of error obviously if the amount being sold is less than what the market has available.

  • There should probably be also a maximum amount that can be entered in the billions or whatever to prevent some kind of calculation problem, maybe?


UX ... basically, the above should result in instant results, e.g. it needs to update in React instantly, and I'm not sure how to do this, but it needs to show the user what the ramifications of their bet will be.

@pwdel
Copy link
Member Author

pwdel commented Aug 21, 2024

  • What I have pushed to the MR so far populates totalYes and totalNo correctly on the API call.
  • Ultimately we need to put this below the BuySharesLayout or SellSharesLayout, either within the layouts themselves or within the TradeTabs.
  • Hypothetically we could start a new layout specifically for, "MarketProjectionLayout," or perhaps for "MarketBuyProjectionLayout," and "MarketSellProjectionLayout" ... which could be put in the proper position.
  • More abstract MarketProjectionLayout would be preferred.

@pwdel
Copy link
Member Author

pwdel commented Aug 22, 2024

Ok, setting up a new endpoint to gather the game setup information.

This information can be used in the calculation but also in other ongoing tickets.

What gets spit out:

-- | --
MarketCreation |  
InitialMarketProbability | 0.5
InitialMarketSubsidization | 10
InitialMarketYes | 0
InitialMarketNo | 0
MarketIncentives |  
CreateMarketCost | 10
TraderBonus | 1
User |  
InitialAccountBalance | 0
MaximumDebtAllowed | 500
Betting |  
MinimumBet | 1
BetFees |  
InitialBetFee | 1
EachBetFee | 0
SellSharesFee | 0

</div>

@pwdel
Copy link
Member Author

pwdel commented Aug 24, 2024

On the buying side, the number projected doesn't seem to match the price number at the top. Rounding might come into play here.

Image

Image

However on the selling side, the number is not updating correctly. There seems to be some complication with how selling shares gets calculated.

Also, this frontend formula doesn't really use the most updated market price, it uses the market price at page upload time.

What would be, "more accurate" hypothetically is to do an API call every time that the proposed bet amount is changed. This would also improve test-ability.

However, it might sacrifice performance, but we would have to decide by how much and what the benefit would be.

I put together a ticket for this:

https://github.com/orgs/openpredictionmarkets/projects/4/views/1?pane=issue&itemId=76256796

@pwdel pwdel added the enhancement New feature or request label Aug 24, 2024
@pwdel
Copy link
Member Author

pwdel commented Aug 24, 2024

I'm going to cancel this MR after putting together a ticket to use the API call method.

Put together a ticket on how to decide how to do this properly. https://github.com/orgs/openpredictionmarkets/projects/4/views/1?pane=issue&itemId=76256796

@pwdel pwdel closed this as completed Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
1 participant