Feeding Strategy Portfolio/Exposed values
#1
Hi there,

due to me having to restart my bots quite a bit at the moment due to bugs I was wondering if it was possible to pass along the 'exposed' variable or the portfolio using 'portfolioValueChanged' or 'portfolioChanged' events so that my strategy knows whether I am long or not upon restart.

Thanks!
  Reply
#2
Hi,

probably best is to sort out the bugs to avoid any restart.

Today I had the same need to get further events inside my strategy. Since the strategy isn't a plugin itself it can not directly subscribe to events, but it is wrapped by the tradingAdvice plugin so it is pretty straight forward to extend your event needs there: https://github.com/askmike/gekko/blob/de...Advisor.js
E.g. I did it to receive the 1 min. candles inside the strategy also, so you can simply setup multi candlesize strategies without the need to change your e.g. existing 60 min. strategy and candlebatch everything manually.
  Reply
#3
That's actually a great idea. Though honestly I am noticing that the "exposed" variable almost always gets in the way and doesn't add any value. Especially since Gekko only allows strategy to trigger a short after a long (and vice versa). Another reason is that there is no real concept of an exposed in the paper trader (also used in backtests).

The exposed var was handy to roughly keep track of whether Gekko was "exposed" with the majority of the funds. Since Gekko used to only buy & sell 95% of the funds. However this has changed: Gekko now sells 100% of the funds (see here: https://github.com/askmike/gekko/issues/...-412465250 ), meaning that now we can simply look at whether the asset is 0 or not to see if there is any exposure.
  Reply
#4
@mark.sch

Quote:E.g. I did it to receive the 1 min. candles inside the strategy also, so you can simply setup multi candlesize strategies without the need to change your e.g. existing 60 min. strategy and candlebatch everything manually.

I do want to keep strategies small and lean, which is why they can't access all events. But yes, 1min candles can be handy. See this PR as well: https://github.com/askmike/gekko/pull/2468
  Reply
#5
(08-23-2018, 03:35 PM)mark.sch Wrote: Hi,

probably best is to sort out the bugs to avoid any restart.

Today I had the same need to get further events inside my strategy. Since the strategy isn't a plugin itself it can not directly subscribe to events, but it is wrapped by the tradingAdvice plugin so it is pretty straight forward to extend your event needs there: https://github.com/askmike/gekko/blob/de...Advisor.js
E.g. I did it to receive the 1 min. candles inside the strategy also, so you can simply setup multi candlesize strategies without the need to change your e.g. existing 60 min. strategy and candlebatch everything manually.

Answering here (already did on Discord but not everyone reads that and this might help someone else) as well.

Thanks for the tip, I can probably use that. And that 1 minute candle passthrough is pretty neat too, should work better for the zTrailingStopLoss I use if it gets updated every 1 minute instead of 5 minutes, I'll add that as well until we get native stop loss.
  Reply
#6
(08-23-2018, 04:02 PM)askmike Wrote: ... meaning that now we can simply look at whether the asset is 0 or not to see if there is any exposure.

Just wanted to mention this in case it gets overlooked, but you almost always can't get to exactly 0 asset in Binance due to minimum sell amounts. So I guess you'd need to check if asset < market.minimalOrder.amount
  Reply
#7
Quote:Thanks for the tip, I can probably use that. And that 1 minute candle passthrough is pretty neat too, should work better for the zTrailingStopLoss I use if it gets updated every 1 minute instead of 5 minutes, I'll add that as well until we get native stop loss.

There is a native trailing stop close to be released, if used in a live trader it checks even more often than once a minute (how often exactly depends on the exchange). It also does not check historical prices but the orderbook (meaning the price you can actually sell for given current liquidity).
  Reply


Forum Jump:


Users browsing this thread: