Bitmex as well as support for margin trading on other platforms (like bitfinex and poloniex) is defintely something I'd love to add to Gekko. The short story: **However it's quite hard and requires a bunch of things that Gekko currently cannot do.**
The long story: The reason why Gekko currently does not support these platforms is not because of the APIs or the exchanges themselves, it's because of how complex their products are and the extra variables we need in order to simulate these markets:
Gekko is not just a live trading bot, it also comes with live order simulation and backtesting (historical order simulation you could say). It's very important that these simulations work for every market Gekko can do. For standard markets where you buy and sell crypto (spot markets) these calculations quite simple and the same for all exchanges: you have some USD and some BTC, whenever the strategy says buy or sell we can simply simulate orders. At the end of the backtest we can simply calculate the cost and price of all orders and figure out how much profit you made.
However when you do any type of margin trading there are other variables involved:
- When you short you actually have a negative exposure to the market, where in a normal market selling BTC takes away your exposure to BTC.
- On some platforms (Poloniex and Bitfinex for example) you are borrowing funds to leverage your position, the costs for this can very wildly over time (driven by a peer2peer lending market). Gekko would need to start track this data, this data is quite hard to get (specifically the historical interest rates)
- On platforms that offer perpetual swaps (Bitmex USDXBT) you are either paying or receiving money every 8 hours when you have a position open, this amount depends on the basis of the product over the underlying spot markets.
- When you are trading on margin you always risk getting liquidated, this is something that would need to be managed by the strategy. There is currently no system or interface in place that describes how this would even work.
All of these problems can be solved, and I hope that Gekko will solve them and offer margin trading one day. But it's a lot harder to crack than an exchange where you simply buy or sell the actual product (spot markets).
The long story: The reason why Gekko currently does not support these platforms is not because of the APIs or the exchanges themselves, it's because of how complex their products are and the extra variables we need in order to simulate these markets:
Gekko is not just a live trading bot, it also comes with live order simulation and backtesting (historical order simulation you could say). It's very important that these simulations work for every market Gekko can do. For standard markets where you buy and sell crypto (spot markets) these calculations quite simple and the same for all exchanges: you have some USD and some BTC, whenever the strategy says buy or sell we can simply simulate orders. At the end of the backtest we can simply calculate the cost and price of all orders and figure out how much profit you made.
However when you do any type of margin trading there are other variables involved:
- When you short you actually have a negative exposure to the market, where in a normal market selling BTC takes away your exposure to BTC.
- On some platforms (Poloniex and Bitfinex for example) you are borrowing funds to leverage your position, the costs for this can very wildly over time (driven by a peer2peer lending market). Gekko would need to start track this data, this data is quite hard to get (specifically the historical interest rates)
- On platforms that offer perpetual swaps (Bitmex USDXBT) you are either paying or receiving money every 8 hours when you have a position open, this amount depends on the basis of the product over the underlying spot markets.
- When you are trading on margin you always risk getting liquidated, this is something that would need to be managed by the strategy. There is currently no system or interface in place that describes how this would even work.
All of these problems can be solved, and I hope that Gekko will solve them and offer margin trading one day. But it's a lot harder to crack than an exchange where you simply buy or sell the actual product (spot markets).