Gekko: Telegram Bot + Gekko integration

Created on 31 Jul 2017  路  8Comments  路  Source: askmike/gekko

Hi there,

I'm doing some researches here using Telegram + Gekko and could not find any examples of gekko's strategies / running information and telegram integration.

For example:
I want to read some strategies variables using the telegram bot.

Is that possible?

Has anybody ever done that?

Thanks guys!

BR,
R

enhancement low-priority

Most helpful comment

Once you figured out exactly what you want the telegram bot to do let me know, and we figure out together how to do it!

All 8 comments

Hi @askmike, thanks for all the previous help.

I'm trying to read some gekko running variables and might need some light here.

How can I read the poloniex balance?

I mean, when gekko does a trade using BTC/USDT. When it first starts, we're out of the market -- no buy has been pulled yet.

When that happens, I've notice that gekko uses all the poloniex balance and converts it into BTC.

I want to be able to read this variables and return them to telegram bot.

Any tip here?

Thanks buddy.

Hey,

The telegram bot is a plugin, read more about what Gekko plugins are and what they can do
here: https://gekko.wizb.it/docs/extending/add_a_plugin.html

Basically this is what happens when you run Gekko:

-                              ( [plugin A] )
[ market data ] --(candles)--> ( [plugin B] )
-                              ( [plugin C] )

Your strat runs inside a plugin (called tradingAdvisor), and the telegram bot runs inside another plugin (called telegram). Finally your real exchange portfolio is managed by another plugin (called trader). Communication between plugins is limited to events, all existing events can be found here: https://gekko.wizb.it/docs/extending/add_a_plugin.html#What-kind-of-events-can-I-listen-to-

How can I read the poloniex balance?

You need to update the telegram plugin so that it listens to the "updatePortfolio" event, this way you can send a telegram notification whenever this changes.

I want to read some strategies variables using the telegram bot.

Not really supported, a hacky way would be triggering "advice" events without long or short (so the telegram bot can listen to data updates).

Hi @askmike. Thanks for the help.
I think I've moving too fast on this. Your explanation is much appreciated but it got me more confused about the communication between plugins. I have no idea how to use this yet.

All I want is to be able to ask the telegram plugin about current trading status, buy price, current profit/loss, etc.

Anyway, thanks a lot for the help. I'll think about this in the next days.

All I want is to be able to ask the telegram plugin about current trading status, buy price, current profit/loss, etc.

The only functionality supported by the telegram plugin is:

  • ask for current advice (say "advice")
  • ask for current price (say "price")

and some random quotes stuff.

All the other stuff you asked is not supported, and thus needs to be added to the "plugin" :)

Once you figured out exactly what you want the telegram bot to do let me know, and we figure out together how to do it!

Hi @askmike.

Thanks a lot for your help. You've been such a guide on this journey.

Well, since you asked (;D) this is what I'm trying to do (still have no clue how to do it).

Add few bot commands to into the gekko bot to intercede some mistaken actions.

  • STOP: works as a stop order. Gekko would sell it if last action was to buy (I know that this trigger should be configured in my strat, but its a safeguard action);
  • STATUS: shows current status, last order infos (date, price, current profit/loss);
  • BALANCE: shows current poloniex balance;
  • BUY: starts a buy when has not done yet (I know that this trigger should be configured in my strat, but its a safeguard action);

Those would be a very nice improvement. I do understand that there might be some limitations regarding this features, but if we could see a light at the end of the tunnel that would be a great start.

I've done some attempts here but no success so far.

this.commands = {
    [...]
    'trades': 'processTrade'
};

Actor.prototype.processTrade = function(trade) {
    this.trade = trade.action;
    if (telegrambot.emitUpdates)
    this.newTrade();
};

Actor.prototype.newTrade = function(trade) {
  if (this.chatId) {
    this.bot.sendMessage(this.chatId, 
      'Check out some trading infos:',
      this.trade
      );
  }
}

But got this errors:

Unhandled rejection TypeError: Cannot read property 'action' of undefined
    at Actor.processTrade (/Users/rafael/Documents/gekko/plugins/telegrambot.js:58:23)
    at Actor.bound [as processTrade] (/Users/rafael/Documents/gekko/node_modules/lodash/dist/lodash.js:729:21)
    at Actor.verifyQuestion (/Users/rafael/Documents/gekko/plugins/telegrambot.js:66:47)
    at Object.bound [as callback] (/Users/rafael/Documents/gekko/node_modules/lodash/dist/lodash.js:729:21)
    at /Users/rafael/Documents/gekko/node_modules/node-telegram-bot-api/lib/telegram.js:135:19
    at Array.forEach (native)
    at TelegramBot.processUpdate (/Users/rafael/Documents/gekko/node_modules/node-telegram-bot-api/lib/telegram.js:130:36)
    at /Users/rafael/Documents/gekko/node_modules/node-telegram-bot-api/lib/telegramPolling.js:59:17
    at Array.forEach (native)
    at /Users/rafael/Documents/gekko/node_modules/node-telegram-bot-api/lib/telegramPolling.js:56:17
    at tryCatcher (/Users/rafael/Documents/gekko/node_modules/node-telegram-bot-api/node_modules/request-promise/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/Users/rafael/Documents/gekko/node_modules/node-telegram-bot-api/node_modules/request-promise/node_modules/bluebird/js/main/promise.js:510:31)
    at Promise._settlePromiseAt (/Users/rafael/Documents/gekko/node_modules/node-telegram-bot-api/node_modules/request-promise/node_modules/bluebird/js/main/promise.js:584:18)
    at Promise._settlePromises (/Users/rafael/Documents/gekko/node_modules/node-telegram-bot-api/node_modules/request-promise/node_modules/bluebird/js/main/promise.js:700:14)
    at Async._drainQueue (/Users/rafael/Documents/gekko/node_modules/node-telegram-bot-api/node_modules/request-promise/node_modules/bluebird/js/main/async.js:123:16)
    at Async._drainQueues (/Users/rafael/Documents/gekko/node_modules/node-telegram-bot-api/node_modules/request-promise/node_modules/bluebird/js/main/async.js:133:10)
    at Immediate.Async.drainQueues (/Users/rafael/Documents/gekko/node_modules/node-telegram-bot-api/node_modules/request-promise/node_modules/bluebird/js/main/async.js:15:14)
    at runCallback (timers.js:672:20)
    at tryOnImmediate (timers.js:645:5)
    at processImmediate [as _immediateCallback] (timers.js:617:5)

Huge thanks bro.

Hi mike,
Love Gekko. Im trying to write an advisor that listens to a telegram bot signal. So signal = buy, we buy. Signal = sell, we sell.

Thanks for your support @askmike!

Similar to @raffus, I'm also trying to pass additional parameters from my strategy to the Telegram bot. What I'm hearing is I could hack it by sending the parameters in the advice event? Something like,

...
this.advice(buy_price);
...

And then in my Telegram bot I could check what the contents of the advice event handler is, ie. whether or not it is 'long' or 'short' and if not, send that to the bot output? The issue with this is that the trader will not execute if there are additional parameters being passed through the advice event handler correct?

Please let me know if I'm on the right track or if I should try making a new event handler or something else.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yacindou picture yacindou  路  3Comments

Chroll91 picture Chroll91  路  5Comments

rcoenen picture rcoenen  路  3Comments

rcoenen picture rcoenen  路  5Comments

thegamecat picture thegamecat  路  4Comments