CLI tool that enhances the features of Gekko's Trading Bot. The tool performs a test with multiple pairs on a single run. Suppose you have a strategy that you want to test on more currency pairs. You enter all the pairs on which you want to test the strategy for the BacktestTool's configuration file. You start the application and everything happens automatically. You are just waiting for the results that appear on the screen. You will see how your strategy falls on other pairs, where it works the best, and where the worst. More detailed data is available in the .CSV file, which you can open in a spreadsheet or text editor.
You can do the same with many strategies and CandleSize values. You can test all your strategies on eg BTC-USD pair and compare results, which will allow you to choose the best strategy you will use in live trade.
- Backtest for multiple strategies and pairs with one command
- Backtests results are exporting to CSV file (see sample)
- Analysis and comparing all strategy and pair results in variables such as: % of profitable backtests for strategy, % of results with profit above market, % of win trades, average P&L for trades and more!
- Import multiple datasets with one command
- Strategy config file - support both TOML and JSON files in CLI mode
- Strategy optimization - searching for optimal parameters (brute force method) for the strategy on many datasets
- Multithreading - in contrast to raw Gekko backtest this tool can uses 100% of your processor
- Extended statistics - 40 variables from single backtest result, such as: volume, price (min, max, avg, volality), percent of win trades, median P&L for trades, marketcap, CoinMarketCap Rank, etc.
- Download latest version from repository's releases.
- Extract downloaded zip.
- Copy all extrated files to main Gekko's directory.
- Clone git https://github.com/xFFFFF/Gekko-BacktestTool
- Copy files to Gekko's main directory
- Install dependies:
$ sudo cpan install Parallel::ForkManager Time::Elapsed Getopt::Long List::MoreUtils File::chdir Statistics::Basic DBI DBD::SQLite JSON::XS TOML File::Basename File::Find::Wanted Template LWP::UserAgent LWP::Protocol::https Set::CrossProduct DBD::CSV Text::Table File::Copy
- Clone git https://github.com/xFFFFF/Gekko-BacktestTool
- Copy files to Gekko's main directory
- Install dependies:
$ su
$ cpan install Parallel::ForkManager Time::Elapsed Getopt::Long List::MoreUtils File::chdir Statistics::Basic DBI DBD::SQLite JSON::XS TOML File::Basename File::Find::Wanted Template LWP::UserAgent LWP::Protocol::https Set::CrossProduct DBD::CSV Text::Table File::Copy
- Install Strawberry Perl
- Download Gekko BacktestTool from here
- Uncompress files from master.zip to Your main Gekko's folder
- Find Run... in Menu Start
- Enter cmd.exe and press enter
- In appeared Window with black background enter command:
cpan install Parallel::ForkManager Time::Elapsed Getopt::Long List::MoreUtils File::chdir Statistics::Basic DBI DBD::SQLite JSON::XS TOML File::Basename File::Find::Wanted Template LWP::UserAgent LWP::Protocol::https Set::CrossProduct DBD::CSV Text::Table File::Copy
The installation tutorial by bald123 can be found in the Wiki: Docker installation.
- Edit backtest-config.pl in text editor.
- In terminal/cmd go to Your main Gekko's folder ex:
Windows -cd C:\Users\xFFFFF\Desktop\gekko
Linux -cd /home/xFFFFF/gekko
- If You are using Open Source version go to next step. For "binaries" add execution privilege:
chmod +x backtest
- Run BacktestTool by command:
a) Open Source version:perl backtest.pl
b) Binaries:./backtest
usage: perl backtest.pl
To run backtests machine
usage: perl backtest.pl [mode] [optional parameter]
To run other features
Mode:
-i, --import - Import new datasets
-g, --paper - Start multiple sessions of PaperTrader
-v, --convert TOMLFILE - Convert TOML file to Gekko's CLI config format, ex: backtest.pl -v MACD.toml
-a, --analyze CSVFILE - Perform comparision of strategies and pairs from csv file, ex: backtest.pl -a database.csv
Optional parameters:
-c, --config - BacktestTool config file. Default is backtest-config.pl
-s, --strat STRAT_NAME - Define strategies for backtests. You can add multiple strategies seperated by commas example: backtest.pl --strat=MACD,CCI
-p, --pair PAIR - Define pairs to backtest in exchange:currency:asset format ex: backtest.pl --p bitfinex:USD:AVT. You can add multiple pairs seperated by commas.
-p exchange:ALL - Perform action on all available pairs. Other usage: exchange:USD:ALL to perform action for all USD pairs.
-n, --candle CANDLE - Define candleSize and warmup period for backtest in candleSize:warmup format, ex: backtest.pl -n 5:144,10:73. You can add multiple values seperated by commas.
-ft, --period DAYS - Time range in days - perform action on period from last x days ex: backtest.pl -ft 7
-f, --from - Time range for backtest datasets or import. Example: backtest.pl --from="2018-01-01 09:10" --to="2018-01-05 12:23"
-t, --to
-f last - Start import from last candle available in DB. If pair not exist in DB then start from 24h ago.
-t now - 'now' is current time in GMT.
-o, --output FILENAME - CSV file name.
-
Backtests of all available pairs for Binance Exchange in Gekko's scan datarange mode:
$ perl backtest.pl -p binance:ALL
-
Backtest on all pairs and strategies defined in backtest-config.pl with candles 5, 10, 20, 40 and 12 hours warmup period:
$ perl backtest.pl -n 5:144,10:73,20:36,40:15
-
Import all new candles for all BNB pairs:
$ perl backtest.pl -i -p binance:BNB:ALL -f last -t now
-
Import all candles for pairs defined in backtest-config.pl from 2017-01-02 to now:
$ perl backtest.pl -i -f 2017-01-02 -t now
-
Search best parameters for strategy: edit TOML file in config/strategies
The above example will generate 15 backtests with unique configurations. Syntax for brute force is: start..end: step (as in the case of TimePeriod) or value1, value2, value3 (example from interval). The generated values for TimePeriod are 15, 20, 25. After saving the file, run the backtest of the given strategy, eg backtest.pl -s BBRSI.