public IndexCalculator(string indexName, TimeSpan indexCalculationInterval, ISettingsService settingsService, IIndexStateRepository indexStateRepository, IIndexHistoryRepository indexHistoryRepository, ITickPricesService tickPricesService, ICoinMarketCapService coinMarketCapService, ITickPricePublisher tickPricePublisher, IWarningRepository warningRepository, IFirstStateAfterResetTimeRepository firstStateAfterResetTimeRepository, IIndexHandler indexHandler, ILogFactory logFactory) { _lastRebuild = DateTime.UtcNow.Date; _allMarketCaps = new List <AssetMarketCap>(); _topAssets = new List <string>(); _lastTopAssetMarketCaps = new ConcurrentDictionary <string, decimal>(); _indexName = indexName; _trigger = new TimerTrigger(nameof(IndexCalculator), indexCalculationInterval, logFactory, TimerHandlerAsync); _settingsService = settingsService; _indexStateRepository = indexStateRepository; _indexHistoryRepository = indexHistoryRepository; _tickPricesService = tickPricesService; _coinMarketCapService = coinMarketCapService; _tickPricePublisher = tickPricePublisher; _warningRepository = warningRepository; _firstStateAfterResetTimeRepository = firstStateAfterResetTimeRepository; _indexHandler = indexHandler; _log = logFactory.CreateLog(this); }
private void InitializeIndexHistoryRepository() { var indexHistoryRepository = new Mock <IIndexHistoryRepository>(); indexHistoryRepository.Setup(o => o.TakeLastAsync(It.IsAny <int>(), It.IsAny <DateTime?>())) .Returns((int take, DateTime? from) => { var indexHistories = _indexHistories; if (from.HasValue) { indexHistories = indexHistories.Where(x => x.Time > from).ToList(); } indexHistories = indexHistories.OrderByDescending(x => x.Time).Take(take).ToList(); return(Task.FromResult((IReadOnlyList <IndexHistory>)indexHistories)); }); indexHistoryRepository.Setup(o => o.InsertAsync(It.IsAny <IndexHistory>())) .Returns((IndexHistory newIndexHistory) => { _indexHistories.Add(newIndexHistory); return(Task.CompletedTask); }); _indexHistoryRepository = indexHistoryRepository.Object; }
public PublicController(IIndexHistoryRepository indexHistoryRepository, IIndexStateRepository indexStateRepository, IIndexCalculator indexCalculator, IStatisticsService statisticsService) { _indexHistoryRepository = indexHistoryRepository; _indexStateRepository = indexStateRepository; _indexCalculator = indexCalculator; _statisticsService = statisticsService; }
public IndexHistoryController(IIndexHistoryRepository indexHistoryRepository, IFirstStateAfterResetTimeRepository firstStateAfterResetTimeRepository, IIndexCalculator indexCalculator) { _indexHistoryRepository = indexHistoryRepository; _firstStateAfterResetTimeRepository = firstStateAfterResetTimeRepository; _indexCalculator = indexCalculator; }
public StatisticsService(IIndexHistoryRepository indexHistoryRepository, IChartHistory5DRepository chartHistory5DRepository, IChartHistory30DRepository chartHistory30DRepository, ILogFactory logFactory) { _indexHistoryRepository = indexHistoryRepository; _chartHistory5DRepository = chartHistory5DRepository; _chartHistory30DRepository = chartHistory30DRepository; _log = logFactory.CreateLog(this); }