public void PrintStatistics(CurrencyPair pair) { IBitcoinPrice allHistoryMax = this._repositoryService.Max(pair); IBitcoinPrice allHistoryMin = this._repositoryService.Min(pair); Console.WriteLine(pair.ToString()); Console.WriteLine("-------"); decimal price = this._repositoryService.GetLastValue(pair, out TrendType trend); Console.ForegroundColor = trend == TrendType.Up ? ConsoleColor.Green : ConsoleColor.Red; Console.WriteLine("LAST: {0:N2}", price); Console.ResetColor(); Console.WriteLine(); Console.WriteLine("AVERAGE: {0:N2}", this._repositoryService.GetAggregatedValue(RepositoryService.AggregateType.Average, pair)); Console.WriteLine("MAX: {0:N2} at {1} (UTC)", allHistoryMax.Value, allHistoryMax.Timestamp.DateTimeFromUnixTimestampSeconds()); Console.WriteLine("MIX: {0:N2} at {1} (UTC)", allHistoryMin.Value, allHistoryMin.Timestamp.DateTimeFromUnixTimestampSeconds()); Console.WriteLine(); Console.WriteLine("Last {0} prices", this._printoutServiceOptions.LastPrices); Console.WriteLine("-------------"); Console.WriteLine("AVERAGE: {0:N2}", this._repositoryService.GetAggregatedValue(RepositoryService.AggregateType.Average, pair, this._printoutServiceOptions.LastPrices)); Console.WriteLine("MAX: {0:N2}", this._repositoryService.GetAggregatedValue(RepositoryService.AggregateType.Max, pair, this._printoutServiceOptions.LastPrices)); Console.WriteLine("MIX: {0:N2}", this._repositoryService.GetAggregatedValue(RepositoryService.AggregateType.Min, pair, this._printoutServiceOptions.LastPrices)); Console.WriteLine(); Console.WriteLine("Last {0} minutes", this._printoutServiceOptions.LastMinutes); Console.WriteLine("--------------"); Console.WriteLine("AVERAGE: {0:N2}", this._repositoryService.GetAggregatedValue(RepositoryService.AggregateType.Average, pair, x => x.Timestamp.BelongsToLastMinutes(this._printoutServiceOptions.LastMinutes))); Console.WriteLine("MAX: {0:N2}", this._repositoryService.GetAggregatedValue(RepositoryService.AggregateType.Max, pair, x => x.Timestamp.BelongsToLastMinutes(this._printoutServiceOptions.LastMinutes))); Console.WriteLine("MIX: {0:N2}", this._repositoryService.GetAggregatedValue(RepositoryService.AggregateType.Min, pair, x => x.Timestamp.BelongsToLastMinutes(this._printoutServiceOptions.LastMinutes))); }
public void Test_Max_Value() { this.InitializeRepositoryWithTestData(); IBitcoinPrice maxPrice = this._repositoryService.Max(CurrencyPair.USDBTC); Assert.Equal(5, maxPrice.Value); Assert.Equal(CurrencyPair.USDBTC, maxPrice.Currency); }
public void Test_Min_Value() { this.InitializeRepositoryWithTestData(); Queue <IBitcoinPrice> testData = this.GetTestBitcoinPrices(); IBitcoinPrice minPrice = this._repositoryService.Min(CurrencyPair.USDBTC); Assert.Equal(testData.Min(x => x.Value), minPrice.Value); Assert.Equal(CurrencyPair.USDBTC, minPrice.Currency); }
public void Persist(IBitcoinPrice bitcoinPrice) { FixedSizedQueue <IBitcoinPrice> newQueue = new FixedSizedQueue <IBitcoinPrice>(this._repositoryServiceOptions.MemorySize); newQueue.Enqueue(bitcoinPrice); this.inMemoryStorage.AddOrUpdate(bitcoinPrice.Currency, newQueue, (key, existingVal) => { existingVal.Enqueue(bitcoinPrice); return(existingVal); }); }
public async Task Execute(CancellationToken token) { while (!token.IsCancellationRequested) { HarvestTask task = this._taskQueue.Take(token); IHarvestingService harvester = this._harvestingServiceFactory.GetHarvestingService(task.Origin); IBitcoinPrice price = await harvester.GetPriceAsync(task); this._repositoryService.Persist(price); } }
public void SaveBitcoinPrice(IBitcoinPrice bitcoinPrice) { throw new System.NotImplementedException(); }
public void SaveBitcoinPrice(IBitcoinPrice bitcoinPrice) { _context.BitcoinPrice.Add((BitcoinPriceSQL)bitcoinPrice); _context.SaveChanges(); }