コード例 #1
0
        private OhlcData GetRangeInternal(TimeRange timeRange)
        {
            if (Ctx.PrimaryApiProvider == null)
            {
                return(null);
            }

            if (Ctx.CurrencyConversionApiProvider != null)
            {
                var cr = Convert(timeRange);
                Ctx.Status(cr == null ? "Data missing" : "Received data");
                return(cr);
            }

            Ctx.Status("Requesting @" + Ctx.PrimaryApiProvider.Title);
            var r = ApiCoordinator.GetOhlc(Ctx.PrimaryApiProvider, new OhlcContext(Ctx.Pair, Ctx.TimeResolution, timeRange, L));

            if (r.IsNull)
            {
                Ctx.Status("Data missing");
                return(null);
            }

            r.Response.ForEach(x => x.CollectedNearLive = x.DateTimeUtc.IsLive(Ctx.TimeResolution));
            Ctx.Status("Received data");
            return(r.Response);
        }
コード例 #2
0
        public OhlcData GetRange(TimeRange timeRange)
        {
            lock (Lock) {
                Ctx.Status("Requesting local data @" + Ctx.Network.Name);

                var seriesId = _adapter.SeriesId;

                var r = GetDbCollection().Where(x => x.SeriesId == seriesId && x.DateTimeUtcTicks >= timeRange.UtcFrom.Ticks && x.DateTimeUtcTicks <= timeRange.UtcTo.Ticks).ToList();
                var d = new OhlcData(timeRange.TimeResolution);
                d.AddRange(r);
                return(d);
            }
        }
コード例 #3
0
        public OhlcData GetRange(TimeRange timeRange)
        {
            lock (Lock) {
                Ctx.Status("Requesting in-memory data");

                var seriesId = _adapter.SeriesId;

                if (!CoverageMap.Covers(timeRange))
                {
                    return(null);
                }

                var r = MemoryCache.Where(x => x.SeriesId == seriesId && x.DateTimeUtc >= timeRange.UtcFrom && x.DateTimeUtc <= timeRange.UtcTo).ToList();
                var d = new OhlcData(timeRange.TimeResolution);
                d.AddRange(r);
                return(d);
            }
        }
コード例 #4
0
        private OhlcData RequestInternal(TimeRange timeRange, bool allowLive = false)
        {
            if (!_apiAdapters.Any() && !_storageAdapters.Any())
            {
                return(null);
            }

            if (!StorageEnabled && !ApiEnabled)
            {
                return(null);
            }

            lock (_lock)
            {
                OhlcData results = null;

                if (StorageEnabled)
                {
                    results = ContinuousOrMergedStorage(timeRange, allowLive);
                }

                var hasRemaining = results.IsEmpty() ? null : results.Remaining(timeRange);

                if (ApiEnabled && (results.IsEmpty() || hasRemaining != null))
                {
                    results = CollectApi(hasRemaining ?? timeRange, results);
                }

                Ctx.Status(results.IsNotEmpty() ? "Data received, processing." : "No data received.");

                if (StorageEnabled && results.IsNotEmpty())
                {
                    StoreResults(timeRange, results);
                }

                return(results);
            }
        }