Skip to content

Commit

Permalink
separate StockResearchService out of StockService
Browse files Browse the repository at this point in the history
- part of overall effort to clean up StockService V2 (cloud)
- V1 (legacy) has not been separated as it is deprecated anyways
  • Loading branch information
vslee committed May 1, 2020
1 parent bfbebd5 commit 1ee1fb1
Show file tree
Hide file tree
Showing 21 changed files with 297 additions and 234 deletions.
5 changes: 5 additions & 0 deletions IEXSharp/IEXCloudClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using IEXSharp.Service.V2.StockFundamentals;
using IEXSharp.Service.V2.StockPrices;
using IEXSharp.Service.V2.StockProfiles;
using IEXSharp.Service.V2.StockResearch;
using System;
using System.Net.Http;
using VSLee.IEXSharp.Service.V2.Account;
Expand Down Expand Up @@ -33,6 +34,7 @@ public class IEXCloudClient : IDisposable
private IStockPricesService stockPricesService;
private IStockProfilesService stockProfilesService;
private IStockFundamentalsService stockFundamentalsService;
private IStockResearchService stockResearchService;
private IStockService stockService;
private ISSEService sseService;
private IAlternativeDataService alternativeDataService;
Expand All @@ -55,6 +57,9 @@ public class IEXCloudClient : IDisposable
public IStockFundamentalsService StockFundamentals => stockFundamentalsService ?? (stockFundamentalsService =
new StockFundamentalsService(client, secretToken, publishableToken, signRequest));

public IStockResearchService StockResearch => stockResearchService ?? (stockResearchService =
new StockResearchService(client, secretToken, publishableToken, signRequest));

public IStockService Stock => stockService ?? (stockService =
new StockService(client, secretToken, publishableToken, signRequest));

Expand Down
1 change: 1 addition & 0 deletions IEXSharp/IEXSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<Folder Include="Model\InvestorsExchangeData\Request\" />
<Folder Include="Model\Shared\Request\" />
<Folder Include="Model\StockProfiles\Request\" />
<Folder Include="Model\StockResearch\Request\" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions IEXSharp/Model/Stock/Response/BatchBySymbolResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using VSLee.IEXSharp.Model.StockFundamentals.Response;
using VSLee.IEXSharp.Model.StockPrices.Response;
using VSLee.IEXSharp.Model.StockProfiles.Response;
using VSLee.IEXSharp.Model.StockResearch.Response;

namespace VSLee.IEXSharp.Model.Stock.Response
{
Expand Down
10 changes: 0 additions & 10 deletions IEXSharp/Model/Stock/Response/EstimateResponse.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System;

namespace VSLee.IEXSharp.Model.Stock.Response
namespace VSLee.IEXSharp.Model.StockResearch.Response
{
public class AdvancedStatsResponse : KeyStatsResponse
{
Expand Down
11 changes: 11 additions & 0 deletions IEXSharp/Model/StockResearch/Response/EstimateResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Collections.Generic;
using VSLee.IEXSharp.Model.Stock.Response;

namespace VSLee.IEXSharp.Model.StockResearch.Response
{
public class EstimateResponse
{
public string symbol { get; set; }
public List<Estimate> estimates { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace VSLee.IEXSharp.Model.Stock.Response
namespace VSLee.IEXSharp.Model.StockResearch.Response
{
public class FundOwnershipResponse
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace VSLee.IEXSharp.Model.Stock.Response
namespace VSLee.IEXSharp.Model.StockResearch.Response
{
public class InstitutionalOwnershipResponse
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System;

namespace VSLee.IEXSharp.Model.Stock.Response
namespace VSLee.IEXSharp.Model.StockResearch.Response
{
public class KeyStatsResponse
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace VSLee.IEXSharp.Model.Stock.Response
namespace VSLee.IEXSharp.Model.StockResearch.Response
{
public class PriceTargetResponse
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Collections.Generic;

namespace VSLee.IEXSharp.Model.Stock.Response
namespace VSLee.IEXSharp.Model.StockResearch.Response
{
public class TechnicalIndicatorsResponse
{
Expand Down
1 change: 1 addition & 0 deletions IEXSharp/Service/V1/Stock/IStockService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using VSLee.IEXSharp.Model.StockProfiles.Response;
using VSLee.IEXSharp.Model.StockFundamentals.Response;
using VSLee.IEXSharp.Model.StockFundamentals.Request;
using VSLee.IEXSharp.Model.StockResearch.Response;

namespace VSLee.IEXSharp.Service.V1.Stock
{
Expand Down
1 change: 1 addition & 0 deletions IEXSharp/Service/V1/Stock/StockService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using VSLee.IEXSharp.Model.StockProfiles.Response;
using VSLee.IEXSharp.Model.StockFundamentals.Response;
using VSLee.IEXSharp.Model.StockFundamentals.Request;
using VSLee.IEXSharp.Model.StockResearch.Response;

namespace VSLee.IEXSharp.Service.V1.Stock
{
Expand Down
68 changes: 0 additions & 68 deletions IEXSharp/Service/V2/Stock/IStockService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,59 +46,13 @@ public interface IStockService
/// <returns></returns>
Task<IEXResponse<IEnumerable<EffectiveSpreadResponse>>> EffectiveSpreadAsync(string symbol);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#estimates"/>
/// </summary>
/// <param name="symbol"></param>
/// <param name="last"></param>
/// <returns></returns>
Task<IEXResponse<EstimateResponse>> EstimateAsync(string symbol, int last = 1);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#estimates"/>
/// </summary>
/// <param name="symbol"></param>
/// <param name="field"></param>
/// <param name="last"></param>
/// <returns></returns>
Task<IEXResponse<string>> EstimateFieldAsync(string symbol, string field, int last = 1);

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

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

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#intraday-prices"/>
/// </summary>
/// <param name="ipoType"></param>
/// <returns></returns>
Task<IEXResponse<IPOCalendar>> IPOCalendarAsync(IPOType ipoType);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#key-stats"/>
/// </summary>
/// <param name="symbol"></param>
/// <returns></returns>
Task<IEXResponse<KeyStatsResponse>> KeyStatsAsync(string symbol);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#key-stats"/>
/// </summary>
/// <param name="symbol"></param>
/// <param name="stat"></param>
/// <returns></returns>
Task<IEXResponse<string>> KeyStatsStatAsync(string symbol, string stat);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#list"/>
/// </summary>
Expand All @@ -120,28 +74,6 @@ public interface IStockService
/// <returns></returns>
Task<IEXResponse<IEnumerable<NewsResponse>>> NewsAsync(string symbol, int last = 10);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#price-target"/>
/// </summary>
/// <param name="symbol"></param>
/// <returns></returns>
Task<IEXResponse<PriceTargetResponse>> PriceTargetAsync(string symbol);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#technical-indicators"/>
/// </summary>
/// <param name="symbol"></param>
/// <param name="indicator"></param>
/// <returns></returns>
Task<IEXResponse<TechnicalIndicatorsResponse>> TechnicalIndicatorsAsync(string symbol, string indicator);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#advanced-stats"/>
/// </summary>
/// <param name="symbol"></param>
/// <returns></returns>
Task<IEXResponse<AdvancedStatsResponse>> AdvancedStatsAsync(string symbol);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#recommendation-trends"/>
/// </summary>
Expand Down
36 changes: 0 additions & 36 deletions IEXSharp/Service/V2/Stock/StockService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,6 @@ public async Task<IEXResponse<IEnumerable<EffectiveSpreadResponse>>> EffectiveSp
await executor.SymbolExecuteAsync<IEnumerable<EffectiveSpreadResponse>>(
"stock/[symbol]/effective-spread", symbol);

public async Task<IEXResponse<EstimateResponse>> EstimateAsync(string symbol, int last = 1) =>
await executor.SymbolLastExecuteAsync<EstimateResponse>("stock/[symbol]/estimates/[last]", symbol, last);

public async Task<IEXResponse<string>> EstimateFieldAsync(string symbol, string field, int last = 1) =>
await executor.SymbolLastFieldExecuteAsync("stock/[symbol]/estimates/[last]/[field]", symbol, field, last);

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

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

public async Task<IEXResponse<IPOCalendar>> IPOCalendarAsync(IPOType ipoType)
{
const string urlPattern = "stock/market/[ipoType]";
Expand All @@ -160,20 +147,6 @@ public async Task<IEXResponse<IPOCalendar>> IPOCalendarAsync(IPOType ipoType)
return await executor.ExecuteAsync<IPOCalendar>(urlPattern, pathNvc, qsb);
}

public async Task<IEXResponse<KeyStatsResponse>> KeyStatsAsync(string symbol) =>
await executor.SymbolExecuteAsync<KeyStatsResponse>("stock/[symbol]/stats", symbol);

public async Task<IEXResponse<string>> KeyStatsStatAsync(string symbol, string stat)
{
const string urlPattern = "stock/[symbol]/stats/[stat]";

var qsb = new QueryStringBuilder();

var pathNvc = new NameValueCollection { { "symbol", symbol }, { "stat", stat } };

return await executor.ExecuteAsync<string>(urlPattern, pathNvc, qsb);
}

public async Task<IEXResponse<IEnumerable<Quote>>> ListAsync(string listType)
{
const string urlPattern = "stock/market/list/[list-type]";
Expand All @@ -191,15 +164,6 @@ public async Task<IEXResponse<IEnumerable<MarketVolumeUSResponse>>> MarketVolume
public async Task<IEXResponse<IEnumerable<NewsResponse>>> NewsAsync(string symbol, int last = 10) =>
await executor.SymbolLastExecuteAsync<IEnumerable<NewsResponse>>("stock/[symbol]/news/last/[last]", symbol, last);

public async Task<IEXResponse<PriceTargetResponse>> PriceTargetAsync(string symbol) =>
await executor.SymbolExecuteAsync<PriceTargetResponse>("stock/[symbol]/price-target", symbol);

public async Task<IEXResponse<TechnicalIndicatorsResponse>> TechnicalIndicatorsAsync(string symbol, string indicator) =>
await executor.SymbolExecuteAsync<TechnicalIndicatorsResponse>($"stock/[symbol]/indicator/{indicator}", symbol);

public async Task<IEXResponse<AdvancedStatsResponse>> AdvancedStatsAsync(string symbol) =>
await executor.SymbolExecuteAsync<AdvancedStatsResponse>("stock/[symbol]/advanced-stats", symbol);

public async Task<IEXResponse<IEnumerable<RecommendationTrendResponse>>> RecommendationTrendAsync(string symbol) =>
await executor.SymbolExecuteAsync<IEnumerable<RecommendationTrendResponse>>(
"stock/[symbol]/recommendation-trends", symbol);
Expand Down
80 changes: 80 additions & 0 deletions IEXSharp/Service/V2/StockResearch/IStockResearchService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using IEXSharp.Model;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using VSLee.IEXSharp.Model.StockResearch.Response;

namespace IEXSharp.Service.V2.StockResearch
{
public interface IStockResearchService
{
/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#advanced-stats"/>
/// </summary>
/// <param name="symbol"></param>
/// <returns></returns>
Task<IEXResponse<AdvancedStatsResponse>> AdvancedStatsAsync(string symbol);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#estimates"/>
/// </summary>
/// <param name="symbol"></param>
/// <param name="last"></param>
/// <returns></returns>
Task<IEXResponse<EstimateResponse>> EstimateAsync(string symbol, int last = 1);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#estimates"/>
/// </summary>
/// <param name="symbol"></param>
/// <param name="field"></param>
/// <param name="last"></param>
/// <returns></returns>
Task<IEXResponse<string>> EstimateFieldAsync(string symbol, string field, int last = 1);

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

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

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#key-stats"/>
/// </summary>
/// <param name="symbol"></param>
/// <returns></returns>
Task<IEXResponse<KeyStatsResponse>> KeyStatsAsync(string symbol);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#key-stats"/>
/// </summary>
/// <param name="symbol"></param>
/// <param name="stat"></param>
/// <returns></returns>
Task<IEXResponse<string>> KeyStatsStatAsync(string symbol, string stat);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#price-target"/>
/// </summary>
/// <param name="symbol"></param>
/// <returns></returns>
Task<IEXResponse<PriceTargetResponse>> PriceTargetAsync(string symbol);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#technical-indicators"/>
/// </summary>
/// <param name="symbol"></param>
/// <param name="indicator"></param>
/// <returns></returns>
Task<IEXResponse<TechnicalIndicatorsResponse>> TechnicalIndicatorsAsync(string symbol, string indicator);
}
}
Loading

0 comments on commit 1ee1fb1

Please sign in to comment.