fix: correct MFE/MAE tracking after partial exits
This commit is contained in:
@@ -563,7 +563,7 @@ export class PositionManager {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const accountPnL = profitPercent * trade.leverage
|
const accountPnL = profitPercent * trade.leverage
|
||||||
trade.unrealizedPnL = (trade.currentSize * profitPercent) / 100
|
trade.unrealizedPnL = (trade.currentSize * accountPnL) / 100
|
||||||
|
|
||||||
// Track peak P&L (MFE - Maximum Favorable Excursion)
|
// Track peak P&L (MFE - Maximum Favorable Excursion)
|
||||||
if (trade.unrealizedPnL > trade.peakPnL) {
|
if (trade.unrealizedPnL > trade.peakPnL) {
|
||||||
@@ -873,6 +873,11 @@ export class PositionManager {
|
|||||||
console.log('✅ All positions closed')
|
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> {
|
private async handlePostTp1Adjustments(trade: ActiveTrade, context: string): Promise<void> {
|
||||||
if (trade.currentSize <= 0) {
|
if (trade.currentSize <= 0) {
|
||||||
console.log(`⚠️ Skipping TP1 adjustments for ${trade.symbol} (${context}) because current size is $${trade.currentSize.toFixed(2)}`)
|
console.log(`⚠️ Skipping TP1 adjustments for ${trade.symbol} (${context}) because current size is $${trade.currentSize.toFixed(2)}`)
|
||||||
|
|||||||
Reference in New Issue
Block a user