Categories
blog

Crypto lifestyle using Bitmex and my scripts

Sometimes you want to keep USD value of your Bitcoin, for example if you know you will have future expenses with known USD value. If you don’t want to go to Ethereum-land for this purpose and want to stay within the BTC ecosystem, you could use Bitmex‘s perpetual swap for this purpose.

Bitmex is a well-known centralized exchange. In order to minimize counterparty risk (hacking, owners of Bitmex just running away with your crypto), you can enter hedging positions, but keep most of your coins outside of Bitmex (for example on your hardware wallet).

In order to do all of this, I decided to write a few scripts. The first one checks if my margin balance on Bitmex is high enough in order for the positions not to get liquidated. If the margin is approaching lower values, I get an encrypted notification via Signal.

The second script allows me to quickly hedge positions of BTC I received or unhedge if I spend them.

This allows me to hedge Bitcoin price risk, earn Bitmex‘s funding rate and stay chilled during day and night, because I know I don’t put too much on Bitmex, but my position won’t get liquidated.

A concrete example

I received 100 USD in BTC as a payment for a project. I know I have to cover my costs of Internet connection, which is 39 USD and it is due next week. I also know I want to have a dinner today which is 21 USD.

Because I have the BTC, I need to quickly hedge 39+21=60 USD in BTC. I have an account on Bitmex with a sufficient margin. I need to sell 60 units of XBTUSD contract:

node trade-bitmex.js market sell 60

In the evening, I pay 21 USD for dinner and because I live in a country where I can pay with BTC in restaurants, I have spent 21 USD worth of BTC for dinner. In order not to leave the position, I need to buy 21 units of XBTUSD contract on Bitmex:

node trade-bitmex.js market buy 21

The rest of the position is still hedged.

After three days, Bitcoin goes up a bit and my position would get liquidated soon, if I do not fund my Bitmex account. I send the transaction from my wallet to Bitmex. Then I have to pay my Internet connection. I pay with BTC using Lamium and I need to exit the rest of the position.

node trade-bitmex.js market buy 39

During the time of the hedging, my 60 USD (and then 39 USD after I ate dinner) were safely hedged, so even a drop of 50% would not hurt me. In addition, I earned funding rate for the duration of my position (could be easily 10% p.a., check Bitmex‘s current funding rate).

Well, the banks are so last century, which bank pays you 10% p.a. on your USD balance? 🙂

Of course, you could do all of this in a web interface. Set up liquidation price notifications in your crypto tracking app, update it with trades and sell and buy XBTUSD contract on Bitmex.

How to do it

Head over to the homepage of the scripts and install them. They are free!

Donate and more information about the crypto lifestyle

If you like these scripts, I’d be happy if you donated Bitcoin to 3LGdXkqYCMPC2S3rJELPjxoK4G7Ao9Qa1s.

This script is inspired by my own check-cdp script (well, I can be my own inspiration sometimes:).

You can also use my referral links to register for the services that allow you to use Bitcoin better:

If you want to learn more about using cryptocurrencies and why it is good, check out my upcoming book Financial Surveillance and Crypto Utopias and see the talk from Hackers Congress Paralelní Polis where I go through the main topics of the first part.

Leave a Reply

Your email address will not be published. Required fields are marked *

You can encrypt your comment so that only juraj can read it.