фикс скорости старта
test / deploy_trader_prod (push) Successful in 1m44s
Details
test / deploy_trader_prod (push) Successful in 1m44s
Details
parent
6e74c05c6d
commit
6c338b1f4f
|
@ -43,6 +43,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
|
|||
internal readonly ConcurrentDictionary<string, ManagedAccount> Accounts = new();
|
||||
private readonly bool _isDataRecievingAllowed = false;
|
||||
private readonly Channel<object> _forSave = Channel.CreateUnbounded<object>();
|
||||
private readonly SemaphoreSlim _syncSemaphore = new SemaphoreSlim(1, 1);
|
||||
private readonly SemaphoreSlim _initSemaphore = new SemaphoreSlim(1, 1);
|
||||
|
||||
public TraderDataProvider(InvestApiClient investApiClient, IOptions<ExchangeConfig> options, IDbContextFactory<TraderDbContext> dbContextFactory, ILogger<ManagedAccount> logger)
|
||||
|
@ -170,7 +171,8 @@ namespace KLHZ.Trader.Core.Exchange.Services
|
|||
{
|
||||
try
|
||||
{
|
||||
await _initSemaphore.WaitAsync(TimeSpan.FromSeconds(3));
|
||||
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(3));
|
||||
await _initSemaphore.WaitAsync(cts.Token);
|
||||
var shares = await _investApiClient.Instruments.SharesAsync();
|
||||
foreach (var share in shares.Instruments)
|
||||
{
|
||||
|
@ -264,7 +266,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
|
|||
|
||||
try
|
||||
{
|
||||
await _initSemaphore.WaitAsync(TimeSpan.FromSeconds(5));
|
||||
await _syncSemaphore.WaitAsync();
|
||||
var portfolio = await _investApiClient.Operations.GetPortfolioAsync(new PortfolioRequest()
|
||||
{
|
||||
AccountId = account.AccountId,
|
||||
|
@ -354,7 +356,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
|
|||
_logger.LogError(ex, "Ошибка при синхранизации портфеля счёта {accountId}", account.AccountId);
|
||||
}
|
||||
|
||||
_initSemaphore.Release();
|
||||
_syncSemaphore.Release();
|
||||
}
|
||||
|
||||
internal async Task UpdateFuturesPrice(INewPrice newPrice, decimal newPriceValue)
|
||||
|
|
Loading…
Reference in New Issue