Sunday, January 13, 2019

How does the perpetual ETHUSD contract works? An intuitive guide

Read my guide to XBTUSD contract first, as this only add complexity.

This is a common language explanation of how the ETHUSD perpetual contract works; it's meant to illustrate the intuition behind it and some of the details you might have to ask. It's not exhaustive, it only useful intuitions.

Note that Bitmex accepts Bitcoin only, and settle contracts in BTC, so you only own, gain or loses Bitcoin, even if you speculate on the price of ETHUSD.

The ETHUSD Perpetual contract

You have an amount of BTC. You want this amount to grow in the same way as the price of ETH-USD (when you buy the contract) or in the opposite direction (when you sell the contract). Please note that even if the contract is settled in BTC, the price of BTC-USD does not influence the computation of PnL and funfing rate for this contract.

Size of the contract

Each contract is worth a variable amount of BTC. From the page https://www.bitmex.com/app/contract/ETHUSD = "Each contract is worth 0.001 mXBT per $1 price". Which means if the price of the ETHUSD contract is 115.95 than each contract is worth 115.95*0.000001 BTC = 0.00011595 BTC.

For example when you buy 20 contracts @115.95 it means you have to pay it with 20115.950.000001 BTC. If later you sell it at 130.0 you will received 201300.000001 BTC.

If you sell 20 contracts @115.95 you have to lock down 20115.950.000001 BTC; later if you buy at 110.0 you will have your fund unlocked and will get the difference of (115.95-110.0)*0.000001 BTC as realised PnL.

Note that you are not specifying anywhere the amount of equivalent ETH that you are trading.

Note also that you are buying contracts and not USD or ETH; so how does it guarantee that the price of the contract will follow the price of ETH-USD? With the Funding Rate.

Funding Rate

https://www.bitmex.com/app/perpetualContractsGuide#Funding

The funding rate work exactly as the funding rate for XBTUSD, see my previous guide for more explantion. The only difference is that the ETH reference price is madde from the .BETH index (instead of .BXBT)

API Explanation

How does API trade messages look like? When a trade happens on the exchange you will receive a JSON message like this throught the websocket or REST API:

'{"timestamp":"2019-01-13T19:11:04.721Z","symbol":"ETHUSD","side":"Sell","size":1100,"price":114,"tickDirection":"ZeroPlusTick","trdMatchID":"48aa6a2a-11ff-fa7c-148a-77fa4ee44ef1","grossValue":12540000,"homeNotional":3.8601909039865245,"foreignNotional":440.06176305446377}'

Let's break it down: remember that by definition each contract with these values is worth 114*0.000001 BTC = 0.000114 BTC

{ "timestamp": "2019-01-13T19:11:04.721Z", // when the trade happened, according to BITMEX server timestamp "symbol": "ETHUSD", // which contract is this "side": "Sell", // Side of the taker "size": 1100, // How many contracts were traded "price": 114, // price of each contract, same as USE for each ETH "tickDirection": "ZeroPlusTick", // this trade has a price equal or lower than the previous one "trdMatchID": "48aa6a2a-11ff-fa7c-148a-77fa4ee44ef1", // unique id of every trade "grossValue": 12540000, // how many satoshis were traded to pay for this contract "homeNotional": 3.8601909039865245, // How many equivalent ETH was this trade worth "foreignNotional": 440.06176305446377 // How many equivalent USD was this trade worth } 

I will happily add or change details if they helps simplifying the explanation.



No comments:

Post a Comment