askmike / gekko

A bitcoin trading bot written in node - https://gekko.wizb.it/
MIT License
10.05k stars 3.95k forks source link

Weird error 2 #219

Closed NeoBelerophon closed 8 years ago

NeoBelerophon commented 10 years ago

Hi,

I had running gekko for 3-4 days and it stopped with this message below. Also when I restart gekko this message is shown.

2014-02-27 13:40:57 (INFO): Gekko v0.1.2 started
2014-02-27 13:40:57 (INFO): I'm gonna make you rich, Bud Fox. 

2014-02-27 13:40:57 (INFO): Setting up Gekko in realtime mode

2014-02-27 13:40:57 (INFO): Setting up:
2014-02-27 13:40:57 (INFO):      Trading Advisor
2014-02-27 13:40:57 (INFO):      Calculate trading advice
2014-02-27 13:40:57 (INFO):      Using the trading method: DEMA

2014-02-27 13:40:57 (INFO): Setting up:
2014-02-27 13:40:57 (INFO):      Profit Simulator
2014-02-27 13:40:57 (INFO):      Paper trader that logs fake profits.

2014-02-27 13:40:57 (INFO): Starting to watch the market: BTC-e BTC/EUR
2014-02-27 13:40:57 (DEBUG):    ~market start
2014-02-27 13:40:57 (DEBUG):    checking history
2014-02-27 13:40:58 (DEBUG):    ~watch market
2014-02-27 13:40:58 (DEBUG):    Requested BTC/EUR trade data from BTC-e ...
2014-02-27 13:41:07 (DEBUG):    Fetched 150 new trades, from 2014-02-27 08:40:11 UTC to 2014-02-27 12:33:33 UTC
2014-02-27 13:41:07 (INFO): We don't have enough history yet to start giving advice, I'll need to gather more data first.
2014-02-27 13:41:07 (INFO): I will start giving advice around 2014-02-28 14:41:00 (local time, that's in a day).
2014-02-27 13:41:07 (DEBUG):    minimum trade treshold: 2014-02-27 08:40:10 UTC
2014-02-27 13:41:07 (DEBUG):    processing 150 trade(s)
2014-02-27 13:41:07 (DEBUG):    from 2014-02-27T08:40:11+00:00 to 2014-02-27T12:33:33+00:00
c [ { s: 520,
    o: 417.059,
    h: 417.059,
    l: 417.059,
    c: 417.059,
    v: 0.121927,
    p: 417.059 },
  { s: 525, o: 417, h: 417, l: 417, c: 417, v: 0.0193097, p: 417 },
  { s: 529,
    o: 416.875,
    h: 416.875,
    l: 416.875,
    c: 416.875,
    v: 0.137,
    p: 416.875 },
  { s: 531,
    o: 412,
    h: 412,
    l: 412,
    c: 412,
    v: 4.373489999999999,
    p: 412 },
  { s: 533,
    o: 416.052,
    h: 416.052,
    l: 412,
    c: 412,
    v: 0.026000000000000002,
    p: 413.55846153846153 },
  { s: 534,
    o: 412,
    h: 412,
    l: 412,
    c: 412,
    v: 0.78018,
    p: 412.00000000000006 },
  { s: 540, o: 412, h: 412, l: 412, c: 412, v: 0.778016, p: 412 },
  { s: 543, o: 412, h: 412, l: 412, c: 412, v: 0.04150251, p: 412 },
  { s: 544, o: 412, h: 412, l: 412, c: 412, v: 0.01, p: 412 },
  { s: 545, o: 412, h: 412, l: 412, c: 412, v: 0.0510164, p: 412 },
  { s: 551,
    o: 416.958,
    h: 418.126,
    l: 416.958,
    c: 418.126,
    v: 0.0762391,
    p: 417.5233595149995 },
  { s: 555,
    o: 417.396,
    h: 417.615,
    l: 417.396,
    c: 417.615,
    v: 0.0325329,
    p: 417.52037121805927 },
  { s: 565,
    o: 419.015,
    h: 419.015,
    l: 419.015,
    c: 419.015,
    v: 0.23799990000000001,
    p: 419.01499999999993 },
  { s: 579,
    o: 412.1,
    h: 412.1,
    l: 412.1,
    c: 412.1,
    v: 2.68347,
    p: 412.09999999999997 },
  { s: 578,
    o: 412.1,
    h: 412.1,
    l: 407.21,
    c: 407.21,
    v: 9.61954862,
    p: 411.6599407463737 },
  { s: 580,
    o: 407.21,
    h: 407.21,
    l: 407.21,
    c: 407.21,
    v: 0.1137407,
    p: 407.21 },
  { s: 581,
    o: 408.039,
    h: 408.039,
    l: 406,
    c: 406,
    v: 5.7576559099999995,
    p: 406.919175376076 },
  { s: 582,
    o: 406,
    h: 408.647,
    l: 406,
    c: 408.647,
    v: 3.3661759100000004,
    p: 406.43204410448345 },
  { s: 584, o: 406, h: 406, l: 406, c: 406, v: 1.20351, p: 406 },
  { s: 587,
    o: 408.647,
    h: 408.647,
    l: 408.647,
    c: 408.647,
    v: 0.147043,
    p: 408.647 },
  { s: 591,
    o: 408.647,
    h: 408.647,
    l: 408.647,
    c: 408.647,
    v: 0.0664431,
    p: 408.647 },
  { s: 592,
    o: 408.647,
    h: 408.647,
    l: 408.647,
    c: 408.647,
    v: 0.0470348,
    p: 408.647 },
  { s: 593,
    o: 408.647,
    h: 408.647,
    l: 408.647,
    c: 408.647,
    v: 0.239697,
    p: 408.647 },
  { s: 594,
    o: 408.647,
    h: 408.647,
    l: 408.647,
    c: 408.647,
    v: 0.060303,
    p: 408.647 },
  { s: 599,
    o: 408.647,
    h: 408.647,
    l: 408.647,
    c: 408.647,
    v: 0.039697,
    p: 408.64699999999993 },
  { s: 600,
    o: 408.647,
    h: 408.647,
    l: 408.647,
    c: 408.647,
    v: 0.42269389999999996,
    p: 408.647 },
  { s: 601,
    o: 408.647,
    h: 408.647,
    l: 408.647,
    c: 408.647,
    v: 0.0255062,
    p: 408.647 },
  { s: 602,
    o: 406,
    h: 406,
    l: 406,
    c: 406,
    v: 0.162773,
    p: 405.99999999999994 },
  { s: 608,
    o: 406.003,
    h: 406.003,
    l: 405.51,
    c: 405.513,
    v: 2.3980075599999995,
    p: 405.5588337038604 },
  { s: 609,
    o: 405.51,
    h: 405.513,
    l: 405.51,
    c: 405.513,
    v: 0.2,
    p: 405.51149999999996 },
  { s: 610,
    o: 405.513,
    h: 405.513,
    l: 405.51,
    c: 405.51,
    v: 0.33012401,
    p: 405.51155032658784 },
  { s: 611,
    o: 405.513,
    h: 405.513,
    l: 405.513,
    c: 405.513,
    v: 0.2103792,
    p: 405.51300000000003 },
  { s: 612,
    o: 405.51,
    h: 405.513,
    l: 405.51,
    c: 405.51,
    v: 0.5060329,
    p: 405.5102311978134 },
  { s: 620,
    o: 405.513,
    h: 405.513,
    l: 405.513,
    c: 405.513,
    v: 0.0242,
    p: 405.513 },
  { s: 621,
    o: 405.513,
    h: 408.647,
    l: 405.513,
    c: 408.647,
    v: 0.38091690999999994,
    p: 406.9486505443668 },
  { s: 622,
    o: 408.647,
    h: 408.647,
    l: 408.647,
    c: 408.647,
    v: 0.0319241,
    p: 408.647 },
  { s: 630,
    o: 408.647,
    h: 408.647,
    l: 408.647,
    c: 408.647,
    v: 0.0680759,
    p: 408.647 },
  { s: 631,
    o: 408.647,
    h: 408.647,
    l: 408.647,
    c: 408.647,
    v: 0.1604,
    p: 408.647 },
  { s: 634,
    o: 408.65,
    h: 408.65,
    l: 408.65,
    c: 408.65,
    v: 0.1705,
    p: 408.65 },
  { s: 640,
    o: 410.283,
    h: 410.283,
    l: 410.283,
    c: 410.283,
    v: 0.1,
    p: 410.283 },
  { s: 650,
    o: 411.13,
    h: 411.13,
    l: 411.13,
    c: 411.13,
    v: 0.32199995,
    p: 411.13 },
  { s: 653,
    o: 411.13,
    h: 411.819,
    l: 411.13,
    c: 411.819,
    v: 0.32245,
    p: 411.78481175376027 },
  { s: 657,
    o: 406.403,
    h: 406.403,
    l: 406.4,
    c: 406.4,
    v: 0.1407,
    p: 406.4021428571429 },
  { s: 664,
    o: 411.376,
    h: 411.423,
    l: 411.376,
    c: 411.423,
    v: 0.48364599999999996,
    p: 411.3877850328546 },
  { s: 677,
    o: 411.266,
    h: 413,
    l: 411.266,
    c: 413,
    v: 1.00000002,
    p: 411.9759784204804 },
  { s: 714,
    o: 411.976,
    h: 412,
    l: 411.976,
    c: 412,
    v: 0.5591997,
    p: 411.979101160462 },
  { s: 724, o: 410.5, h: 410.5, l: 410.5, c: 410.5, v: 0.2, p: 410.5 },
  { s: 732, o: 408, h: 408, l: 408, c: 408, v: 0.0133158, p: 408 },
  { s: 742, o: 410, h: 410, l: 410, c: 410, v: 2.96415, p: 410 },
  { s: 743,
    o: 410,
    h: 410.5,
    l: 410,
    c: 410.5,
    v: 1.5218500000000001,
    p: 410.03285474915396 },
  { s: 753, o: 411, h: 411, l: 411, c: 411, v: 0.0132891, p: 411 } ] s undefined e undefined
mazhead commented 10 years ago

Seeing the same today, 2014-02-27 14:05:58 (DEBUG): minimum trade treshold: 2014-02-27 13:04:58 UTC 2014-02-27 14:05:58 (DEBUG): processing 11 trade(s) 2014-02-27 14:05:58 (DEBUG): from 2014-02-27T13:04:59+00:00 to 2014-02-27T13:05:44+00:00 c [ { s: 784, o: 561, h: 561, l: 560, c: 560.187, v: 11.165906700000003, p: 560.449578615886 }, { s: 785, o: 560.187, h: 560.187, l: 560, c: 560, v: 0.5427232, p: 560.014720650232 }, { s: 784, o: 560.187, h: 561, l: 560, c: 560, v: 0.16381405, p: 560.198739099302 } ] s { s: 784, o: 561, h: 561, l: 560, c: 560.187, v: 11.165906700000003, p: 560.449578615886 } e undefined

Weird error 2

After this gekko crashes

askmike commented 10 years ago

This error is killing me, fortunately I am currently rewriting the way Gekko handles 1 min candles (core part of gekko) and persisting them to disk. So that should really fix this once and for all!

consp commented 10 years ago

I can confirm this also happens with the cryptsy exchange made by mlmurray. Most of them seem to go away when I added timeouts to the http requests but that might be unrelated.

geekasylum commented 10 years ago

Can confirm I am also seeing this on BTC-e with 0.1.2, pulled fresh from github. It comes up after a while, and gekko crashes. I also run a second gekko on cexio which does not seem to have this issue..

c [ { s: 248, o: 561.999, h: 562, l: 555, c: 555, v: 123.3367699, p: 555.4418553820594 }, { s: 249, o: 555, h: 555, l: 555, c: 555, v: 7.870041999999999, p: 555.0000000000001 }, { s: 248, o: 555, h: 560, l: 554.8, c: 560, v: 18.237196289999996, p: 557.5807985370706 } ] s { s: 248, o: 561.999, h: 562, l: 555, c: 555, v: 123.3367699, p: 555.4418553820594 } e undefined

bigboi212 commented 10 years ago

I get the weird 2 error also. and this happens too:

2014-02-27 21:15:32 (INFO): We have new trading advice! 2014-02-27 21:15:32 (INFO): Position to take: long 2014-02-27 21:15:32 (INFO): Market price: 559 2014-02-27 21:15:32 (INFO): Based on market time: 2014-02-27 21:15: 00

2014-02-27 21:15:32 (DEBUG): Processed trades, sleeping for a minute...

TypeError: Cannot read property 'ticker' of undefined at set (c:\gekko\exchanges\btce.js:108:31) at bound (c:\gekko\node_modules\lodash\dist\lodash.js:729:21) at Request._callback (c:\gekko\node_modules\btc-e\btc-e.js:62:16) at self.callback (c:\gekko\node_modules\btc-e\node_modules\request\index.js: 142:22) at Request.EventEmitter.emit (events.js:95:17) at ClientRequest.self.clientErrorHandler (c:\gekko\node_modules\btc-e\node_m odules\request\index.js:246:10) at ClientRequest.EventEmitter.emit (events.js:95:17) at CleartextStream.socketErrorListener (http.js:1547:9) at CleartextStream.EventEmitter.emit (events.js:95:17) at Socket.onerror (tls.js:1445:17)

ahousley commented 10 years ago

Same issue here. I haven't tried debugging but sharing the log in case this helps someone. Gekko was running fine for 10 hours before the error was thrown by candleManager.js: https://github.com/askmike/gekko/blob/69e2b17bf3a551ce984725317b2120f4746b9818/core/candleManager.js#L794

2014-02-28 10:13:23 (DEBUG):    Requested BTC/USD trade data from BTC-e ...
2014-02-28 10:13:23 (DEBUG):    Fetched 150 new trades, from 2014-02-28 10:05:10 UTC to 2014-02-28 10:12:49 UTC
2014-02-28 10:13:23 (DEBUG):    minimum trade treshold: 2014-02-28 10:11:53 UTC
2014-02-28 10:13:23 (DEBUG):    processing 28 trade(s)
2014-02-28 10:13:23 (DEBUG):    from 2014-02-28T10:12:20+00:00 to 2014-02-28T10:12:49+00:00
2014-02-28 10:13:23 (DEBUG):    Skipping creation of already loaded database 2014-02-28
2014-02-28 10:13:23 (DEBUG):    inserting candle 611 (2014-02-28 10:11:00 UTC) volume: 19.956357200000006
2014-02-28 10:13:23 (DEBUG):    Processed trades, sleeping for a minute...
2014-02-28 10:14:11 (DEBUG):    Requested BTC/USD trade data from BTC-e ...
2014-02-28 10:14:27 (DEBUG):    Fetched 150 new trades, from 2014-02-28 10:08:13 UTC to 2014-02-28 10:13:57 UTC
2014-02-28 10:14:27 (DEBUG):    minimum trade treshold: 2014-02-28 10:12:49 UTC
2014-02-28 10:14:27 (DEBUG):    processing 42 trade(s)
2014-02-28 10:14:27 (DEBUG):    from 2014-02-28T10:12:59+00:00 to 2014-02-28T10:13:57+00:00
2014-02-28 10:14:27 (DEBUG):    Skipping creation of already loaded database 2014-02-28
2014-02-28 10:14:27 (DEBUG):    inserting candle 612 (2014-02-28 10:12:00 UTC) volume: 14.730925829999999
2014-02-28 10:14:27 (DEBUG):    inserting candle 613 (2014-02-28 10:13:00 UTC) volume: 7.893141100000001
2014-02-28 10:14:27 (DEBUG):    Processed trades, sleeping for a minute...
2014-02-28 10:15:15 (DEBUG):    Requested BTC/USD trade data from BTC-e ...
2014-02-28 10:15:15 (DEBUG):    Fetched 150 new trades, from 2014-02-28 10:09:43 UTC to 2014-02-28 10:14:45 UTC
2014-02-28 10:15:15 (DEBUG):    minimum trade treshold: 2014-02-28 10:13:57 UTC
2014-02-28 10:15:15 (DEBUG):    processing 33 trade(s)
2014-02-28 10:15:15 (DEBUG):    from 2014-02-28T10:13:59+00:00 to 2014-02-28T10:14:45+00:00
c [ { s: 613,
    o: 551.5,
    h: 552.997,
    l: 551.5,
    c: 552.997,
    v: 7.893141100000001,
    p: 551.9916412373143 },
  { s: 614,
    o: 552.997,
    h: 553,
    l: 552.997,
    c: 552.997,
    v: 3.6666197000000005,
    p: 552.998530746971 },
  { s: 613,
    o: 551.5,
    h: 553.899,
    l: 551.5,
    c: 553.899,
    v: 21.172104500000003,
    p: 553.3696096081284 } ] s { s: 613,
  o: 551.5,
  h: 552.997,
  l: 551.5,
  c: 552.997,
  v: 7.893141100000001,
  p: 551.9916412373143 } e undefined
geekasylum commented 10 years ago

Just some extra info.... in case it helps... I did not get this error while trading on cexio, with 5,15, or 60 minute candles. I did however get it constantly on BTC-e with 5 and 15 minute candles, but since switching to 60 minute candles I have not seen it since. I'm not sure if the recent code push (I pull just about daily) addressed this issue, but for several days before that, using 60 minute candles eliminated this for me, even before that pull.

SSzretter commented 9 years ago

I am looking at this same issue.

I can tell you it has to do with the candles being out of order. For example, if you look at all the candle data for people with the issue above you will see they have one candle that is out of order "s: 614" then "s: 613" for example.

SSzretter commented 9 years ago

Found a fix that appears to be working

In candleManager.js:

Manager.prototype.addEmtpyCandles = function(candles, start, end) {

candles = this.sortCandles(candles);  // add this line to fix
Pascal66 commented 8 years ago

fix confirmed on cryptsy

macedd commented 8 years ago

+1 for this.sortCandles

askmike commented 8 years ago

should be fixed in gekko 0.2!