protected override async Task ExecuteAsync() { var nxsSummary = await _bittrexClient.GetMarketSummaryAsync(Market); var btcTicket = await _bittrexClient.GetTickerAsync(UsdMarket); if (btcTicket != null) { await _redis.SetAsync(Settings.Redis.BittrexLastUsdBtcPrice, btcTicket.Last); } if (nxsSummary == null) { Logger.LogInformation("Bittrex data not availible"); return; } await _redis.SetAsync(Settings.Redis.BittrexLastBtcNxsPrice, nxsSummary.Last); var summary = nxsSummary.ToBittrexSummary(); Interlocked.Increment(ref _runCount); if (_runCount == DbSaveRunInterval) { await _nexusDb.BittrexSummaries.AddAsync(summary); await _nexusDb.SaveChangesAsync(); Interlocked.Exchange(ref _runCount, 0); Logger.LogInformation("Latest Bittrex data saved to DB"); } var summaryDto = new BittrexSummaryDto(summary); await _redis.PublishAsync(Settings.Redis.BittrexSummaryPubSub, summaryDto); await _redis.SetAsync(Settings.Redis.BittrexSummaryPubSub, summaryDto); }
private Task UpdateLatestPriceData(BittrexSummaryDto summary) { return(_layoutContext.Clients.All.SendAsync("UpdateLatestPriceData", summary)); }