Remove logs for position update on pnl
This commit is contained in:
@@ -812,11 +812,14 @@ public class TradingBotBase : ITradingBot
|
|||||||
|
|
||||||
var currentTime = Config.IsForBacktest ? lastCandle.Date : DateTime.UtcNow;
|
var currentTime = Config.IsForBacktest ? lastCandle.Date : DateTime.UtcNow;
|
||||||
var currentPnl = positionForSignal.ProfitAndLoss?.Net ?? 0;
|
var currentPnl = positionForSignal.ProfitAndLoss?.Net ?? 0;
|
||||||
var pnlPercentage = TradingBox.CalculatePnLPercentage(currentPnl, positionForSignal.Open.Price, positionForSignal.Open.Quantity);
|
var pnlPercentage = TradingBox.CalculatePnLPercentage(currentPnl, positionForSignal.Open.Price,
|
||||||
|
positionForSignal.Open.Quantity);
|
||||||
|
|
||||||
var isPositionInProfit = TradingBox.IsPositionInProfit(positionForSignal.Open.Price, lastCandle.Close, positionForSignal.OriginDirection);
|
var isPositionInProfit = TradingBox.IsPositionInProfit(positionForSignal.Open.Price, lastCandle.Close,
|
||||||
|
positionForSignal.OriginDirection);
|
||||||
|
|
||||||
var hasExceededTimeLimit = TradingBox.HasPositionExceededTimeLimit(positionForSignal.Open.Date, currentTime, Config.MaxPositionTimeHours);
|
var hasExceededTimeLimit = TradingBox.HasPositionExceededTimeLimit(positionForSignal.Open.Date,
|
||||||
|
currentTime, Config.MaxPositionTimeHours);
|
||||||
|
|
||||||
if (hasExceededTimeLimit)
|
if (hasExceededTimeLimit)
|
||||||
{
|
{
|
||||||
@@ -1852,7 +1855,8 @@ public class TradingBotBase : ITradingBot
|
|||||||
var entryPrice = position.Open.Price;
|
var entryPrice = position.Open.Price;
|
||||||
var positionSize = TradingBox.CalculatePositionSize(position.Open.Quantity, position.Open.Leverage);
|
var positionSize = TradingBox.CalculatePositionSize(position.Open.Quantity, position.Open.Leverage);
|
||||||
|
|
||||||
decimal pnl = TradingBox.CalculatePnL(entryPrice, closingPrice, position.Open.Quantity, position.Open.Leverage, position.OriginDirection);
|
decimal pnl = TradingBox.CalculatePnL(entryPrice, closingPrice, position.Open.Quantity,
|
||||||
|
position.Open.Leverage, position.OriginDirection);
|
||||||
|
|
||||||
if (position.ProfitAndLoss == null)
|
if (position.ProfitAndLoss == null)
|
||||||
{
|
{
|
||||||
@@ -1880,18 +1884,10 @@ public class TradingBotBase : ITradingBot
|
|||||||
$"Total Fees: `${position.GasFees + position.UiFees:F2}`\n" +
|
$"Total Fees: `${position.GasFees + position.UiFees:F2}`\n" +
|
||||||
$"Net P&L (after fees): `${position.ProfitAndLoss.Net:F2}`";
|
$"Net P&L (after fees): `${position.ProfitAndLoss.Net:F2}`";
|
||||||
|
|
||||||
if (Config.IsForBacktest)
|
if (!Config.IsForBacktest)
|
||||||
{
|
|
||||||
// For backtest, use Console.WriteLine to see in test output
|
|
||||||
Console.WriteLine(logMessage);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
await LogDebug(logMessage);
|
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SkipCandleBasedCalculation:
|
SkipCandleBasedCalculation:
|
||||||
@@ -2281,7 +2277,6 @@ public class TradingBotBase : ITradingBot
|
|||||||
/// <param name="position">The position to check</param>
|
/// <param name="position">The position to check</param>
|
||||||
/// <param name="currentTime">The current time to compare against</param>
|
/// <param name="currentTime">The current time to compare against</param>
|
||||||
/// <returns>True if the position has exceeded the time limit, false otherwise</returns>
|
/// <returns>True if the position has exceeded the time limit, false otherwise</returns>
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the trading bot configuration with new settings.
|
/// Updates the trading bot configuration with new settings.
|
||||||
/// This method validates the new configuration and applies it to the running bot.
|
/// This method validates the new configuration and applies it to the running bot.
|
||||||
@@ -2591,7 +2586,8 @@ public class TradingBotBase : ITradingBot
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate cooldown end time based on last position closing time
|
// Calculate cooldown end time based on last position closing time
|
||||||
var cooldownEndTime = TradingBox.CalculateCooldownEndTime(LastPositionClosingTime.Value, Config.Timeframe, Config.CooldownPeriod);
|
var cooldownEndTime =
|
||||||
|
TradingBox.CalculateCooldownEndTime(LastPositionClosingTime.Value, Config.Timeframe, Config.CooldownPeriod);
|
||||||
var isInCooldown = (Config.IsForBacktest ? LastCandle.Date : DateTime.UtcNow) < cooldownEndTime;
|
var isInCooldown = (Config.IsForBacktest ? LastCandle.Date : DateTime.UtcNow) < cooldownEndTime;
|
||||||
|
|
||||||
if (isInCooldown)
|
if (isInCooldown)
|
||||||
|
|||||||
Reference in New Issue
Block a user