Skip to content

Commit

Permalink
test: Run benchmark with 100 candles
Browse files Browse the repository at this point in the history
  • Loading branch information
bennycode committed Oct 24, 2021
1 parent ea91808 commit e387924
Show file tree
Hide file tree
Showing 3 changed files with 517,569 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/start/startBenchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@ import Benchmark, {Event} from 'benchmark';
import {BollingerBands} from '../BBANDS/BollingerBands';
import {SMA} from '../SMA/SMA';
import {FasterSMA} from '../SMA/FasterSMA';
import candles from '../test/fixtures/candles/100-candles.json';

const interval = 20;
const price = 72;
const prices = candles.map(candle => parseInt(candle.close, 10));

const bb = new BollingerBands(interval, 2);
const sma = new SMA(interval);
const fasterSMA = new FasterSMA(interval);

new Benchmark.Suite('Technical Indicators')
.add('BollingerBands', () => {
while (!bb.isStable) {
for (const price of prices) {
bb.update(price);
}
})
.add('SMA', () => {
while (!sma.isStable) {
for (const price of prices) {
sma.update(price);
}
})
.add('FasterSMA', () => {
while (!fasterSMA.isStable) {
for (const price of prices) {
fasterSMA.update(price);
}
})
Expand Down
Loading

0 comments on commit e387924

Please sign in to comment.