26medias / timeseries-analysis

NPM Package - Timeseries analysis, noise removal, stats, ...
237 stars 48 forks source link

Returning NAN after length of indicator. #12

Closed thisisloze closed 5 years ago

thisisloze commented 5 years ago
const dataForge = require('data-forge');
require('data-forge-fs');
require('data-forge-plot');
const timeseries = require("timeseries-analysis");

const df = dataForge.readFileSync('binance_btc_usdt_time_5m.csv')
    .parseCSV()
    .dropSeries(['id', 'open', 'high', 'low', 'volume', 'startTime', 'endTime', 'tradeId']) // Drop certain columns

const newDfArray = df.toArray()

// Load the data
const t     = new timeseries.main(newDfArray);
const trend = t.lwma({
    period:    6
});

// returns https://chart.googleapis.com/chart?cht=lc&chs=800x200&chxt=y&chd=s:JDOLhghn0s92xuilnptvxz1110zzzyyvrlgZUPMHA&chco=76a4fb&chm=&chds=63.13,70.78&chxr=0,63.13,70.78,10
console.log(t.ma().output())

Trying to use your script. Its returning this for t.ma().output();

[ { close: '4261.48' },
  { close: '4266.29' },
  { close: '4261.45' },
  { close: '4296.63' },
  { close: '4300.38' },
  { close: '4310.07' },
  [ undefined, NaN ],
  [ undefined, NaN ],
  [ undefined, NaN ],
  [ undefined, NaN ],
  [ undefined, NaN ],
  [ undefined, NaN ],
  [ undefined, NaN ],
  [ undefined, NaN ],
  [ undefined, NaN ],
  [ undefined, NaN ],
  [ undefined, NaN ],
  [ undefined, NaN ],
  [ undefined, NaN ],
etc....

Any clue why?