Gekko: [Feacture] Init strat async

Created on 13 Sep 2018  ·  7Comments  ·  Source: askmike/gekko

Behaviour to have async function in init method of the strategy:
if (!strat.init() instanceof Promise) keep actual
if (strat.init() instanceof Promise) wait defered

help wanted open-for-pulls wontfix

Most helpful comment

Great discussion at the right time :-) Also for the strat.update and strat.check function it will be very useful to have either a callback function or the ability to return a Promise.

I am just wrapping the tulip and talib indicators into a native gekko indicator with async/await to use them in multi timeframe strategies where asyncIndicatorRunner is not available. Runs already pretty well, the strat.update callback is the last missing part.

Sample usage:

strat.init = function () {
this.tulipFOSC = new TULIPSYNC({ indicator: 'fosc', length: 500, candleinput: 'close', options:[ this.Period ] });
}

strat.update = async function (candle) {
this.tulipFOSC.result = await this.tulipFOSC.update(candle);
}

strat.check = function (candle) {
console.log(candle.start.format(), this.tulipFOSC.result);
}

In case there is a general interest I can open a pull request for these new wrappers.

All 7 comments

Great idea! I would like to go for the callback pattern, as the plugin API also supports async init (of plugins) via a callback.

The biggest issue I see is that I would like to keep backwards compatibility, so that strategies which are not async don't break (because they don't call any callback).

What do you think of strategies exposing some meta data, similar to the how exchange wrappers expose information on how Gekko should work with an exchange:

https://github.com/askmike/gekko/blob/9cfb331bfd68ed888c2cddf2c72bc04084f30648/exchange/wrappers/bitfinex.js#L297-L311

That way we can have strategies providing some information about them, like whether the init function is async or not.

Yes perfect, with default values to ensure no breaking change with existing
strategy

On Thu, 13 Sep 2018 1:51 pm Mike van Rossum, notifications@github.com
wrote:

What do you think of strategies exposing some meta data, similar to the
how exchange wrappers expose information on how Gekko should work with an
exchange:

https://github.com/askmike/gekko/blob/9cfb331bfd68ed888c2cddf2c72bc04084f30648/exchange/wrappers/bitfinex.js#L297-L311

That way we can have strategies providing some information about them,
like whether the init function is async or not.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/askmike/gekko/issues/2525#issuecomment-420891625, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AGkqRIJTsH9BPSwK_iDBqb7tII8FbVpQks5uafJSgaJpZM4WmkWE
.

Great discussion at the right time :-) Also for the strat.update and strat.check function it will be very useful to have either a callback function or the ability to return a Promise.

I am just wrapping the tulip and talib indicators into a native gekko indicator with async/await to use them in multi timeframe strategies where asyncIndicatorRunner is not available. Runs already pretty well, the strat.update callback is the last missing part.

Sample usage:

strat.init = function () {
this.tulipFOSC = new TULIPSYNC({ indicator: 'fosc', length: 500, candleinput: 'close', options:[ this.Period ] });
}

strat.update = async function (candle) {
this.tulipFOSC.result = await this.tulipFOSC.update(candle);
}

strat.check = function (candle) {
console.log(candle.start.format(), this.tulipFOSC.result);
}

In case there is a general interest I can open a pull request for these new wrappers.

Async would be a great thing to have. It opens up completely new scenarios. I once tried to trade using forecasts I created based on xfffff's gekko datasets and fb prophet. Sadly it didn't work because there was no await possible inside the strat.init() and the dataset would load a few seconds upon init. So 👍 for this feature ;)

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If you feel this is very a important issue please reach out the maintainer of this project directly via e-mail: gekko at mvr dot me.

Was this page helpful?
0 / 5 - 0 ratings