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.
33 lines (26 loc) • 745 B
text/typescript
import { Indicator } from '@/lib/Indicator'
import { parseIntoRows } from '@/utils/parseOHLCV'
import ta from 'technicalindicators'
export class ForceIndex extends Indicator {
public period: number = 9
constructor(key: string, options: ForceIndexOptions) {
super({
name: 'ForceIndex',
key: key,
description: 'Force Index.',
})
if (options.period) this.period = options.period
}
generate(): number[] {
const { closes, volumes } = parseIntoRows(this.data)
const forceIndex = ta.ForceIndex.calculate({
period: this.period,
close: closes,
volume: volumes,
})
return forceIndex
}
}
export interface ForceIndexOptions {
period: number
}