Skip to content

Commit

Permalink
incorporated IEXResponse into some StockService V2 methods which use …
Browse files Browse the repository at this point in the history
…SymbolExecuteAsync()

- adjusted tests accordingly
- second half of methods in StockService V2
  • Loading branch information
vslee committed Mar 21, 2020
1 parent dce66d3 commit 51b943c
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 53 deletions.
20 changes: 10 additions & 10 deletions IEXSharp/Service/V2/Stock/IStockService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public interface IStockService
/// </summary>
/// <param name="symbol"></param>
/// <returns></returns>
Task<BookResponse> BookAsync(string symbol);
Task<IEXResponse<BookResponse>> BookAsync(string symbol);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#cash-flow"/>
Expand Down Expand Up @@ -86,14 +86,14 @@ public interface IStockService
/// </summary>
/// <param name="symbol"></param>
/// <returns></returns>
Task<CompanyResponse> CompanyAsync(string symbol);
Task<IEXResponse<CompanyResponse>> CompanyAsync(string symbol);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#delayed-quote"/>
/// </summary>
/// <param name="symbol"></param>
/// <returns></returns>
Task<DelayedQuoteResponse> DelayedQuoteAsync(string symbol);
Task<IEXResponse<DelayedQuoteResponse>> DelayedQuoteAsync(string symbol);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#dividends-basic"/>
Expand Down Expand Up @@ -132,7 +132,7 @@ public interface IStockService
/// </summary>
/// <param name="symbol"></param>
/// <returns></returns>
Task<IEnumerable<EffectiveSpreadResponse>> EffectiveSpreadAsync(string symbol);
Task<IEXResponse<IEnumerable<EffectiveSpreadResponse>>> EffectiveSpreadAsync(string symbol);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#estimates"/>
Expand Down Expand Up @@ -173,7 +173,7 @@ public interface IStockService
/// </summary>
/// <param name="symbol"></param>
/// <returns></returns>
Task<FundOwnershipResponse> FundOwnershipAsync(string symbol);
Task<IEXResponse<FundOwnershipResponse>> FundOwnershipAsync(string symbol);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#historical-prices"/>
Expand Down Expand Up @@ -225,35 +225,35 @@ public interface IStockService
/// </summary>
/// <param name="symbol"></param>
/// <returns></returns>
Task<IEnumerable<InsiderRosterResponse>> InsiderRosterAsync(string symbol);
Task<IEXResponse<IEnumerable<InsiderRosterResponse>>> InsiderRosterAsync(string symbol);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#insider-summary"/>
/// </summary>
/// <param name="symbol"></param>
/// <returns></returns>
Task<IEnumerable<InsiderSummaryResponse>> InsiderSummaryAsync(string symbol);
Task<IEXResponse<IEnumerable<InsiderSummaryResponse>>> InsiderSummaryAsync(string symbol);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#insider-transactions"/>
/// </summary>
/// <param name="symbol"></param>
/// <returns></returns>
Task<IEnumerable<InsiderTransactionResponse>> InsiderTransactionAsync(string symbol);
Task<IEXResponse<IEnumerable<InsiderTransactionResponse>>> InsiderTransactionAsync(string symbol);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#institutional-ownership"/>
/// </summary>
/// <param name="symbol"></param>
/// <returns></returns>
Task<IEnumerable<InstitutionalOwnershipResponse>> InstitutionalOwnerShipAsync(string symbol);
Task<IEXResponse<IEnumerable<InstitutionalOwnershipResponse>>> InstitutionalOwnerShipAsync(string symbol);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#institutional-ownership"/>
/// </summary>
/// <param name="symbol"></param>
/// <returns></returns>
Task<IEnumerable<IntradayPriceResponse>> IntradayPriceAsync(string symbol);
Task<IEXResponse<IEnumerable<IntradayPriceResponse>>> IntradayPriceAsync(string symbol);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#intraday-prices"/>
Expand Down
40 changes: 20 additions & 20 deletions IEXSharp/Service/V2/Stock/StockService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ public async Task<IEXResponse<Dictionary<string, BatchBySymbolResponse>>> BatchB
return await executor.ExecuteAsync<Dictionary<string, BatchBySymbolResponse>>(urlPattern, pathNvc, qsb);
}

public async Task<BookResponse> BookAsync(string symbol) =>
await executor.SymbolExecuteAsyncLegacy<BookResponse>("stock/[symbol]/book", symbol);
public async Task<IEXResponse<BookResponse>> BookAsync(string symbol) =>
await executor.SymbolExecuteAsync<BookResponse>("stock/[symbol]/book", symbol);

public async Task<IEXResponse<CashFlowResponse>> CashFlowAsync(string symbol, Period period = Period.Quarter, int last = 1)
{
Expand Down Expand Up @@ -197,11 +197,11 @@ public async Task<IEXResponse<IEnumerable<Quote>>> CollectionsAsync(CollectionTy
return await executor.ExecuteAsync<IEnumerable<Quote>>(urlPattern, pathNvc, qsb);
}

public async Task<CompanyResponse> CompanyAsync(string symbol) =>
await executor.SymbolExecuteAsyncLegacy<CompanyResponse>("stock/[symbol]/company", symbol);
public async Task<IEXResponse<CompanyResponse>> CompanyAsync(string symbol) =>
await executor.SymbolExecuteAsync<CompanyResponse>("stock/[symbol]/company", symbol);

public async Task<DelayedQuoteResponse> DelayedQuoteAsync(string symbol) =>
await executor.SymbolExecuteAsyncLegacy<DelayedQuoteResponse>("stock/[symbol]/delayed-quote", symbol);
public async Task<IEXResponse<DelayedQuoteResponse>> DelayedQuoteAsync(string symbol) =>
await executor.SymbolExecuteAsync<DelayedQuoteResponse>("stock/[symbol]/delayed-quote", symbol);

public async Task<IEXResponse<IEnumerable<DividendResponse>>> DividendAsync(string symbol, DividendRange range)
{
Expand All @@ -227,8 +227,8 @@ public async Task<IEXResponse<string>> EarningFieldAsync(string symbol, string f
public async Task<IEXResponse<EarningTodayResponse>> EarningTodayAsync() =>
await executor.NoParamExecute<EarningTodayResponse>("stock/market/today-earnings");

public async Task<IEnumerable<EffectiveSpreadResponse>> EffectiveSpreadAsync(string symbol) =>
await executor.SymbolExecuteAsyncLegacy<IEnumerable<EffectiveSpreadResponse>>(
public async Task<IEXResponse<IEnumerable<EffectiveSpreadResponse>>> EffectiveSpreadAsync(string symbol) =>
await executor.SymbolExecuteAsync<IEnumerable<EffectiveSpreadResponse>>(
"stock/[symbol]/effective-spread", symbol);

public async Task<IEXResponse<EstimateResponse>> EstimateAsync(string symbol, int last = 1) =>
Expand All @@ -243,8 +243,8 @@ public async Task<IEXResponse<FinancialResponse>> FinancialAsync(string symbol,
public async Task<IEXResponse<string>> FinancialFieldAsync(string symbol, string field, int last = 1) =>
await executor.SymbolLastFieldExecuteAsync("stock/[symbol]/financials/[last]/[field]", symbol, field, last);

public async Task<FundOwnershipResponse> FundOwnershipAsync(string symbol) =>
await executor.SymbolExecuteAsyncLegacy<FundOwnershipResponse>("stock/[symbol]/fund-ownership", symbol);
public async Task<IEXResponse<FundOwnershipResponse>> FundOwnershipAsync(string symbol) =>
await executor.SymbolExecuteAsync<FundOwnershipResponse>("stock/[symbol]/fund-ownership", symbol);

public async Task<IEXResponse<IEnumerable<HistoricalPriceResponse>>> HistoricalPriceAsync(string symbol,
ChartRange range = ChartRange._1m, QueryStringBuilder qsb = null)
Expand Down Expand Up @@ -323,24 +323,24 @@ public async Task<IEXResponse<string>> IncomeStatementFieldAsync(string symbol,
return await executor.ExecuteAsync<string>(urlPattern, pathNvc, qsb);
}

public async Task<IEnumerable<InsiderRosterResponse>> InsiderRosterAsync(string symbol) =>
await executor.SymbolExecuteAsyncLegacy<IEnumerable<InsiderRosterResponse>>("stock/[symbol]/insider-roster",
public async Task<IEXResponse<IEnumerable<InsiderRosterResponse>>> InsiderRosterAsync(string symbol) =>
await executor.SymbolExecuteAsync<IEnumerable<InsiderRosterResponse>>("stock/[symbol]/insider-roster",
symbol);

public async Task<IEnumerable<InsiderSummaryResponse>> InsiderSummaryAsync(string symbol) =>
await executor.SymbolExecuteAsyncLegacy<IEnumerable<InsiderSummaryResponse>>("stock/[symbol]/insider-summary",
public async Task<IEXResponse<IEnumerable<InsiderSummaryResponse>>> InsiderSummaryAsync(string symbol) =>
await executor.SymbolExecuteAsync<IEnumerable<InsiderSummaryResponse>>("stock/[symbol]/insider-summary",
symbol);

public async Task<IEnumerable<InsiderTransactionResponse>> InsiderTransactionAsync(string symbol) =>
await executor.SymbolExecuteAsyncLegacy<IEnumerable<InsiderTransactionResponse>>(
public async Task<IEXResponse<IEnumerable<InsiderTransactionResponse>>> InsiderTransactionAsync(string symbol) =>
await executor.SymbolExecuteAsync<IEnumerable<InsiderTransactionResponse>>(
"stock/[symbol]/insider-transactions", symbol);

public async Task<IEnumerable<InstitutionalOwnershipResponse>> InstitutionalOwnerShipAsync(string symbol) =>
await executor.SymbolExecuteAsyncLegacy<IEnumerable<InstitutionalOwnershipResponse>>(
public async Task<IEXResponse<IEnumerable<InstitutionalOwnershipResponse>>> InstitutionalOwnerShipAsync(string symbol) =>
await executor.SymbolExecuteAsync<IEnumerable<InstitutionalOwnershipResponse>>(
"stock/[symbol]/institutional-ownership", symbol);

public async Task<IEnumerable<IntradayPriceResponse>> IntradayPriceAsync(string symbol) =>
await executor.SymbolExecuteAsyncLegacy<IEnumerable<IntradayPriceResponse>>("stock/[symbol]/intraday-prices", symbol);
public async Task<IEXResponse<IEnumerable<IntradayPriceResponse>>> IntradayPriceAsync(string symbol) =>
await executor.SymbolExecuteAsync<IEnumerable<IntradayPriceResponse>>("stock/[symbol]/intraday-prices", symbol);

public async Task<IEXResponse<IPOCalendar>> IPOCalendarAsync(IPOType ipoType)
{
Expand Down
63 changes: 40 additions & 23 deletions IEXSharpTest/Cloud(V2)/StockTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public async Task BatchBySymbolAsyncTest(string symbol, IEnumerable<BatchType> t
{
var response = await sandBoxClient.Stock.BatchBySymbolAsync(symbol, types, range, last);

Assert.NotNull(response);
Assert.IsNull(response.ErrorMessage);
Assert.IsNotNull(response.Data);
}

[Test]
Expand All @@ -75,8 +76,9 @@ public async Task BookAsyncTest(string symbol)
{
var response = await sandBoxClient.Stock.BookAsync(symbol);

Assert.IsNotNull(response);
Assert.IsNotNull(response.quote);
Assert.IsNull(response.ErrorMessage);
Assert.IsNotNull(response.Data);
Assert.IsNotNull(response.Data.quote);
}

[Test]
Expand All @@ -86,7 +88,8 @@ public async Task CashFlowAsyncTest(string symbol, Period period = Period.Quarte
{
var response = await sandBoxClient.Stock.CashFlowAsync(symbol, period, last);

Assert.IsNotNull(response);
Assert.IsNull(response.ErrorMessage);
Assert.IsNotNull(response.Data);
}

[Test]
Expand All @@ -96,7 +99,8 @@ public async Task CashFlowFieldAsyncTest(string symbol, string field, Period per
{
var response = await sandBoxClient.Stock.CashFlowFieldAsync(symbol, field, period, last);

Assert.IsNotNull(response);
Assert.IsNull(response.ErrorMessage);
Assert.IsNotNull(response.Data);
}

[Test]
Expand All @@ -119,7 +123,8 @@ public async Task CompanyAsyncTest(string symbol)
{
var response = await sandBoxClient.Stock.CompanyAsync(symbol);

Assert.IsNotNull(response);
Assert.IsNull(response.ErrorMessage);
Assert.IsNotNull(response.Data);
}

[Test]
Expand All @@ -129,7 +134,8 @@ public async Task DelayedQuoteAsyncTest(string symbol)
{
var response = await sandBoxClient.Stock.DelayedQuoteAsync(symbol);

Assert.IsNotNull(response);
Assert.IsNull(response.ErrorMessage);
Assert.IsNotNull(response.Data);
}

[Test]
Expand All @@ -145,7 +151,8 @@ public async Task DividendAsyncTest(string symbol, DividendRange range)
{
var response = await sandBoxClient.Stock.DividendAsync(symbol, range);

Assert.IsNotNull(response);
Assert.IsNull(response.ErrorMessage);
Assert.IsNotNull(response.Data);
}

[Test]
Expand All @@ -155,7 +162,8 @@ public async Task EarningAsyncTest(string symbol, int last)
{
var response = await sandBoxClient.Stock.EarningAsync(symbol, last);

Assert.IsNotNull(response);
Assert.IsNull(response.ErrorMessage);
Assert.IsNotNull(response.Data);
}

[Test]
Expand Down Expand Up @@ -185,7 +193,8 @@ public async Task EffectiveSpreadAsyncTest(string symbol)
{
var response = await sandBoxClient.Stock.EffectiveSpreadAsync(symbol);

Assert.IsNotNull(response);
Assert.IsNull(response.ErrorMessage);
Assert.IsNotNull(response.Data);
}

[Test]
Expand Down Expand Up @@ -242,7 +251,8 @@ public async Task FundOwnershipAsyncTest(string symbol)
{
var response = await sandBoxClient.Stock.FundOwnershipAsync(symbol);

Assert.IsNotNull(response);
Assert.IsNull(response.ErrorMessage);
Assert.IsNotNull(response.Data);
}

[Test]
Expand Down Expand Up @@ -349,7 +359,8 @@ public async Task InComeStatementFieldAsyncTest(string symbol, string field, Per
{
var response = await sandBoxClient.Stock.IncomeStatementFieldAsync(symbol, field, period, last);

Assert.IsNotNull(response);
Assert.IsNull(response.ErrorMessage);
Assert.IsNotNull(response.Data);
}

// Not supported for free account
Expand All @@ -360,8 +371,9 @@ public async Task InsiderRosterAsyncTest(string symbol)
{
var response = await sandBoxClient.Stock.InsiderRosterAsync(symbol);

Assert.IsNotNull(response);
Assert.GreaterOrEqual(response.Count(), 0);
Assert.IsNull(response.ErrorMessage);
Assert.IsNotNull(response.Data);
Assert.GreaterOrEqual(response.Data.Count(), 1);
}

// Not supported for free account
Expand All @@ -372,8 +384,9 @@ public async Task InsiderSummaryAsyncTest(string symbol)
{
var response = await sandBoxClient.Stock.InsiderSummaryAsync(symbol);

Assert.IsNotNull(response);
Assert.GreaterOrEqual(response.Count(), 0);
Assert.IsNull(response.ErrorMessage);
Assert.IsNotNull(response.Data);
Assert.GreaterOrEqual(response.Data.Count(), 1);
}

// Not supported for free account
Expand All @@ -384,8 +397,9 @@ public async Task InsiderTransactionAsyncTest(string symbol)
{
var response = await sandBoxClient.Stock.InsiderTransactionAsync(symbol);

Assert.IsNotNull(response);
Assert.GreaterOrEqual(response.Count(), 0);
Assert.IsNull(response.ErrorMessage);
Assert.IsNotNull(response.Data);
Assert.GreaterOrEqual(response.Data.Count(), 1);
}

// Not supported for free account
Expand All @@ -396,8 +410,9 @@ public async Task InstitutionalOwnerShipAsyncTest(string symbol)
{
var response = await sandBoxClient.Stock.InstitutionalOwnerShipAsync(symbol);

Assert.IsNotNull(response);
Assert.GreaterOrEqual(response.Count(), 0);
Assert.IsNull(response.ErrorMessage);
Assert.IsNotNull(response.Data);
Assert.GreaterOrEqual(response.Data.Count(), 1);
}

[Test]
Expand All @@ -407,8 +422,9 @@ public async Task IntradayPriceAsyncTest(string symbol)
{
var response = await sandBoxClient.Stock.IntradayPriceAsync(symbol);

Assert.IsNotNull(response);
Assert.GreaterOrEqual(response.Count(), 0);
Assert.IsNull(response.ErrorMessage);
Assert.IsNotNull(response.Data);
Assert.GreaterOrEqual(response.Data.Count(), 1);
}

[Test]
Expand All @@ -418,7 +434,8 @@ public async Task IPOCalendarAsyncTest(IPOType ipoType)
{
var response = await sandBoxClient.Stock.IPOCalendarAsync(ipoType);

Assert.IsNotNull(response);
Assert.IsNull(response.ErrorMessage);
Assert.IsNotNull(response.Data);
}

[Test]
Expand Down

0 comments on commit 51b943c

Please sign in to comment.