Beispiel #1
0
        public async Task <PublicVolumeResponse> GetAggVolumeDataAsync(AggVolumeDataContext context)
        {
            var pair = context.Pair;

            var api  = GetApi <ICryptoCompareApi>();
            var apir = await api.GetTopExchangesAsync(pair.Asset1.ToRemoteCode(this), pair.Asset2.ToRemoteCode(this)).ConfigureAwait(false);

            if (apir.IsError() || apir.Data == null)
            {
                return(null);
            }

            var vols = new List <NetworkPairVolume>();

            foreach (var i in apir.Data)
            {
                var pcheck = new AssetPair(i.fromSymbol, i.toSymbol, this);
                if (pcheck.Id != pair.Id)
                {
                    continue;
                }

                var vb = new Money((decimal)i.volume24h, pair.Asset1);
                var vq = new Money((decimal)i.volume24hTo, pair.Asset2);
                var v  = new NetworkPairVolume(Networks.I.Get(i.exchange), pair, vb, vq);
                vols.Add(v);
            }

            return(new PublicVolumeResponse(vols));
        }
Beispiel #2
0
 private NetworkPairVolume PostProcess(NetworkPairVolume vol, bool mustSave)
 {
     if (mustSave && CanSave)
     {
         Data.SavePublic();
     }
     return(vol);
 }