fix: correct MFE/MAE tracking after partial exits
This commit is contained in:
@@ -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)}`)
|
||||
|
||||
Reference in New Issue
Block a user