feat: Short-Seite — Indikator, Strategie, Chandelier, Sizing, Portfolio
- donchianLow: Spiegelbild von donchianHigh (tiefstes Tief der N Candles vor i) - evaluateAt(allowShort=false): Short-Signal wenn close < donchianLow && close < trendEma - IndicatorSet + Evaluation erweitert um donchianLow; signal: 'long'|'short'|null - updateChandelierShort: ll + mult×ATR, wandert nur abwärts - sizePosition(side): Short ignoriert Cash-Cap, stopDist = stop − entry - Portfolio: highestHigh → trailExtreme; open/close/equity für Shorts; side auf Position + ClosedTrade Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { expect, test } from 'bun:test';
|
||||
import type { Candle } from '../types';
|
||||
import { donchianHigh } from './donchian';
|
||||
import { donchianHigh, donchianLow } from './donchian';
|
||||
|
||||
function c(h: number): Candle {
|
||||
return { ts: 0, open: h, high: h, low: h - 1, close: h, volume: 1 };
|
||||
@@ -13,3 +13,12 @@ test('donchianHigh: höchstes Hoch der letzten N Candles VOR i (i exklusiv)', ()
|
||||
expect(out[3]).toBe(12); // max(10,12,11)
|
||||
expect(out[4]).toBe(12); // max(12,11,9) — Candle 4 selbst zählt nicht
|
||||
});
|
||||
|
||||
test('donchianLow: tiefstes Tief der letzten N Candles VOR i (i exklusiv)', () => {
|
||||
// c(h) erzeugt low = h-1, daher: c(10)→low=9, c(12)→low=11, c(11)→low=10, c(9)→low=8, c(15)→low=14
|
||||
const candles = [c(10), c(12), c(11), c(9), c(15)];
|
||||
const out = donchianLow(candles, 3);
|
||||
expect(out.slice(0, 3).every(Number.isNaN)).toBe(true);
|
||||
expect(out[3]).toBe(9); // min(9,11,10) — lows von c(10),c(12),c(11)
|
||||
expect(out[4]).toBe(8); // min(11,10,8) — lows von c(12),c(11),c(9); Candle 4 selbst zählt nicht
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user