meridianalgo-js
Version:
Advanced algorithmic trading library for Node.js & TypeScript with 100+ technical indicators, pattern recognition, and risk management tools.
169 lines • 7.08 kB
TypeScript
/**
* Volatility Technical Indicators
*
* This module provides volatility-based technical analysis indicators including
* Keltner Channels, Donchian Channels, Standard Deviation, and other volatility metrics.
*
* @fileoverview Volatility indicators for technical analysis
* @author MeridianAlgo
* @version 1.0.0
*/
/**
* Keltner Channels
*
* Keltner Channels are volatility-based envelopes set above and below an exponential
* moving average. The channels are typically set 2 standard deviations away from
* the EMA, and the indicator is used to identify overbought and oversold conditions.
*
* @param high - Array of high prices
* @param low - Array of low prices
* @param close - Array of closing prices
* @param period - Number of periods for EMA calculation (default: 20)
* @param multiplier - Standard deviation multiplier (default: 2)
* @param atrPeriod - ATR period for calculation (default: 10)
* @returns Object containing upper, middle, and lower channel values
*
* @example
* ```typescript
* const high = [100, 101, 102, 103, 104];
* const low = [99, 100, 101, 102, 103];
* const close = [99.5, 100.5, 101.5, 102.5, 103.5];
* const keltner = VolatilityIndicators.keltnerChannels(high, low, close);
* ```
*/
export declare function keltnerChannels(high: number[], low: number[], close: number[], period?: number, multiplier?: number, atrPeriod?: number): {
upper: number[];
middle: number[];
lower: number[];
};
/**
* Standard Deviation
*
* Calculates the standard deviation of price data over a specified period.
* This is useful for measuring price volatility and creating volatility-based indicators.
*
* @param prices - Array of price data
* @param period - Number of periods for calculation (default: 20)
* @returns Array of standard deviation values
*/
export declare function standardDeviation(prices: number[], period?: number): number[];
/**
* Variance
*
* Calculates the variance of price data over a specified period.
* Variance is the square of standard deviation and measures price dispersion.
*
* @param prices - Array of price data
* @param period - Number of periods for calculation (default: 20)
* @returns Array of variance values
*/
export declare function variance(prices: number[], period?: number): number[];
/**
* Average Deviation
*
* Calculates the average deviation (mean absolute deviation) of price data
* over a specified period. This provides a measure of price volatility.
*
* @param prices - Array of price data
* @param period - Number of periods for calculation (default: 20)
* @returns Array of average deviation values
*/
export declare function averageDeviation(prices: number[], period?: number): number[];
/**
* Historical Volatility
*
* Calculates the historical volatility of price data using the standard deviation
* of logarithmic returns over a specified period.
*
* @param prices - Array of price data
* @param period - Number of periods for calculation (default: 20)
* @param annualized - Whether to annualize the volatility (default: true)
* @returns Array of historical volatility values
*/
export declare function historicalVolatility(prices: number[], period?: number, annualized?: boolean): number[];
/**
* Parkinson Volatility
*
* Parkinson volatility uses high and low prices to estimate volatility.
* It's more efficient than close-to-close volatility as it uses more information.
*
* @param high - Array of high prices
* @param low - Array of low prices
* @param period - Number of periods for calculation (default: 20)
* @param annualized - Whether to annualize the volatility (default: true)
* @returns Array of Parkinson volatility values
*/
export declare function parkinsonVolatility(high: number[], low: number[], period?: number, annualized?: boolean): number[];
/**
* Garman-Klass Volatility
*
* Garman-Klass volatility uses open, high, low, and close prices to estimate volatility.
* It's more efficient than Parkinson volatility as it uses all OHLC data.
*
* @param open - Array of opening prices
* @param high - Array of high prices
* @param low - Array of low prices
* @param close - Array of closing prices
* @param period - Number of periods for calculation (default: 20)
* @param annualized - Whether to annualize the volatility (default: true)
* @returns Array of Garman-Klass volatility values
*/
export declare function garmanKlassVolatility(open: number[], high: number[], low: number[], close: number[], period?: number, annualized?: boolean): number[];
/**
* Rogers-Satchell Volatility
*
* Rogers-Satchell volatility is another OHLC-based volatility estimator
* that doesn't require the assumption of zero drift.
*
* @param open - Array of opening prices
* @param high - Array of high prices
* @param low - Array of low prices
* @param close - Array of closing prices
* @param period - Number of periods for calculation (default: 20)
* @param annualized - Whether to annualize the volatility (default: true)
* @returns Array of Rogers-Satchell volatility values
*/
export declare function rogersSatchellVolatility(open: number[], high: number[], low: number[], close: number[], period?: number, annualized?: boolean): number[];
/**
* Yang-Zhang Volatility
*
* Yang-Zhang volatility is the most efficient volatility estimator that uses
* OHLC data and doesn't require the assumption of zero drift.
*
* @param open - Array of opening prices
* @param high - Array of high prices
* @param low - Array of low prices
* @param close - Array of closing prices
* @param period - Number of periods for calculation (default: 20)
* @param annualized - Whether to annualize the volatility (default: true)
* @returns Array of Yang-Zhang volatility values
*/
export declare function yangZhangVolatility(open: number[], high: number[], low: number[], close: number[], period?: number, annualized?: boolean): number[];
/**
* Volatility Ratio
*
* Calculates the ratio of current volatility to historical volatility.
* Values above 1 indicate higher than normal volatility.
*
* @param prices - Array of price data
* @param shortPeriod - Short period for current volatility (default: 10)
* @param longPeriod - Long period for historical volatility (default: 20)
* @returns Array of volatility ratio values
*/
export declare function volatilityRatio(prices: number[], shortPeriod?: number, longPeriod?: number): number[];
/**
* Collection of volatility-based technical indicators
*/
export declare const VolatilityIndicators: {
keltnerChannels: typeof keltnerChannels;
standardDeviation: typeof standardDeviation;
variance: typeof variance;
averageDeviation: typeof averageDeviation;
historicalVolatility: typeof historicalVolatility;
parkinsonVolatility: typeof parkinsonVolatility;
garmanKlassVolatility: typeof garmanKlassVolatility;
rogersSatchellVolatility: typeof rogersSatchellVolatility;
yangZhangVolatility: typeof yangZhangVolatility;
volatilityRatio: typeof volatilityRatio;
};
//# sourceMappingURL=volatility.d.ts.map