askmike / gekko

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

Bot crashes when providing new trade advice #267

Closed donttrustem closed 8 years ago

donttrustem commented 9 years ago

Hi Mike,

Been running Geeko for 4 days and the first time is offered advice it crashed with the error below.

Thanks Mark ..

2015-02-10 08:24:44 (INFO): Trading Advisor 2015-02-10 08:24:44 (INFO): Calculate trading advice 2015-02-10 08:24:44 (WARN): Warning, trading method has no name

2015-02-10 08:24:44 (INFO): Setting up: 2015-02-10 08:24:44 (INFO): IRC bot 2015-02-10 08:24:44 (INFO): IRC module lets you communicate with Gekko on IRC.

2015-02-10 08:24:44 (INFO): Setting up: 2015-02-10 08:24:44 (INFO): Trader 2015-02-10 08:24:44 (INFO): Trader will follow the advice and create real orders.

2015-02-10 08:24:45 (INFO): Trading at Bitfinex ACTIVE 2015-02-10 08:24:45 (INFO): Bitfinex trading fee will be: 0.1% 2015-02-10 08:24:45 (INFO): Bitfinex portfolio: 2015-02-10 08:24:45 (INFO): Setting up: 2015-02-10 08:24:45 (INFO): Profit Simulator 2015-02-10 08:24:45 (INFO): Paper trader that logs fake profits.

2015-02-10 08:24:45 (INFO): Starting to watch the market: Bitfinex BTC/USD 2015-02-10 08:24:46 (INFO): We have all required history, going to calculate advice from this point. 2015-02-10 08:24:46 (INFO): Trader Received advice to go long Buying BTC

2015-02-10 08:24:46 (INFO): We have new trading advice! 2015-02-10 08:24:46 (INFO): Position to take: long 2015-02-10 08:24:46 (INFO): Market price: 216.76 2015-02-10 08:24:46 (INFO): Based on market time: 2015-02-10 08:24:35

SyntaxError: Unexpected token u at Object.parse (native) at /opt/gekko/exchanges/bitfinex.js:64:21 at Request._callback (/opt/gekko/node_modules/bitfinex/bitfinex.js:106:16) at Request.self.callback (/opt/gekko/node_modules/bitfinex/node_modules/request/request.js:123:22) at Request.emit (events.js:98:17) at Request. (/opt/gekko/node_modules/bitfinex/node_modules/request/request.js:893:14) at Request.emit (events.js:117:20) at IncomingMessage. (/opt/gekko/node_modules/bitfinex/node_modules/request/request.js:844:12) at IncomingMessage.emit (events.js:117:20) at _stream_readable.js:944:16

christosporios commented 9 years ago

Has this happened only once? It seems like bitfinex provided invalid JSON at a URL like https://api.bitfinex.com/v1/ticker/btcusd.

In any case gekko should handle the error neatly.

michaelryancaputo commented 9 years ago

I've been running the "candle-rewrite" branch here locally for about 3 days now and it hasn't errored on me. I have seen similar errors to that previously on the main branch though.

donttrustem commented 9 years ago

Hi,

It is happening every time it gives advice... It is possible to do a pull of the "candle-rewrite" branch ?

Thanks

Mark

donttrustem commented 9 years ago

Thanks I guys I just did a pull and will see how it goes. One more question ... what is the custom settings section all about?

Mark

donttrustem commented 9 years ago

Dam ... it crashed again, It was going to make a good trade as well....

Any ideas?

2015-02-18 15:23:31 (DEBUG): Processed trades, sleeping for a minute... 2015-02-18 15:24:19 (DEBUG): Requested BTC/USD trade data from Bitfinex ... 2015-02-18 15:24:20 (DEBUG): Fetched 1000 new trades, from 2015-02-18 14:46:35 UTC to 2015-02-18 15:24:18 UTC 2015-02-18 15:24:20 (DEBUG): minimum trade treshold: 2015-02-18 15:23:30 UTC 2015-02-18 15:24:20 (DEBUG): processing 8 trade(s) 2015-02-18 15:24:20 (DEBUG): from 2015-02-18T15:23:36+00:00 to 2015-02-18T15:24:18+00:00 2015-02-18 15:24:20 (DEBUG): Skipping creation of already loaded database 2015-02-18 2015-02-18 15:24:20 (DEBUG): inserting candle 923 (2015-02-18 15:23:00 UTC) volume: 9.9 2015-02-18 15:24:20 (DEBUG): calculated RSI properties for candle: 2015-02-18 15:24:20 (DEBUG): rsi: 28.48598342 2015-02-18 15:24:20 (DEBUG): price: 236.62000000 2015-02-18 15:24:20 (DEBUG): In low since 2 candle(s) 2015-02-18 15:24:20 (INFO): Trader Received advice to go long Buying BTC

2015-02-18 15:24:20 (INFO): We have new trading advice! 2015-02-18 15:24:20 (INFO): Position to take: long 2015-02-18 15:24:20 (INFO): Market price: 236.48 2015-02-18 15:24:20 (INFO): Based on market time: 2015-02-18 15:24:18

2015-02-18 15:24:20 (DEBUG): Processed trades, sleeping for a minute... 2015-02-18 15:24:20 (INFO): Send advice via email.

SyntaxError: Unexpected token u at Object.parse (native) at /opt/gekko/exchanges/bitfinex.js:64:21 at Request._callback (/opt/gekko/node_modules/bitfinex/bitfinex.js:106:16) at Request.self.callback (/opt/gekko/node_modules/bitfinex/node_modules/request/request.js:123:22) at Request.emit (events.js:98:17) at Request. (/opt/gekko/node_modules/bitfinex/node_modules/request/request.js:893:14) at Request.emit (events.js:117:20) at IncomingMessage. (/opt/gekko/node_modules/bitfinex/node_modules/request/request.js:844:12) at IncomingMessage.emit (events.js:117:20) at _stream_readable.js:944:16

donttrustem commented 9 years ago

I am wondering if this could be the problem

npm WARN unmet dependency /opt/gekko/node_modules/nedb requires async@'0.2.9' but will load npm WARN unmet dependency /opt/gekko/node_modules/async, npm WARN unmet dependency which is version 0.2.10

michaelryancaputo commented 9 years ago

@donttrustem Looks more likely that the bitfinex module is returning data that gekko isn't expecting.

donttrustem commented 9 years ago

@michaelryancaputo I am not a dev ... how do I debug this :(

Thanks

Mark

donttrustem commented 9 years ago

New error Been running the bot for 2 days and it crashed with this:

2015-02-19 19:47:52 (INFO): Bitfinex portfolio: 2015-02-19 19:47:52 (INFO): Setting up: 2015-02-19 19:47:52 (INFO): Profit Simulator 2015-02-19 19:47:52 (INFO): Paper trader that logs fake profits.

2015-02-19 19:47:52 (INFO): Starting to watch the market: Bitfinex BTC/USD 2015-02-19 19:47:53 (INFO): We don't have enough history yet to start giving advice, I'll need to gather more data first. 2015-02-19 19:47:53 (INFO): I will start giving advice around 2015-02-20 05:53:00 (local time, that's in 10 hours). 2015-02-20 05:51:56 (INFO): We have all required history, going to calculate advice from this point.

/opt/gekko/core/candleManager.js:560 this.days[mom.dayString].handle.find({ ^ TypeError: Object false has no method 'find' at Manager.getCandles (/opt/gekko/core/candleManager.js:560:35) at bound as getCandles at iterator (/opt/gekko/core/candleManager.js:516:10) at bound (/opt/gekko/node_modules/lodash/dist/lodash.js:729:21) at /opt/gekko/node_modules/async/lib/async.js:227:13 at /opt/gekko/node_modules/async/lib/async.js:111:13 at Array.forEach (native) at _each (/opt/gekko/node_modules/async/lib/async.js:32:24) at async.each (/opt/gekko/node_modules/async/lib/async.js:110:9) at _asyncMap (/opt/gekko/node_modules/async/lib/async.js:226:9)

Any ideas...?

Thanks Mark

donttrustem commented 9 years ago

This is driving me nuts now :( ... I cannot find any fix for this?

2015-02-21 09:31:47 (INFO): Send advice via email.

SyntaxError: Unexpected token u at Object.parse (native) at /opt/gekko/exchanges/bitfinex.js:64:21 at Request._callback (/opt/gekko/node_modules/bitfinex/bitfinex.js:106:16) at Request.self.callback (/opt/gekko/node_modules/bitfinex/node_modules/request/request.js:123:22) at Request.emit (events.js:98:17) at Request. (/opt/gekko/node_modules/bitfinex/node_modules/request/request.js:893:14) at Request.emit (events.js:117:20) at IncomingMessage. (/opt/gekko/node_modules/bitfinex/node_modules/request/request.js:844:12) at IncomingMessage.emit (events.js:117:20) at _stream_readable.js:944:16

michaelryancaputo commented 9 years ago

Could be token undefined.

donttrustem commented 9 years ago

@michaelryancaputo which one though :) 8ball:

Thanks

michaelryancaputo commented 9 years ago

@donttrustem Not sure I can help you, sorry. Good luck.

robusta commented 9 years ago

Fixed it - pull request pending - See https://github.com/robusta/gekko

askmike commented 8 years ago

fixed in 3eddf7813228438252ffb9669e7d7fe8f66e0454.!