gekkowarez / gekkoga

Genetic Algorithm for solving optimization of trading strategies using Gekko
309 stars 106 forks source link

Error 500 even though ui shows it's working #30

Open dordsor21 opened 6 years ago

dordsor21 commented 6 years ago

The same error 500 "Internal Server Error" everyone's getting.

It's clearly running fine in the ui - https://pastebin.com/raw/3rJxqC0t with no errors that I can see anywhere.

Yet gekkoga still falls on its face.

Red-Maximus commented 6 years ago

I am having the same issue.

lenzoburger commented 6 years ago

I think it is related to gekkoGA not supporting nested Arrays in Strat files. See the issue #24 for more details and solution.

xFFFFF commented 6 years ago

Starting GA with epoch populations of 20, running 5 units at a time!
{ StatusCodeError: 500 - "Internal Server Error"
    at new StatusCodeError (/home/f/!skrypty/gekko/gekkoga/node_modules/request-promise-core/lib/errors.js:32:15)
    at Request.plumbing.callback (/home/f/!skrypty/gekko/gekkoga/node_modules/request-promise-core/lib/plumbing.js:104:33)
    at Request.RP$callback [as _callback] (/home/f/!skrypty/gekko/gekkoga/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at Request.self.callback (/home/f/!skrypty/gekko/gekkoga/node_modules/request/request.js:186:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (/home/f/!skrypty/gekko/gekkoga/node_modules/request/request.js:1163:10)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at IncomingMessage.<anonymous> (/home/f/!skrypty/gekko/gekkoga/node_modules/request/request.js:1085:12)
    at Object.onceWrapper (events.js:313:30)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1055:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
  name: 'StatusCodeError',
  statusCode: 500,
  message: '500 - "Internal Server Error"',
  error: 'Internal Server Error',
  options: 
   { url: 'http://localhost:3000/api/backtest',
     json: true,
     body: { gekkoConfig: [Object], data: [Object] },
     headers: { 'Content-Type': 'application/json' },
     timeout: 1200000,
     method: 'POST',
     callback: [Function: RP$callback],
     transform: undefined,
     simple: true,
     resolveWithFullResponse: false,
     transform2xxOnly: false },
  response: 
   IncomingMessage {
     _readableState: 
      ReadableState {
        objectMode: false,
        highWaterMark: 16384,
        buffer: [Object],
        length: 0,
        pipes: null,
        pipesCount: 0,
        flowing: true,
        ended: true,
        endEmitted: true,
        reading: false,
        sync: true,
        needReadable: false,
        emittedReadable: false,
        readableListening: false,
        resumeScheduled: false,
        destroyed: false,
        defaultEncoding: 'utf8',
        awaitDrain: 0,
        readingMore: false,
        decoder: null,
        encoding: null },
     readable: false,
     domain: null,
     _events: 
      { end: [Array],
        close: [Array],
        data: [Function],
        error: [Function] },
     _eventsCount: 4,
     _maxListeners: undefined,
     socket: 
      Socket {
        connecting: false,
        _hadError: false,
        _handle: null,
        _parent: null,
        _host: 'localhost',
        _readableState: [Object],
        readable: false,
        domain: null,
        _events: [Object],
        _eventsCount: 9,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: false,
        allowHalfOpen: false,
        _bytesDispatched: 904,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: null,
        _server: null,
        parser: null,
        _httpMessage: [Object],
        read: [Function],
        _consuming: true,
        _idleTimeout: -1,
        _idleNext: null,
        _idlePrev: null,
        _idleStart: 2340,
        _destroyed: false,
        [Symbol(asyncId)]: 19,
        [Symbol(bytesRead)]: 176,
        [Symbol(asyncId)]: 62,
        [Symbol(triggerAsyncId)]: 55 },
     connection: 
      Socket {
        connecting: false,
        _hadError: false,
        _handle: null,
        _parent: null,
        _host: 'localhost',
        _readableState: [Object],
        readable: false,
        domain: null,
        _events: [Object],
        _eventsCount: 9,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: false,
        allowHalfOpen: false,
        _bytesDispatched: 904,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: null,
        _server: null,
        parser: null,
        _httpMessage: [Object],
        read: [Function],
        _consuming: true,
        _idleTimeout: -1,
        _idleNext: null,
        _idlePrev: null,
        _idleStart: 2340,
        _destroyed: false,
        [Symbol(asyncId)]: 19,
        [Symbol(bytesRead)]: 176,
        [Symbol(asyncId)]: 62,
        [Symbol(triggerAsyncId)]: 55 },
     httpVersionMajor: 1,
     httpVersionMinor: 1,
     httpVersion: '1.1',
     complete: true,
     headers: 
      { 'content-type': 'text/plain; charset=utf-8',
        'content-length': '21',
        date: 'Wed, 14 Feb 2018 12:21:32 GMT',
        connection: 'close' },
     rawHeaders: 
      [ 'Content-Type',
        'text/plain; charset=utf-8',
        'Content-Length',
        '21',
        'Date',
        'Wed, 14 Feb 2018 12:21:32 GMT',
        'Connection',
        'close' ],
     trailers: {},
     rawTrailers: [],
     upgrade: false,
     url: '',
     method: null,
     statusCode: 500,
     statusMessage: 'Internal Server Error',
     client: 
      Socket {
        connecting: false,
        _hadError: false,
        _handle: null,
        _parent: null,
        _host: 'localhost',
        _readableState: [Object],
        readable: false,
        domain: null,
        _events: [Object],
        _eventsCount: 9,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: false,
        allowHalfOpen: false,
        _bytesDispatched: 904,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: null,
        _server: null,
        parser: null,
        _httpMessage: [Object],
        read: [Function],
        _consuming: true,
        _idleTimeout: -1,
        _idleNext: null,
        _idlePrev: null,
        _idleStart: 2340,
        _destroyed: false,
        [Symbol(asyncId)]: 19,
        [Symbol(bytesRead)]: 176,
        [Symbol(asyncId)]: 62,
        [Symbol(triggerAsyncId)]: 55 },
     _consuming: true,
     _dumped: false,
     req: 
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 6,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: true,
        upgrading: false,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedConnection: false,
        _removedContLen: false,
        _removedTE: false,
        _contentLength: null,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [Object],
        connection: [Object],
        _header: 'POST /api/backtest HTTP/1.1\r\nContent-Type: application/json\r\nhost: localhost:3000\r\naccept: application/json\r\ncontent-length: 753\r\nConnection: close\r\n\r\n',
        _onPendingData: [Function: noopPendingOutput],
        agent: [Object],
        socketPath: undefined,
        timeout: undefined,
        method: 'POST',
        path: '/api/backtest',
        _ended: true,
        res: [Circular],
        aborted: undefined,
        timeoutCb: [Function: emitTimeout],
        upgradeOrConnect: false,
        parser: null,
        maxHeadersCount: null,
        [Symbol(outHeadersKey)]: [Object] },
     request: 
      Request {
        domain: null,
        _events: [Object],
        _eventsCount: 5,
        _maxListeners: undefined,
        body: '{"gekkoConfig":{"watch":{"exchange":"binance","currency":"BTC","asset":"MOD"},"paperTrader":{"slippage":0.05,"feeTaker":0.25,"feeMaker":0.15,"feeUsing":"taker","simulationBalance":{"asset":1,"currency":1},"reportRoundtrips":true,"enabled":true},"writer":{"enabled":false,"logpath":""},"tradingAdvisor":{"enabled":true,"method":"custom_macd","candleSize":10,"historySize":5},"trader":{"enabled":false},"backtest":{"daterange":"scan"},"performanceAnalyzer":{"riskFreeReturn":5,"enabled":true},"valid":true,"custom_macd":{"historySize":5,"macd_short":10,"macd_long":29,"macd_signal":12,"macd_up":"3.58","macd_down":"-12.72","candleSize":10}},"data":{"candleProps":["close","start"],"indicatorResults":false,"report":true,"roundtrips":false,"trades":false}}',
        headers: [Object],
        timeout: 1200000,
        method: 'POST',
        readable: true,
        writable: true,
        explicitMethod: true,
        _qs: [Object],
        _auth: [Object],
        _oauth: [Object],
        _multipart: [Object],
        _redirect: [Object],
        _tunnel: [Object],
        _rp_resolve: [Function],
        _rp_reject: [Function],
        _rp_promise: [Object],
        _rp_callbackOrig: undefined,
        callback: [Function],
        _rp_options: [Object],
        setHeader: [Function],
        hasHeader: [Function],
        getHeader: [Function],
        removeHeader: [Function],
        localAddress: undefined,
        pool: {},
        dests: [],
        __isRequestRequest: true,
        _callback: [Function: RP$callback],
        uri: [Object],
        proxy: null,
        tunnel: false,
        setHost: true,
        originalCookieHeader: undefined,
        _disableCookies: true,
        _jar: undefined,
        port: '3000',
        host: 'localhost',
        path: '/api/backtest',
        _json: true,
        httpModule: [Object],
        agentClass: [Object],
        agent: [Object],
        _started: true,
        href: 'http://localhost:3000/api/backtest',
        req: [Object],
        ntick: true,
        timeoutTimer: null,
        response: [Circular],
        originalHost: 'localhost:3000',
        originalHostHeaderName: 'host',
        responseContent: [Circular],
        _destdata: true,
        _ended: true,
        _callbackCalled: true },
     toJSON: [Function: responseToJSON],
     caseless: Caseless { dict: [Object] },
     read: [Function],
     body: 'Internal Server Error' } }```
AtlanticSkyrocket commented 6 years ago

It might be the specific strat your are evaluating. I can run gekkkoGA fine with some public strats (StrategoSLv7, BodhiDI, and scalp) once I make sure the variables/parameters are set correct in the gekkoga config/strat and within the strat itself.

dwarda commented 6 years ago

I am having the same error. did you guys figure out how to fix it? i am running gekko 5.0.12

generalectric commented 6 years ago

@dwarda 500 internal server is going to be strat not found... or the data is not available... one of those two. Double check your stratname and strat filename make sure they are the same (minus the .js in your config). Minimize your daterange to a few hours of data you are 100% sure that you have. Make sure your db settings are correct in ~/gekko/web/routes/baseConfig.js.... and increase your timeout setting in ~/gekko/web/vue/UIconfig.js if you plan on running larger datasets, parallelqueries, or smaller candles.

JasLin commented 6 years ago

@generalectric after print trace some debug information, i found this issue is cause by problem of the implementing of [stream] (https://nodejs.org/api/stream.html#stream_buffering) in gekko

api/backtest will randomly stop on this line

this.push(c);

I guess the buffer increase to the highWaterMark limit of stream buffer.

because consumer process speed is lower then reader push() speed. this stream implementing is little complex , I have no idea how to fix it yet.

generalectric commented 6 years ago

@JasLin i havent seen any of the behavior you're experiencing, have you managed to get it sorted out yet?