Typically you’re going to start a strategy against a trading account that holds one side of the trading pair you are trading against. This means that if you are going to trade ETH/BTC you will start with ETH (the asset) in your trading account and zero Bitcoin (the currency).
Because Gekko doesn’t link your trading account to the trading strategy you can run into problems in 3 scenarios:
- When you first start your strategy Gekko may try and sell the currency first, which is not going to work given you have started with zero Bitcoin (the currency).
- When Gekko crashes (yes this happens!) or something else stops your Gekko instance while your strategy holds ETH (the asset).
- When Gekko crashes (yes this happens!) or something else stops your Gekko instance while your strategy holds BTC (the currency).
What is the solution?
Ensure your strategy knows which trade type to make first. This is actually really straight forward.
- Set a “firsttimetradetype” variable as “buy” (if you hold asset) in the Strategy config.
- Set a “firsttimetrade” variable as boolean false.
- Then inside the Strategy buy / sell logic check which is the type to trade first, and the “firsttimetrade” variable being false. If so then perform the trade and set the “firsttimetrade” to true.
In the event that Gekko crashes and you are left with currency and zero asset then you can switch the “firsttimetradetype” variable to sell.
The bottom line here is this initially seems like a simple problem to solve, but because Gekko separates the Trading (and trading account) from the Strategy the reality is there not a hands free solution.
The separation of trading, trading account and strategy is a fundamental weakness of the trading bot and it will be interesting to see how people try and solve it moving forward.