From a6389dcbe74865fc6022a9c1cdb51116fb72fea8 Mon Sep 17 00:00:00 2001 From: Lee Date: Mon, 8 Jan 2018 09:58:52 +0000 Subject: [PATCH] Support querying a single 24h price change pair, or returning all price changes --- .../Interfaces/IBinanceClient.cs | 10 ++++++++-- Binance.API.Csharp.Client.Test/BinanceTest.cs | 10 ++++++++-- Binance.API.Csharp.Client/BinanceClient.cs | 17 +++++++++++++---- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Binance.API.Csharp.Client.Domain/Interfaces/IBinanceClient.cs b/Binance.API.Csharp.Client.Domain/Interfaces/IBinanceClient.cs index 5312215..8aac2a6 100644 --- a/Binance.API.Csharp.Client.Domain/Interfaces/IBinanceClient.cs +++ b/Binance.API.Csharp.Client.Domain/Interfaces/IBinanceClient.cs @@ -54,11 +54,17 @@ public interface IBinanceClient Task> GetCandleSticks(string symbol, TimeInterval interval, DateTime? startTime = null, DateTime? endTime = null, int limit = 500); /// - /// 24 hour price change statistics. + /// Single 24 hour price change statistics. /// /// Ticker symbol. /// - Task> GetPriceChange24H(string symbol); + Task GetPriceChange24H(string symbol); + + /// + /// All 24 hour price change statistics. + /// + /// + Task> GetAllPriceChanges24H(); /// /// Latest price for all symbols. diff --git a/Binance.API.Csharp.Client.Test/BinanceTest.cs b/Binance.API.Csharp.Client.Test/BinanceTest.cs index 4dce8bd..156e2e3 100644 --- a/Binance.API.Csharp.Client.Test/BinanceTest.cs +++ b/Binance.API.Csharp.Client.Test/BinanceTest.cs @@ -45,9 +45,15 @@ public void GetAggregateTrades() } [TestMethod] - public void GetPriceChange24H() + public void GetAllPriceChanges24H() { - var priceChangeInfo = binanceClient.GetPriceChange24H().Result; + var priceChangeInfo = binanceClient.GetAllPriceChanges24H().Result; + } + + [TestMethod] + public void GetSinglePriceChanges24H() + { + var priceChangeInfo = binanceClient.GetPriceChange24H("ethbtc").Result; } [TestMethod] diff --git a/Binance.API.Csharp.Client/BinanceClient.cs b/Binance.API.Csharp.Client/BinanceClient.cs index fd65700..558786c 100644 --- a/Binance.API.Csharp.Client/BinanceClient.cs +++ b/Binance.API.Csharp.Client/BinanceClient.cs @@ -189,12 +189,21 @@ public async Task> GetCandleSticks(string symbol, TimeI /// /// Ticker symbol. /// - public async Task> GetPriceChange24H(string symbol = "") + public async Task GetPriceChange24H(string symbol) { - var args = string.IsNullOrWhiteSpace(symbol) ? "" : $"symbol={symbol.ToUpper()}"; - - var result = await _apiClient.CallAsync>(ApiMethod.GET, EndPoints.TickerPriceChange24H, false, args); + var args = $"symbol={symbol.ToUpper()}"; + var result = await _apiClient.CallAsync(ApiMethod.GET, EndPoints.TickerPriceChange24H, false, args); + return result; + } + /// + /// All 24 hour price change statistics. + /// + /// Ticker symbol. + /// + public async Task> GetAllPriceChanges24H() + { + var result = await _apiClient.CallAsync>(ApiMethod.GET, EndPoints.TickerPriceChange24H, false); return result; }