gekko icon indicating copy to clipboard operation
gekko copied to clipboard

For Nodejs Gekko Genetic algo discussion

Open thegamecat opened this issue 9 years ago • 56 comments

Separating this from the other issue.

thegamecat avatar Sep 09 '17 18:09 thegamecat

Re: http://gekkowarez.com/gekko-genetic-algorithm/

Hey @thegamecat - thanks for sharing this :)

I'm getting an error at this step though:

[gekko]$ node run-ga-parallel.js
/home/gekko/run-ga-parallel.js:206
            "data": {
            ^^^^^^

SyntaxError: Unexpected string
    at createScript (vm.js:74:10)
    at Object.runInThisContext (vm.js:116:10)
    at Module._compile (module.js:537:28)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)
    at Function.Module._load (module.js:462:3)
    at Function.Module.runMain (module.js:609:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:598:3

Any ideas?

imkane avatar Sep 09 '17 18:09 imkane

Do I really have to long in, to download this? Can someone give me a link?

Edit: never mind i logged in

krieghof avatar Sep 09 '17 18:09 krieghof

@imkane I said this in the other thread as well, but just add the comment closure tag to wrap the specified date range option.

mnoseworthy avatar Sep 09 '17 19:09 mnoseworthy

@mnoseworthy Thanks! Good catch.

Now I'm getting errors from my terminal1 that's running the server:

  <-- POST /api/backtest
2017-09-09 12:23:44 (INFO):     Setting up Gekko in backtest mode
2017-09-09 12:23:44 (INFO):
2017-09-09 12:23:44 (INFO):     Setting up:
2017-09-09 12:23:44 (INFO):              Trading Advisor
2017-09-09 12:23:44 (INFO):              Calculate trading advice
  xxx POST /api/backtest 500 413ms -

  Error: non-error thrown: Child process has died.
      at Object.onerror (/home/gekko/node_modules/koa/lib/context.js:105:40)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

Has anyone seen this before?

imkane avatar Sep 09 '17 19:09 imkane

@imkane This is due to your trading method being configured improperly, post your gekkoConfig object

mnoseworthy avatar Sep 09 '17 19:09 mnoseworthy

Ok, I think I'm slowly getting it lol

In config.js:

// RSI settings:
config.RSI = {
  interval: 8,
  thresholds: {
    low: 29,
    high: 68,
    // How many candle intervals should a trend persist
    // before we consider it real?
    persistence: 1
  }
};

In run-ga-parallel.js:

"gekkoConfig": {
                "watch": {
                    "exchange": "gdax",
                    "currency": "BTC",
                    "asset": "LTC"
                },
                "paperTrader": {
                    "fee": 0.25,
                    "slippage": 0.05,
                    "feeTaker": 0.25,
                    "feeUsing": "maker",					
                    "simulationBalance": {
                        "asset": 1,
                        "currency": 100
                    },
                    "reportRoundtrips": true,
                    "enabled": true
                },
				"writer": {
					"enabled": false,
					"logpath": ""
				},				
                "tradingAdvisor": {
                    "enabled": true,
                    "method": "RSI",
					"candleSize": data.candleSize,
//					"candleSize": 1,
                    "historySize": 10,
					  talib: {
							enabled: false,
							version: '1.0.2'
					}
                },
//this is just the same as your usual setup in config.js				
                "add your strategy here, it's the same name you use in config.js": {
                    "parameters": {
                        "interval": 8,
                        "thresholds": {
				//here we reference the indicator range outputs into the config
				"low": data.rsilong,
				"high": data.rsishort,
				"persistence": 1
			}				
                    },
               },
                "backtest": {
//use scan or a daterange by commenting / uncommenting out					
					//"daterange": "scan",
                   "daterange": {
                        "from": "2017-07-01 00:00:00",
                        "to": "2017-08-01 00:00:00"
						}					
				},
                "performanceAnalyzer": {
                    "riskFreeReturn": 5,
                    "enabled": true
                },
                "valid": true
            },
            "data": {
                "candleProps": ["close", "start"],
                "indicatorResults": true,
                "report": true,
                "roundtrips": true,
                "trades": true
            }

New error:

2017-09-09 12:35:18 (INFO):              Using the strategy: RSI
/home/gekko/strategies/indicators/RSI.js:6
  this.weight = settings.interval;
                        ^

TypeError: Cannot read property 'interval' of undefined
    at new Indicator (/home/gekko/strategies/indicators/RSI.js:6:25)
    at Base.addIndicator (/home/gekko/plugins/tradingAdvisor/baseTradingMethod.js:290:27)
    at Base.bound [as addIndicator] (/home/gekko/node_modules/lodash/dist/lodash.js:729:21)
    at Base.method.init (/home/gekko/strategies/RSI.js:34:8)
    at Base.bound [as init] (/home/gekko/node_modules/lodash/dist/lodash.js:729:21)
    at new Base (/home/gekko/plugins/tradingAdvisor/baseTradingMethod.js:117:8)
    at Actor.setupTradingMethod (/home/gekko/plugins/tradingAdvisor/tradingAdvisor.js:58:17)
    at Actor.bound [as setupTradingMethod] (/home/gekko/node_modules/lodash/dist/lodash.js:729:21)
    at new Actor (/home/gekko/plugins/tradingAdvisor/tradingAdvisor.js:23:8)
    at load (/home/gekko/core/pluginUtil.js:95:22)
  xxx POST /api/backtest 500 543ms -

  Error: non-error thrown: Child process has died.
      at Object.onerror (/home/gekko/node_modules/koa/lib/context.js:105:40)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

imkane avatar Sep 09 '17 19:09 imkane

            "add your strategy here, it's the same name you use in config.js": {
                "parameters": {

put your strat name in the first bit: "add your strategy here, it's the same name you use in config.js": {

Then delete the parameters line and the corresponding closure.

thegamecat avatar Sep 09 '17 19:09 thegamecat

For example:

          "divergeance": {
				  "logging": false,
				  "interval": 25,
				  "historylength": data.historylength,
				  "candleintervallong": data.candleintervallong,
				  "candleintervalshort": data.candleintervalshort,
				  "pricelldiff": data.pricelldiff,
				  "pricehhdiff": data.pricehhdiff
            },

thegamecat avatar Sep 09 '17 19:09 thegamecat

@thegamecat I can't get profit outputs, I've tracked it down to asset getting set as NaN in the performance Analyzer instance, which was probably bled through other plugin's as well. Any idea why this would occur?

Edit: This only seems to happen when I use a DASH pairing

Edit 2: Nevermind, It seems to not occur the first time running a specific pair, but any tests after the first it occurs

mnoseworthy avatar Sep 09 '17 19:09 mnoseworthy

It maybe you need to start with both currency and asset having values, neither can be 0 (I think...)

thegamecat avatar Sep 09 '17 20:09 thegamecat

@thegamecat I have the defaults left for that, { ... asset : 1, currency: 100 ...}

mnoseworthy avatar Sep 09 '17 20:09 mnoseworthy

Oh god I have no idea then. Maybe worth chucking up some code.

thegamecat avatar Sep 09 '17 20:09 thegamecat

@thegamecat Very odd, on the first run of a pair, the asset is set correctly and therefore the profit calculations work. However, as soon as a trade is made, the asset becomes NaN, and currency 0. This occurs even if i reset the server. Then, the second time the script is ran, no profits are calculated.

Values in performanceAnalyzer: On init: { asset: 1, currency: 100, balance: 428.11 } After first position open: { asset: NaN, currency: 0, balance: 428.11 } Which on positon close changes to: { asset: 0, currency: NaN, balance: 428.11 }

Here's my config:

        let outconfig = {
            "gekkoConfig": {
                "watch": {
                    "exchange": "gdax",
                    "currency": "USD",
                    "asset": "ETH"
                },
                "paperTrader": {
                    "fee": 0.25,
                    "slippage": 0.05,
                    "feeTaker": 0.25,
                    "feeUsing": "maker",
                    "reportInCurrency": true,					
                    "simulationBalance": {
                        "asset": 1,
                        "currency": 100
                    },
                    "reportRoundtrips": true,
                    "enabled": true
                },
				"writer": {
					"enabled": false,
					"logpath": ""
				},				
                "tradingAdvisor": {
                    "enabled": true,
                    "method": "RSI",
					"candleSize": data.candleSize,
//					"candleSize": 1,
                    "historySize": 10,
					  talib: {
							enabled: false,
							version: '1.0.2'
					}
                },
               'MACD' : {

                        'short': data.rsishort,
                        'long': data.rsilong,
                        'signal': 9,
                        // the difference between the EMAs (to act as triggers)
                        'thresholds': {
                            'down': -0.025,
                            'up': 0.025,
                            // How many candle intervals should a trend persist
                            // before we consider it real?
                            'persistence': 1
                        }
                    
                },
                'RSI' : {
                    interval: 14,
                    thresholds: {
                      low: data.rsilow,
                      high: data.rsihigh,
                      // How many candle intervals should a trend persist
                      // before we consider it real?
                      persistence: 1
                    }
                },
                "backtest": {
//use scan or a daterange by commenting / uncommenting out					
					//"daterange": "scan",
                   "daterange": {
                        "from": "	2017-09-07 04:00",
                        "to": "	2017-09-07 19:00"
                   },
                   "bactchSize" : 50

					
				},
                "performanceAnalyzer": {
                    "riskFreeReturn": 5,
                    "enabled": true
                },
                "valid": true
            },
            "data": {
                "candleProps": ["close", "start"],
                "indicatorResults": true,
                "report": true,
                "roundtrips": true,
                "trades": true
            }
        };

Here's a print-out of the first iteration (calculates profit correctly):

{ trades: [],
  candles:
   [ { close: 329.92, start: '2017-09-07T04:00:00.000Z' },
     { close: 324.4, start: '2017-09-07T06:00:00.000Z' },
     { close: 330, start: '2017-09-07T08:00:00.000Z' },
     { close: 331.75, start: '2017-09-07T10:00:00.000Z' },
     { close: 335.87, start: '2017-09-07T12:00:00.000Z' },
     { close: 336.8, start: '2017-09-07T14:00:00.000Z' },
     { close: 333.44, start: '2017-09-07T16:00:00.000Z' } ],
  report:
   { currency: 'USD',
     asset: 'ETH',
     startTime: '2017-09-07 04:00:00',
     endTime: '2017-09-07 19:00:00',
     timespan: '15 hours',
     market: 1.7341745146444794,
     balance: 433.8,
     profit: 5.689999999999998,
     relativeProfit: 1.3290976618158794,
     yearlyProfit: '3322.96000000',
     relativeYearlyProfit: '776.19303450',
     startPrice: 328.11,
     endPrice: 333.8,
     trades: 0,
     startBalance: 428.11,
     sharpe: 0,
     alpha: 3.9558254853555184 },
  roundtrips: [] }
{ trades: [],
  candles:
   [ { close: 329.92, start: '2017-09-07T04:00:00.000Z' },
     { close: 324.4, start: '2017-09-07T06:00:00.000Z' },
     { close: 330, start: '2017-09-07T08:00:00.000Z' },
     { close: 331.75, start: '2017-09-07T10:00:00.000Z' },
     { close: 335.87, start: '2017-09-07T12:00:00.000Z' },
     { close: 336.8, start: '2017-09-07T14:00:00.000Z' },
     { close: 333.44, start: '2017-09-07T16:00:00.000Z' } ],
  report:
   { currency: 'USD',
     asset: 'ETH',
     startTime: '2017-09-07 04:00:00',
     endTime: '2017-09-07 19:00:00',
     timespan: '15 hours',
     market: 1.7341745146444794,
     balance: 433.8,
     profit: 5.689999999999998,
     relativeProfit: 1.3290976618158794,
     yearlyProfit: '3322.96000000',
     relativeYearlyProfit: '776.19303450',
     startPrice: 328.11,
     endPrice: 333.8,
     trades: 0,
     startBalance: 428.11,
     sharpe: 0,
     alpha: 3.9558254853555184 },
  roundtrips: [] }
{ trades:
   [ { action: 'buy',
       price: 328.96,
       portfolio: [Object],
       balance: null,
       date: '2017-09-07T06:15:00.000Z' } ],
  candles:
   [ { close: 327.23, start: '2017-09-07T04:00:00.000Z' },
     { close: 326.7, start: '2017-09-07T04:15:00.000Z' },
     { close: 327.49, start: '2017-09-07T04:30:00.000Z' },
     { close: 327.98, start: '2017-09-07T04:45:00.000Z' },
     { close: 329.52, start: '2017-09-07T05:00:00.000Z' },
     { close: 329.24, start: '2017-09-07T05:15:00.000Z' },
     { close: 329.84, start: '2017-09-07T05:30:00.000Z' },
     { close: 329.92, start: '2017-09-07T05:45:00.000Z' },
     { close: 327.9, start: '2017-09-07T06:00:00.000Z' },
     { close: 328.96, start: '2017-09-07T06:15:00.000Z' },
     { close: 327.16, start: '2017-09-07T06:30:00.000Z' },
     { close: 327.16, start: '2017-09-07T06:45:00.000Z' },
     { close: 325.91, start: '2017-09-07T07:00:00.000Z' },
     { close: 325.2, start: '2017-09-07T07:15:00.000Z' },
     { close: 325.27, start: '2017-09-07T07:30:00.000Z' },
     { close: 324.4, start: '2017-09-07T07:45:00.000Z' },
     { close: 324.11, start: '2017-09-07T08:00:00.000Z' },
     { close: 324.52, start: '2017-09-07T08:15:00.000Z' },
     { close: 324.59, start: '2017-09-07T08:30:00.000Z' },
     { close: 326.83, start: '2017-09-07T08:45:00.000Z' },
     { close: 326.5, start: '2017-09-07T09:00:00.000Z' },
     { close: 328.72, start: '2017-09-07T09:15:00.000Z' },
     { close: 330, start: '2017-09-07T09:30:00.000Z' },
     { close: 330, start: '2017-09-07T09:45:00.000Z' },
     { close: 330.76, start: '2017-09-07T10:00:00.000Z' },
     { close: 329.46, start: '2017-09-07T10:15:00.000Z' },
     { close: 328.84, start: '2017-09-07T10:30:00.000Z' },
     { close: 329.55, start: '2017-09-07T10:45:00.000Z' },
     { close: 329.33, start: '2017-09-07T11:00:00.000Z' },
     { close: 332.42, start: '2017-09-07T11:15:00.000Z' },
     { close: 330.51, start: '2017-09-07T11:30:00.000Z' },
     { close: 331.75, start: '2017-09-07T11:45:00.000Z' },
     { close: 331.72, start: '2017-09-07T12:00:00.000Z' },
     { close: 330.92, start: '2017-09-07T12:15:00.000Z' },
     { close: 331.4, start: '2017-09-07T12:30:00.000Z' },
     { close: 334.99, start: '2017-09-07T12:45:00.000Z' },
     { close: 334.96, start: '2017-09-07T13:00:00.000Z' },
     { close: 335.02, start: '2017-09-07T13:15:00.000Z' },
     { close: 334.91, start: '2017-09-07T13:30:00.000Z' },
     { close: 335.87, start: '2017-09-07T13:45:00.000Z' },
     { close: 335.57, start: '2017-09-07T14:00:00.000Z' },
     { close: 334.77, start: '2017-09-07T14:15:00.000Z' },
     { close: 335.98, start: '2017-09-07T14:30:00.000Z' },
     { close: 335.4, start: '2017-09-07T14:45:00.000Z' },
     { close: 335.5, start: '2017-09-07T15:00:00.000Z' },
     { close: 335.99, start: '2017-09-07T15:15:00.000Z' },
     { close: 337.4, start: '2017-09-07T15:30:00.000Z' },
     { close: 336.8, start: '2017-09-07T15:45:00.000Z' },
     { close: 338.31, start: '2017-09-07T16:00:00.000Z' },
     { close: 337.43, start: '2017-09-07T16:15:00.000Z' },
     { close: 337.34, start: '2017-09-07T16:30:00.000Z' },
     { close: 335.51, start: '2017-09-07T16:45:00.000Z' },
     { close: 333.1, start: '2017-09-07T17:00:00.000Z' },
     { close: 333.19, start: '2017-09-07T17:15:00.000Z' },
     { close: 333.34, start: '2017-09-07T17:30:00.000Z' },
     { close: 333.44, start: '2017-09-07T17:45:00.000Z' },
     { close: 333.71, start: '2017-09-07T18:00:00.000Z' },
     { close: 333.54, start: '2017-09-07T18:15:00.000Z' },
     { close: 333.14, start: '2017-09-07T18:30:00.000Z' },
     { close: 333.8, start: '2017-09-07T18:45:00.000Z' } ],
  report:
   { currency: 'USD',
     asset: 'ETH',
     startTime: '2017-09-07 04:00:00',
     endTime: '2017-09-07 19:00:00',
     timespan: '15 hours',
     market: 1.7341745146444794,
     balance: null,
     profit: null,
     relativeProfit: null,
     yearlyProfit: 'NaN',
     relativeYearlyProfit: 'NaN',
     startPrice: 328.11,
     endPrice: 333.8,
     trades: 1,
     startBalance: 428.11,
     sharpe: 0,
     alpha: null },
  roundtrips: [] }
--------------------------------------------------------------
Epoch number: 50
Time it took (seconds): 1.152
Max profit: 5.689999999999998$ max profit position: 0
Max parametars:
{ rsihigh: 73, rsilow: 17, candleSize: 120 }
Other metrics:
{ balance: 433.8,
  profit: 5.689999999999998,
  relativeProfit: 1.3290976618158794,
  yearlyProfit: '3322.96000000',
  relativeYearlyProfit: '776.19303450',
  startPrice: 328.11,
  endPrice: 333.8,
  trades: 0 }
--------------------------------------------------------------
Global maximum: 5.689999999999998$, parameters:
{ rsihigh: 73, rsilow: 17, candleSize: 120 }
Other metrics of global maximum:
Global maximum so far:
{ balance: 433.8,
  profit: 5.689999999999998,
  relativeProfit: 1.3290976618158794,
  yearlyProfit: '3322.96000000',
  relativeYearlyProfit: '776.19303450',
  startPrice: 328.11,
  endPrice: 333.8,
  trades: 0 }
--------------------------------------------------------------
`

and here's an output on a second script run, where it doesn't:
`
{ trades:
   [ { action: 'buy',
       price: 326.83,
       portfolio: [Object],
       balance: null,
       date: '2017-09-07T08:30:00.000Z' } ],
  candles:
   [ { close: 326.7, start: '2017-09-07T04:00:00.000Z' },
     { close: 327.98, start: '2017-09-07T04:30:00.000Z' },
     { close: 329.24, start: '2017-09-07T05:00:00.000Z' },
     { close: 329.92, start: '2017-09-07T05:30:00.000Z' },
     { close: 328.96, start: '2017-09-07T06:00:00.000Z' },
     { close: 327.16, start: '2017-09-07T06:30:00.000Z' },
     { close: 325.2, start: '2017-09-07T07:00:00.000Z' },
     { close: 324.4, start: '2017-09-07T07:30:00.000Z' },
     { close: 324.52, start: '2017-09-07T08:00:00.000Z' },
     { close: 326.83, start: '2017-09-07T08:30:00.000Z' },
     { close: 328.72, start: '2017-09-07T09:00:00.000Z' },
     { close: 330, start: '2017-09-07T09:30:00.000Z' },
     { close: 329.46, start: '2017-09-07T10:00:00.000Z' },
     { close: 329.55, start: '2017-09-07T10:30:00.000Z' },
     { close: 332.42, start: '2017-09-07T11:00:00.000Z' },
     { close: 331.75, start: '2017-09-07T11:30:00.000Z' },
     { close: 330.92, start: '2017-09-07T12:00:00.000Z' },
     { close: 334.99, start: '2017-09-07T12:30:00.000Z' },
     { close: 335.02, start: '2017-09-07T13:00:00.000Z' },
     { close: 335.87, start: '2017-09-07T13:30:00.000Z' },
     { close: 334.77, start: '2017-09-07T14:00:00.000Z' },
     { close: 335.4, start: '2017-09-07T14:30:00.000Z' },
     { close: 335.99, start: '2017-09-07T15:00:00.000Z' },
     { close: 336.8, start: '2017-09-07T15:30:00.000Z' },
     { close: 337.43, start: '2017-09-07T16:00:00.000Z' },
     { close: 335.51, start: '2017-09-07T16:30:00.000Z' },
     { close: 333.19, start: '2017-09-07T17:00:00.000Z' },
     { close: 333.44, start: '2017-09-07T17:30:00.000Z' },
     { close: 333.54, start: '2017-09-07T18:00:00.000Z' },
     { close: 333.8, start: '2017-09-07T18:30:00.000Z' } ],
  report:
   { currency: 'USD',
     asset: 'ETH',
     startTime: '2017-09-07 04:00:00',
     endTime: '2017-09-07 19:00:00',
     timespan: '15 hours',
     market: 1.7341745146444794,
     balance: null,
     profit: null,
     relativeProfit: null,
     yearlyProfit: 'NaN',
     relativeYearlyProfit: 'NaN',
     startPrice: 328.11,
     endPrice: 333.8,
     trades: 1,
     startBalance: 428.11,
     sharpe: 0,
     alpha: null },
  roundtrips: [] }
{ trades:
   [ { action: 'buy',
       price: 326.83,
       portfolio: [Object],
       balance: null,
       date: '2017-09-07T08:30:00.000Z' } ],
  candles:
   [ { close: 326.7, start: '2017-09-07T04:00:00.000Z' },
     { close: 327.98, start: '2017-09-07T04:30:00.000Z' },
     { close: 329.24, start: '2017-09-07T05:00:00.000Z' },
     { close: 329.92, start: '2017-09-07T05:30:00.000Z' },
     { close: 328.96, start: '2017-09-07T06:00:00.000Z' },
     { close: 327.16, start: '2017-09-07T06:30:00.000Z' },
     { close: 325.2, start: '2017-09-07T07:00:00.000Z' },
     { close: 324.4, start: '2017-09-07T07:30:00.000Z' },
     { close: 324.52, start: '2017-09-07T08:00:00.000Z' },
     { close: 326.83, start: '2017-09-07T08:30:00.000Z' },
     { close: 328.72, start: '2017-09-07T09:00:00.000Z' },
     { close: 330, start: '2017-09-07T09:30:00.000Z' },
     { close: 329.46, start: '2017-09-07T10:00:00.000Z' },
     { close: 329.55, start: '2017-09-07T10:30:00.000Z' },
     { close: 332.42, start: '2017-09-07T11:00:00.000Z' },
     { close: 331.75, start: '2017-09-07T11:30:00.000Z' },
     { close: 330.92, start: '2017-09-07T12:00:00.000Z' },
     { close: 334.99, start: '2017-09-07T12:30:00.000Z' },
     { close: 335.02, start: '2017-09-07T13:00:00.000Z' },
     { close: 335.87, start: '2017-09-07T13:30:00.000Z' },
     { close: 334.77, start: '2017-09-07T14:00:00.000Z' },
     { close: 335.4, start: '2017-09-07T14:30:00.000Z' },
     { close: 335.99, start: '2017-09-07T15:00:00.000Z' },
     { close: 336.8, start: '2017-09-07T15:30:00.000Z' },
     { close: 337.43, start: '2017-09-07T16:00:00.000Z' },
     { close: 335.51, start: '2017-09-07T16:30:00.000Z' },
     { close: 333.19, start: '2017-09-07T17:00:00.000Z' },
     { close: 333.44, start: '2017-09-07T17:30:00.000Z' },
     { close: 333.54, start: '2017-09-07T18:00:00.000Z' },
     { close: 333.8, start: '2017-09-07T18:30:00.000Z' } ],
  report:
   { currency: 'USD',
     asset: 'ETH',
     startTime: '2017-09-07 04:00:00',
     endTime: '2017-09-07 19:00:00',
     timespan: '15 hours',
     market: 1.7341745146444794,
     balance: null,
     profit: null,
     relativeProfit: null,
     yearlyProfit: 'NaN',
     relativeYearlyProfit: 'NaN',
     startPrice: 328.11,
     endPrice: 333.8,
     trades: 1,
     startBalance: 428.11,
     sharpe: 0,
     alpha: null },
  roundtrips: [] }
--------------------------------------------------------------
Epoch number: 1
Time it took (seconds): 0.954
Max profit: 0$ max profit position: 0
Max parametars:
{ rsihigh: 74, rsilow: 33, candleSize: 30 }
Other metrics:
{ balance: 0,
  profit: 0,
  relativeProfit: 0,
  yearlyProfit: 0,
  relativeYearlyProfit: 0,
  startPrice: 328.11,
  endPrice: 333.8,
  trades: 1 }
--------------------------------------------------------------
Global maximum: 0$, parameters:
{ rsihigh: 74, rsilow: 33, candleSize: 30 }
Other metrics of global maximum:
Global maximum so far:
{ balance: 0,
  profit: 0,
  relativeProfit: 0,
  yearlyProfit: 0,
  relativeYearlyProfit: 0,
  startPrice: 328.11,
  endPrice: 333.8,
  trades: 1 }
--------------------------------------------------------------
{ trades:
   [ { action: 'buy',
       price: 326.83,
       portfolio: [Object],
       balance: null,
       date: '2017-09-07T08:30:00.000Z' } ],
  candles:
   [ { close: 326.7, start: '2017-09-07T04:00:00.000Z' },
     { close: 327.98, start: '2017-09-07T04:30:00.000Z' },
     { close: 329.24, start: '2017-09-07T05:00:00.000Z' },
     { close: 329.92, start: '2017-09-07T05:30:00.000Z' },
     { close: 328.96, start: '2017-09-07T06:00:00.000Z' },
     { close: 327.16, start: '2017-09-07T06:30:00.000Z' },
     { close: 325.2, start: '2017-09-07T07:00:00.000Z' },
     { close: 324.4, start: '2017-09-07T07:30:00.000Z' },
     { close: 324.52, start: '2017-09-07T08:00:00.000Z' },
     { close: 326.83, start: '2017-09-07T08:30:00.000Z' },
     { close: 328.72, start: '2017-09-07T09:00:00.000Z' },
     { close: 330, start: '2017-09-07T09:30:00.000Z' },
     { close: 329.46, start: '2017-09-07T10:00:00.000Z' },
     { close: 329.55, start: '2017-09-07T10:30:00.000Z' },
     { close: 332.42, start: '2017-09-07T11:00:00.000Z' },
     { close: 331.75, start: '2017-09-07T11:30:00.000Z' },
     { close: 330.92, start: '2017-09-07T12:00:00.000Z' },
     { close: 334.99, start: '2017-09-07T12:30:00.000Z' },
     { close: 335.02, start: '2017-09-07T13:00:00.000Z' },
     { close: 335.87, start: '2017-09-07T13:30:00.000Z' },
     { close: 334.77, start: '2017-09-07T14:00:00.000Z' },
     { close: 335.4, start: '2017-09-07T14:30:00.000Z' },
     { close: 335.99, start: '2017-09-07T15:00:00.000Z' },
     { close: 336.8, start: '2017-09-07T15:30:00.000Z' },
     { close: 337.43, start: '2017-09-07T16:00:00.000Z' },
     { close: 335.51, start: '2017-09-07T16:30:00.000Z' },
     { close: 333.19, start: '2017-09-07T17:00:00.000Z' },
     { close: 333.44, start: '2017-09-07T17:30:00.000Z' },
     { close: 333.54, start: '2017-09-07T18:00:00.000Z' },
     { close: 333.8, start: '2017-09-07T18:30:00.000Z' } ],
  report:
   { currency: 'USD',
     asset: 'ETH',
     startTime: '2017-09-07 04:00:00',
     endTime: '2017-09-07 19:00:00',
     timespan: '15 hours',
     market: 1.7341745146444794,
     balance: null,
     profit: null,
     relativeProfit: null,
     yearlyProfit: 'NaN',
     relativeYearlyProfit: 'NaN',
     startPrice: 328.11,
     endPrice: 333.8,
     trades: 1,
     startBalance: 428.11,
     sharpe: 0,
     alpha: null },
  roundtrips: [] }
{ trades: [],
  candles:
   [ { close: 329.92, start: '2017-09-07T04:00:00.000Z' },
     { close: 324.4, start: '2017-09-07T06:00:00.000Z' },
     { close: 330, start: '2017-09-07T08:00:00.000Z' },
     { close: 331.75, start: '2017-09-07T10:00:00.000Z' },
     { close: 335.87, start: '2017-09-07T12:00:00.000Z' },
     { close: 336.8, start: '2017-09-07T14:00:00.000Z' },
     { close: 333.44, start: '2017-09-07T16:00:00.000Z' } ],
  report:
   { currency: 'USD',
     asset: 'ETH',
     startTime: '2017-09-07 04:00:00',
     endTime: '2017-09-07 19:00:00',
     timespan: '15 hours',
     market: 1.7341745146444794,
     balance: 433.8,
     profit: 5.689999999999998,
     relativeProfit: 1.3290976618158794,
     yearlyProfit: '3322.96000000',
     relativeYearlyProfit: '776.19303450',
     startPrice: 328.11,
     endPrice: 333.8,
     trades: 0,
     startBalance: 428.11,
     sharpe: 0,
     alpha: 3.9558254853555184 },
  roundtrips: [] }
{ trades:
   [ { action: 'buy',
       price: 326.83,
       portfolio: [Object],
       balance: null,
       date: '2017-09-07T08:30:00.000Z' } ],
  candles:
   [ { close: 326.7, start: '2017-09-07T04:00:00.000Z' },
     { close: 327.98, start: '2017-09-07T04:30:00.000Z' },
     { close: 329.24, start: '2017-09-07T05:00:00.000Z' },
     { close: 329.92, start: '2017-09-07T05:30:00.000Z' },
     { close: 328.96, start: '2017-09-07T06:00:00.000Z' },
     { close: 327.16, start: '2017-09-07T06:30:00.000Z' },
     { close: 325.2, start: '2017-09-07T07:00:00.000Z' },
     { close: 324.4, start: '2017-09-07T07:30:00.000Z' },
     { close: 324.52, start: '2017-09-07T08:00:00.000Z' },
     { close: 326.83, start: '2017-09-07T08:30:00.000Z' },
     { close: 328.72, start: '2017-09-07T09:00:00.000Z' },
     { close: 330, start: '2017-09-07T09:30:00.000Z' },
     { close: 329.46, start: '2017-09-07T10:00:00.000Z' },
     { close: 329.55, start: '2017-09-07T10:30:00.000Z' },
     { close: 332.42, start: '2017-09-07T11:00:00.000Z' },
     { close: 331.75, start: '2017-09-07T11:30:00.000Z' },
     { close: 330.92, start: '2017-09-07T12:00:00.000Z' },
     { close: 334.99, start: '2017-09-07T12:30:00.000Z' },
     { close: 335.02, start: '2017-09-07T13:00:00.000Z' },
     { close: 335.87, start: '2017-09-07T13:30:00.000Z' },
     { close: 334.77, start: '2017-09-07T14:00:00.000Z' },
     { close: 335.4, start: '2017-09-07T14:30:00.000Z' },
     { close: 335.99, start: '2017-09-07T15:00:00.000Z' },
     { close: 336.8, start: '2017-09-07T15:30:00.000Z' },
     { close: 337.43, start: '2017-09-07T16:00:00.000Z' },
     { close: 335.51, start: '2017-09-07T16:30:00.000Z' },
     { close: 333.19, start: '2017-09-07T17:00:00.000Z' },
     { close: 333.44, start: '2017-09-07T17:30:00.000Z' },
     { close: 333.54, start: '2017-09-07T18:00:00.000Z' },
     { close: 333.8, start: '2017-09-07T18:30:00.000Z' } ],
  report:
   { currency: 'USD',
     asset: 'ETH',
     startTime: '2017-09-07 04:00:00',
     endTime: '2017-09-07 19:00:00',
     timespan: '15 hours',
     market: 1.7341745146444794,
     balance: null,
     profit: null,
     relativeProfit: null,
     yearlyProfit: 'NaN',
     relativeYearlyProfit: 'NaN',
     startPrice: 328.11,
     endPrice: 333.8,
     trades: 1,
     startBalance: 428.11,
     sharpe: 0,
     alpha: null },
  roundtrips: [] }
--------------------------------------------------------------
Epoch number: 2
Time it took (seconds): 1.108
Max profit: 0$ max profit position: 0
Max parametars:
{ rsihigh: 89, rsilow: 33, candleSize: 30 }
Other metrics:
{ balance: 0,
  profit: 0,
  relativeProfit: 0,
  yearlyProfit: 0,
  relativeYearlyProfit: 0,
  startPrice: 328.11,
  endPrice: 333.8,
  trades: 1 }
--------------------------------------------------------------
Global maximum: 0$, parameters:
{ rsihigh: 89, rsilow: 33, candleSize: 30 }
Other metrics of global maximum:
Global maximum so far:
{ balance: 0,
  profit: 0,
  relativeProfit: 0,
  yearlyProfit: 0,
  relativeYearlyProfit: 0,
  startPrice: 328.11,
  endPrice: 333.8,
  trades: 1 }
--------------------------------------------------------------

mnoseworthy avatar Sep 09 '17 20:09 mnoseworthy

Ok I'm not sure from that, can you try a month ? I don't know if you'll learn much from 12 hours (I'm happy to be wrong though).

Also, maybe ensure the candle size array doesn't have large candle sizes compared to your date range - could also be partly to blame.

thegamecat avatar Sep 09 '17 20:09 thegamecat

Edit: I forgot to mention that the console output shows 0's for everything because I made it sub NaN or null for 0.

Sure, here's the output from running a test over a month period (With only 1hour candles):


{ trades:
   [ { action: 'buy',
       price: 0.09239999,
       portfolio: [Object],
       balance: null,
       date: '2017-06-07T06:16:00.000Z' },
     { action: 'sell',
       price: 0.1493028,
       portfolio: [Object],
       balance: null,
       date: '2017-06-12T22:16:00.000Z' },
     { action: 'buy',
       price: 0.12793296,
       portfolio: [Object],
       balance: null,
       date: '2017-06-20T14:16:00.000Z' } ],
  candles:
   [ { close: 0.09248966, start: '2017-06-05T18:16:00.000Z' },
     { close: 0.08870465, start: '2017-06-05T22:16:00.000Z' },
     { close: 0.08980017, start: '2017-06-06T02:16:00.000Z' },
     { close: 0.08999998, start: '2017-06-06T06:16:00.000Z' },
     { close: 0.092, start: '2017-06-06T10:16:00.000Z' }
     ... all of the items ],
  report:
   { currency: 'BTC',
     asset: 'ETH',
     startTime: '2017-06-05 18:16:00',
     endTime: '2017-07-03 02:16:00',
     timespan: 'a month',
     market: 17.391316796534127,
     balance: null,
     profit: null,
     relativeProfit: null,
     yearlyProfit: 'NaN',
     relativeYearlyProfit: 'NaN',
     startPrice: 0.09429999,
     endPrice: 0.1107,
     trades: 3,
     startBalance: 100.09429999,
     sharpe: null,
     alpha: null },
  roundtrips:
   [ { entryAt: '2017-06-07T06:16:00.000Z',
       entryPrice: 0.09239999,
       entryBalance: null,
       exitAt: '2017-06-12T22:16:00.000Z',
       exitPrice: 0.1464,
       exitBalance: null,
       duration: 489600000,
       pnl: null,
       profit: null } ] }

mnoseworthy avatar Sep 09 '17 20:09 mnoseworthy

I really have no idea, not seen that before :(

thegamecat avatar Sep 09 '17 20:09 thegamecat

@thegamecat - thanks! I'm clearly dumb when it comes to debugging or understanding comments lol

imkane avatar Sep 09 '17 21:09 imkane

@thegamecat I've tracked it down to an error in paperTrader.js when initalizing this.fee:

this.fee = 1 - (calcConfig['fee' + calcConfig.feeUsing.charAt(0).toUpperCase() + calcConfig.feeUsing.slice(1)] + calcConfig.slippage) / 100;

The problem is of course, that the config parameter required.. was not set. Sorry for all the confusion for my silly problem. I've only recently started looking at this codebase and didn't understand the significance of the feeUsing parameter.

Upward and onward !

P.s. After I integrate my own strats into this, I may implement a UI for it. How would I approach contributing to this with you?

mnoseworthy avatar Sep 09 '17 21:09 mnoseworthy

Thats brilliant thanks @mnoseworthy - I've updated the file.

Also the GA is now on github again in this repo: https://github.com/thegamecat/gekko-trading-stuff

Just contact me on the discord group - I'm .zuki! @ https://discord.gg/Ws3M2A

thegamecat avatar Sep 09 '17 21:09 thegamecat

I let it run for awhile, then went back to look at terminal2:

Global maximum: 0$, parameters:
{ rsishort: 62, rsilong: 29, candleSize: 1440 }
Other metrics of global maximum:
Global maximum so far:
{ balance: null,
  profit: null,
  relativeProfit: null,
  yearlyProfit: 'NaN',
  relativeYearlyProfit: 'NaN',
  startPrice: 0.01605,
  endPrice: 0.01479,
  trades: 1 }
--------------------------------------------------------------
{ Error: socket hang up
    at createHangUpError (_http_client.js:345:15)
    at Socket.socketOnEnd (_http_client.js:437:23)
    at emitNone (events.js:110:20)
    at Socket.emit (events.js:207:7)
    at endReadableNT (_stream_readable.js:1059:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9) code: 'ECONNRESET' }
/home/arbitrage/gekko2/run-ga-parallel.js:229
                                        let report = body.report;
                                                         ^

TypeError: Cannot read property 'report' of undefined
    at Request._callback (/home/arbitrage/gekko2/run-ga-parallel.js:229:23)
    at self.callback (/home/arbitrage/gekko2/node_modules/request/request.js:188:22)
    at emitOne (events.js:115:13)
    at Request.emit (events.js:210:7)
    at Request.onRequestError (/home/arbitrage/gekko2/node_modules/request/request.js:884:8)
    at emitOne (events.js:115:13)
    at ClientRequest.emit (events.js:210:7)
    at Socket.socketOnEnd (_http_client.js:437:9)
    at emitNone (events.js:110:20)
    at Socket.emit (events.js:207:7)

imkane avatar Sep 09 '17 22:09 imkane