bitfinexcom / bfx-hf-indicators

Apache License 2.0
58 stars 36 forks source link

RSI return value undefined #63

Closed AntoLC closed 3 years ago

AntoLC commented 3 years ago

Issue type

Brief description

I have a problem with the RSI indicator, in some cases it returns "undefined" values. I created a simple test based on the example inside the README.md, I get every time "undefined".

Steps to reproduce

Inside the directory test, create a file rsi.js by example, with the following, then tape "yarn mocha"

/* eslint-env mocha */
 'use strict'

 const assert = require('assert')
 const { RSI } = require('../dist')

 describe('RSI', () => {
  it('Test', () => {
    for (let index = 0; index < 100; index++) {
      const rsi = new RSI([8])
      rsi.add(14000)
      rsi.add(14010)
      rsi.add(14025)
      rsi.add(14035)
      rsi.add(14500)
      rsi.add(14100)
      rsi.add(14125)
      rsi.add(14335)
      rsi.add(14600)
      rsi.add(14710)

      console.debug('RSI', rsi.v())

      if (rsi.v().isUndefined()) {
        assert.fail('RSI problem:' + index)
      }
    }

    assert.isOk('RSI OK')
   })
 })
robertkowalski commented 3 years ago

thanks for reporting, was able to reproduce the issue. we are going to fix it soon

robertkowalski commented 3 years ago

fixed on current master branch :)