feat: 4h-Aggregation, EMA, ATR, Donchian-High (TDD)

This commit is contained in:
2026-06-09 20:18:53 +00:00
parent 568e282b07
commit c2f1221eb9
8 changed files with 169 additions and 0 deletions

View 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
});