Prepare for refactoring

This commit is contained in:
2025-11-26 19:26:57 +07:00
parent f81a2da9df
commit ab26260f6d
4 changed files with 10 additions and 45 deletions

View File

@@ -0,0 +1,5 @@
namespace Managing.Application.Bots;
public class BacktestFuturesBot
{
}

View File

@@ -0,0 +1,5 @@
namespace Managing.Application.Bots;
public class FuturesBot
{
}

View File

@@ -2727,51 +2727,6 @@ public class TradingBotBase : ITradingBot
}
}
/// <summary>
/// Gets the trade that was used to close the position
/// </summary>
/// <param name="position">The position to check</param>
/// <returns>The closing trade, or null if none found</returns>
private Trade GetClosingTrade(Position position)
{
// Check which trade was used to close the position
if (position.StopLoss?.Status == TradeStatus.Filled)
{
return position.StopLoss;
}
else if (position.TakeProfit1?.Status == TradeStatus.Filled)
{
return position.TakeProfit1;
}
else if (position.TakeProfit2?.Status == TradeStatus.Filled)
{
return position.TakeProfit2;
}
// If no specific closing trade is found, create a synthetic one based on the position
// This handles cases where the position was closed manually or by the exchange
if (position.ProfitAndLoss?.Realized != null)
{
var closeDirection = position.OriginDirection == TradeDirection.Long
? TradeDirection.Short
: TradeDirection.Long;
return new Trade(
DateTime.UtcNow,
closeDirection,
TradeStatus.Filled,
TradeType.StopMarket,
position.Ticker,
position.Open.Quantity,
position.Open.Price, // Use open price as approximation
position.Open.Leverage,
"synthetic-close",
"Position closed"
);
}
return null;
}
/// <summary>
/// Notifies both AgentGrain and PlatformSummaryGrain about bot events using unified event data
/// </summary>