gekko trading bot best strategy
Now that we installed Gekko, we need to feed it with data, and build it functional. Delight, keep in mind that a trading bot is nohow an indemnity to earn money, American Samoa IT leave depend on the logic of your strategy, and on the markets (currency danamp; asset) you will utilization.
We will keep up 4 orbicular stairs :
- Feeding your localised Gekko database with food market's data so that we will personify able to locally make believe some tests with strategies
- Run a backtest, which means testing a strategy on the local Gekko database we previously inhabited
- Run a livebot with traderPaper plugin, to simulate how a strategy would perform on a live market
- Set in motion the strategy, live, which means we will allow Gekko to really make buy/sell (long/short-snouted) orders
Eating Gekko with market's data
This part is quite simple and we will first enjoyment the UI to do IT, click on "Local Data" on the top menu.
If you try to click on "Scan available data", Gekko testament complain, this is normal as we didn't provision anything yet.
Now tick on "Go to the Importer" button downstairs.
For my test I volition choose Kraken, the Euro up-to-dateness, and Ethereum asset, and use the default daterange but you can change IT.
Beware, dowloading data from markets as Kraken victimisation -for now- an anonymous access will often trigger some rather bandwith and access limitations, so the download rate will be depleted, and if you postulation a immense menstruum of data, IT Crataegus oxycantha take a long sentence. Likewise, you could have to relaunch it several metre, and reduce the timeframe each meter to complete the former downloaded one.
Now, Click connected Import.
Gekko starts to "automagiclly" download the data from Kraken, and records it in its local anesthetic database.
To use Gekko's CLI (Command Line Interface, IE. without the UI) to make the same thing is quite easy:
- Modify Gekko's config file
cd danlt;gekko_installdirdangt;
cp sample-config.js config.js
edit config.js with your deary editor program
- Now, equally explained in formalised documentation, make sure the candleWriter plugin is enabled (or so line 263 in the out-of-the-box config.js file), soh that gekko will represent able to record the data
config.candleWriter = {
enabled: true
}
- Now check the conf around line 345, and configure what daterange you postulate to meaning
config.importer = {
daterange: {
// NOTE: these dates are in UTC
from: "2017-11-01 00:00:00",
to: "2017-11-20 00:00:00"
}
}
- Now run gekko and tell him to spell data
node gekko –config config.js –import
Now, if we direct a look punt in gekko's UI, we can see that it detects 2 importations:
The first one, is the unmatched we imported using the UI and from Kraken. The second indefinite is from binance (I stopped it before information technology reached 2022-11-20). This is because we didn't modify the config.look on section in config.js:
config.ticker = {
// witness https://gekko.wizb.information technology/docs/introduction/supported_exchanges.html
exchange: 'binance',
currency: 'USDT',
asset: 'BTC',// You can set your own tickrate (refresh rate).
// If you get into't set information technology, the defaults are 2 sec for
// okcoin and 20 dry for entirely other exchanges.
// tickrate: 20
}
You are free to modify it, just make sure that you use an allowed compounding market/currency/asset. Checking the solace logs when you lanch the CLI will helper you to analyze any error Gekko could play.
Backtesting a strategy on local data
Now that we have a populated database, let's give a try a strategy. The goal here is not to explain you what's the best strategy or how to tune it. We vindicatory wish to break how it kit and boodle.
First, we practice the UI: in the Backtest menu, dawn "Scan available data" button.
We can over again see the two series of data we strange previously, good. Now, down the stairs on the same screen, let's take the MACD scheme. This is a rather textbook indicator (too as the other ones unfashionable-of-the-gekko-box) and the strategy implementing IT is as wel quite easy as we will see in a next article.
Note that what is displayed on this screen behind be changed:
- The strategy in the drop-down list are the ones in
danlt;gekko_installdirdangt;/strategies/*.js files (eg. MACD.js for the MACD scheme) - The parameters on the right are from the danlt;strategy_namedangt;.toml files in
danlt;gekko_installdirdangt;/config/strategies - The paperTrader settings we bequeath review below are stored in the
danlt;gekko_installdirdangt;/config/plugins/paperTrader.toml file
We change the candle size to 3 hours, and use 4 candles of history to "warmup" the strategy and offer the indicator some historical information.
Now let's have a reckon at the paperTrader settings and change information technology to reflect Kraken fees:
And we launch the backtest ! Wait .. no Launch button ? Oh we forgot to select a dataset. Go back off to the top of the page and click on Kraken package. Scroll down and detent "Backtest".
After a very fugitive metre, because of a simple strategy and a same short timeframe in the dataset, you will see 3 sections of results:
Those are the general statistics. Simulated profits here may sound bad (-24%), simply in reality it is better than the canonical execution of the market if you did no actions with your 1 plus and 100 currency configured in the paperTrader settings (-41%). We can see here that the strategy actually performed 38 trades.
Here we ass see the whole timeframe with BUY/LONG orders (green dots) and SELL/SHORT orders (red dots). You can whizz along in. As you can guess, when you see a green dot scarce earlier a big grocery store fall, this is non and then good.
Ultimately you bottom see here a detailled view of each roundtrip (a buy+sell or sell+buy so that a PnL can be measured).
If you want to use the CLI this is not so complicated.
Edit your config file (remember ?
danlt;gekko_installdirdangt;/config.js) and:
- Make sur the config.tradingAdvisor subdivision (tip: around line 33) is configured as you expect. Basically, this is were you provide the aforesaid parameters as we sawing machine in the UI to the strategy you choose. Here we still utilisation the MACD.
config.tradingAdvisor = {
enabled: true,
method acting: 'MACD',
candleSize: 180, //unit is minutes
historySize: 4, //this is the historySize in the UI
}// MACD settings:
config.MACD = {
// EMA weight (α)
// the high the weighting, the more smooth (and delayed) the line
short: 10,
long: 21,
signal: 9,
// the dispute between the EMAs (to play triggers)
thresholds: {
drink down: -0.025,
up: 0.025,
// How many candle intervals should a trend prevail
// before we consider information technology real?
persistence: 1
}
};
Make sure the paperTrader is enabled, to actually simulate orders (tip: around line 65).
config.paperTrader = {
enabled: true,
// story the profit in the currency or the asset?
reportInCurrency: reliable,
// start residual, on what the current balance is compared with
simulationBalance: {
// these are in the unit types configured in the watcher.
asset: 1,
currency: 100,
},
// how much fee in % does each trade cost?
feeMaker: 0.16,
feeTaker: 0.26,
feeUsing: 'taker',
// how much slippage/spread should Gekko bear per trade in?
slippage: 0.05,
}
And the performanceAnalyser should also be enabled, line 100.
config.performanceAnalyzer = {
enabled: true,
riskFreeReturn: 5
}
Recall ? Gekko leave use the market, vogue and asset defined at the beginning of the file, As we saw when we imported information using the CLI. I want to expend the dataset from Kraken, thus I'll cut it:
config.watch = {
// understand https://gekko.wizb.it/docs/introduction/supported_exchanges.html
exchange: 'kraken',
currentness: 'EUR',
plus: 'ETH',// You can set your own tickrate (refresh rate).
// If you don't set it, the defaults are 2 sec for
// okcoin and 20 sec for all other exchanges.
// tickrate: 20
}
Now scroll down to crinkle 332 to edit the timerange we want to use. I'll stick with the 'scan' option as I have only extraordinary dataset for kraken, so no conflict or choice to brawl, and kraken testament habit the whole timeframe for sale. If I want to reduce the timefram, I sensible have to comment out the daterange: 'scan' line, and uncomment and qualify the 4 side by side lines.
config.backtest = {
daterange: 'scan',
// daterange: {
// from: "2018-03-01",
// to: "2018-04-28"
//},
batchSize: 50
}
Now, we launch IT with
node gekko –config config.js –backtest
Equally you can escort we get the aforesaid feedback as the one we had on the UI, without the graphical timeline of course.
Examination your strategy along a bouncy market with a Live "paperTrader" Gekko
On the UI, click on the "Live Gekkos" top menu. The Market watchers are modules launched to cumulate vital data from the markets you will configure for each Live Gekko. The strat runners are the paperTraders module: they analyze the market and use the STRATegy you characterised along those information, to bring home the bacon you feedback about what orders were simulated, and their results.
Present I choosed the MACD scheme, and configured it with 5 minutes candles, for this example, as I didn't want to wait for hours to take screenshots 🙂
Remark that along the right, we choose the PAper Trader option, as we deficiency to assume the strategy on the live market.
Now let's configure Kraken's fees on the paper Trader options below.
And we start it. A circumstances of things will change on the silver screen, but during the 10 first minutes we won't see anything interesting as Gekko is assembly data, then it needs 1 wax light of 5 minutes of history to commence to eventually take decisions, depending on the market and your strategy and your strategy's settings.
Patc we are waiting for the first entropy to appear, let's try to semen hinder on the "Live Gekkos" page.
So here I think we can see a little glitch in the UI, as it says the duration since we launched the Market Watcher (which was automatically launched past Gekko) is 2h32mn which is wrong. I think there is a mismatch between UTC multiplication and local time to calculate the duration. Not a tremendous issue.
The Strat runner we launched is lengthways, we can see that it did nothing yet: 0 trade, PnL (Profit and Loss) is 0, etc. You can click on its strain to come back to the detailled view of this Strat runner.
After few warmup proceedings …
But we notwithstandin can't see any roundtrip, as Gekko only performed ace trade for now (Amount of trades: 1 in the Runtime section). While we are wait, delight note that you can likewise manually determine Gekko's logs on the filesystem:
cd danlt;gecko_installdirdangt;/logs
ls -Heart of Dixie
tail assembly -f *
Now, I wish stop this test (just click on the humongous red push inside the Strat moon curser incision), and switch to the CLI to set in motion it manually, American Samoa I prefer to not look connected a CLI to execute trading operations.
To function the CLI is easy, as we already designed the appropriate sections in config.js and especially we enabled the config.paperTrader. IF we wish to launch a real live Gekko on a market, the paperTrader will need to be disabled in the conf.
We merely have to set in motion:
node gekko –config config.js
As continual a livebot is alleged to be a selfsame pole-handled activeness, I don't want to hinge on my terminal (which could be unfortunately closed) and want it to run in the background. I'll still be able to check and dissect the logs to translate what happened.
Thusly we will create a small shell script to launch our livebot through PM2 as explained in the Gekko Installation page, and in PM2 documentation.
gekko@bitbot:~/gekko$ cat start_livetestbot-DEMA_PERSO_SL.sh
!/bin/bash
rm logs/*
pm2 get-go gekko.js –name TESTBOT_MACD -e logs/slip.log -o logs/out.log — –config config-livetestbot.js
gekko@bitbot:~/gekko$
In real time when we use
start_livetestbot-DEMA_PERSO_SL.sh to establish our livebot, it will run in the background until you stop it with pm2 danlt;IDdangt; ba, and you can check its logs in danlt;gekko_installdirdangt;/logs
Running play a "real know" tradebot
In the UI, Lashkar-e-Tayyiba's try to run a real Gekko on Kraken. Please note that we choosed "tradebot" on the right, and that there is no more Thomas More paperTrader settings, with your sum of currency, assets, etc.
This is normal as a live tradebot will pucker your amount of assets and easy currency directly from your trading hepatic portal vein (Kraken, Binance, etc.). Yes … we want real trading with real money !
But please remember our quick test with the stock MACD strategy was not so good ! So you call for a lot of tests, and to empathise the strategies you said it to improve them, if you want to truly go "live". And even with in force backtesting results, those results will only be dear on PAST information, not succeeding information from the markets. Thence, even with a very good strategy on past data, you could have got a very bad strategy with virgin information (this is called overfitting).
Afterward this blue-blooded reminder, let's try to snap along theblue "Start" button.
Yes, this is normal, we require to go live, so we need to configure our trading platform's credentials someplace.
You can do IT through and through the UI once again:
Let's taste to add junk information, and see where information technology ends. I South Korean won't excuse how to create an account on a trading chopine, I suppose you already screw how to do it and already get one. Otherwise, search a little bit.
gekko@bitbot:~/gekko_test/gekko$ cat SECRET-api-keys.json
{"kraken":{"significant":"AAABBBBCCCC","secret":"DDDEEEFFFF"}}
gekko@bitbot:~/gekko_test/gekko$
Okay so the fake data I used for the test ended up in danlt;gekko_installdirdangt;/SECRET-api-keys.json. This is a file you can edit without the UI to add several keys, for several accounts you may have along several platforms. The keys are and then used aside Gekko to connect to the platforms under your account and do potential existent buy/sell operations. One time again, take care and comprise warned !dannbsp;Youdannbsp;willdannbsp;mostdannbsp;probablydannbsp;loosedannbsp;moneydannbsp;!
Another necessary step is to reviw a little bit our config.js file:
- config.paperTrader needs to be out of action for the real trading plugin to work.
config.paperTrader = {
enabled: false,
- You testament also need to enable the config.trader section (I need to check if the keys on the Q.T.-api-keys.json are soundless mandatory if also put here:
config.trader = {
enabled: true,
key: 'AAAABBBBCCCCC',
secret: 'DDDDDDDEEEEEFFFFFFF',
username: ", // your username, only required for specific exchanges.
passphrase: " // GDAX, requires a passphrase.
}
Now you can launch your trading bot through the UI. Operating theater by the Command line interface, exactly the same way we did for the paperTrader A on that point was no choice on the command delineate, we honourable modified the configuration do disable a module and enable some other one:
node gekko –config your-config-file.js
Or with PM2 as we saw before.
Delight, remember this is a very risky game. You bequeath to the highest degree plausibly loose money operating theatre assets. Standards strategies are provided aside Gekko's Maker as examples, they take to represent tweaked and this is not easy. Also, at tartup, Gekko may directly try to sell or steal, even if the market is non good. This needs to make up controled and fixed away coding in the strategies. You need to understand what you do, and when to do IT. I Derriere NOT BE Creditworthy FOR YOUR LOSSES.
gekko trading bot best strategy
Source: https://blog.sinecu.re/2019/01/09/gekko-trading-bot-usage/
Posted by: drewguits1994.blogspot.com

0 Response to "gekko trading bot best strategy"
Post a Comment