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

Wrong Calculation in Q64.96 number of sqrt Price #88

Open
OoXooOx opened this issue Jan 11, 2024 · 1 comment
Open

Wrong Calculation in Q64.96 number of sqrt Price #88

OoXooOx opened this issue Jan 11, 2024 · 1 comment

Comments

@OoXooOx
Copy link

OoXooOx commented Jan 11, 2024

In book you use lower price 4545$, so sqrt from P * 2 * * 96 will be 5341294542274603406682713227264 (in book it is 5314786713428871004159001755648)
import math
q96 = 2**96
def price_to_sqrtp(p):
return int(math.sqrt(p) * q96)
print (price_to_sqrtp(4545))

5341294542274603406682713227264

I don't know, mb error in define lower price. If you want assign it to 4500, then it will be correct.
import math
q96 = 2**96
def price_to_sqrtp(p):
return int(math.sqrt(p) * q96)
print (price_to_sqrtp(4500))

5314786713428871004159001755648

@OoXooOx
Copy link
Author

OoXooOx commented Jan 11, 2024

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant