fix: correct MFE/MAE tracking after partial exits

This commit is contained in:
mindesbunister
2025-11-05 10:29:32 +01:00
parent 18e3e73e83
commit b58e08778e

View File

@@ -562,8 +562,8 @@ export class PositionManager {
trade.direction
)
const accountPnL = profitPercent * trade.leverage
trade.unrealizedPnL = (trade.currentSize * profitPercent) / 100
const accountPnL = profitPercent * trade.leverage
trade.unrealizedPnL = (trade.currentSize * accountPnL) / 100
// Track peak P&L (MFE - Maximum Favorable Excursion)
if (trade.unrealizedPnL > trade.peakPnL) {
@@ -873,6 +873,11 @@ export class PositionManager {
console.log('✅ All positions closed')
}
refreshConfig(): void {
this.config = getMergedConfig()
console.log('⚙️ Position manager config refreshed from environment')
}
private async handlePostTp1Adjustments(trade: ActiveTrade, context: string): Promise<void> {
if (trade.currentSize <= 0) {
console.log(`⚠️ Skipping TP1 adjustments for ${trade.symbol} (${context}) because current size is $${trade.currentSize.toFixed(2)}`)