Fix all tests
This commit is contained in:
@@ -1895,11 +1895,27 @@ public class TradingBotBase : ITradingBot
|
||||
position.ProfitAndLoss.Net = netPnl;
|
||||
}
|
||||
|
||||
await LogDebug(
|
||||
$"💰 P&L Calculated for Position {position.Identifier}\n" +
|
||||
$"Entry: `${entryPrice:F2}` | Exit: `${closingPrice:F2}`\n" +
|
||||
$"Realized P&L: `${pnl:F2}` | Net P&L (after fees): `${position.ProfitAndLoss.Net:F2}`\n" +
|
||||
$"Total Fees: `${position.GasFees + position.UiFees:F2}`");
|
||||
// Enhanced logging for backtest debugging
|
||||
var logMessage = $"💰 P&L Calculated for Position {position.Identifier}\n" +
|
||||
$"Direction: `{position.OriginDirection}`\n" +
|
||||
$"Entry Price: `${entryPrice:F2}` | Exit Price: `${closingPrice:F2}`\n" +
|
||||
$"Position Size: `{position.Open.Quantity:F8}` | Leverage: `{position.Open.Leverage}x`\n" +
|
||||
$"Position Value: `${positionSize:F8}`\n" +
|
||||
$"Price Difference: `${(position.OriginDirection == TradeDirection.Long ? closingPrice - entryPrice : entryPrice - closingPrice):F2}`\n" +
|
||||
$"Realized P&L: `${pnl:F2}`\n" +
|
||||
$"Gas Fees: `${position.GasFees:F2}` | UI Fees: `${position.UiFees:F2}`\n" +
|
||||
$"Total Fees: `${position.GasFees + position.UiFees:F2}`\n" +
|
||||
$"Net P&L (after fees): `${position.ProfitAndLoss.Net:F2}`";
|
||||
|
||||
if (Config.IsForBacktest)
|
||||
{
|
||||
// For backtest, use Console.WriteLine to see in test output
|
||||
Console.WriteLine(logMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
await LogDebug(logMessage);
|
||||
}
|
||||
|
||||
// Fees are now tracked separately in UiFees and GasFees properties
|
||||
// No need to subtract fees from PnL as they're tracked separately
|
||||
|
||||
Reference in New Issue
Block a user