当前位置: 首页 > 软件库 > Web3 > 开源货币/比特币 >

Gekko-BacktestTool

授权协议 MIT License
开发语言 Python
所属分类 Web3、 开源货币/比特币
软件类型 开源软件
地区 不详
投 递 者 夹谷晋
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Gekko BacktestTool

Logo




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.
Top Dataset
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.

DEMO

Backtest machine

GBT run

Database file

CSV file

Features

  • 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.

Minimal requirements

Installation

Binaries: Easiest install way

  1. Download latest version from repository's releases.
  2. Extract downloaded zip.
  3. Copy all extrated files to main Gekko's directory.

Open Source: Debian, Ubuntu, Linux Mint

  1. Clone git https://github.com/xFFFFF/Gekko-BacktestTool
  2. Copy files to Gekko's main directory
  3. 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

Open Source: Other Unix-like OS

  1. Clone git https://github.com/xFFFFF/Gekko-BacktestTool
  2. Copy files to Gekko's main directory
  3. 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

Open Source: MS Windows

  1. Install Strawberry Perl
  2. Download Gekko BacktestTool from here
  3. Uncompress files from master.zip to Your main Gekko's folder
  4. Find Run... in Menu Start
  5. Enter cmd.exe and press enter
  6. 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

Open Source: Docker container

The installation tutorial by bald123 can be found in the Wiki: Docker installation.

Run

  1. Edit backtest-config.pl in text editor.
  2. In terminal/cmd go to Your main Gekko's folder ex:
    Windows - cd C:\Users\xFFFFF\Desktop\gekko
    Linux - cd /home/xFFFFF/gekko
  3. If You are using Open Source version go to next step. For "binaries" add execution privilege: chmod +x backtest
  4. Run BacktestTool by command:
    a) Open Source version: perl backtest.pl
    b) Binaries: ./backtest

All available commands

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.

Some examples

  • 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
    Strat config example
    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.
    Brute force

See also

 相关资料
  • This repo is not maintained anymore I am officially not maintaining this project anymore. It was an amazing journey and I want to thank everyone forplaying the role in this amazing story! More details

  • 我正在解决这个优化问题,我需要计算出我需要打开多少个配送中心,以满足12家公司设施的需求,同时最小化运输成本。运输成本只是配送中心之间的距离乘以每英里成本,然而在这个问题中,每英里成本是一美元。我有5个选择,分别是波士顿、纳舒亚、普罗维登斯、斯普林菲尔德和伍斯特,这5个是12家公司设施的一部分。 我解决了这个问题,得到了正确的答案,但是后来我试图在同一个代码中添加两个约束,我得到的答案是不正确的。

  • 我刚刚开始使用Gekko优化软件。到目前为止,我找到了如何获得问题的最优解。但我不确定是否有可能看到满足约束的所有可能结果?(不仅是最佳值)。问题是,对于我的特定任务,我需要多次进行优化,尽管最优值在某一点上是最优的,但最优决策序列可能会随着时间的推移而不同。我想通过创建MDP来检查这一点。但要做到这一点,我需要知道可能的状态,这些状态表示要优化的变量的所有可能值,它们满足约束。我还没有发现如何在

  • 我想知道这是APM SOLVERs背后的理论方法。 我正在解决一个问题,在这个问题上,我必须求解一个没有任何约束的非线性方程组。我正在使用BPOPT求解器,它工作得很好。我只是想知道用什么方法来求解这样的系统。牛顿方法?拟牛顿方法?我找不到任何关于这个的留档。你能告诉我在哪里可以找到这样的信息吗? 也可以先验地知道gekko求解器求解具有(N)个变量的非线性方程组所需的RAM吗? 谢谢你

  • 我还没有看到与此相关的问题,尽管我做了几次相反的努力,但它还是出现了,所以我希望有人能帮我理解发生了什么。 我是Python的Gekko包的新手,我试图运行一个非线性求解器来解决正在发生的事情。我得到了一个奇怪的错误消息(),似乎是编程/语法而不是数学。这是一个更大的函数/数据/输入中的一个函数,所以我很难提供足够的信息来帮助您复制它-但是- y(即self.get_days_energy(日期=

  • 我试图用Python中的GEKKO定义一个优化问题,我想使用一些带有预定义选择列表的设计变量。此外,每个选择都有一个相关的成本,约束条件是总成本应低于指定的限制。 下面是一个常见的壁虎示例(在这里找到),修改后的x1和x2是sos1。此外,利用所选值x1和x2的索引,我从另一个列表中找到了它们的相关成本,它们的总和应该小于某个值(约束)。 注意:我必须在函数中添加一个if块作为的初始值,而似乎为零