Clean tradingbot and spot and future

This commit is contained in:
2025-12-11 14:10:38 +07:00
parent 292a48d108
commit df8c199cce
5 changed files with 32 additions and 61 deletions

View File

@@ -1,3 +1,4 @@
#nullable enable
using Managing.Application.Abstractions.Grains;
using Managing.Application.Abstractions.Services;
using Managing.Application.Trading.Commands;
@@ -68,15 +69,7 @@ public class SpotBot : TradingBotBase
// For live trading, get position from database via trading service
return await ServiceScopeHelpers.WithScopedService<ITradingService, Position>(
_scopeFactory,
async tradingService => { return await tradingService.GetPositionByIdentifierAsync(position.Identifier); });
}
protected override async Task<List<Position>> GetBrokerPositionsForUpdate(Account account)
{
// For live spot trading, we don't have broker positions like futures
// Positions are verified via token balances in UpdatePositionWithBrokerData and SynchronizeWithBrokerPositions
// Return empty list - actual verification happens in those methods
return new List<Position>();
async tradingService => await tradingService.GetPositionByIdentifierAsync(position.Identifier));
}
protected override async Task UpdatePositionWithBrokerData(Position position, List<Position> brokerPositions)
@@ -88,7 +81,7 @@ public class SpotBot : TradingBotBase
_scopeFactory,
async exchangeService => await exchangeService.GetBalance(Account, Config.Ticker));
if (tokenBalance == null || tokenBalance.Amount <= 0)
if (tokenBalance is not { Amount: > 0 })
{
// No token balance found - position might be closed
return;
@@ -225,8 +218,7 @@ public class SpotBot : TradingBotBase
}
protected override async Task SynchronizeWithBrokerPositions(Position internalPosition, Position positionForSignal,
List<Position> brokerPositions)
protected override async Task SynchronizeWithBrokerPositions(Position internalPosition, Position positionForSignal)
{
// For spot trading, fetch token balance directly and verify/match with internal position
try