UNPKG

quant-zero

Version:

Node-Quant is a powerful Node.js package for developing and testing quantitative trading strategies in cryptocurrency markets, offering tools for backtesting and performance analysis.

35 lines (28 loc) 807 B
import { Indicator } from '@/lib/Indicator' import { parseIntoRows } from '@/utils/parseOHLCV' import ta from 'technicalindicators' import { ADXOutput } from 'technicalindicators/declarations/directionalmovement/ADX' export class ADX extends Indicator { public period: number = 9 constructor(key: string, options: ADXOptions) { super({ name: 'ADX', key: key, description: 'Trend Strength.', }) if (options.period) this.period = options.period } generate(): ADXOutput[] { const { closes, highs, lows } = parseIntoRows(this.data) const adx = ta.ADX.calculate({ period: this.period, close: closes, high: highs, low: lows, }) return adx } } export interface ADXOptions { period?: number }