nick-dolan / gekko-batcher

Batch backtest tool for Gekko.
MIT License
36 stars 15 forks source link

Different results with Gekko UI and gekko-batcher #5

Closed WilbertNL closed 5 years ago

WilbertNL commented 5 years ago

Hi, I can't seem to figure out why I have different results in the Gekko UI when I run seemingly the same test with bruteforce. If the profit percentages were off, that could be explained by the papertrader settings but the problem is already in a huge difference in the amount of trades.

image

The red boxes show the results/values of the bruteforce.csv. This shows 4 trades by the bruteforce tool and 73 by Gekko UI.

batcher config.js

const config = {};

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//                          GENERAL SETTINGS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

config.gekkoPath = '../gekko/';

config.apiUrl = "http://localhost:3000";

config.parallelQueries = 4;

config.candleSizes = [45, 60, 75];

config.historySizes = [10, 15];

// Format: [exchange, currency, asset]
config.tradingPairs = [
    ["binance", "usdt", "btc"],
];

config.daterange = {
    from: '2018-11-19T00:00:00Z',
    to: '2018-12-24T00:00:00Z'
};

// Where to get method's settings.
// The first has high priority. Then second, if there's no settings in first place and so on.

// batcher – strategy settings below here
// gekko – gekko's config.js
// toml.js – gekko's toml files
config.configPriorityLocations = ['batcher', 'gekko', 'gekko-toml'];

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//                          BACKTEST BATCHER
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

config.methods = ['MACD'];

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//                          BRUTEFORCE SEARCHER
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

config.method = 'MACD';

// Shuffle generated combinations of method's configs
config.shuffle = true;

// Generate all possible combinations of set of settings with given ranges
// Format for range: 'start:step:end'
config.ranges = {
    short: '8:1:10',
    long: '17:1:24',
    signal: '7:1:9',
    thresholds: {
        down: '-0.025',
        up: '0.025',
        persistence: 1
    }
};

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//                          STRATEGY SETTINGS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

config.MACD = {
    short: '8:1:10',
    long: '17:1:24', 
    signal: '7:1:9',
    thresholds: {
        down: '-0.025',
        up: '0.025',
        persistence: 1
    }
};

module.exports = config;

Any idea what I'm missing here?

Please let me know which gekko config you would like to see.

EDIT: added batcher's config.js

nick-dolan commented 5 years ago

@WilbertNL, thank you for the issue! It was an error in "generateRange" that returns strings instead of numbers. I fix it so you can pull and test. In addition, note that the values ​​in the CSV file are rounded to three decimal places since 7c1a69d87b4b8a29d38d5eaeb20d31bc88f06121 commit. Fees and slippage/spread also affect the final price, you can set up it now in your config, see example in sample-config.js.

If this does not solve the problem, please let me know.

WilbertNL commented 5 years ago

Thanks for the quick actions! I've applied the changes and am currently running a test. Not sure if I'm able to provide feedback today, but surely tomorrow.

WilbertNL commented 5 years ago

Awesome, your fix worked, thanks! Now I get the same results across the board with my test with the MACD strategy. I'm now running the bit more complex RSI_BULL_BEAR_ADX.

I did see this messages during the bruteforce:

((node:1444) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 201 unhandledRejection listeners added. Use emitter.setMaxListeners() to increase limit

Is that something I should investigate?

Great job, thanks!

WilbertNL commented 5 years ago

Ah, bruteforcing the RSI_BULL_BEAR_ADX. Perhaps related to the MaxListeners..-warning or am I just too ambitious with 531441 combinations?

$ node bruteforce.js 
531441 combinations
Started: RSI_BULL_BEAR_ADX USDT/BTC 5/1000 Binance
Started: RSI_BULL_BEAR_ADX USDT/BTC 5/1000 Binance
Started: RSI_BULL_BEAR_ADX USDT/BTC 5/1000 Binance
Started: RSI_BULL_BEAR_ADX USDT/BTC 5/1000 Binance
{ Error: socket hang up
    at createHangUpError (_http_client.js:342:15)
    at Socket.socketOnEnd (_http_client.js:437:23)
    at emitNone (events.js:111:20)
    at Socket.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:139:11)
    at process._tickCallback (internal/process/next_tick.js:181:9)
  code: 'ECONNRESET',
<...>

I can post the full, loooooooong output if interested?

WilbertNL commented 5 years ago

Never mind, my bad: I should've added more cores to the VM or lower config.parallelQueries = 4; in the config.js.

Brutforce is running now.

nick-dolan commented 5 years ago

I did see this messages during the bruteforce:

((node:1444) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 201 unhandledRejection listeners added. Use emitter.setMaxListeners() to increase limit

@WilbertNL could you open a new issue and attach config as you did here, please. I will make some tests.