Move workers
This commit is contained in:
66
src/Managing.Application/Workers/PricesBaseWorker.cs
Normal file
66
src/Managing.Application/Workers/PricesBaseWorker.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using Managing.Application.Abstractions.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
namespace Managing.Application.Workers;
|
||||
|
||||
public abstract class PricesBaseWorker<T> : BaseWorker<T> where T : class
|
||||
{
|
||||
private readonly IPricesService _pricesService;
|
||||
private readonly IStatisticService _statisticService;
|
||||
private readonly Timeframe _timeframe;
|
||||
|
||||
public PricesBaseWorker(
|
||||
ILogger<T> logger,
|
||||
IPricesService pricesService,
|
||||
IServiceProvider serviceProvider,
|
||||
IStatisticService statisticService,
|
||||
TimeSpan delay,
|
||||
WorkerType workerType,
|
||||
Timeframe timeframe) : base(
|
||||
workerType,
|
||||
logger,
|
||||
delay,
|
||||
serviceProvider
|
||||
)
|
||||
{
|
||||
_pricesService = pricesService;
|
||||
_statisticService = statisticService;
|
||||
_timeframe = timeframe;
|
||||
}
|
||||
|
||||
private List<Ticker> _eligibleTickers = new List<Ticker>
|
||||
{
|
||||
Ticker.BTC,
|
||||
Ticker.ETH,
|
||||
Ticker.BNB,
|
||||
Ticker.DOGE,
|
||||
Ticker.ADA,
|
||||
Ticker.SOL,
|
||||
Ticker.XRP,
|
||||
Ticker.LINK,
|
||||
Ticker.RENDER,
|
||||
Ticker.SUI,
|
||||
Ticker.GMX,
|
||||
Ticker.ARB,
|
||||
Ticker.PEPE,
|
||||
Ticker.PENDLE,
|
||||
Ticker.AAVE,
|
||||
Ticker.HYPE
|
||||
};
|
||||
|
||||
protected override async Task Run(CancellationToken cancellationToken)
|
||||
{
|
||||
var tickers = await _statisticService.GetTickers();
|
||||
|
||||
var filteredTickers = tickers
|
||||
.Where(t => _eligibleTickers.Contains(t))
|
||||
.ToList();
|
||||
|
||||
// Filter with the eligible tickers
|
||||
foreach (var ticker in filteredTickers)
|
||||
{
|
||||
await _pricesService.UpdatePrice(TradingExchanges.Evm, ticker, _timeframe);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user