Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Error: cb is not a function #2329

Closed
dominik-fr opened this issue Jul 17, 2018 · 34 comments · Fixed by #2611
Closed

Error: cb is not a function #2329

dominik-fr opened this issue Jul 17, 2018 · 34 comments · Fixed by #2611
Labels

Comments

@dominik-fr
Copy link

I'm submitting a ...
[X ] bug report
[ ] question about the decisions made in the repository

Action taken (what you did)
Running trader (NEO strategy) via CLI (Gekko 6.2); app reaches setting up market watcher

Expected result (what you hoped would happen)
Running Strategy

Actual result (unexpected outcome)
App crashes:
TypeError: cb is not a function
at afterWrite (_stream_writable.js:464:3)
at _combinedTickCallback (internal/process/next_tick.js:144:20)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)

@askmike
Copy link
Owner

askmike commented Jul 18, 2018

Can you post more logs? With debug turned on.

@dominik-fr
Copy link
Author

dominik-fr commented Jul 18, 2018

That's it - after that Gekko crashes. Debug set to true also doesn't provide any more info. Binance market btw. Other strategy seems to work fine.

@askmike
Copy link
Owner

askmike commented Jul 18, 2018 via email

@dominik-fr
Copy link
Author

dominik-fr commented Jul 18, 2018

Well, ok. I'll post the whole log later on today.

@askmike
Copy link
Owner

askmike commented Jul 18, 2018 via email

@salihcirgan
Copy link

If your history has empty data this error occurs. For example, a new coin has 1 hour of market data on binance but you imported 1 day. ( gekko needs at least one day import)
try to remove history db and restart strategy..

@dominik-fr
Copy link
Author

@salihcirgan Thx, will try it out.

Here's the log, debug is set to true:

______   ________  __    __  __    __   ______

/ \ / |/ | / |/ | / | /
/$$$$$$ |$$$$$$$$/ $$ | /$$/ $$ | /$$/ /$$$$$$ |
$$ | $$/ $$ |_ $$ |/$$/ $$ |/$$/ $$ | $$ |
$$ |/ |$$ | $$ $$< $$ $$< $$ | $$ |
$$ |$$$$ |$$$$$/ $$$$$ \ $$$$$ \ $$ | $$ |
$$ _$$ |$$ |_____ $$ |$$ \ $$ |$$ \ $$ _$$ |
$$ $$/ $$ |$$ | $$ |$$ | $$ |$$ $$/
$$$$$$/ $$$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/

Gekko v0.6.2
I'm gonna make you rich, Bud Fox. 

2018-07-17 22:19:14 (INFO): Setting up Gekko in realtime mode
2018-07-17 22:19:14 (INFO):
2018-07-17 22:19:14 (INFO): Setting up:
2018-07-17 22:19:14 (INFO): Candle writer
2018-07-17 22:19:14 (INFO): Store candles in a database
2018-07-17 22:19:14 (INFO):

2018-07-17 22:19:14 (INFO): Setting up:
2018-07-17 22:19:14 (INFO): Trading Advisor
2018-07-17 22:19:14 (INFO): Calculate trading advice
2018-07-17 22:19:14 (INFO): Using the strategy: NEO
2018-07-17 22:19:14 (ERROR): Failed to load indicator Alligator
2018-07-17 22:19:14 (ERROR): Failed to load indicator HEIKEN
2018-07-17 22:19:15 (ERROR): Failed to load indicator RSI-beta
2018-07-17 22:19:17 (INFO): The trading method requests 150 minutes of historic data. Checking availablity..
2018-07-17 22:19:17 (INFO):

2018-07-17 22:19:17 (INFO): Usable local data available, trying to match with exchange data..
2018-07-17 22:19:18 (INFO): Full history locally available. Seeding the trading method with all required historical candles.
2018-07-17 22:19:18 (INFO): Setting up:
2018-07-17 22:19:18 (INFO): Trader
2018-07-17 22:19:18 (INFO): Follows the advice and create real orders.
2018-07-17 22:19:18 (INFO):

2018-07-17 22:19:24 (INFO): Portfolio:
2018-07-17 22:19:24 (INFO): xxx BNB
2018-07-17 22:19:24 (INFO): xxx ADX
2018-07-17 22:19:24 (INFO): Balance:
2018-07-17 22:19:24 (INFO): xxx BNB
2018-07-17 22:19:24 (INFO): Exposed:
2018-07-17 22:19:24 (INFO): yes (65.43%)
2018-07-17 22:19:24 (INFO): Setting up:
2018-07-17 22:19:24 (INFO): Performance Analyzer
2018-07-17 22:19:24 (INFO): Analyzes performances of trades
2018-07-17 22:19:24 (INFO):

2018-07-17 22:19:24 (INFO): Starting to watch the market: Binance ADX/BNB
TypeError: cb is not a function
at afterWrite (_stream_writable.js:464:3)
at _combinedTickCallback (internal/process/next_tick.js:144:20)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)

@salihcirgan
Copy link

I see this exact problem if DB has null data. Every time DB deletion or if full history is available problem gone. maybe, you have something different.
did you backup and delete all history DB files under "history" directory?

@dominik-fr
Copy link
Author

@salihcirgan I've just finished importing and running simple test :) It seems to work now. Strange, as I'm pretty sure that db wasn't empty...

@askmike
Copy link
Owner

askmike commented Jul 18, 2018

Interesting, I'll have a look at that. Thanks @salihcirgan.

@askmike askmike added the bug label Jul 18, 2018
@dominik-fr
Copy link
Author

Another funny thing - thing seemed to be working, but after yet enother crash (logs below) TypeError: cb is not a functionis back again...


/ \ / |/ | / |/ | / | /
/$$$$$$ |$$$$$$$$/ $$ | /$$/ $$ | /$$/ /$$$$$$ |
$$ | $$/ $$ |_ $$ |/$$/ $$ |/$$/ $$ | $$ |
$$ |/ |$$ | $$ $$< $$ $$< $$ | $$ |
$$ |$$$$ |$$$$$/ $$$$$ \ $$$$$ \ $$ | $$ |
$$ _$$ |$$ |_____ $$ |$$ \ $$ |$$ \ $$ _$$ |
$$ $$/ $$ |$$ | $$ |$$ | $$ |$$ $$/
$$$$$$/ $$$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/

Gekko v0.6.2
I'm gonna make you rich, Bud Fox. 

2018-07-18 17:57:17 (INFO): Setting up Gekko in realtime mode
2018-07-18 17:57:17 (INFO):
2018-07-18 17:57:17 (INFO): Setting up:
2018-07-18 17:57:17 (INFO): Candle writer
2018-07-18 17:57:17 (INFO): Store candles in a database
2018-07-18 17:57:17 (INFO):

2018-07-18 17:57:17 (INFO): Setting up:
2018-07-18 17:57:17 (INFO): Trading Advisor
2018-07-18 17:57:17 (INFO): Calculate trading advice
2018-07-18 17:57:17 (INFO): Using the strategy: NEO
2018-07-18 17:57:17 (ERROR): Failed to load indicator Alligator
2018-07-18 17:57:18 (ERROR): Failed to load indicator HEIKEN
2018-07-18 17:57:18 (ERROR): Failed to load indicator RSI-beta
2018-07-18 17:57:20 (INFO): The trading method requests 150 minutes of historic data. Checking availablity..
2018-07-18 17:57:20 (INFO):

2018-07-18 17:57:20 (INFO): Usable local data available, trying to match with exchange data..
2018-07-18 17:57:20 (INFO): Not seeding locally available data to the trading method.
2018-07-18 17:57:20 (INFO): The exchange does not return enough data. 0 minutes are still missing.
2018-07-18 17:57:20 (INFO): Setting up:
2018-07-18 17:57:20 (INFO): Trader
2018-07-18 17:57:20 (INFO): Follows the advice and create real orders.
2018-07-18 17:57:20 (INFO):

2018-07-18 17:57:26 (INFO): Portfolio:
2018-07-18 17:57:26 (INFO): xxxBNB
2018-07-18 17:57:26 (INFO): xxxADX
2018-07-18 17:57:26 (INFO): Balance:
2018-07-18 17:57:26 (INFO): xxxBNB
2018-07-18 17:57:26 (INFO): Exposed:
2018-07-18 17:57:26 (INFO): yes (67.20%)
2018-07-18 17:57:26 (INFO): Setting up:
2018-07-18 17:57:26 (INFO): Performance Analyzer
2018-07-18 17:57:26 (INFO): Analyzes performances of trades
2018-07-18 17:57:26 (INFO):

2018-07-18 17:57:26 (INFO): Starting to watch the market: Binance ADX/BNB
2018-07-18 20:35:48 (INFO): Trader Received advice to go short. Selling ADX
Error: Lot size is too small
at StickyOrder.submit (/home/pi/gekko/exchange/orders/order.js:69:13)
at StickyOrder.createOrder (/home/pi/gekko/exchange/orders/sticky.js:121:10)
at StickyOrder.create (/home/pi/gekko/exchange/orders/sticky.js:68:10)
at syncPrivateData (/home/pi/gekko/exchange/gekkoBroker.js:141:13)
at /home/pi/gekko/exchange/node_modules/async/dist/async.js:3874:9
at /home/pi/gekko/exchange/node_modules/async/dist/async.js:473:16
at replenish (/home/pi/gekko/exchange/node_modules/async/dist/async.js:993:25)
at iterateeCallback (/home/pi/gekko/exchange/node_modules/async/dist/async.js:983:17)
at /home/pi/gekko/exchange/node_modules/async/dist/async.js:958:16
at Timeout._onTimeout (/home/pi/gekko/exchange/node_modules/async/dist/async.js:3871:13)

@hiyan
Copy link
Contributor

hiyan commented Jul 19, 2018

I had the same "cb is not a function" error.

Tried deleting node_module and npm install -- same error.

Restored a backup db -- works.

I'm using sqllite as db.

@SavageShade
Copy link

I get this error anytime I have done an import of data and then try to run a strategy after that requires history. When the DataSticher has to piece together both local and exchange data, it when this is happening 100% for me. I have been trying to dig out the unique functionality that is ran in this scenario to find the issue.

@crypto49er
Copy link
Contributor

crypto49er commented Jul 26, 2018

I'm having the same issue. In the config file, I set candleWriter to false for now to get around this bug.

@nicolasbonnici
Copy link

Got the same issue, I have deleted the "node_modules" folder then run npm i --only-production in both root and "exchange" folders to solve it.

@GuysmoB
Copy link
Contributor

GuysmoB commented Aug 16, 2018

Same problem here but the @crypto49er's solution doesn't work for me :/
Once import was done, I ran the paper trader config and the error occurs only it's not needed to import the remaining data if i'm right.
@nicolasbonnici, npm i --only-production will create new "node_modules" folder in both root and exchange ?

@nicolasbonnici
Copy link

@GuysmoB Nope only in the current folder that's why you need to it twice, once at the root folder and a second time in the exchange folder.

@GuysmoB
Copy link
Contributor

GuysmoB commented Aug 18, 2018

@nicolasbonnici, your method doesn't work for me. You didn't do something else ?

@nicolasbonnici
Copy link

@GuysmoB Nope just deleted both node_modules/ and exchange/node_modules then reinstall all dependencies in both folders.

@cstegmann
Copy link

Deleting both node_modules folders worked for me, thanks. Wasn't that horrible since it looped in pm2 until it eventually worked, but this is nicer.

@danielm001
Copy link

I have this often when a market watcher (UI) is running and i start the tradebot (CLI) for the same pair. After stopping the market watcher it works for me.

@crypto49er
Copy link
Contributor

Deleting the node_modules folders and reinstalling them work if you don't use the import process to update the historical data. If you update, you will get the same error. My workaround, which I should have clarify, will not work if you try to use historical data. I think we need a real fix for this, not a workaround.

@askmike
Copy link
Owner

askmike commented Aug 27, 2018 via email

@crypto49er
Copy link
Contributor

@askmike

I'm running on a Mac with sqlite. I believe I am able to replicate this on Linux as well. I will confirm shortly and also provide the exact steps.

@askmike
Copy link
Owner

askmike commented Aug 27, 2018 via email

@bobychain
Copy link

Hi,

I've the same error, on version 0.6.6 today
My config is a Debian 9 with NodeJS v8.11.4 on Gekko CLI only (no UI).

The strategie is RSI_BULL_BEAR_ADX using 1225 minutes of historic data with all datas neede:
Full history locally available. Seeding the trading method with all required historical candles

I also got before this error :
2018-08-27 15:24:16 (WARN): NOT creating order! Reason: Lot size is too small
even if the ORDER went well on Binance.

Hellpppp : )
Sorry but I have a lot of troubles with the 0.6.x branch and the 0.5.14 is not working on Binance anymore.

Let me know if you need any other infos to help reproduce it.

@bobychain
Copy link

p.s.: @askmike > I can share with you the access to the Instance (SSH) if you want to check

@crypto49er
Copy link
Contributor

@askmike

Here are the steps to replicate this issue:

  1. Install following your instructions.
  2. Change sample-config.js to monitor gdax/LTC/USD and the candleSize: 1 and historySize: 30.
  3. Run Gekko.
  4. Stop (CTRL + C) Gekko after it processes 2 lines of trades (100 + 3, in my case).
  5. Re-run Gekko, error will appear.

I know people are running into this error with other exchanges, trade pairs and strategies. I haven't been able to replicate this on command with other trade pairs I suspect because Gekko doesn't try to stitch the local data with data from the exchange. I'm quite certain once it tries to stitch the data together, the historical data get corrupted and the user have to re-download that data set, which is a huge pain (unless they backed it up beforehand).

Here's how it looks from Terminal:

crypto49er (stable *) gekko $ node gekko --config sample-config.js

    ______   ________  __    __  __    __   ______
   /      \ /        |/  |  /  |/  |  /  | /      \
  /$$$$$$  |$$$$$$$$/ $$ | /$$/ $$ | /$$/ /$$$$$$  |
  $$ | _$$/ $$ |__    $$ |/$$/  $$ |/$$/  $$ |  $$ |
  $$ |/    |$$    |   $$  $$<   $$  $$<   $$ |  $$ |
  $$ |$$$$ |$$$$$/    $$$$$  \  $$$$$  \  $$ |  $$ |
  $$ \__$$ |$$ |_____ $$ |$$  \ $$ |$$  \ $$ \__$$ |
  $$    $$/ $$       |$$ | $$  |$$ | $$  |$$    $$/ 
   $$$$$$/  $$$$$$$$/ $$/   $$/ $$/   $$/  $$$$$$/

	Gekko v0.6.6
	I'm gonna make you rich, Bud Fox. 


2018-08-27 16:31:25 (INFO):	Setting up Gekko in realtime mode
2018-08-27 16:31:25 (INFO):	
2018-08-27 16:31:25 (INFO):	Setting up:
2018-08-27 16:31:25 (INFO):		 Candle writer
2018-08-27 16:31:25 (INFO):		 Store candles in a database
2018-08-27 16:31:25 (INFO):	

2018-08-27 16:31:25 (INFO):	Setting up:
2018-08-27 16:31:25 (INFO):		 Trading Advisor
2018-08-27 16:31:25 (INFO):		 Calculate trading advice
2018-08-27 16:31:25 (INFO):		 Using the strategy: MACD
2018-08-27 16:31:26 (INFO):		The trading method requests 30 minutes of historic data. Checking availablity..
2018-08-27 16:31:26 (INFO):	

2018-08-27 16:31:26 (INFO):		No usable local data available, trying to get as much as possible from the exchange..
2018-08-27 16:31:26 (DEBUG):		Fetching exchange data since 30 minutes ago
Scanning back in the history needed... moment.utc("2018-08-27T20:01:00.000+00:00")
2018-08-27 16:31:27 (DEBUG):		Available exchange data:
2018-08-27 16:31:27 (DEBUG):			from: 8 minutes ago
2018-08-27 16:31:27 (DEBUG):			to: 0 minutes ago
2018-08-27 16:31:27 (DEBUG):		Unable to stitch datasets.
2018-08-27 16:31:27 (INFO):		Not seeding locally available data to the trading method.
2018-08-27 16:31:27 (INFO):	Setting up:
2018-08-27 16:31:27 (INFO):		 Paper Trader
2018-08-27 16:31:27 (INFO):		 Paper trader that simulates fake trades.
2018-08-27 16:31:27 (INFO):	

2018-08-27 16:31:27 (INFO):	Setting up:
2018-08-27 16:31:27 (INFO):		 Performance Analyzer
2018-08-27 16:31:27 (INFO):		 Analyzes performances of trades
2018-08-27 16:31:27 (INFO):	

2018-08-27 16:31:27 (INFO):	Starting to watch the market: GDAX LTC/USD
2018-08-27 16:31:27 (DEBUG):	scheduling ticks
2018-08-27 16:31:27 (DEBUG):	Requested LTC/USD trade data from GDAX ...
2018-08-27 16:31:27 (DEBUG):	Processing 100 new trades. From 2018-08-27 20:22:38 UTC to 2018-08-27 20:31:11 UTC. (9 minutes)
2018-08-27 16:31:47 (DEBUG):	Requested LTC/USD trade data from GDAX ...
2018-08-27 16:31:47 (DEBUG):	Processing 3 new trades. From 2018-08-27 20:31:44 UTC to 2018-08-27 20:31:44 UTC. (a few seconds)
^C
crypto49er (stable *) gekko $ node gekko --config sample-config.js

    ______   ________  __    __  __    __   ______
   /      \ /        |/  |  /  |/  |  /  | /      \
  /$$$$$$  |$$$$$$$$/ $$ | /$$/ $$ | /$$/ /$$$$$$  |
  $$ | _$$/ $$ |__    $$ |/$$/  $$ |/$$/  $$ |  $$ |
  $$ |/    |$$    |   $$  $$<   $$  $$<   $$ |  $$ |
  $$ |$$$$ |$$$$$/    $$$$$  \  $$$$$  \  $$ |  $$ |
  $$ \__$$ |$$ |_____ $$ |$$  \ $$ |$$  \ $$ \__$$ |
  $$    $$/ $$       |$$ | $$  |$$ | $$  |$$    $$/ 
   $$$$$$/  $$$$$$$$/ $$/   $$/ $$/   $$/  $$$$$$/

	Gekko v0.6.6
	I'm gonna make you rich, Bud Fox. 


2018-08-27 16:31:53 (INFO):	Setting up Gekko in realtime mode
2018-08-27 16:31:53 (INFO):	
2018-08-27 16:31:53 (INFO):	Setting up:
2018-08-27 16:31:53 (INFO):		 Candle writer
2018-08-27 16:31:53 (INFO):		 Store candles in a database
2018-08-27 16:31:53 (INFO):	

2018-08-27 16:31:53 (INFO):	Setting up:
2018-08-27 16:31:53 (INFO):		 Trading Advisor
2018-08-27 16:31:53 (INFO):		 Calculate trading advice
2018-08-27 16:31:53 (INFO):		 Using the strategy: MACD
2018-08-27 16:31:54 (INFO):		The trading method requests 30 minutes of historic data. Checking availablity..
2018-08-27 16:31:54 (INFO):	

2018-08-27 16:31:54 (INFO):		Local data is still too recent, trying to get as much as possible from the exchange
2018-08-27 16:31:54 (DEBUG):		Fetching exchange data since 30 minutes ago
Scanning back in the history needed... moment.utc("2018-08-27T20:01:00.000+00:00")
2018-08-27 16:31:54 (DEBUG):		Available exchange data:
2018-08-27 16:31:54 (DEBUG):			from: 8 minutes ago
2018-08-27 16:31:54 (DEBUG):			to: 0 minutes ago
2018-08-27 16:31:54 (DEBUG):		Stitching datasets
2018-08-27 16:31:54 (INFO):		Partial history locally available, but 21 minutes are missing.
2018-08-27 16:31:54 (INFO):		Seeding the trading method with partial historical data (Gekko needs more time before it can give advice).
2018-08-27 16:31:54 (DEBUG):		Seeding with:
2018-08-27 16:31:54 (DEBUG):			from: 9 minutes ago
2018-08-27 16:31:54 (DEBUG):			to: 9 minutes ago
2018-08-27 16:31:54 (INFO):	Setting up:
2018-08-27 16:31:54 (INFO):		 Paper Trader
2018-08-27 16:31:54 (INFO):		 Paper trader that simulates fake trades.
2018-08-27 16:31:54 (INFO):	

2018-08-27 16:31:54 (INFO):	Setting up:
2018-08-27 16:31:54 (INFO):		 Performance Analyzer
2018-08-27 16:31:54 (INFO):		 Analyzes performances of trades
2018-08-27 16:31:54 (INFO):	

2018-08-27 16:31:54 (INFO):	Starting to watch the market: GDAX LTC/USD
2018-08-27 16:31:54 (DEBUG):	scheduling ticks
2018-08-27 16:31:54 (DEBUG):	Requested LTC/USD trade data from GDAX ...
2018-08-27 16:31:54 (DEBUG):	Processing 100 new trades. From 2018-08-27 20:23:08 UTC to 2018-08-27 20:31:50 UTC. (9 minutes)
_stream_writable.js:477
  cb();
  ^

TypeError: cb is not a function
    at afterWrite (_stream_writable.js:477:3)
    at process._tickCallback (internal/process/next_tick.js:178:19)

askmike added a commit that referenced this issue Aug 28, 2018
@askmike
Copy link
Owner

askmike commented Aug 28, 2018

Thanks a lot to @crypto49er for providing me with steps to reproduce. These kind of issues are impossible for me to fix without being able to reproduce.

@bobychain @moodyswing @danielm001 @cstegmann @nicolasbonnici @hiyan I was finally able to fix this! Fix landed in develop for now (see #2482), see here for documentation on running that: https://gekko.wizb.it/docs/installation/updating_gekko.html#Updating-the-develop-branch

@hiyan
Copy link
Contributor

hiyan commented Aug 28, 2018

Thanks @askmike. Will try.

However, I have not seen this error, since I upgraded node to v10 and rebuild node_modules, for a few weeks now.

Will report if I see this error again.

@askmike
Copy link
Owner

askmike commented Aug 28, 2018 via email

@bobychain
Copy link

Thanl you @askmike, trying it now!

@bobychain
Copy link

I still have the problem, randomly or at start with the version 0.6.6.
Is it possible to re-open the ticket?

Gekko got the error 3 days ago and didn't trade since then, I had to restart manually.

@crypto49er
Copy link
Contributor

I have seen other variables that are listed as not a function ("done is not a function"), but not cb. @bobychain, I think you should open a new issue. If you want a quick fix, you can have cb return only if it is a function (if typeof cb == 'function).

This was referenced Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.