fix: Review-Fixes Sizing/Portfolio (invalid_stop-Guard, Doppel-Open-Schutz, Tests)
This commit is contained in:
@@ -41,13 +41,14 @@ export class Portfolio {
|
||||
}
|
||||
|
||||
open(pair: Pair, ts: number, signalPrice: number, initialStop: number, qty: number, riskAmount: number): void {
|
||||
if (this.positions.has(pair)) throw new Error(`open auf bestehende Position: ${pair}`);
|
||||
const fill = signalPrice * (1 + this.exec.slippage);
|
||||
const cost = qty * fill;
|
||||
const fee = cost * this.exec.feeRate;
|
||||
this.cash -= cost + fee;
|
||||
this.positions.set(pair, {
|
||||
pair, qty, entryTs: ts, entryPrice: fill, entryCost: cost + fee,
|
||||
initialStop, stop: initialStop, highestHigh: signalPrice, riskAmount,
|
||||
initialStop, stop: initialStop, highestHigh: signalPrice, riskAmount, // Markt-Preis, nicht Fill: der Chandelier trailt Markt-Hochs, Slippage ist Ausführungsartefakt
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user