Skip to content

Commit

Permalink
refactor: Sort supported technical indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
bennycode committed Jan 3, 2022
1 parent 65b2314 commit c2be219
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ All indicators can be updated over time by streaming data (prices or candles) to
1. Mean Absolute Deviation (MAD)
1. Momentum (MOM / MTM)
1. Moving Average Convergence Divergence (MACD)
1. On-Balance Volume (OBV)
1. Rate-of-Change (ROC)
1. Relative Strength Index (RSI)
1. Simple Moving Average (SMA)
1. Stochastic Oscillator (STOCH)
1. Stochastic RSI (STOCHRSI)
1. True Range (TR)
1. On-Balance Volume (OBV)
1. Wilder's Smoothed Moving Average (WSMA / WMA / WWS / SMMA / MEMA)

Utility Methods:
Expand Down
52 changes: 26 additions & 26 deletions src/start/startBenchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,73 +61,73 @@ import {
const shortInterval = 10;
const interval = 20;
const longInterval = 40;
const prices: number[] = candles.map(candle => parseInt(candle.close, 10));
const openHighLowCloseVolumes: OpenHighLowCloseVolumeNumber[] = candles.map(candle => ({
close: parseInt(candle.close, 10),
high: parseInt(candle.high, 10),
low: parseInt(candle.low, 10),
open: parseInt(candle.open, 10),
volume: parseInt(candle.volume, 10),
const prices: number[] = candles.map(candle => parseFloat(candle.close));
const floatCandles: OpenHighLowCloseVolumeNumber[] = candles.map(candle => ({
close: parseFloat(candle.close),
high: parseFloat(candle.high),
low: parseFloat(candle.low),
open: parseFloat(candle.open),
volume: parseFloat(candle.volume),
}));

new Benchmark.Suite('Technical Indicators')
.add('AccelerationBands', () => {
const accBands = new AccelerationBands(interval, 4);
for (const candle of openHighLowCloseVolumes) {
for (const candle of floatCandles) {
accBands.update(candle);
}
})
.add('FasterAccelerationBands', () => {
const fasterAccBands = new FasterAccelerationBands(interval, 4);
for (const candle of openHighLowCloseVolumes) {
for (const candle of floatCandles) {
fasterAccBands.update(candle);
}
})
.add('AC', () => {
const ac = new AC(shortInterval, longInterval, interval);
for (const candle of openHighLowCloseVolumes) {
for (const candle of floatCandles) {
ac.update(candle);
}
})
.add('FasterAC', () => {
const fasterAC = new FasterAC(shortInterval, longInterval, interval);
for (const candle of openHighLowCloseVolumes) {
for (const candle of floatCandles) {
fasterAC.update(candle);
}
})
.add('ADX', () => {
const adx = new ADX(interval);
for (const candle of openHighLowCloseVolumes) {
for (const candle of floatCandles) {
adx.update(candle);
}
})
.add('FasterADX', () => {
const fasterADX = new FasterADX(interval);
for (const candle of openHighLowCloseVolumes) {
for (const candle of floatCandles) {
fasterADX.update(candle);
}
})
.add('AO', () => {
const ao = new AO(shortInterval, interval);
for (const candle of openHighLowCloseVolumes) {
for (const candle of floatCandles) {
ao.update(candle);
}
})
.add('FasterAO', () => {
const fasterAO = new FasterAO(shortInterval, interval);
for (const candle of openHighLowCloseVolumes) {
for (const candle of floatCandles) {
fasterAO.update(candle);
}
})
.add('ATR', () => {
const atr = new ATR(interval);
for (const candle of openHighLowCloseVolumes) {
for (const candle of floatCandles) {
atr.update(candle);
}
})
.add('FasterATR', () => {
const fasterATR = new FasterATR(interval);
for (const candle of openHighLowCloseVolumes) {
for (const candle of floatCandles) {
fasterATR.update(candle);
}
})
Expand Down Expand Up @@ -157,13 +157,13 @@ new Benchmark.Suite('Technical Indicators')
})
.add('CCI', () => {
const cci = new CCI(interval);
for (const candle of openHighLowCloseVolumes) {
for (const candle of floatCandles) {
cci.update(candle);
}
})
.add('FasterCCI', () => {
const fasterCCI = new FasterCCI(interval);
for (const candle of openHighLowCloseVolumes) {
for (const candle of floatCandles) {
fasterCCI.update(candle);
}
})
Expand Down Expand Up @@ -205,13 +205,13 @@ new Benchmark.Suite('Technical Indicators')
})
.add('DX', () => {
const dx = new DX(interval);
for (const candle of openHighLowCloseVolumes) {
for (const candle of floatCandles) {
dx.update(candle);
}
})
.add('FasterDX', () => {
const fasterDX = new FasterDX(interval);
for (const candle of openHighLowCloseVolumes) {
for (const candle of floatCandles) {
fasterDX.update(candle);
}
})
Expand Down Expand Up @@ -270,13 +270,13 @@ new Benchmark.Suite('Technical Indicators')
})
.add('OBV', () => {
const obv = new OBV();
for (const candle of openHighLowCloseVolumes) {
for (const candle of floatCandles) {
obv.update(candle);
}
})
.add('FasterOBV', () => {
const fasterOBV = new FasterOBV();
for (const candle of openHighLowCloseVolumes) {
for (const candle of floatCandles) {
fasterOBV.update(candle);
}
})
Expand Down Expand Up @@ -336,7 +336,7 @@ new Benchmark.Suite('Technical Indicators')
})
.add('FasterStochasticOscillator', () => {
const fasterStoch = new FasterStochasticOscillator(shortInterval, interval, interval);
for (const candle of openHighLowCloseVolumes) {
for (const candle of floatCandles) {
fasterStoch.update(candle);
}
})
Expand All @@ -354,13 +354,13 @@ new Benchmark.Suite('Technical Indicators')
})
.add('TR', () => {
const tr = new TR();
for (const candle of openHighLowCloseVolumes) {
for (const candle of floatCandles) {
tr.update(candle);
}
})
.add('FasterTR', () => {
const fasterTR = new FasterTR();
for (const candle of openHighLowCloseVolumes) {
for (const candle of floatCandles) {
fasterTR.update(candle);
}
})
Expand Down

0 comments on commit c2be219

Please sign in to comment.