Esempio n. 1
0
        public async Task <IReadOnlyList <IndexHistory> > GetLastIndexHistoriesAsync(int limit)
        {
            var firstStateTime = await _firstStateAfterResetTimeRepository.GetAsync();

            var domain = await _indexHistoryRepository.TakeLastAsync(limit, firstStateTime);

            var result = Mapper.Map <IReadOnlyList <IndexHistory> >(domain);

            return(result);
        }
Esempio n. 2
0
        private void Initialize()
        {
            _log.Info("Initializing last state from history if needed...");

            lock (_syncLastReset)
                _lastReset = _firstStateAfterResetTimeRepository.GetAsync().GetAwaiter().GetResult();

            // Initialize _allMarketCaps
            RefreshCoinMarketCapDataAsync().GetAwaiter().GetResult();

            // Restore top assets from DB
            var lastIndexHistory = _indexHistoryRepository.TakeLastAsync(1).GetAwaiter().GetResult().SingleOrDefault();

            // if found then restore _topAssets (constituents)
            if (lastIndexHistory != null)
            {
                lock (_syncLastIndexHistory)
                    _lastIndexHistory = lastIndexHistory;

                lock (_sync)
                    _topAssets.AddRange(lastIndexHistory.Weights.Keys);

                _log.Info("Initialized previous weights and market caps from history.");
            }
        }