askmike / gekko

A bitcoin trading bot written in node - https://gekko.wizb.it/
MIT License
10.08k stars 3.93k forks source link

How to restart Gekko via api without warming up? #2752

Closed toschitsch closed 5 years ago

toschitsch commented 5 years ago

How to use history from market watcher for warming up when starting a trade bot via api?

I'm submitting a ... Question

Action taken (what you did) From time to time tradebot gets an Error 2001 from Binance and does not trade any more. So I have to kill the old one and start a new tradebot. Then I decided to write a simple Python script using Gekko api as I don't know node.js at all. The algorithm is very simple: the script gets all live tradebots and checks their logs for "ERROR". Once an error is met, the script kills the tradebot and starts a new one with the following configuration (conf is simply a dictionary with configuration got from the old bot):

{ "market":{ "type":"leech" }, "mode":"realtime", "watch":{ "exchange":conf["exchange"], "currency":conf["currency"], "asset":conf["asset"] }, "tradingAdvisor":{ "enabled":True, "method":conf["strat_name"], "candleSize":conf["candleSize"], "historySize":conf["historySize"] }, conf["strat_name"]: conf["strat_settings"], "candleWriter":{"enabled":True,"adapter":"sqlite"}, "type":"tradebot", "performanceAnalyzer":{"riskFreeReturn":2,"enabled":True}, "trader":{"enabled":True},"valid":True }

Expected result (what you hoped would happen) I thought that it would work as if I simply restarted a tradebot from the browser and the tradebot would use the history from market watcher for warming up.

Actual result (unexpected outcome) However, every time the trade bot is restarted, is starts getting history only from the moment when it was actually started and not from the market watcher that is already working for a day for example, though it refers to it.

Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc)

I believe that there is an easy option to use in the config which is sent via api using POST /api/startGekko to instruct the bot to take candles from the watcher as it does if started from the browser. Please don't request using the command line as I find it very сomfortable to be able to check bots via UI.

I am looking forward to your help.

toschitsch commented 5 years ago

I managed to fix the issue myself simply by adding "from" to the market part of the config like this: "market":{ "type":"leech", "from": }

IAMtheIAM commented 5 years ago

I have this same question. Which is the setting to use to enable the "LIVE / PAPER TRADING" bot to use history from the market watcher, so it doesn't need to warm up?

toschitsch commented 5 years ago

If you start a new bot from a browser with a market watcher already running, live/paper trader will take information from it automatically. If you want to start a bot using api, you should add field "from" to the field "market". ,"From" is obviously a date when market watcher was started, however, I don't remember the format. But you'll see the right format to use once you get one's bot configuration as an example. I haven't used gekko for a long time, so I don't remember much.