Prepare for refactoring
This commit is contained in:
5
src/Managing.Application/Bots/BacktestFuturesBot.cs
Normal file
5
src/Managing.Application/Bots/BacktestFuturesBot.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace Managing.Application.Bots;
|
||||
|
||||
public class BacktestFuturesBot
|
||||
{
|
||||
}
|
||||
5
src/Managing.Application/Bots/FuturesBot.cs
Normal file
5
src/Managing.Application/Bots/FuturesBot.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace Managing.Application.Bots;
|
||||
|
||||
public class FuturesBot
|
||||
{
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user