Пример #1
0
        private void CheckFileSystem()
        {
            if (_keys.Any() || !ApiConfigPath.Exists)
            {
                return;
            }

            var files = ApiConfigPath.GetFiles("*.api.txt", SearchOption.AllDirectories);

            if (!files.Any())
            {
                return;
            }

            CollectFilesystem(files);
        }
Пример #2
0
        private void FilterVolume(IReadOnlyDictionary <Network, IReadOnlyList <AssetPair> > pbn)
        {
            var r = new Dictionary <Network, IReadOnlyList <AssetPair> >();

            foreach (var kv in pbn)
            {
                var pairs = new UniqueList <AssetPair>();
                foreach (var pair in kv.Value)
                {
                    if (!VolumeCheck(kv.Key, pair))
                    {
                        continue;
                    }

                    pairs.Add(pair);
                }

                if (pairs.Any())
                {
                    r.Add(kv.Key, pairs);
                }
            }

            _dN.BuildData(r);
        }
Пример #3
0
 public bool HasRequests()
 {
     lock (_timerLock)
     {
         return(_pairRequests.Any());
     }
 }
Пример #4
0
        public async Task <AssetPairs> GetAssetPairsAsync(NetworkProviderContext context)
        {
            if (_pairs.Any())
            {
                return(new AssetPairs(_pairs));
            }

            var rates = await GetRatesAsync().ConfigureAwait(false);

            lock (_lock)
            {
                var pairs = new AssetPairs(rates.Select(x => x.Key));
                _pairs.Clear();
                _pairs.AddRange(pairs);
                return(pairs);
            }
        }
Пример #5
0
        private void DoFinal()
        {
            lock (_lock)
            {
                _items.RemoveAll(x => x.IsTotalLine);
                var qa = _quoteAsset;


                SubscribePriceConversion(qa);

                if (_items.Any())
                {
                    _items.Add(new PortfolioTotalLineItem()
                    {
                        Items = _items
                    });
                }

                _groupedAsset.Clear();

                foreach (var i in _items.GroupBy(x => x.Asset))
                {
                    _groupedAsset.Add(PortfolioGroupedItem.Create(qa, i.Key, i.ToList()));
                }

                foreach (var n in _infoItems)
                {
                    n.ConvertedTotal = _items.Where(x => !x.IsTotalLine && Equals(x.Network, n.Network)).Select(x => x.Converted).Sum(_quoteAsset);
                }

                if (_infoItems.All(x => x.ConvertedTotal != null))
                {
                    var t = _infoItems.Select(x => x.ConvertedTotal).Sum();
                    var r = t == 0 ? 0 : 100 / t;

                    foreach (var n in _infoItems)
                    {
                        n.Percentage = Math.Round(n.ConvertedTotal.Value.ToDecimalValue() * r, 2);
                    }
                }
            }
        }
Пример #6
0
 internal static bool TestPlatformFlags(this UniqueList <Platform> platforms, Platform platformFlags)
 {
     return(platforms.Any(platform => platformFlags.HasFlag(platform)));
 }