Fix a bit the spot trading
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user