Beispiel #1
0
 private void Save(MarketPrices prices)
 {
     foreach (var kv in prices.GroupBy(x => x.Network))
     {
         var p = new MarketPrices(kv);
         p.SavePublic();
     }
 }
Beispiel #2
0
        public MarketPricesResult(MarketPrice price)
        {
            if (price != null)
            {
                MarketPrices.Add(price);
            }

            WasViaSingleMethod = true;
        }
Beispiel #3
0
        public void Refresh(MarketPrices newPrices = null)
        {
            var source = _dN.DeNormalise(NetworkGraph.PairsByNetworkRaw);

            _pricesByNetwork = (newPrices ?? PopulatePriceGraph(source)).GroupBy(x => x.Network).ToDictionary(x => x.Key, y => y.AsReadOnlyList());

            RemoveEmptyPricing(_pricesByNetwork);

            _dN.BuildData(_pricesByNetwork.ToDictionary(x => x.Key, y => y.Value.Select(x => x.Pair).AsReadOnlyList()));

            _prices       = _pricesByNetwork.Values.SelectMany(x => x).ToList();
            _pricesByPair = _prices.GroupBy(x => x.Pair).ToDictionary(x => x.Key, y => y.AsReadOnlyList());
        }
Beispiel #4
0
        public void Update(MarketPrices prices)
        {
            var ps = Prices.ToList();

            foreach (var p in prices)
            {
                var e = ps.FirstOrDefault(x => x.Network?.Id == p.Network?.Id && x.Pair.Id == p.Pair.Id);
                if (e != null)
                {
                    ps.Remove(e);
                }
                ps.Add(p);
            }
            var newprices = new MarketPrices(ps);

            Save(newprices);
            Refresh(newprices);
        }
Beispiel #5
0
 public PublicVolumeResponse(Network network, MarketPrices marketPrices) : this(network, marketPrices?.Select(x => x?.Volume), marketPrices?.MissedPairs)
 {
 }
Beispiel #6
0
        private MarketPrices GetDbPrices(Network network)
        {
            var fromDb = network.NameLowered != "###" ? PublicContext.I.As <MarketPrices>().FirstOrDefault(x => x.Id == MarketPrices.GetHash(network)) : null;

            if (fromDb != null && !fromDb.UtcCreated.IsWithinTheLast(TimeSpan.FromHours(1)))
            {
                return(null);
            }

            return(fromDb);
        }