stock-indicator
Version:
Stock Indicator Library
22 lines • 994 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BOLL = BOLL;
const common_1 = require("../common");
const index_1 = require("./../common/index");
/**
* - 计算BOLL指标
* @param {number[]} CLOSE - 收盘价序列
* @param {number} M - 周期 default: 20
* @returns {{ BOLL: TMixed[]; UB: TMixed[]; LB: TMixed[] }} - BOLL指标结果
*/
function BOLL(CLOSE, M = 20) {
(0, common_1.checkArrayOfNumbers)(CLOSE, "CLOSE");
(0, common_1.checkNumber)(M, 1, Number.MAX_SAFE_INTEGER, "M", "BOLL");
const mid = (0, common_1.funMA)(CLOSE, M);
const std = (0, common_1.funSTD)(CLOSE, M);
const BOLL = mid.map((v, i) => (0, index_1.funRound)(v, 3));
const UB = mid.map((v, i) => v === null || std[i] === null ? null : (0, index_1.funRound)(v + 2 * std[i], 3));
const LB = mid.map((v, i) => v === null || std[i] === null ? null : (0, index_1.funRound)(v - 2 * std[i], 3));
return { BOLL, UB, LB };
}
//# sourceMappingURL=boll.js.map