Proper stop losses coming soon
#31
Very cool that you have added this now, but could I just please ask for a simple step by step process on how to install any dependancies, and whatever else I need to get this working on one of my strategies

Many many thanks
  Reply
#32
Today is possible to me just set a limit order entry, stop loss and take profit at the same time? Or at least set a limit order to buy and a stop loss? I don't know how to code
  Reply
#33
Quote:I don't know how to code

Not sure if the open source Gekko platform is the tool for you, you are supposed to code your own strategies.

Quote:Today is possible to me just set a limit order entry, stop loss and take profit at the same time? Or at least set a limit order to buy and a stop loss?

(most) exchanges won't let you add all these orders at once, and no Gekko doesn't support it either. Also the idea about Gekko is that you build a strategy that only concerns itself with alpha, and not with execution. If you want a lot of control on your execution (what kind of orders are places, very precise control on stop triggers and such) Gekko is definitely the wrong tool for the job. Please see this page: https://gekko.wizb.it/docs/introduction/scope.html
  Reply
#34
(09-06-2018, 11:13 PM)mark.sch Wrote: You need only to add a couple of lines into your strategy to get notified when the gekko event system is firing a trade completed event. It is the same way like you add the init or check function to your strategy:

strat.onTrade = function (trade) {


    //catch all trades.  Whether from manual buy/sell (telegram bot), a stoploss trigger or from a strategy advice
  
    if (trade.action == 'sell') {
        // do something here
    }

}


From console.log(trade) output you see all properties the trade object is containing:

{ id: 'trade-7',
  adviceId: 'advice-4',
  action: 'buy',
  cost: 1.4524059748649476,
  amount: 0.07355882,
  price: 13143.47,
  portfolio: { asset: 0.07355882, currency: 0 },
  balance: 966.8181439053999,
  date: moment("2018-01-16T01:45:00.000"),
  effectivePrice: 13123.754795,
  feePercent: 0.15,
  status: 'tradeCompleted',
  trigger: { origin: 'trailingStop', trailPercentage: 2 } }

Hi there. 
I tried to console.log trade within the onTrade event in my strategy on both sell and buy condition, but I couldn't see any trigger key in that object. This is what's happening at least in papermode test, not with actual trading. 
I'm wondering if there is an event or a way to check if the native stopLoss has been triggered so that I can send a message to slack or telegram. 
Thanks in advance for your help.
Thanks a lot Mike for this incredible work!
  Reply
#35
(08-11-2018, 07:32 AM)askmike Wrote: Trailing stop implementation started!

Follow this PR for details: https://github.com/askmike/gekko/pull/2429

This is great news! Learned all about it in your youtube vid from Aug 10. 
Are we able to make volatility-based stop losses? Like an ATR stop loss?

Thanks!
  Reply
#36
Quote:Are we able to make volatility-based stop losses? Like an ATR stop loss?

Right now you have to script them yourself into your strategy. Gekko won't calculate them for you but you can easily calculate them inside your strategy.

Quote:I tried to console.log trade within the onTrade event in my strategy on both sell and buy condition, but I couldn't see any trigger key in that object. This is what's happening at least in papermode test, not with actual trading. I'm wondering if there is an event or a way to check if the native stopLoss has been triggered so that I can send a message to slack or telegram.

These keys are indeed not part the tradeCompleted event (paper trader nor live trader), all the properties are listed here: https://gekko.wizb.it/docs/internals/eve...eted-event

For now: you check the event, if you get a sell with the same `adviceId` you previously received a buy from you know it's a trade from the same advice. And a stoploss is the only possible reason for this. I might add a key like the one from @mark.sch to the event to make this more clear Smile
  Reply
#37
(09-28-2018, 04:16 AM)askmike Wrote: Today is possible to me just set a limit order entry, stop loss and take profit at the same time? Or at least set a limit order to buy and a stop loss? 

(most) exchanges won't let you add all these orders at once, and no Gekko doesn't support it either. Also the idea about Gekko is that you build a strategy that only concerns itself with alpha, and not with execution. If you want a lot of control on your execution (what kind of orders are places, very precise control on stop triggers and such) Gekko is definitely the wrong tool for the job. Please see this page: https://gekko.wizb.it/docs/introduction/scope.html

Hello. But how people currently get profit with gekko without proper execution (stop-loss + take-profit) and money-management (% of deposit per order) politics? They are scripting it themselves?
  Reply
#38
Quote:Hello. But how people currently get profit with gekko without proper execution (stop-loss + take-profit) and money-management (% of deposit per order) politics? They are scripting it themselves?

I might have not worded this properly. What I mean:

Most exchanges don't let you actually create orders (submit them into the orderbook) unless you have funds for all of them. So imagine you have some USD and trade on USD/BTC. As soon as you see an entry you:

1. Buy BTC with all your USD.
2. Set a stoploss to sell all your BTC under the price.
3. Set a take profit to sell are your BTC above the price.

Most exchanges won't let you do 2 and 3 at the same time, since you only have enough BTC to do one of these (that's what I meant previously). When you are working Gekko you can:

- Trigger a buy signal to do step 1.
- Add a stoploss to that trigger so Gekko will automatically do step 2 -> Note that it doesn't actually submit any order at this time, but instead Gekko will watch the price contentiously (faster than it will pump candles into your strategy, it's actually watching the orderbook in a live trader - not just historical trade flow).
- In your strategy you can set up a watcher to do the take profit (step 3): you simply register your TP when you trigger a BUY, and after that you check every time if the price hits your TP.

As you can see it is very much possible to do entry + SL + TP. But TP requires you to do it manually for now (5 lines of code you need to add to your strategy). I will add this to Gekko as well at some point, but since TA is so heavy on trends and momentum that I rarely see people wanting to do a TP, instead they want to ride the trend while watching for a potential reversal. If you buy and schedule a stoploss you can at any point manually sell again and Gekko will delete the stop loss.
  Reply
#39
(10-22-2018, 04:26 AM)askmike Wrote: 1. Buy BTC with all your USD.

So, there is no way not to entry in each trade with the whole deposit?
  Reply
#40
Quote:So, there is no way not to entry in each trade with the whole deposit?

There is no way to not do this with Gekko. Because all Gekko's profit calculations and graphical interfaces are designed around the concept of roundtrips, which is buying (with full balance) and later (hopefully when the price is higher) selling again - either via a signal from your strategy or a trigger like a trailingStop.

If you want more control and trade into and out of a position in steps like for example:

- current position neutral (0)
-> buy 100
-> buy 100
-> sell 150
- current position LONG (50)

You'll need to invent a few concepts so that everyone understands what is happening along the way, concepts such as PnL, uPnL, etc. (margin traders and derivative trades are familiar with these concepts, but most spot traders are not). Forgetting about the code this would be a very different type of bot. I recommend watching this video that explains what kind of trading Gekko is designed for: https://youtu.be/PKIxZ-Qaphk

---

If you want to develop such a different bot you can definitely use a lot of modules from the Gekko project. For example you can use order execution engine called Gekko Broker: https://gekko.wizb.it/docs/gekko-broker/...ction.html You can also use things like the candle aggregator, backtesting engine, strategy runner (though you'll need to come up with a new interface for all the extra stuff you want).
  Reply


Forum Jump:


Users browsing this thread: