Tucsky / SignificantTrades

better than 1 min chart
https://aggr.trade
GNU General Public License v3.0
623 stars 212 forks source link

Question #114

Open bitRomney opened 3 years ago

bitRomney commented 3 years ago

With BitMEX how are you calculating the USD value for ETHUSD perpetual contracts? bc i see a lot of whale alerts denominated in USD but they take the 1 contract = 1 USD for ETH which is not true for BitMEX.

it's .000001 contracts ethusdPrice * btcusdPrice.

Tucsky commented 3 years ago

I had no idea about that formula. I just show what bitmex is sending through api

here is a trade : image

Im just taking the "price" property and "size" property sent by bitmex api and if contract is quoted in USD which is the case I think for perps on bitmex, I divide size by the price (because thats how I store the sizes on all exchanges, thats the number of coins, of tokens, of "contracts", never keep the price in the size). So I only have 2 distinct props. SIZE and PRICE Then in the list on the UI I just print the price, and size * price (and thats the original "size" sent by bitmex) image

So given the example above, you are saying that I should instead print the size like that : .000001 contracts ethusdPrice * btcusdPrice === *.000001 20090 383.85 13500 (..13500 beeing a rough estimate of btc price which the app do not know when listening to ethusd trades btw) === 104105.878**

which actually seems to be the "foreignNotional" value in the trade sent by bitmex

Honestly I see this number, Ive no idea what it is or refering to lol. And the formula is probably different depending on the exchange.. I would prefer to display the size in a way that speak to the greater number of people.

bitRomney commented 3 years ago

Yeah foreignNotional is actually the usd value.

On Fri, Oct 30, 2020, 1:27 PM Kevin Rostagni notifications@github.com wrote:

I had no idea about that formula. I just show what bitmex is sending through api

here is a trade : [image: image] https://user-images.githubusercontent.com/5738336/97747586-7f94e300-1aec-11eb-8d30-0c23d4d9e9a5.png

Im just taking the "price" property and "size" property sent by bitmex api and if contract is quoted in USD which is the case I think for perps on bitmex, I divide size by the price (because thats how I store the sizes on all exchanges, thats the number of coins, of tokens, of "contracts", never keep the price in the size). So I only have 2 distinct props. SIZE and PRICE Then in the list on the UI I just print the price, and size * price (and thats the original "size" sent by bitmex) [image: image] https://user-images.githubusercontent.com/5738336/97747606-87ed1e00-1aec-11eb-8f84-12f7fed95774.png

So given the example above, you are saying that I should instead print the size like that : .000001 contracts ethusdPrice btcusdPrice === .000001 20090 383.85 13500 (..13500 beeing a rough estimate of btc price which the app do not know when listening to ethusd trades btw) === 104105.878

which actually seems to be the "foreignNotional" value in the trade sent by bitmex

Honestly I see this number, Ive no idea what it is or refering to lol. And the formula is probably different depending on the exchange.. I would prefer to display the size in a way that speak to the greater number of people.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Tucsky/SignificantTrades/issues/114#issuecomment-719752311, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGA2WHDK7TK5LTCDDPADZUTSNMHTDANCNFSM4TFHPMVQ .

bitRomney commented 3 years ago

It's weird because BitMEX XBTUSD contract is $1 = 1 contract. It's just not for ETHUSD.

It gives the value of the ETHUSD contract here in the Contract Specification https://www.bitmex.com/app/contract/ETHUSD. Where it says each contract is worth 0.001 mXBT per $1 price.

Screen Shot 2020-10-30 at 2 29 08 PM

From the API you get the description of foreignNotional is the value of position in units of the quote currency. ETHUSD quote currency is USD. Screen Shot 2020-10-30 at 2 31 39 PM

And from the Perp Guide you get the bitcoin multiplier which is where I got the formula where .000001 is the bitcoin multiplier for the ETHUSD contract. Screen Shot 2020-10-30 at 2 32 55 PM

You did the math correctly in your response here. But I think for BitMEX ETHUSD at least it would be easier to just pull and display the foreignNotional value. Which currently is a lot higher than 1 contract = 1 dollar. At 0.001 mXBT per $1 price it's at 1 contract = $5.22. It increases linearly with the prices of BTC and ETH.

bitRomney commented 3 years ago

Screen Shot 2020-10-30 at 2 52 57 PM Can you please link me to the files in the source code where this all happens?

Tucsky commented 3 years ago

Can you please link me to the files in the source code where this all happens?

https://github.com/Tucsky/SignificantTrades/blob/master/src/components/TradeList.vue#L149 But the modification being discussed here should be here https://github.com/Tucsky/SignificantTrades/blob/master/src/exchanges/bitmex.js#L83

Screenshot below is a comparison of bitmex trades panel on the left and this tool with no aggregation / no threshold on the right image so bitmex is not showing the USD value of each trade but the number of contracts valued to 0.0003 XBT ? Im reading their contracts guides rn..., feels like fucking chinese I really have no clue lol

I think ive already got all the sizing right on XBT quoted contracts (by displaying size property as it is and not use foreignNotional) But USD quoted contract I should use foreignNotional and print it as it is (USD) Do you confirm ?

bitRomney commented 3 years ago

Sorry for the slow response. Yes you are correct. I'm not sure if it's just ETHUSD or all alt-USD pairs. But the foreignNotional should be correct I would think in all cases.