示例#1
0
 private void Save(MarketPrices prices)
 {
     foreach (var kv in prices.GroupBy(x => x.Network))
     {
         var p = new MarketPrices(kv);
         p.SavePublic();
     }
 }
示例#2
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());
        }
示例#3
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);
        }
示例#4
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);
        }
示例#5
0
 public PublicVolumeResponse(Network network, MarketPrices marketPrices) : this(network, marketPrices?.Select(x => x?.Volume), marketPrices?.MissedPairs)
 {
 }