Example #1
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());
        }
Example #2
0
        public PriceGraph(PricesContext context, NetworkGraph networkGraph)
        {
            PricesContext  = context;
            NetworkContext = networkGraph.Context;
            NetworkGraph   = networkGraph;

            _dN.BuildData(networkGraph.PairsByNetworkN);

            var source = _dN.DeNormalise(NetworkGraph.PairsByNetworkRaw);

            _pricesByNetwork = PopulatePriceGraph(source).ToDictionary(x => x.Key, y => y.Value.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());
        }