Beispiel #1
0
        public async static Task <SpotRate> GetSpotPrice(string currency = null)
        {
            var url = GetSpotRateUrl(currency);
            var spotPriceJObject = await GetUnauthenticatedJResource(url);

            return(new SpotRate(PriceUnit.FromJToken(spotPriceJObject)));
        }
Beispiel #2
0
        public async Task <PriceUnit> GetBalance()
        {
            var url      = GetAccountBalanceUrl();
            var response = await this.GetAuthenticatedResource(url);

            return(PriceUnit.FromJToken(response));
        }
Beispiel #3
0
        public async static Task <PriceBuyResponse> GetBitcoinBuyPrice(decimal bitcoinQuantity = 1, string currency = null)
        {
            if (bitcoinQuantity < 0)
            {
                throw new ArgumentOutOfRangeException("bitcoinQuantity", "Argument bitcoinQuantity must be a non-negative value.");
            }

            // Do not validate currency.
            var url          = GetBuyPricesUrl(bitcoinQuantity, currency);
            var priceJObject = await GetUnauthenticatedJResource(url);

            var subtotal = PriceUnit.FromJToken(priceJObject["subtotal"]);
            var fees     = priceJObject["fees"]
                           .SelectMany(t => t)
                           .Cast <JProperty>()
                           .Select(jProperty => new CoinbaseFee(jProperty.Name,
                                                                PriceUnit.FromJToken(jProperty.Value)
                                                                ));
            var total = PriceUnit.FromJToken(priceJObject["total"]);

            return(new PriceBuyResponse(subtotal, fees, total));
        }