diff --git a/IEXSharp/Service/V2/Stock/IStockService.cs b/IEXSharp/Service/V2/Stock/IStockService.cs index 9b035578..b846b430 100644 --- a/IEXSharp/Service/V2/Stock/IStockService.cs +++ b/IEXSharp/Service/V2/Stock/IStockService.cs @@ -267,7 +267,7 @@ public interface IStockService /// /// /// - Task KeyStatsAsync(string symbol); + Task> KeyStatsAsync(string symbol); /// /// @@ -282,7 +282,7 @@ public interface IStockService /// /// /// - Task> LargestTradesAsync(string symbol); + Task>> LargestTradesAsync(string symbol); /// /// @@ -296,7 +296,7 @@ public interface IStockService /// /// /// - Task LogoAsync(string symbol); + Task> LogoAsync(string symbol); /// /// @@ -317,42 +317,42 @@ public interface IStockService /// /// /// - Task OHLCAsync(string symbol); + Task> OHLCAsync(string symbol); /// /// /// /// /// - Task> PeersAsync(string symbol); + Task>> PeersAsync(string symbol); /// /// /// /// /// - Task PreviousDayPriceAsync(string symbol); + Task> PreviousDayPriceAsync(string symbol); /// /// /// /// /// - Task PriceAsync(string symbol); + Task> PriceAsync(string symbol); /// /// /// /// /// - Task PriceTargetAsync(string symbol); + Task> PriceTargetAsync(string symbol); /// /// /// /// /// - Task QuoteAsync(string symbol); + Task> QuoteAsync(string symbol); /// /// @@ -367,7 +367,7 @@ public interface IStockService /// /// /// - Task> RecommendationTrendAsync(string symbol); + Task>> RecommendationTrendAsync(string symbol); /// /// @@ -404,6 +404,6 @@ public interface IStockService /// /// /// - Task VolumeByVenueAsync(string symbol); + Task> VolumeByVenueAsync(string symbol); } } \ No newline at end of file diff --git a/IEXSharp/Service/V2/Stock/StockService.cs b/IEXSharp/Service/V2/Stock/StockService.cs index 84db99d1..50a91dfd 100644 --- a/IEXSharp/Service/V2/Stock/StockService.cs +++ b/IEXSharp/Service/V2/Stock/StockService.cs @@ -354,8 +354,8 @@ public async Task> IPOCalendarAsync(IPOType ipoType) return await executor.ExecuteAsync(urlPattern, pathNvc, qsb); } - public async Task KeyStatsAsync(string symbol) => - await executor.SymbolExecuteAsyncLegacy("stock/[symbol]/stats", symbol); + public async Task> KeyStatsAsync(string symbol) => + await executor.SymbolExecuteAsync("stock/[symbol]/stats", symbol); public async Task> KeyStatsStatAsync(string symbol, string stat) { @@ -369,8 +369,8 @@ public async Task> KeyStatsStatAsync(string symbol return await executor.ExecuteAsync(urlPattern, pathNvc, qsb); } - public async Task> LargestTradesAsync(string symbol) => - await executor.SymbolExecuteAsyncLegacy>("stock/[symbol]/largest-trades", symbol); + public async Task>> LargestTradesAsync(string symbol) => + await executor.SymbolExecuteAsync>("stock/[symbol]/largest-trades", symbol); public async Task>> ListAsync(string listType) { @@ -384,8 +384,8 @@ public async Task>> ListAsync(string listType) return await executor.ExecuteAsync>(urlPattern, pathNvc, qsb); } - public async Task LogoAsync(string symbol) => - await executor.SymbolExecuteAsyncLegacy("stock/[symbol]/logo", symbol); + public async Task> LogoAsync(string symbol) => + await executor.SymbolExecuteAsync("stock/[symbol]/logo", symbol); public async Task>> MarketVolumeUSAsync() => await executor.NoParamExecute>("market"); @@ -393,26 +393,29 @@ public async Task>> MarketVolume public async Task>> NewsAsync(string symbol, int last = 10) => await executor.SymbolLastExecuteAsync>("stock/[symbol]/news/last/[last]", symbol, last); - public async Task OHLCAsync(string symbol) => - await executor.SymbolExecuteAsyncLegacy("stock/[symbol]/ohlc", symbol); + public async Task> OHLCAsync(string symbol) => + await executor.SymbolExecuteAsync("stock/[symbol]/ohlc", symbol); - public async Task> PeersAsync(string symbol) => - await executor.SymbolExecuteAsyncLegacy>("stock/[symbol]/peers", symbol); + public async Task>> PeersAsync(string symbol) => + await executor.SymbolExecuteAsync>("stock/[symbol]/peers", symbol); - public async Task PreviousDayPriceAsync(string symbol) => - await executor.SymbolExecuteAsyncLegacy("stock/[symbol]/previous", symbol); + public async Task> PreviousDayPriceAsync(string symbol) => + await executor.SymbolExecuteAsync("stock/[symbol]/previous", symbol); - public async Task PriceAsync(string symbol) + public async Task> PriceAsync(string symbol) { - var returnValue = await executor.SymbolExecuteAsyncLegacy("stock/[symbol]/price", symbol); - return decimal.Parse(returnValue); + var returnValue = await executor.SymbolExecuteAsync("stock/[symbol]/price", symbol); + if (returnValue.ErrorMessage != null) + return new IEXResponse() { ErrorMessage = returnValue.ErrorMessage }; + else + return new IEXResponse() { Data = decimal.Parse(returnValue.Data) }; } - public async Task PriceTargetAsync(string symbol) => - await executor.SymbolExecuteAsyncLegacy("stock/[symbol]/price-target", symbol); + public async Task> PriceTargetAsync(string symbol) => + await executor.SymbolExecuteAsync("stock/[symbol]/price-target", symbol); - public async Task QuoteAsync(string symbol) => - await executor.SymbolExecuteAsyncLegacy("stock/[symbol]/quote", symbol); + public async Task> QuoteAsync(string symbol) => + await executor.SymbolExecuteAsync("stock/[symbol]/quote", symbol); public async Task> QuoteFieldAsync(string symbol, string field) { @@ -426,8 +429,8 @@ public async Task> QuoteFieldAsync(string symbol, string fie return await executor.ExecuteAsync(urlPattern, pathNvc, qsb); } - public async Task> RecommendationTrendAsync(string symbol) => - await executor.SymbolExecuteAsyncLegacy>( + public async Task>> RecommendationTrendAsync(string symbol) => + await executor.SymbolExecuteAsync>( "stock/[symbol]/recommendation-trends", symbol); public async Task>> SectorPerformanceAsync() => @@ -469,7 +472,7 @@ public async Task> UpcomingEventMarketA return await executor.ExecuteAsync(urlPattern, pathNvc, qsb); } - public async Task VolumeByVenueAsync(string symbol) => - await executor.SymbolExecuteAsyncLegacy("stock/[symbol]/delayed-quote", symbol); + public async Task> VolumeByVenueAsync(string symbol) => + await executor.SymbolExecuteAsync("stock/[symbol]/delayed-quote", symbol); } } \ No newline at end of file diff --git a/IEXSharpTest/Cloud(V2)/StockTest.cs b/IEXSharpTest/Cloud(V2)/StockTest.cs index bfda8c06..c6db7cc2 100644 --- a/IEXSharpTest/Cloud(V2)/StockTest.cs +++ b/IEXSharpTest/Cloud(V2)/StockTest.cs @@ -445,7 +445,8 @@ public async Task KeyStatsAsyncTest(string symbol) { var response = await sandBoxClient.Stock.KeyStatsAsync(symbol); - Assert.IsNotNull(response); + Assert.IsNull(response.ErrorMessage); + Assert.IsNotNull(response.Data); } [Test] @@ -455,7 +456,8 @@ public async Task KeyStatsStatAsync(string symbol, string stat) { var response = await sandBoxClient.Stock.KeyStatsStatAsync(symbol, stat); - Assert.IsNotNull(response); + Assert.IsNull(response.ErrorMessage); + Assert.IsNotNull(response.Data); } [Test] @@ -465,8 +467,9 @@ public async Task LargestTradesAsyncTest(string symbol) { var response = await sandBoxClient.Stock.LargestTradesAsync(symbol); - Assert.IsNotNull(response); - Assert.GreaterOrEqual(response.Count(), 0); + Assert.IsNull(response.ErrorMessage); + Assert.IsNotNull(response.Data); + Assert.GreaterOrEqual(response.Data.Count(), 1); } [Test] @@ -492,7 +495,8 @@ public async Task LogoAsyncTest(string symbol) { var response = await sandBoxClient.Stock.LogoAsync(symbol); - Assert.IsNotNull(response); + Assert.IsNull(response.ErrorMessage); + Assert.IsNotNull(response.Data); } [Test] @@ -524,7 +528,8 @@ public async Task OHLCAsyncTest(string symbol) { var response = await sandBoxClient.Stock.OHLCAsync(symbol); - Assert.IsNotNull(response); + Assert.IsNull(response.ErrorMessage); + Assert.IsNotNull(response.Data); } [Test] @@ -534,8 +539,9 @@ public async Task PeersAsyncTest(string symbol) { var response = await sandBoxClient.Stock.PeersAsync(symbol); - Assert.IsNotNull(response); - Assert.GreaterOrEqual(response.Count(), 0); + Assert.IsNull(response.ErrorMessage); + Assert.IsNotNull(response.Data); + Assert.GreaterOrEqual(response.Data.Count(), 1); } [Test] @@ -545,7 +551,8 @@ public async Task PreviousDayPriceAsyncTest(string symbol) { var response = await sandBoxClient.Stock.PreviousDayPriceAsync(symbol); - Assert.IsNotNull(response); + Assert.IsNull(response.ErrorMessage); + Assert.IsNotNull(response.Data); } [Test] @@ -555,7 +562,8 @@ public async Task PriceAsyncTest(string symbol) { var response = await sandBoxClient.Stock.PriceAsync(symbol); - Assert.IsNotNull(response); + Assert.IsNull(response.ErrorMessage); + Assert.IsNotNull(response.Data); } [Test] @@ -565,7 +573,8 @@ public async Task PriceTargetAsyncTest(string symbol) { var response = await sandBoxClient.Stock.PriceTargetAsync(symbol); - Assert.IsNotNull(response); + Assert.IsNull(response.ErrorMessage); + Assert.IsNotNull(response.Data); } [Test] @@ -575,7 +584,8 @@ public async Task QuoteAsyncTest(string symbol) { var response = await sandBoxClient.Stock.QuoteAsync(symbol); - Assert.IsNotNull(response); + Assert.IsNull(response.ErrorMessage); + Assert.IsNotNull(response.Data); } [Test] @@ -585,7 +595,8 @@ public async Task QuoteFieldAsyncTest(string symbol, string field) { var response = await sandBoxClient.Stock.QuoteFieldAsync(symbol, field); - Assert.IsNotNull(response); + Assert.IsNull(response.ErrorMessage); + Assert.IsNotNull(response.Data); } [Test] @@ -595,8 +606,9 @@ public async Task RecommandationTrendAsyncTest(string symbol) { var response = await sandBoxClient.Stock.RecommendationTrendAsync(symbol); - Assert.IsNotNull(response); - Assert.GreaterOrEqual(response.Count(), 0); + Assert.IsNull(response.ErrorMessage); + Assert.IsNotNull(response.Data); + Assert.GreaterOrEqual(response.Data.Count(), 1); } [Test] @@ -637,7 +649,8 @@ public async Task UpcomingEventSymbolAsyncTest(string symbol, UpcomingEventType { var response = await sandBoxClient.Stock.UpcomingEventSymbolAsync(symbol, type); - Assert.IsNotNull(response); + Assert.IsNull(response.ErrorMessage); + Assert.IsNotNull(response.Data); } // Not supported for free account @@ -651,7 +664,8 @@ public async Task UpcomingEventMarketAsyncTest(UpcomingEventType type) { var response = await sandBoxClient.Stock.UpcomingEventMarketAsync(type); - Assert.IsNotNull(response); + Assert.IsNull(response.ErrorMessage); + Assert.IsNotNull(response.Data); } [Test] @@ -661,7 +675,8 @@ public async Task VolumeByVenueAsyncTest(string symbol) { var response = await sandBoxClient.Stock.VolumeByVenueAsync(symbol); - Assert.IsNotNull(response); + Assert.IsNull(response.ErrorMessage); + Assert.IsNotNull(response.Data); } } } \ No newline at end of file