Fix a bit the spot trading

This commit is contained in:
2025-12-10 23:16:46 +07:00
parent 931af3d3af
commit 8ff9437400
8 changed files with 44 additions and 113 deletions

View File

@@ -1,4 +1,4 @@
using System.Diagnostics;
using System.Diagnostics;
using Managing.Application.Abstractions;
using Managing.Application.Abstractions.Grains;
using Managing.Application.Abstractions.Services;
@@ -852,10 +852,15 @@ public abstract class TradingBotBase : ITradingBot
async tradingService => { await tradingService.UpdatePositionAsync(position); });
}
protected virtual async Task<decimal> GetLastPriceForPositionOpeningAsync()
protected async Task<decimal> GetLastPriceForPositionOpeningAsync()
{
// Default implementation - subclasses should override
return 0;
if (TradingBox.IsLiveTrading(Config.TradingType))
{
return await ServiceScopeHelpers.WithScopedService<IExchangeService, decimal>(_scopeFactory,
async exchangeService => await exchangeService.GetCurrentPrice(Account, Config.Ticker));
}
return LastCandle?.Close ?? 0;
}
protected async Task<Position> OpenPosition(LightSignal signal)