Bot & Automation
Treding Forex Ai
/root/hermes-projects/Treding Forex Ai
dist/tests/math.test.js
text
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const math_1 = require("../src/utils/math");
(0, vitest_1.describe)("indicator helpers", () => {
(0, vitest_1.it)("calculates EMA for a known increasing series", () => {
const ema = (0, math_1.exponentialMovingAverage)([1, 2, 3, 4, 5], 3);
(0, vitest_1.expect)(ema).toBeGreaterThan(3);
(0, vitest_1.expect)(ema).toBeLessThan(5);
});
(0, vitest_1.it)("returns neutral RSI for insufficient data", () => {
(0, vitest_1.expect)((0, math_1.relativeStrengthIndex)([1, 2, 3], 14)).toBe(50);
});
(0, vitest_1.it)("calculates ATR above zero when candles move", () => {
const candles = [
{ time: "1", open: 1, high: 2, low: 0.5, close: 1.5, volume: 10 },
{ time: "2", open: 1.5, high: 2.5, low: 1.2, close: 2, volume: 10 },
{ time: "3", open: 2, high: 3, low: 1.8, close: 2.6, volume: 10 }
];
(0, vitest_1.expect)((0, math_1.averageTrueRange)(candles, 2)).toBeGreaterThan(0);
});
});