diff --git a/src/helper/numArray.test.ts b/src/helper/numArray.test.ts index b5d1ae5..f70258e 100644 --- a/src/helper/numArray.test.ts +++ b/src/helper/numArray.test.ts @@ -67,21 +67,21 @@ describe('Number Array', () => { deepStrictEqual(actual, expected); }); - it('should be able to substract values', () => { + it('should be able to subtract values', () => { const values1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]; const values2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; const expected = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]; - const actual = NumArray.substract(values1, values2); + const actual = NumArray.subtract(values1, values2); deepStrictEqual(actual, expected); }); - it('should be able to substract by', () => { + it('should be able to subtract by', () => { const values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]; const expected = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99]; const n = 1; - const actual = NumArray.substractBy(n, values); + const actual = NumArray.subtractBy(n, values); deepStrictEqual(actual, expected); }); diff --git a/src/helper/numArray.ts b/src/helper/numArray.ts index 8a89dac..4c507ea 100644 --- a/src/helper/numArray.ts +++ b/src/helper/numArray.ts @@ -129,12 +129,12 @@ export function multiplyBy(n: number, values: number[]): number[] { } /** - * Substracts values2 from values1. + * Subtracts values2 from values1. * @param values1 values one. * @param values2 values two. * @return result array. */ -export function substract(values1: number[], values2: number[]): number[] { +export function subtract(values1: number[], values2: number[]): number[] { checkSameLength(values1, values2); const result = new Array(values1.length); @@ -147,12 +147,12 @@ export function substract(values1: number[], values2: number[]): number[] { } /** - * Substractes n from values. - * @param n substract value. + * Subtractes n from values. + * @param n subtract value. * @param values values array. * @return result array. */ -export function substractBy(n: number, values: number[]): number[] { +export function subtractBy(n: number, values: number[]): number[] { const result = new Array(values.length); for (let i = 0; i < values.length; i++) { @@ -204,7 +204,7 @@ export function shiftRightBy(n: number, values: number[]): number[] { * @returns changes array. */ export function changes(n: number, values: number[]): number[] { - return substract(values, shiftRightBy(n, values)); + return subtract(values, shiftRightBy(n, values)); } /** diff --git a/src/indicator/momentum/awesomeOscillator.ts b/src/indicator/momentum/awesomeOscillator.ts index 46f2eda..a55230d 100644 --- a/src/indicator/momentum/awesomeOscillator.ts +++ b/src/indicator/momentum/awesomeOscillator.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { add, divideBy, substract } from '../../helper/numArray'; +import { add, divideBy, subtract } from '../../helper/numArray'; import { sma } from '../trend/sma'; /** @@ -18,6 +18,6 @@ export function awesomeOscillator(highs: number[], lows: number[]): number[] { const medianPrice = divideBy(2, add(lows, highs)); const sma5 = sma(5, medianPrice); const sma34 = sma(34, medianPrice); - const ao = substract(sma5, sma34); + const ao = subtract(sma5, sma34); return ao; } diff --git a/src/indicator/momentum/chaikinOscillator.ts b/src/indicator/momentum/chaikinOscillator.ts index 27fd068..d60622a 100644 --- a/src/indicator/momentum/chaikinOscillator.ts +++ b/src/indicator/momentum/chaikinOscillator.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { substract } from '../../helper/numArray'; +import { subtract } from '../../helper/numArray'; import { ema } from '../trend/ema'; import { accumulationDistribution } from '../volume/accumulationDistribution'; @@ -39,7 +39,7 @@ export function chaikinOscillator( volumes: number[] ): ChaikinOscillator { const ad = accumulationDistribution(highs, lows, closings, volumes); - const co = substract(ema(fastPeriod, ad), ema(slowPeriod, ad)); + const co = subtract(ema(fastPeriod, ad), ema(slowPeriod, ad)); return { ad, diff --git a/src/indicator/momentum/percentagePriceOscillator.ts b/src/indicator/momentum/percentagePriceOscillator.ts index 1edb982..d97fff6 100644 --- a/src/indicator/momentum/percentagePriceOscillator.ts +++ b/src/indicator/momentum/percentagePriceOscillator.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { divide, multiplyBy, substract } from '../../helper/numArray'; +import { divide, multiplyBy, subtract } from '../../helper/numArray'; import { ema } from '../trend/ema'; /** Default fast period value. */ @@ -46,9 +46,9 @@ export function percentagePriceOscillator( const fastEma = ema(fastPeriod, prices); const slowEma = ema(slowPeriod, prices); - const ppo = multiplyBy(100, divide(substract(fastEma, slowEma), slowEma)); + const ppo = multiplyBy(100, divide(subtract(fastEma, slowEma), slowEma)); const signal = ema(signalPeriod, ppo); - const histogram = substract(ppo, signal); + const histogram = subtract(ppo, signal); return { ppo, diff --git a/src/indicator/momentum/percentageVolumeOscillator.ts b/src/indicator/momentum/percentageVolumeOscillator.ts index 8b79ab6..25beaee 100644 --- a/src/indicator/momentum/percentageVolumeOscillator.ts +++ b/src/indicator/momentum/percentageVolumeOscillator.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { divide, multiplyBy, substract } from '../../helper/numArray'; +import { divide, multiplyBy, subtract } from '../../helper/numArray'; import { ema } from '../trend/ema'; /** Default fast period value. */ @@ -46,9 +46,9 @@ export function percentageVolumeOscillator( const fastEma = ema(fastPeriod, volumes); const slowEma = ema(slowPeriod, volumes); - const pvo = multiplyBy(100, divide(substract(fastEma, slowEma), slowEma)); + const pvo = multiplyBy(100, divide(subtract(fastEma, slowEma), slowEma)); const signal = ema(signalPeriod, pvo); - const histogram = substract(pvo, signal); + const histogram = subtract(pvo, signal); return { pvo, diff --git a/src/indicator/momentum/stochasticOscillator.ts b/src/indicator/momentum/stochasticOscillator.ts index f9a40e9..c2b31d2 100644 --- a/src/indicator/momentum/stochasticOscillator.ts +++ b/src/indicator/momentum/stochasticOscillator.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { divide, multiplyBy, substract } from '../../helper/numArray'; +import { divide, multiplyBy, subtract } from '../../helper/numArray'; import { mmin } from '../trend/mmin'; import { mmax } from '../trend/mmax'; import { sma } from '../trend/sma'; @@ -38,8 +38,8 @@ export function stochasticOscillator( const k = multiplyBy( 100, divide( - substract(closings, lowestLow14), - substract(highestHigh14, lowestLow14) + subtract(closings, lowestLow14), + subtract(highestHigh14, lowestLow14) ) ); diff --git a/src/indicator/momentum/williamsR.ts b/src/indicator/momentum/williamsR.ts index e33ac97..53282c9 100644 --- a/src/indicator/momentum/williamsR.ts +++ b/src/indicator/momentum/williamsR.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { divide, multiplyBy, substract } from '../../helper/numArray'; +import { divide, multiplyBy, subtract } from '../../helper/numArray'; import { mmax } from '../trend/mmax'; import { mmin } from '../trend/mmin'; @@ -28,6 +28,6 @@ export function williamsR( const lowestLow = mmin(PERIOD, lows); return multiplyBy( -100, - divide(substract(highestHigh, closings), substract(highestHigh, lowestLow)) + divide(subtract(highestHigh, closings), subtract(highestHigh, lowestLow)) ); } diff --git a/src/indicator/trend/absolutePriceOscillator.ts b/src/indicator/trend/absolutePriceOscillator.ts index e11550f..a157cde 100644 --- a/src/indicator/trend/absolutePriceOscillator.ts +++ b/src/indicator/trend/absolutePriceOscillator.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { substract } from '../../helper/numArray'; +import { subtract } from '../../helper/numArray'; import { ema } from './ema'; /** @@ -26,7 +26,7 @@ export function absolutePriceOscillator( ): number[] { const fast = ema(fastPeriod, values); const slow = ema(slowPeriod, values); - const apo = substract(fast, slow); + const apo = subtract(fast, slow); return apo; } diff --git a/src/indicator/trend/balanceOfPower.ts b/src/indicator/trend/balanceOfPower.ts index 0478c96..a85b3d9 100644 --- a/src/indicator/trend/balanceOfPower.ts +++ b/src/indicator/trend/balanceOfPower.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { divide, substract } from '../../helper/numArray'; +import { divide, subtract } from '../../helper/numArray'; /** * The Balance of Power (BOP) function calculates the strength of buying and @@ -23,5 +23,5 @@ export function balanceOfPower( lows: number[], closings: number[] ): number[] { - return divide(substract(closings, openings), substract(highs, lows)); + return divide(subtract(closings, openings), subtract(highs, lows)); } diff --git a/src/indicator/trend/chandeForecastOscillator.ts b/src/indicator/trend/chandeForecastOscillator.ts index ce9cf72..11c8ded 100644 --- a/src/indicator/trend/chandeForecastOscillator.ts +++ b/src/indicator/trend/chandeForecastOscillator.ts @@ -5,7 +5,7 @@ import { divide, generateNumbers, multiplyBy, - substract, + subtract, } from '../../helper/numArray'; import { linearRegressionUsingLeastSquare, @@ -28,7 +28,7 @@ import { export function chandeForecastOscillator(closings: number[]): number[] { const x = generateNumbers(0, closings.length, 1); const r = linearRegressionUsingLeastSquare(x, closings); - const cfo = multiplyBy(100, divide(substract(closings, r), closings)); + const cfo = multiplyBy(100, divide(subtract(closings, r), closings)); return cfo; } @@ -55,6 +55,6 @@ export function movingChandeForecastOscillator( ): number[] { const x = generateNumbers(0, closings.length, 1); const r = movingLinearRegressionUsingLeastSquare(period, x, closings); - const cfo = multiplyBy(100, divide(substract(closings, r), closings)); + const cfo = multiplyBy(100, divide(subtract(closings, r), closings)); return cfo; } diff --git a/src/indicator/trend/communityChannelIndex.ts b/src/indicator/trend/communityChannelIndex.ts index 6631e9a..5c0aa28 100644 --- a/src/indicator/trend/communityChannelIndex.ts +++ b/src/indicator/trend/communityChannelIndex.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { abs, divide, multiplyBy, substract } from '../../helper/numArray'; +import { abs, divide, multiplyBy, subtract } from '../../helper/numArray'; import { sma } from './sma'; import { typicalPrice } from './typicalPrice'; @@ -33,8 +33,8 @@ export function communityChannelIndex( ): number[] { const tp = typicalPrice(highs, lows, closings); const ma = sma(period, tp); - const md = sma(period, abs(substract(tp, ma))); - const cci = divide(substract(tp, ma), multiplyBy(0.015, md)); + const md = sma(period, abs(subtract(tp, ma))); + const cci = divide(subtract(tp, ma), multiplyBy(0.015, md)); return cci; } diff --git a/src/indicator/trend/dema.ts b/src/indicator/trend/dema.ts index 6467f01..1a84be6 100644 --- a/src/indicator/trend/dema.ts +++ b/src/indicator/trend/dema.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { multiplyBy, substract } from '../../helper/numArray'; +import { multiplyBy, subtract } from '../../helper/numArray'; import { ema } from './ema'; /** @@ -17,7 +17,7 @@ export function dema(period: number, values: number[]): number[] { const ema1 = ema(period, values); const ema2 = ema(period, ema1); - const dema = substract(multiplyBy(2, ema1), ema2); + const dema = subtract(multiplyBy(2, ema1), ema2); return dema; } diff --git a/src/indicator/trend/kdj.ts b/src/indicator/trend/kdj.ts index 023e291..1d2dfea 100644 --- a/src/indicator/trend/kdj.ts +++ b/src/indicator/trend/kdj.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { divide, multiplyBy, substract } from '../../helper/numArray'; +import { divide, multiplyBy, subtract } from '../../helper/numArray'; import { mmin } from './mmin'; import { mmax } from './mmax'; import { sma } from './sma'; @@ -52,12 +52,12 @@ export function kdj( const rsv = multiplyBy( 100, - divide(substract(closings, lowest), substract(highest, lowest)) + divide(subtract(closings, lowest), subtract(highest, lowest)) ); const k = sma(kPeriod, rsv); const d = sma(dPeriod, k); - const j = substract(multiplyBy(3, k), multiplyBy(2, d)); + const j = subtract(multiplyBy(3, k), multiplyBy(2, d)); return { k, diff --git a/src/indicator/trend/macd.ts b/src/indicator/trend/macd.ts index 649a53f..df369bd 100644 --- a/src/indicator/trend/macd.ts +++ b/src/indicator/trend/macd.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { substract } from '../../helper/numArray'; +import { subtract } from '../../helper/numArray'; import { ema } from './ema'; export interface MacdResult { @@ -22,7 +22,7 @@ export function macd(closings: number[]): MacdResult { const ema12 = ema(12, closings); const ema26 = ema(26, closings); - const macdLine = substract(ema12, ema26); + const macdLine = subtract(ema12, ema26); const signalLine = ema(9, macdLine); return { diff --git a/src/indicator/trend/massIndex.ts b/src/indicator/trend/massIndex.ts index f79aa28..7f4d8b3 100644 --- a/src/indicator/trend/massIndex.ts +++ b/src/indicator/trend/massIndex.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { divide, substract } from '../../helper/numArray'; +import { divide, subtract } from '../../helper/numArray'; import { ema } from './ema'; import { msum } from './msum'; @@ -19,7 +19,7 @@ import { msum } from './msum'; * @returns mi values. */ export function massIndex(highs: number[], lows: number[]): number[] { - const ema1 = ema(9, substract(highs, lows)); + const ema1 = ema(9, subtract(highs, lows)); const ema2 = ema(9, ema1); const ratio = divide(ema1, ema2); const mi = msum(25, ratio); diff --git a/src/indicator/trend/qstick.ts b/src/indicator/trend/qstick.ts index 9844a6f..04d35da 100644 --- a/src/indicator/trend/qstick.ts +++ b/src/indicator/trend/qstick.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { substract } from '../../helper/numArray'; +import { subtract } from '../../helper/numArray'; import { sma } from './sma'; /** @@ -19,5 +19,5 @@ export function qstick( openings: number[], closings: number[] ): number[] { - return sma(period, substract(closings, openings)); + return sma(period, subtract(closings, openings)); } diff --git a/src/indicator/trend/tema.ts b/src/indicator/trend/tema.ts index 10656b1..f7ca7ee 100644 --- a/src/indicator/trend/tema.ts +++ b/src/indicator/trend/tema.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { add, multiplyBy, substract } from '../../helper/numArray'; +import { add, multiplyBy, subtract } from '../../helper/numArray'; import { ema } from './ema'; /** @@ -22,7 +22,7 @@ export function tema(period: number, values: number[]): number[] { const ema3 = ema(period, ema2); const temaLine = add( - substract(multiplyBy(3, ema1), multiplyBy(3, ema2)), + subtract(multiplyBy(3, ema1), multiplyBy(3, ema2)), ema3 ); diff --git a/src/indicator/trend/trix.ts b/src/indicator/trend/trix.ts index 5e1700a..e1dbc8b 100644 --- a/src/indicator/trend/trix.ts +++ b/src/indicator/trend/trix.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { divide, shiftRightAndFillBy, substract } from '../../helper/numArray'; +import { divide, shiftRightAndFillBy, subtract } from '../../helper/numArray'; import { ema } from './ema'; /** @@ -24,6 +24,6 @@ export function trix(period: number, values: number[]): number[] { const ema2 = ema(period, ema1); const ema3 = ema(period, ema2); const previous = shiftRightAndFillBy(1, ema3[0], ema3); - const trix = divide(substract(ema3, previous), previous); + const trix = divide(subtract(ema3, previous), previous); return trix; } diff --git a/src/indicator/trend/vortex.ts b/src/indicator/trend/vortex.ts index e7074c8..3f66a51 100644 --- a/src/indicator/trend/vortex.ts +++ b/src/indicator/trend/vortex.ts @@ -7,7 +7,7 @@ import { divide, max, shiftRightBy, - substract, + subtract, } from '../../helper/numArray'; import { msum } from './msum'; @@ -56,16 +56,16 @@ export function vortex( const prevClosings = shiftRightBy(1, closings); - const plusVm = abs(substract(highs, shiftRightBy(1, lows))); - const minusVm = abs(substract(lows, shiftRightBy(1, highs))); + const plusVm = abs(subtract(highs, shiftRightBy(1, lows))); + const minusVm = abs(subtract(lows, shiftRightBy(1, highs))); const plusVmSum = msum(VORTEX_PERIOD, plusVm); const minusVmSum = msum(VORTEX_PERIOD, minusVm); const tr = max( - substract(highs, lows), - abs(substract(highs, prevClosings)), - abs(substract(lows, prevClosings)) + subtract(highs, lows), + abs(subtract(highs, prevClosings)), + abs(subtract(lows, prevClosings)) ); const trSum = msum(VORTEX_PERIOD, tr); diff --git a/src/indicator/volatility/accelerationBands.ts b/src/indicator/volatility/accelerationBands.ts index fb7eff9..348dde4 100644 --- a/src/indicator/volatility/accelerationBands.ts +++ b/src/indicator/volatility/accelerationBands.ts @@ -8,7 +8,7 @@ import { divide, multiply, multiplyBy, - substract, + subtract, } from '../../helper/numArray'; import { sma } from '../trend/sma'; @@ -41,7 +41,7 @@ export function accelerationBands( ): AccelerationBands { checkSameLength(highs, lows, closings); - const k = divide(substract(highs, lows), add(highs, lows)); + const k = divide(subtract(highs, lows), add(highs, lows)); const upperBand = sma(20, multiply(highs, addBy(1, multiplyBy(4, k)))); const middleBand = sma(20, closings); diff --git a/src/indicator/volatility/atr.ts b/src/indicator/volatility/atr.ts index 64200d8..4b54594 100644 --- a/src/indicator/volatility/atr.ts +++ b/src/indicator/volatility/atr.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { checkSameLength, max, substract } from '../../helper/numArray'; +import { checkSameLength, max, subtract } from '../../helper/numArray'; import { sma } from '../../indicator/trend/sma'; /** @@ -35,9 +35,9 @@ export function atr( checkSameLength(highs, lows, closings); const trLine = max( - substract(highs, lows), - substract(highs, closings), - substract(closings, lows) + subtract(highs, lows), + subtract(highs, closings), + subtract(closings, lows) ); const atrLine = sma(period, trLine); diff --git a/src/indicator/volatility/bollingerBands.ts b/src/indicator/volatility/bollingerBands.ts index 313c546..eece22a 100644 --- a/src/indicator/volatility/bollingerBands.ts +++ b/src/indicator/volatility/bollingerBands.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { add, multiplyBy, substract } from '../../helper/numArray'; +import { add, multiplyBy, subtract } from '../../helper/numArray'; import { sma } from '../trend/sma'; import { mstd } from './mstd'; @@ -30,7 +30,7 @@ export function bollingerBands(closings: number[]): BollingerBands { const std2 = multiplyBy(2, mstd(BB_PERIOD, closings)); const middleBand = sma(BB_PERIOD, closings); const upperBand = add(middleBand, std2); - const lowerBand = substract(middleBand, std2); + const lowerBand = subtract(middleBand, std2); return { upperBand, diff --git a/src/indicator/volatility/bollingerBandsWidth.ts b/src/indicator/volatility/bollingerBandsWidth.ts index 95f051f..ea149fd 100644 --- a/src/indicator/volatility/bollingerBandsWidth.ts +++ b/src/indicator/volatility/bollingerBandsWidth.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { divide, substract } from '../../helper/numArray'; +import { divide, subtract } from '../../helper/numArray'; import { ema } from '../trend/ema'; import { BollingerBands } from './bollingerBands'; @@ -30,7 +30,7 @@ export interface BollingerBandsWidth { */ export function bollingerBandsWidth(bb: BollingerBands): BollingerBandsWidth { const bandWidth = divide( - substract(bb.upperBand, bb.lowerBand), + subtract(bb.upperBand, bb.lowerBand), bb.middleBand ); diff --git a/src/indicator/volatility/chandelierExit.ts b/src/indicator/volatility/chandelierExit.ts index 3ef2373..acb8c12 100644 --- a/src/indicator/volatility/chandelierExit.ts +++ b/src/indicator/volatility/chandelierExit.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { add, multiplyBy, substract } from '../../helper/numArray'; +import { add, multiplyBy, subtract } from '../../helper/numArray'; import { mmax } from '../trend/mmax'; import { mmin } from '../trend/mmin'; import { atr } from './atr'; @@ -38,7 +38,7 @@ export function chandelierExit( const highestHigh = mmax(PERIOD, highs); const lowestLow = mmin(PERIOD, lows); - const exitLong = substract(highestHigh, atrLine3); + const exitLong = subtract(highestHigh, atrLine3); const exitShort = add(lowestLow, atrLine3); return { diff --git a/src/indicator/volatility/keltnerChannel.ts b/src/indicator/volatility/keltnerChannel.ts index c315eca..a0eb13f 100644 --- a/src/indicator/volatility/keltnerChannel.ts +++ b/src/indicator/volatility/keltnerChannel.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { add, multiplyBy, substract } from '../../helper/numArray'; +import { add, multiplyBy, subtract } from '../../helper/numArray'; import { ema } from '../trend/ema'; import { atr } from './atr'; @@ -45,7 +45,7 @@ export function keltnerChannel( const middleLine = ema(period, closings); const upperBand = add(middleLine, atr2); - const lowerBand = substract(middleLine, atr2); + const lowerBand = subtract(middleLine, atr2); return { middleLine, diff --git a/src/indicator/volatility/projectionOscillator.ts b/src/indicator/volatility/projectionOscillator.ts index c6989c9..183e1fa 100644 --- a/src/indicator/volatility/projectionOscillator.ts +++ b/src/indicator/volatility/projectionOscillator.ts @@ -7,7 +7,7 @@ import { generateNumbers, multiply, multiplyBy, - substract, + subtract, } from '../../helper/numArray'; import { movingLeastSquare } from '../../helper/regression'; import { ema } from '../trend/ema'; @@ -59,8 +59,8 @@ export function projectionOscillator( const pl = mmin(period, vLows); const po = divide( - multiplyBy(100, substract(closings, pl)), - substract(pu, pl) + multiplyBy(100, subtract(closings, pl)), + subtract(pu, pl) ); const spo = ema(smooth, po); diff --git a/src/indicator/volatility/ulcerIndex.ts b/src/indicator/volatility/ulcerIndex.ts index 6e3b0d0..93a29ff 100644 --- a/src/indicator/volatility/ulcerIndex.ts +++ b/src/indicator/volatility/ulcerIndex.ts @@ -6,7 +6,7 @@ import { multiply, multiplyBy, sqrt, - substract, + subtract, } from '../../helper/numArray'; import { mmax } from '../trend/mmax'; import { sma } from '../trend/sma'; @@ -34,7 +34,7 @@ export function ulcerIndex(period: number, closings: number[]): number[] { const highClosings = mmax(period, closings); const percentageDrawdown = multiplyBy( 100, - divide(substract(closings, highClosings), highClosings) + divide(subtract(closings, highClosings), highClosings) ); const squaredAverage = sma( period, diff --git a/src/indicator/volume/accumulationDistribution.ts b/src/indicator/volume/accumulationDistribution.ts index 9509129..49f8205 100644 --- a/src/indicator/volume/accumulationDistribution.ts +++ b/src/indicator/volume/accumulationDistribution.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { divide, multiply, substract } from '../../helper/numArray'; +import { divide, multiply, subtract } from '../../helper/numArray'; /** * Accumulation/Distribution Indicator (A/D). Cumulative indicator @@ -25,8 +25,8 @@ export function accumulationDistribution( volume: number[] ): number[] { const mfm = divide( - substract(substract(closings, lows), substract(highs, closings)), - substract(highs, lows) + subtract(subtract(closings, lows), subtract(highs, closings)), + subtract(highs, lows) ); const mfv = multiply(mfm, volume); diff --git a/src/indicator/volume/chaikinMoneyFlow.ts b/src/indicator/volume/chaikinMoneyFlow.ts index a77cdfe..1155dae 100644 --- a/src/indicator/volume/chaikinMoneyFlow.ts +++ b/src/indicator/volume/chaikinMoneyFlow.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { divide, multiply, substract } from '../../helper/numArray'; +import { divide, multiply, subtract } from '../../helper/numArray'; import { msum } from '../trend/msum'; /** @@ -30,8 +30,8 @@ export function chaikinMoneyFlow( volumes: number[] ): number[] { const moneyFlowMultipler = divide( - substract(substract(closings, lows), substract(highs, closings)), - substract(highs, lows) + subtract(subtract(closings, lows), subtract(highs, closings)), + subtract(highs, lows) ); const moneyFlowVolume = multiply(moneyFlowMultipler, volumes); diff --git a/src/indicator/volume/easeOfMovement.ts b/src/indicator/volume/easeOfMovement.ts index 078f065..254c342 100644 --- a/src/indicator/volume/easeOfMovement.ts +++ b/src/indicator/volume/easeOfMovement.ts @@ -6,7 +6,7 @@ import { changes, divide, divideBy, - substract, + subtract, } from '../../helper/numArray'; import { sma } from '../trend/sma'; @@ -37,7 +37,7 @@ export function easeOfMovement( volumes: number[] ): number[] { const distanceMoved = changes(1, divideBy(2, add(highs, lows))); - const boxRatio = divide(divideBy(100000000, volumes), substract(highs, lows)); + const boxRatio = divide(divideBy(100000000, volumes), subtract(highs, lows)); const emv = sma(period, divide(distanceMoved, boxRatio)); return emv; } diff --git a/src/indicator/volume/volumePriceTrend.ts b/src/indicator/volume/volumePriceTrend.ts index fadc287..3ebe4b0 100644 --- a/src/indicator/volume/volumePriceTrend.ts +++ b/src/indicator/volume/volumePriceTrend.ts @@ -5,7 +5,7 @@ import { divide, multiply, shiftRightAndFillBy, - substract, + subtract, } from '../../helper/numArray'; import { msum } from '../trend/msum'; @@ -26,7 +26,7 @@ export function volumePriceTrend( const previousClosings = shiftRightAndFillBy(1, closings[0], closings); const vpt = multiply( volumes, - divide(substract(closings, previousClosings), previousClosings) + divide(subtract(closings, previousClosings), previousClosings) ); return msum(vpt.length, vpt); } diff --git a/src/strategy/volume/volumeWeightedAveragePriceStrategy.ts b/src/strategy/volume/volumeWeightedAveragePriceStrategy.ts index 21414fb..316bfd0 100644 --- a/src/strategy/volume/volumeWeightedAveragePriceStrategy.ts +++ b/src/strategy/volume/volumeWeightedAveragePriceStrategy.ts @@ -1,7 +1,7 @@ // Copyright (c) 2022 Onur Cinar. All Rights Reserved. // https://github.com/cinar/indicatorts -import { substract } from '../../helper/numArray'; +import { subtract } from '../../helper/numArray'; import { defaultVolumeWeightedAveragePrice } from '../../indicator/volume/volumeWeightedAveragePrice'; import { Action } from '../action'; import { Asset } from '../asset'; @@ -18,7 +18,7 @@ import { Asset } from '../asset'; export function volumeWeightedAveragePriceStrategy(asset: Asset): Action[] { const vwap = defaultVolumeWeightedAveragePrice(asset.closings, asset.volumes); - const diff = substract(vwap, asset.closings); + const diff = subtract(vwap, asset.closings); return diff.map((value) => { if (value > 0) {