Browse Source

Improved T5optimizer, new optimizer backtest results

develop
mark-sch 1 year ago
parent
commit
ac74e50108
8 changed files with 2344 additions and 73 deletions
  1. +1026
    -0
      backtest-results/20180101-20190901/T5multimix_ETHEUR_20180101-20190901-dynamicRsi.html
  2. +1024
    -0
      backtest-results/20180101-20190901/T5multimix_ETHEUR_20180101-20190901-staticRSI.html
  3. +1
    -1
      backtest2html.sh
  4. +5
    -5
      exchange/package-lock.json
  5. +199
    -27
      exchange/wrappers/kraken-markets.json
  6. +10
    -2
      package-lock.json
  7. +1
    -1
      package.json
  8. +78
    -37
      strategies/T5optimizer.js

+ 1026
- 0
backtest-results/20180101-20190901/T5multimix_ETHEUR_20180101-20190901-dynamicRsi.html
File diff suppressed because it is too large
View File


+ 1024
- 0
backtest-results/20180101-20190901/T5multimix_ETHEUR_20180101-20190901-staticRSI.html
File diff suppressed because it is too large
View File


+ 1
- 1
backtest2html.sh View File

@ -1,6 +1,6 @@
#!/bin/bash
( /usr/bin/time --verbose node gekko.js --config cfg/mark/config-eth.js --backtest --set debug=true | aha --black --title 'T5multimix_ETHEUR_20180101-20190228' > backtest-results/T5multimix_ETHEUR_20180101-20190228.html &)
( /usr/bin/time --verbose node gekko.js --config cfg/mark/config-eth.js --backtest --set debug=true | aha --black --title 'T5multimix_ETHEUR_20180101-20190901' > backtest-results/T5multimix_ETHEUR_20180101-20190901.html &)
#( /usr/bin/time --verbose node gekko.js --config config-xrp.js --backtest --set debug=true | aha --black --title 'T5multitime_XRPEUR_20180101-20181231' > backtest-results/T5multitime_XRPEUR_20180101-20181231.html &)
#( /usr/bin/time --verbose node gekko.js --config config-bch.js --backtest --set debug=true | aha --black --title 'T5multitime_BCHEUR_20180101-20181231' > backtest-results/T5multitime_BCHEUR_20180101-20181231.html &)
#( /usr/bin/time --verbose node gekko.js --config config-ltc.js --backtest --set debug=true | aha --black --title 'T5multitime_LTCEUR_20180101-20181231' > backtest-results/T5multitime_LTCEUR_20180101-20181231.html &)

+ 5
- 5
exchange/package-lock.json View File

@ -1042,11 +1042,6 @@
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc="
},
"through": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU="
},
"therocktrading": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/therocktrading/-/therocktrading-0.9.0.tgz",
@ -1062,6 +1057,11 @@
}
}
},
"through": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU="
},
"timed-out": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz",

+ 199
- 27
exchange/wrappers/kraken-markets.json View File

@ -1,13 +1,15 @@
{
"assets": [
"ADA",
"ATOM",
"BAT",
"BCH",
"BSV",
"DASH",
"EOS",
"GNO",
"QTUM",
"USDT",
"WAVES",
"ETC",
"ETH",
"LTC",
@ -116,105 +118,207 @@
"pricePrecision": 8,
"amountPrecision": 8
},
{
"pair": [
"CAD",
"ATOM"
],
"prefixed": [
"ZCAD",
"ATOM"
],
"book": "ATOMCAD",
"minimalOrder": {
"amount": 0.01,
"unit": "asset"
},
"pricePrecision": 4,
"amountPrecision": 8
},
{
"pair": [
"ETH",
"ATOM"
],
"prefixed": [
"XETH",
"ATOM"
],
"book": "ATOMETH",
"minimalOrder": {
"amount": 0.01,
"unit": "asset"
},
"pricePrecision": 6,
"amountPrecision": 8
},
{
"pair": [
"EUR",
"BCH"
"ATOM"
],
"prefixed": [
"ZEUR",
"BCH"
"ATOM"
],
"book": "BCHEUR",
"book": "ATOMEUR",
"minimalOrder": {
"amount": "0.002",
"amount": 0.01,
"unit": "asset"
},
"pricePrecision": 1,
"pricePrecision": 4,
"amountPrecision": 8
},
{
"pair": [
"USD",
"BCH"
"ATOM"
],
"prefixed": [
"ZUSD",
"BCH"
"ATOM"
],
"book": "BCHUSD",
"book": "ATOMUSD",
"minimalOrder": {
"amount": "0.002",
"amount": 0.01,
"unit": "asset"
},
"pricePrecision": 1,
"pricePrecision": 4,
"amountPrecision": 8
},
{
"pair": [
"XBT",
"BCH"
"ATOM"
],
"prefixed": [
"XXBT",
"BCH"
"ATOM"
],
"book": "BCHXBT",
"book": "ATOMXBT",
"minimalOrder": {
"amount": "0.002",
"amount": 0.01,
"unit": "asset"
},
"pricePrecision": 5,
"pricePrecision": 7,
"amountPrecision": 8
},
{
"pair": [
"ETH",
"BAT"
],
"prefixed": [
"XETH",
"BAT"
],
"book": "BATETH",
"minimalOrder": {
"amount": 0.01,
"unit": "asset"
},
"pricePrecision": 7,
"amountPrecision": 8
},
{
"pair": [
"EUR",
"BSV"
"BAT"
],
"prefixed": [
"ZEUR",
"BSV"
"BAT"
],
"book": "BSVEUR",
"book": "BATEUR",
"minimalOrder": {
"amount": 0.01,
"unit": "asset"
},
"pricePrecision": 1,
"pricePrecision": 5,
"amountPrecision": 8
},
{
"pair": [
"USD",
"BSV"
"BAT"
],
"prefixed": [
"ZUSD",
"BSV"
"BAT"
],
"book": "BSVUSD",
"book": "BATUSD",
"minimalOrder": {
"amount": 0.01,
"unit": "asset"
},
"pricePrecision": 1,
"pricePrecision": 5,
"amountPrecision": 8
},
{
"pair": [
"XBT",
"BSV"
"BAT"
],
"prefixed": [
"XXBT",
"BSV"
"BAT"
],
"book": "BSVXBT",
"book": "BATXBT",
"minimalOrder": {
"amount": 0.01,
"unit": "asset"
},
"pricePrecision": 8,
"amountPrecision": 8
},
{
"pair": [
"EUR",
"BCH"
],
"prefixed": [
"ZEUR",
"BCH"
],
"book": "BCHEUR",
"minimalOrder": {
"amount": "0.002",
"unit": "asset"
},
"pricePrecision": 1,
"amountPrecision": 8
},
{
"pair": [
"USD",
"BCH"
],
"prefixed": [
"ZUSD",
"BCH"
],
"book": "BCHUSD",
"minimalOrder": {
"amount": "0.002",
"unit": "asset"
},
"pricePrecision": 1,
"amountPrecision": 8
},
{
"pair": [
"XBT",
"BCH"
],
"prefixed": [
"XXBT",
"BCH"
],
"book": "BCHXBT",
"minimalOrder": {
"amount": "0.002",
"unit": "asset"
},
"pricePrecision": 5,
"amountPrecision": 8
},
@ -507,6 +611,74 @@
"pricePrecision": 4,
"amountPrecision": 8
},
{
"pair": [
"ETH",
"WAVES"
],
"prefixed": [
"XETH",
"WAVES"
],
"book": "WAVESETH",
"minimalOrder": {
"amount": 0.01,
"unit": "asset"
},
"pricePrecision": 7,
"amountPrecision": 8
},
{
"pair": [
"EUR",
"WAVES"
],
"prefixed": [
"ZEUR",
"WAVES"
],
"book": "WAVESEUR",
"minimalOrder": {
"amount": 0.01,
"unit": "asset"
},
"pricePrecision": 4,
"amountPrecision": 8
},
{
"pair": [
"USD",
"WAVES"
],
"prefixed": [
"ZUSD",
"WAVES"
],
"book": "WAVESUSD",
"minimalOrder": {
"amount": 0.01,
"unit": "asset"
},
"pricePrecision": 4,
"amountPrecision": 8
},
{
"pair": [
"XBT",
"WAVES"
],
"prefixed": [
"XXBT",
"WAVES"
],
"book": "WAVESXBT",
"minimalOrder": {
"amount": 0.01,
"unit": "asset"
},
"pricePrecision": 8,
"amountPrecision": 8
},
{
"pair": [
"ETH",

+ 10
- 2
package-lock.json View File

@ -1,6 +1,6 @@
{
"name": "gekko",
"version": "2019.0.68.269",
"version": "2019.0.68.271",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -3211,7 +3211,6 @@
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"dev": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
@ -5921,6 +5920,15 @@
}
}
},
"ripemd160": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz",
"integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==",
"requires": {
"hash-base": "^3.0.0",
"inherits": "^2.0.1"
}
},
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",

+ 1
- 1
package.json View File

@ -1,6 +1,6 @@
{
"name": "gekko",
"version": "2019.0.68.266",
"version": "2019.0.68.271",
"description": "A crypto trading bot for auto trading at various exchanges",
"keywords": [
"trading",

+ 78
- 37
strategies/T5optimizer.js View File

@ -9,16 +9,33 @@ var rsiOptimizer = {
rsiOptimizer.init = function(context) {
this.enabled = context.settings.enableT5optimizer;
this.limitT5optitrades = context.settings.limitT5optitrades;
this.T5os = context.settings.T5optimizer;
this.T5optimizeFrom = context.settings.T5optimizeFrom;
this.T5optimizeTo = context.settings.T5optimizeTo;
this.lastCheckedPrice = 100000;
this.initialCurrency = 1000;
console.log(''); //blank line
try {
this.data = JSON.parse(fs.readFileSync(program['config'] + '.optimizer'));
log.info('*** Runtime optimizer: Loading optimizer data from disk successfully!');
this.getBestResults(true);
log.info('*** Runtime optimizer: Best RSI is', this.data.buyTreshold, '/', this.data.sellTreshold, '(within the scope of last', context.settings.limitT5optitrades, 'trades)');
//log.info('*** Runtime optimizer: Best RSI for all recorded history trades:', this.best.totalBuyRsi, '/', this.best.totalSellRsi);
log.info('*** T5 Runtime optimizer: Loading optimizer data from disk successfully!');
log.info('*** T5 Runtime optimizer: Discovering recorded data...');
this.getBestResults(this.T5optimizeFrom, this.T5optimizeTo);
this.data.buyTreshold = this.best.buyRsi;
this.data.sellTreshold = this.best.sellRsi;
log.info('*** Best RSI is', this.best.buyRsi, '/', this.best.sellRsi, '(From', this.best.from, 'to', this.best.to, '- Profit: ' + this.best.totalProfit + '%');
if (this.T5os != undefined && this.T5os.switch != undefined && this.T5os.switch.length >= 2) {
console.log(''); //blank line
log.info('*** Best market segmentation:');
for (let i=0; i < this.T5os.switch.length-1; i++) {
this.getBestResults(this.T5os.switch[i].date, this.T5os.switch[i+1].date, this.T5os.switch[i].buyRSI, this.T5os.switch[i].sellRSI);
log.info('*** ', 'From', this.best.from, 'to', this.best.to, '- Profit: ' + this.best.totalProfit + '% with best RSI', this.best.buyRsi, '/', this.best.sellRsi, 'and ' + this.best.testRsiProfit + '% with ' + this.T5os.switch[i].buyRSI + ' / ' + this.T5os.switch[i].sellRSI);
}
}
log.info('*** Optimizer data is already present, disabling T5optifilesave now');
context.settings.enableT5optifilesave = false;
} catch (error) {
this.data = rsiOptimizer.data;
for (let i=51; i<= 70; i++) {
@ -33,9 +50,8 @@ rsiOptimizer.init = function(context) {
this.data.buyTreshold = context.settings.thresholds.RSIhigh;
this.data.sellTreshold = context.settings.thresholds.RSIlow;
log.info('*** Runtime optimizer: Started with blank trade history dataset!');
log.info('*** Runtime optimizer: Using initial RSI values', this.data.buyTreshold, '/', this.data.sellTreshold);
//log.info('*** Runtime optimizer: Dynamically optimize strategy for the last', context.settings.limitT5optitrades,'trades');
log.info('*** T5 Runtime optimizer: Started with blank trade history dataset!');
log.info('*** T5 Runtime optimizer: Using initial RSI values', this.data.buyTreshold, '/', this.data.sellTreshold);
}
//autosave optimizer data
@ -51,8 +67,28 @@ rsiOptimizer.init = function(context) {
}
rsiOptimizer.checkRSIadjustment = function(dtCandle) {
if (this.T5os != undefined && this.T5os.switch != undefined && this.T5os.switch.length >= 2) {
for (let i=this.T5os.switch.length-1; i >= 0; i--) {
if (dtCandle >= this.T5os.switch[i].date) {
if (this.data.buyTreshold != Number(this.T5os.switch[i].buyRSI) || this.data.sellTreshold != Number(this.T5os.switch[i].sellRSI)) {
console.log(''); //blank line
log.info('*** T5 optimizer: Changing RSI thresholds to', this.T5os.switch[i].buyRSI, '/' , this.T5os.switch[i].sellRSI);
console.log(''); //blank line
this.data.buyTreshold = Number(this.T5os.switch[i].buyRSI);
this.data.sellTreshold = Number(this.T5os.switch[i].sellRSI);
}
break;
}
}
}
}
rsiOptimizer.logPossibleSells = function(rsi, price, start) {
if (this.enabled === false) return;
this.checkRSIadjustment(start);
for (let i=51; i<= 70; i++) {
for (let j=30; j<= 50; j++) {
@ -75,21 +111,12 @@ rsiOptimizer.logPossibleSells = function(rsi, price, start) {
}
}
}
//calc new, best rsi results when the price has moved 10% from the last check
/*
let pricediff = Math.abs(this.lastCheckedPrice - price) / price;
if (pricediff > 0.01) {
this.lastCheckedPrice = price;
this.getBestResults();
}
*/
}
rsiOptimizer.logPossibleBuys = function(rsi, price, start) {
if (this.enabled === false) return;
this.checkRSIadjustment(start);
for (let i=51; i<= 70; i++) {
if (rsi > i) {
@ -112,41 +139,55 @@ rsiOptimizer.logPossibleBuys = function(rsi, price, start) {
}
rsiOptimizer.getBestResults = function(forceCalc) {
rsiOptimizer.getBestResults = function(from, to, testBuyRsi, testSellRsi) {
this.best = {
totalProfit: 0,
buyRsi: 51,
sellRsi: 30,
};
//calc profit for a certain timeframe
if (from != undefined && to != undefined) {
for (var i=51; i<= 70; i++) {
for (var j=30; j<= 50; j++) {
this.data['Buy'+i]['Sell'+j].profit = 0;
for (var k=0; k<this.data['Buy'+i]['Sell'+j].trades.length; k++) {
if (this.data['Buy'+i]['Sell'+j].trades[k].type == 'sell' && this.data['Buy'+i]['Sell'+j].trades[k].date >= from && this.data['Buy'+i]['Sell'+j].trades[k].date <= to) {
this.data['Buy'+i]['Sell'+j].profit += this.data['Buy'+i]['Sell'+j].trades[k].profit;
}
}
}
}
}
else {
for (var i=51; i<= 70; i++) {
for (var j=30; j<= 50; j++) {
this.data['Buy'+i]['Sell'+j].profit = 0;
for (var k=0; k<this.data['Buy'+i]['Sell'+j].trades.length; k++) {
if (this.data['Buy'+i]['Sell'+j].trades[k].type == 'sell') {
this.data['Buy'+i]['Sell'+j].profit += this.data['Buy'+i]['Sell'+j].trades[k].profit;
}
}
}
}
}
for (var i=51; i<= 70; i++) {
for (var j=30; j<= 50; j++) {
if (this.data['Buy'+i]['Sell'+j].profit >= this.best.totalProfit) {
this.best.totalProfit = this.data['Buy'+i]['Sell'+j].profit;
this.best.buyRsi = i;
this.best.sellRsi = j;
this.best.changed = true;
//console.log('bestProfit:', this.best.totalProfit, this.best.buyRsi, this.best.sellRsi);
}
}
}
if (forceCalc) {
this.data.buyTreshold = this.best.buyRsi;
this.data.sellTreshold = this.best.sellRsi;
}
this.best.from = this.data['Buy'+this.best.buyRsi]['Sell'+this.best.sellRsi].trades[0].date;
this.best.to = this.data['Buy'+this.best.buyRsi]['Sell'+this.best.sellRsi].trades[this.data['Buy'+this.best.buyRsi]['Sell'+this.best.sellRsi].trades.length-1].date;
if (this.best.changed && this.data.buyTreshold !== this.best.buyRsi && this.data.sellTreshold !== this.best.sellRsi) {
this.best.changed = false;
//change rsi params dynamically when optimized enough trades
var tLength = this.data['Buy'+this.best.buyRsi]['Sell'+this.best.sellRsi].trades.length;
if (forceCalc || tLength >= this.limitT5optitrades-2) {
this.data.buyTreshold = this.best.buyRsi;
this.data.sellTreshold = this.best.sellRsi;
console.log('*** Runtime optimizer: Changing strategy RSIs to', this.data.buyTreshold, '/', this.data.sellTreshold);
}
else {
console.log('*** Runtime optimizer: Best strategy RSIs during last', tLength, 'trades (but not applied yet)', this.best.buyRsi, '/', this.best.sellRsi);
}
if (testBuyRsi != undefined && testSellRsi != undefined) {
this.best.testRsiProfit = this.data['Buy'+testBuyRsi]['Sell'+testSellRsi].profit;
}
}

Loading…
Cancel
Save