UNPKG

jesse-indicators

Version:

A Technical indicator library for TypeScript.

51 lines 2.54 kB
"use strict"; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const _1 = __importStar(require(".")); const lodash_1 = __importDefault(require("lodash")); const close = [44.34, 44.09, 44.15, 43.61, 44.33, 44.83, 45.1, 45.42, 45.84, 46.08, 45.89, 46.03, 45.61, 46.28]; it('Should return the current RSI based on prices over the period', () => { expect(lodash_1.default.round(_1.default(close, 14).RSI, 2)).toBe(70.46); }); it('Should return the current RSI based on previous info', () => { const { averageGain, averageLoss } = _1.averageLossAndGain(close); expect(lodash_1.default.round(_1.quickRSI(46, close[close.length - 1], 14, averageGain, averageLoss).RSI, 2)).toBe(66.25); }); it('Should see if quickRSI and RSI return exactly the same on a larger dataset', () => { const values1 = [81.59, 81.06, 82.87, 83, 83.61, 83.15]; const RSIs1 = []; let rsi = _1.default(values1, 6); expect(Math.round(rsi.RSI)).toBe(Math.round(72.03)); RSIs1.push(rsi.RSI); rsi = _1.quickRSI(82.84, 83.15, 6, rsi.averageGain, rsi.averageLoss); expect(Math.round(rsi.RSI)).toBe(Math.round(64.93)); RSIs1.push(rsi.RSI); rsi = _1.quickRSI(83.99, 82.84, 6, rsi.averageGain, rsi.averageLoss); expect(Math.round(rsi.RSI)).toBe(Math.round(75.94)); RSIs1.push(rsi.RSI); rsi = _1.quickRSI(84.55, 83.99, 6, rsi.averageGain, rsi.averageLoss); expect(Math.round(rsi.RSI)).toBe(Math.round(79)); RSIs1.push(rsi.RSI); rsi = _1.quickRSI(84.36, 84.55, 6, rsi.averageGain, rsi.averageLoss); expect(Math.round(rsi.RSI)).toBe(Math.round(74.71)); RSIs1.push(rsi.RSI); rsi = _1.quickRSI(85.53, 84.36, 6, rsi.averageGain, rsi.averageLoss); expect(Math.round(rsi.RSI)).toBe(Math.round(82)); RSIs1.push(rsi.RSI); rsi = _1.quickRSI(86.54, 85.53, 6, rsi.averageGain, rsi.averageLoss); expect(Math.round(rsi.RSI)).toBe(Math.round(86)); RSIs1.push(rsi.RSI); rsi = _1.quickRSI(86.89, 86.54, 6, rsi.averageGain, rsi.averageLoss); expect(Math.round(rsi.RSI)).toBe(Math.round(88)); RSIs1.push(rsi.RSI); }); //# sourceMappingURL=RSI.test.js.map