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.
36 lines (29 loc) • 888 B
text/typescript
import { Indicator } from '@/lib/Indicator'
import { parseIntoRows } from '@/utils/parseOHLCV'
import ta from 'technicalindicators'
export class VolumeProfile extends Indicator {
public numberOfBars: number = 20
constructor(key: string, options: VolumeProfileOptions) {
super({
name: 'Volume Profile',
key: key,
description: 'Volume Profile.',
})
if (options.numberOfBars) this.numberOfBars = options.numberOfBars
}
generate(): number[] {
const { closes, highs, lows, opens, volumes } = parseIntoRows(this.data)
const volumeProfile = ta.VolumeProfile.calculate({
close: closes,
high: highs,
low: lows,
open: opens,
volume: volumes,
noOfBars: this.numberOfBars,
})
return volumeProfile
}
}
export interface VolumeProfileOptions {
numberOfBars?: number
}