feat: 4h-Aggregation, EMA, ATR, Donchian-High (TDD)
This commit is contained in:
15
src/server/indicators/donchian.test.ts
Normal file
15
src/server/indicators/donchian.test.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { expect, test } from 'bun:test';
|
||||
import type { Candle } from '../types';
|
||||
import { donchianHigh } from './donchian';
|
||||
|
||||
function c(h: number): Candle {
|
||||
return { ts: 0, open: h, high: h, low: h - 1, close: h, volume: 1 };
|
||||
}
|
||||
|
||||
test('donchianHigh: höchstes Hoch der letzten N Candles VOR i (i exklusiv)', () => {
|
||||
const candles = [c(10), c(12), c(11), c(9), c(15)];
|
||||
const out = donchianHigh(candles, 3);
|
||||
expect(out.slice(0, 3).every(Number.isNaN)).toBe(true);
|
||||
expect(out[3]).toBe(12); // max(10,12,11)
|
||||
expect(out[4]).toBe(12); // max(12,11,9) — Candle 4 selbst zählt nicht
|
||||
});
|
||||
Reference in New Issue
Block a user