csupnig / ta-lib

A technical analysis library written in JavaScript/TypeScript
MIT License
47 stars 13 forks source link

readme example contains error #9

Closed hems closed 6 years ago

hems commented 7 years ago

If i try to run the example from the demo: talib.SMA([23,34,12,34,23], 12) it will yield an error:

TypeError: Reduce of empty array with no initial value
    at Array.reduce (native)
    at Object.SMA (/Users/h/git/makers_demo/node_modules/ta-lib/index.js:142:24)
    at repl:1:11
    at ContextifyScript.Script.runInThisContext (vm.js:25:33)
    at Object.exports.runInThisContext (vm.js:77:17)
    at runInContext (/Users/h/.nvm/versions/node/v6.9.5/lib/node_modules/coffee-script/lib/coffee-script/repl.js:58:17)
    at REPLServer.eval (/Users/h/.nvm/versions/node/v6.9.5/lib/node_modules/coffee-script/lib/coffee-script/repl.js:47:25)
    at bound (domain.js:280:14)
....
csupnig commented 7 years ago

Hi Hems... thanks for pointing that out. You need to passt an array which has a greater length than the provided sample length (12). I will fix the example as soon as possible ;)

hems commented 7 years ago

yeah i got that! was just doing a demo the other day and noticed that copy+paste from readme doesn't work ( :

csupnig commented 6 years ago

I extended the Readme ;)