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

Fix spread #2

Open
zbuc opened this issue May 11, 2023 · 1 comment
Open

Fix spread #2

zbuc opened this issue May 11, 2023 · 1 comment

Comments

@zbuc
Copy link
Member

zbuc commented May 11, 2023

Seems like spread is lower than we'd expect:

 ID                                                                Trading Pair           State   Reserves                                                  Trading Function
 plpid17syw9sl0mwsrr482hxf7y9tmh0jv7w6hs6277nzv80rwe8a636kqwnl8k7  (test_usd, test_atom)  opened  (1475645.79296386000351049, 3333129.882812)               fee: 7bps, p/q: 0.000000, q/p: 10904000000000.000000000000000000
 plpid1kjqpfh7ua7epfdxr2pdzvut3ne0w66kdf4nxnjsnyjqklsy2dj5qs5faym  (test_btc, test_eth)   opened  (1995754.39095497, 1991842.091083526611328125)            fee: 0bps, p/q: 151515151515.151520, q/p: 0.000000000006600000
 plpid1lzw82fhhtdfccj77lxc7hq7axz0u9awajvje8auqda8j9z3mn40qgz9ugh  (test_btc, test_usd)   opened  (2005718.42491626, 1411875.357335929948021658)            fee: 2bps, p/q: 269594400000000.000000, q/p: 0.000000000000003709
 plpid1uqz2wee8cjnrpnutepxuj4r8kmtdz7tjy9kc3u0952pm0vwr6kzqhews9f  (test_usd, test_eth)   opened  (1507059.578293592494446784, 1994176.059961318969726562)  fee: 3bps, p/q: 0.000557, q/p: 1795.420000000000072760
@zbuc
Copy link
Member Author

zbuc commented May 12, 2023

The spreads need to be multiplied by 2, currently they are only reflecting the distance between the midpoint and best bid.

 ID                                                                Trading Pair           State   Reserves            Trading Function
 plpid17mp92jyulqfvrzcf70ufyt8zaz58yx8vv70n4x49n2h2x0q2z9uq5y6jg3  (test_btc, test_atom)  opened  (1250000, 2500000)  fee: 29bps, p/q: 24.509804, q/p: 0.040800000000000003
 plpid17scedn6mclhh5q62llnyzwh0hwwyqvge6smpneakytjdzzzzmlmsc97h4p  (test_usd, test_eth)   opened  (156250, 625000)    fee: 1bps, p/q: 0.000555, q/p: 1800.339999999999918145
 plpid19v7le8kah45gzzrehmuffqgkyhv4ewm4egw9lmv8yrqhlxtjtjhqcfdl02  (test_btc, test_usd)   opened  (625000, 312500)    fee: 1bps, p/q: 270577500000000.000000, q/p: 0.000000000000003696
 plpid1hhepyuzrvv88mx42d5gxr7gengllsawh4hpfmefq8atd7wulxens2hsf3y  (test_usd, test_atom)  opened  (2578125, 3125000)  fee: 7bps, p/q: 0.000000, q/p: 11054000000000.000000000000000000
 plpid1wwxn0lyp03pkwhjj5h4gjlzmlga6y0zfvt606feucqh63gfka06qxkkmwa  (test_btc, test_eth)   opened  (312500, 1250000)   fee: 4bps, p/q: 151515151515.151520, q/p: 0.000000000006600000

For the test_usd, test_eth pair:

>>> best_bid = 1799.91000000
>>> best_ask = 1800.44000000
>>> midpoint = (best_bid + best_ask)/2.0
>>> midpoint
1800.1750000000002
>>> (midpoint - best_bid) / midpoint
0.00014720791034210563
>>> ((midpoint - best_bid) / midpoint) * 100 * 100
1.472079103421056
>>> ((best_ask - best_bid) / midpoint) * 100 * 100
2.9441582068408496

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