[EDIT]
I'm working hard on implementing native trailing stop losses! Follow this PR: https://github.com/askmike/gekko/pull/2429
[/EDIT]
Stop losses are a very big part of trading successfully, whether it is automated trading or not. Gekko currently does not support proper stop losses (unless users implement those themselves in their strategies, which is far from ideal) due to the complexities around different exchanges API capabilities (most do not support native stop losses at all).
Now Gekko v0.6 is out I am planning to enhance Gekko Broker with proper stop losses while giving strategies a way to include stop losses when giving advice. I'm working on Gekko Plus where I am taking Gekko to the next level and I feel this has to include proper stop losses.
What is a stoploss?
A stoploss is an order designed to get out of a position that might turn the wrong direction, limiting risk. Imagine you are using Gekko to trade on USD/BTC and your strategy sees an opportunity to buy. It will trigger a buy advice and Gekko will gladly buy BTC with your USD. But what if your strategy turned out wrong and the price of BTC tanks? With a stoploss you can limit your potential loss to say 1% by automatically selling the BTC once the price drops 1%. Stop losses are not perfect: If there is a small dip in the price you will sell, even though the price might go up after.
Why are there currently no stop losses?
There are two big reasons for this:
1. Up until recently Gekko had a lot of limitations in the communication between strategies and the module responsible for executing (simulated or real) trade orders at the exchange. Gekko v0.6 introduced a new event system that allows for bi-directional communication needed to update the strategy in case a stop loss gets executed.
2. Not all exchanges support stop losses natively, in cases exchanges don't Gekko needs a way to offer them (by watching the price and trading whenever it hits X). Since v0.6 Gekko comes with a library that can be extended to support this: Gekko Broker.
What will Gekko support in the future?
I haven't fully figured this out yet (which is why I am posting this thread). But this is what I am currently thinking:
- introduce the concept of triggers such as:
- stop loss (create an order when the price goes AGAINST your direction).
- trailing stop loss (same as above the the price trigger will move with the price, slowly securing more profit).
- take profit (create an order when the price goes IN your direction - and you want to secure your profit).
- allow for strategies to specify how to execute the trigger, such as:
- market order
- sticky order
- limit order
There is already a "tradeCompleted" event which can be extended to include information about what caused it (an advice, a stoploss or takeprofit trigger). As for now triggers can be passed along with "LONG" (buy) advice signals as to end a roundtrip early (before the strategy adviced to "SHORT" (sell)).
I'm still thinking about this execution part, I might split this design into two phases: first with only triggers and second with more order types.
What do you think?
I'm working hard on implementing native trailing stop losses! Follow this PR: https://github.com/askmike/gekko/pull/2429
[/EDIT]
Stop losses are a very big part of trading successfully, whether it is automated trading or not. Gekko currently does not support proper stop losses (unless users implement those themselves in their strategies, which is far from ideal) due to the complexities around different exchanges API capabilities (most do not support native stop losses at all).
Now Gekko v0.6 is out I am planning to enhance Gekko Broker with proper stop losses while giving strategies a way to include stop losses when giving advice. I'm working on Gekko Plus where I am taking Gekko to the next level and I feel this has to include proper stop losses.
What is a stoploss?
A stoploss is an order designed to get out of a position that might turn the wrong direction, limiting risk. Imagine you are using Gekko to trade on USD/BTC and your strategy sees an opportunity to buy. It will trigger a buy advice and Gekko will gladly buy BTC with your USD. But what if your strategy turned out wrong and the price of BTC tanks? With a stoploss you can limit your potential loss to say 1% by automatically selling the BTC once the price drops 1%. Stop losses are not perfect: If there is a small dip in the price you will sell, even though the price might go up after.
Why are there currently no stop losses?
There are two big reasons for this:
1. Up until recently Gekko had a lot of limitations in the communication between strategies and the module responsible for executing (simulated or real) trade orders at the exchange. Gekko v0.6 introduced a new event system that allows for bi-directional communication needed to update the strategy in case a stop loss gets executed.
2. Not all exchanges support stop losses natively, in cases exchanges don't Gekko needs a way to offer them (by watching the price and trading whenever it hits X). Since v0.6 Gekko comes with a library that can be extended to support this: Gekko Broker.
What will Gekko support in the future?
I haven't fully figured this out yet (which is why I am posting this thread). But this is what I am currently thinking:
- introduce the concept of triggers such as:
- stop loss (create an order when the price goes AGAINST your direction).
- trailing stop loss (same as above the the price trigger will move with the price, slowly securing more profit).
- take profit (create an order when the price goes IN your direction - and you want to secure your profit).
- allow for strategies to specify how to execute the trigger, such as:
- market order
- sticky order
- limit order
There is already a "tradeCompleted" event which can be extended to include information about what caused it (an advice, a stoploss or takeprofit trigger). As for now triggers can be passed along with "LONG" (buy) advice signals as to end a roundtrip early (before the strategy adviced to "SHORT" (sell)).
I'm still thinking about this execution part, I might split this design into two phases: first with only triggers and second with more order types.
What do you think?