Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Question #114

Open
bitRomney opened this issue Oct 30, 2020 · 6 comments
Open

Question #114

bitRomney opened this issue Oct 30, 2020 · 6 comments

Comments

@bitRomney
Copy link

bitRomney commented Oct 30, 2020

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
Copy link
Owner

Tucsky commented Oct 30, 2020

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
Copy link
Author

bitRomney commented Oct 30, 2020 via email

@bitRomney
Copy link
Author

bitRomney commented Oct 30, 2020

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
Copy link
Author

bitRomney commented Oct 30, 2020

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
Copy link
Owner

Tucsky commented Oct 30, 2020

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
Copy link
Author

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.

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

No branches or pull requests

2 participants