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.

29 lines (24 loc) 616 B
import { Indicator } from '@/lib/Indicator' import { parseIntoRows } from '@/utils/parseOHLCV' import ta from 'technicalindicators' export class VWAP extends Indicator { constructor(key: string) { super({ name: 'VWAP', key: key, description: 'Volume-weighted Average Price.', }) } generate(): number[] { const { closes, highs, lows, opens, timestamps, volumes } = parseIntoRows( this.data, ) const vwap = ta.VWAP.calculate({ close: closes, high: highs, low: lows, volume: volumes, }) return vwap } }