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

Error: invalid bucket size spec: undefined #938

Open
efams opened this issue Dec 19, 2017 · 8 comments
Open

Error: invalid bucket size spec: undefined #938

efams opened this issue Dec 19, 2017 · 8 comments
Labels

Comments

@efams
Copy link

efams commented Dec 19, 2017

Hi,
after last git pull i get this error when i try to start a simulation.
Lubuntu: 17.10

Error: invalid bucket size spec: undefined
at BucketSize.parse (/home/enri/gdax/zenbot/node_modules/timebucket/lib/bucket-size.js:15:21)
at new BucketSize (/home/enri/gdax/zenbot/node_modules/timebucket/lib/bucket-size.js:5:21)
at Bucket.resize (/home/enri/gdax/zenbot/node_modules/timebucket/lib/bucket.js:30:14)
at Command. (/home/enri/gdax/zenbot/commands/sim.js:84:51)
at Command.listener (/home/enri/gdax/zenbot/node_modules/commander/index.js:315:8)
at emitTwo (events.js:126:13)
at Command.emit (events.js:214:7)
at Command.parseArgs (/home/enri/gdax/zenbot/node_modules/commander/index.js:653:12)
at Command.parse (/home/enri/gdax/zenbot/node_modules/commander/index.js:475:21)
at /home/enri/gdax/zenbot/zenbot.js:39:11
at /home/enri/gdax/zenbot/boot.js:24:7
at f (/home/enri/gdax/zenbot/node_modules/once/once.js:25:25)
at Glob. (/home/enri/gdax/zenbot/node_modules/glob/glob.js:151:7)
at emitOne (events.js:116:13)
at Glob.emit (events.js:211:7)
at Glob._finish (/home/enri/gdax/zenbot/node_modules/glob/glob.js:197:8)
at done (/home/enri/gdax/zenbot/node_modules/glob/glob.js:182:14)
at Glob.processGlobStar2 (/home/enri/gdax/zenbot/node_modules/glob/glob.js:637:12)
at /home/enri/gdax/zenbot/node_modules/glob/glob.js:626:10
at RES (/home/enri/gdax/zenbot/node_modules/inflight/inflight.js:31:16)
at f (/home/enri/gdax/zenbot/node_modules/once/once.js:25:25)
at lstatcb
(/home/enri/gdax/zenbot/node_modules/glob/glob.js:519:7)

Thx
Enri

@efams efams changed the title Error: invalid bucket size spec: undefined [BUG] Error: invalid bucket size spec: undefined Label:bug Dec 19, 2017
@efams efams changed the title Error: invalid bucket size spec: undefined Label:bug Error: invalid bucket size spec: undefined Label: bug Dec 19, 2017
@efams efams changed the title Error: invalid bucket size spec: undefined Label: bug Error: invalid bucket size spec: undefined Dec 19, 2017
@haxwell
Copy link
Contributor

haxwell commented Dec 19, 2017

I'll take this.. I think it is somehow related to my PR #926.

@haxwell
Copy link
Contributor

haxwell commented Dec 20, 2017

See PR #940 .

@DeviaVir DeviaVir added the bug label Dec 20, 2017
haxwell added a commit to haxwell/zenbot that referenced this issue Dec 21, 2017
…ng instances of --period to --periodLength
haxwell added a commit to haxwell/zenbot that referenced this issue Dec 21, 2017
…ng instances of --period to --periodLength
haxwell added a commit to haxwell/zenbot that referenced this issue Dec 21, 2017
haxwell added a commit to haxwell/zenbot that referenced this issue Dec 21, 2017
…rs, renaming instances of --period to --periodLength
DeviaVir pushed a commit that referenced this issue Dec 21, 2017
* In addition to the options on a command, there are options on
strategies. There is a callback function in engine.js which sets the
options as defined in a strategy. The strategy objects were not
updated to have a periodSize option, only a period option. So,
the periodSize attribute was not being set. This caused the
execption in this bug.

This commit adds a second option, named 'periodLength'. The name
'periodLength' was chosen, rather than the previous 'periodSize' for
consistency; the description for the --period option already said
'period length', so it made sense that the additional variable be named
that as well.

Each reference to *.periodSize has been changed to *.periodLength.

This commit continues PR #926.

* In addition to the options on a command, there are options on
strategies. There is a callback function in engine.js which sets the
options as defined in a strategy. The strategy objects were not
updated to have a periodSize option, only a period option. So,
the periodSize attribute was not being set. This caused the
execption in this bug.

This commit adds a second option, named 'periodLength'. The name
'periodLength' was chosen, rather than the previous 'periodSize' for
consistency; the description for the --period option already said
'period length', so it made sense that the additional variable be named
that as well.

Each reference to *.periodSize has been changed to *.periodLength.

This commit continues PR #926 and #940. Third time is the charm :)

* #926, #938, #940 - In the backtesters, renaming instances of --period to --periodLength

* #926, #938, #940 - In the backtesters, renaming instances of --period to --periodLength

* Added period and periodLength option, as they were expected for the darwin.js genetic backtest. #926 #938 #940

* #926, #938, #940 - In the (genetic) backtesters, renaming instances of --period to --periodLength
@canselcik
Copy link

I'm having the exact same problem. I tried to see if I could cherry-pick some of your changes but it isn't clear which ones are bundled together. Are older releases not having this issue?

@haxwell
Copy link
Contributor

haxwell commented Dec 22, 2017

@canselcik all my recent changes are in.. you should be able to pull the master branch, and not run into this problem. And no, older releases would not have this specific problem.

@canselcik
Copy link

Sounds good, thanks @haxwell. I'll give it a try right now.

@canselcik
Copy link

canselcik commented Dec 23, 2017

@haxwell Pulling master and rebuilding didn't work. Or perhaps it did but it brought up another issue. And I do have a local fix for it.

After the changes, sure, the trade subcommand works now, however now balance is broken with:

➜  zenbot git:(master) ✗ zenbot balance gdax.BTC-USD
/mnt/tempos/zenbot/lib/engine.js:17
    s.exchange = get('exchanges.' + so.selector.exchange_id)
                                                ^
TypeError: Cannot read property 'exchange_id' of undefined
    at /mnt/tempos/zenbot/lib/engine.js:18:49
    <rest of backtrace>

Looks like so is simply s.options. Looking at s:

{ options: { debug: undefined },
  selector:
   { exchange_id: 'gdax',
     product_id: 'BTC-USD',
     asset: 'BTC',
     currency: 'USD',
     normalized: 'gdax.BTC-USD' },
  exchange:
   { name: 'gdax',
     historyScan: 'backward',
     makerFee: 0,
     takerFee: 0.3,
     getProducts: [Function: getProducts],
     getTrades: [Function: getTrades],
     getBalance: [Function: getBalance],
     getQuote: [Function: getQuote],
     cancelOrder: [Function: cancelOrder],
     buy: [Function: buy],
     sell: [Function: sell],
     getOrder: [Function: getOrder],
     getCursor: [Function: getCursor] },
  product_id: 'BTC-USD',
  asset: 'BTC',
  currency: 'USD' }

Looks like the following patch takes care of it:

diff --git a/lib/engine.js b/lib/engine.js
index 9b6bf25..bb5690b 100644
--- a/lib/engine.js
+++ b/lib/engine.js
@@ -13,7 +13,9 @@ module.exports = function container (get, set, clear) {
   var c = get('conf')
   var notify = get('lib.notify')
   return function (s) {
-   var so = s.options
+   var so = s

and everything suddenly works. However this is clearly not the right patch, refactoring so for s and getting rid of so would make more sense. Although even when that's done, that breaks the trade subcommand with the same error. It seems like trade and balance subcommands expect different s objects.

@haxwell
Copy link
Contributor

haxwell commented Dec 23, 2017

Yes, the present design shares state between the engine and certain commands. The problem you just found was that balance.js was not putting that state in the same place the engine expected to find it. I have submitted PR #978 to correct this.

Good write-up! The ultimate solution I think will come in refactoring that state to be accessible via one object, rather than two or more as it currently is. This will be part of a unit-testing effort, issue #403.

@LoneWolf345
Copy link
Contributor

Are you still experiencing this problem? If not, consider closing this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants