UNPKG

jesse-indicators

Version:

A Technical indicator library for TypeScript.

36 lines 1.55 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; }; Object.defineProperty(exports, "__esModule", { value: true }); const RSI_1 = __importStar(require("../RSI")); const _1 = require("."); const testData_1 = __importStar(require("./testData")); it('Should return the current StochRSI', () => { const RSIs = []; const stochs = []; const SRSIs = []; const period = 14; const smoothK = 3; let currentRSI = RSI_1.default(testData_1.default.slice(0, period), period); RSIs.push(currentRSI.RSI); for (let i = period; i < testData_1.default.length; i++) { currentRSI = RSI_1.quickRSI(testData_1.default[i], testData_1.default[i - 1], period, currentRSI.averageGain, currentRSI.averageLoss); RSIs.push(currentRSI.RSI); if (RSIs.length >= period) { stochs.push(_1.stoch(RSIs.slice(i - (period - 1) * 2), period)); } if (stochs.length >= smoothK) { SRSIs.push(_1.smoothedStoch(stochs.slice(i - period * 2), smoothK)); } } expect(RSIs.length).toBe(testData_1.default.length - (period - 1)); expect(SRSIs.length).toBe(testData_1.rawCandles.length - period * 2); expect(RSIs).toEqual(testData_1.expectedRSI); expect(SRSIs).toEqual(testData_1.expectedSRSI); }); //# sourceMappingURL=StochRSI.test.js.map