stock-indicator
Version:
Stock Indicator Library
139 lines (138 loc) • 6.32 kB
TypeScript
export type TMixed = number | null;
/**
* - check if the parameter is an array of numbers or null values
* @param {number[]} arr - array to be checked
* @param {string} parameName - name of the parameter
*/
export declare function checkArrayOfNumbers(arr: number[], parameName: string): void;
/**
* - check if the parameter is a number between min and max
* @param {number} num - number to be checked
* @param {number} min - minimum value
* @param {number} max - maximum value
* @param {string} parameName - name of the parameter
* @param {string} maxName - name of the array
*/
export declare function checkNumber(num: number, min: number, max: TMixed[] | number, parameName: string, maxName: string): void;
/**
* - Sum of n-period moving averages (SUM)
* @param {TMixed[]} arr - closing prices of the stock
* @param {number} n - number of periods to calculate the SUM, must be greater than 1 and less than the length of the CLOSE array
*/
export declare function funMS(arr: TMixed[], n: number): TMixed[];
/**
* - Moving Average (MA)
* @param {TMixed[]} arr - - closing prices of the stock
* @param {number} n - - number of periods to calculate the moving average, must be between 2 and the length of the CLOSE array
* @returns { TMixed[] } } - array of moving average values
*/
export declare function funMA(arr: TMixed[], n: number): TMixed[];
/**
* SMA (Simple Moving Average)
* @param {TMixed[]} arr - An array of the closing price of the stock
* @param {number} n - The number of periods to calculate the SMA for. Must be between 2 and the length of the CLOSE array.
* @param {number} m - The number of periods to calculate the SMA for. Must be between 0 and N-1.
* @returns {{ SMA: TMixed[] }} - The SMA values for the given data and parameters
*/
export declare function funSMA(arr: TMixed[], n: number, m: number): TMixed[];
/**
* - Exponential Moving Average (EMA)
* @param {TMixed[]} arr - closing prices of the stock
* @param {number} n - number of periods to calculate the EMA,must be greater than 1 and less than the length of the CLOSE array
* @param {number} m - number of periods to calculate the initial EMA, default is 1,must be less than N
* @returns {{ EMA: TMixed[] }} - object with the EMA values
*/
export declare function funEMA(arr: TMixed[], n: number, m?: number): TMixed[];
/**
* WMA - Weighted Moving Average
* @param {TMixed[]} arr should be an array of numbers or null values
* @param {number} n should be a number between 2 and the length of the data array
* @returns {TMixed[]} WMA values
*/
export declare function funWMA(arr: TMixed[], n: number): TMixed[];
/**
* - Standard Deviation (STD)
* @param {TMixed[]} arr - closing prices of the stock
* @param {number} n - number of periods to calculate the STD, must be greater than 1 and less than the length of the CLOSE array
* @returns { TMixed[] } - array of standard deviation values
*/
export declare function funSTD(arr: TMixed[], n: number): TMixed[];
/**
* - Average Variance Enhanced (AVEDEV)
* @param {TMixed[]} arr - closing prices of the stock
* @param {number} n - number of periods to calculate the AVEDEV, must be greater than 1 and less than the length of the CLOSE array
* @returns { TMixed[] } - array of average variance enhanced values
*/
export declare function funAVEDEV(arr: TMixed[], n: number): TMixed[];
/**
* - subtract two arrays element by element
* @param {TMixed[]} subtractor - array to be subtracted from
* @param {TMixed[]} minuend - array to be subtracted
* @returns {TMixed[]} - array of subtracted values
*/
export declare function funArrSub(subtractor: TMixed[], minuend: TMixed[]): TMixed[];
/**
* - add two or more arrays element by element
* @param {TMixed[]}...args - arrays to be added
* @returns {TMixed[]} - array of added values
*/
export declare function funArrAdd(...args: TMixed[][]): TMixed[];
/**
* - divide two arrays element by element
* @param {TMixed[]} divisor - array to be divided
* @param {TMixed[]} dividend - array to divide by
* @returns {TMixed[]}- array of divided values
*/
export declare function funArrDiv(divisor: TMixed[], dividend: TMixed[]): TMixed[];
/**
* - multiply two arrays element by element
* @param {TMixed[]} arr1 - first array to be multiplied
* @param {TMixed[]} arr2 - second array to be multiplied
* @returns {TMixed[]} - array of multiplied values
*/
export declare function funArrMul(arr1: TMixed[], arr2: TMixed[]): TMixed[];
/**
* - absolute value of an array
* @param {TMixed[]} arr - array to be absolute value of
* @returns {TMixed[]} - array of absolute values
*/
export declare function funArrAbs(arr: TMixed[]): TMixed[];
/**
* - rounded to n decimal places
* @param {number} num - number to be rounded
* @param {number} n - number of decimal places to round to
* @returns {number} - rounded number
*/
export declare function funRound(num: TMixed, n: number): TMixed;
/**
* - check if a is greater than b with a given precision
* @param {number} a - first number
* @param {number} b - second number
* @param {number} precision - precision to compare the numbers
* @returns {boolean} - true if a is greater than b, false otherwise
*/
export declare function aGtB(a: number, b: number, precision?: number): boolean;
/**
* - check if a is less than b with a given precision
* @param {number} a - first number
* @param {number} b - second number
* @param {number} precision - precision to compare the numbers
* @returns {boolean} - true if a is less than b, false otherwise
*/
export declare function aLtB(a: number, b: number, precision?: number): boolean;
/**
* - check if a is equal to b with a given precision
* @param {number} a - first number
* @param {number} b - second number
* @param {number} precision - precision to compare the numbers
* @returns {boolean} - true if a is equal to b, false otherwise
*/
export declare function aEqB(a: number, b: number, precision?: number): boolean;
/**
* - check if a is not equal to b with a given precision
* @param {number} a - first number
* @param {number} b - second number
* @param {number} precision - precision to compare the numbers
* @returns {boolean} - true if a is not equal to b, false otherwise
*/
export declare function aNeqB(a: number, b: number, precision?: number): boolean;