Skip to content

Commit

Permalink
Renamed SSE endpoints for consistency
Browse files Browse the repository at this point in the history
- renamed earlier SSE endpoints to XStream, where X is the endpoint name
- this is consistent w/ recent work by Jamie Prentice
- now, the endpoint names line up alphabetically next to their non-streaming variants
- updated REAMDE.md and tests
  • Loading branch information
vslee committed Jun 3, 2020
1 parent 14617ff commit 8525264
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 25 deletions.
6 changes: 3 additions & 3 deletions IEXSharp/Service/Cloud/CoreData/Crypto/CryptoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ public CryptoService(ExecutorREST executor, ExecutorSSE executorSSE)
public async Task<IEXResponse<CryptoBookResponse>> BookAsync(string symbol) =>
await executor.SymbolExecuteAsync<CryptoBookResponse>("crypto/[symbol]/book", symbol);

public SSEClient<CryptoBookResponse> SubscribeCryptoBook(IEnumerable<string> symbols) =>
public SSEClient<CryptoBookResponse> BookStream(IEnumerable<string> symbols) =>
executorSSE.SymbolsSubscribeSSE<CryptoBookResponse>("cryptoBook", symbols);

public SSEClient<EventCrypto> SubscribeCryptoEvents(IEnumerable<string> symbols) =>
public SSEClient<EventCrypto> EventStream(IEnumerable<string> symbols) =>
executorSSE.SymbolsSubscribeSSE<EventCrypto>("cryptoEvents", symbols);

public async Task<IEXResponse<CryptoPriceResponse>> PriceAsync(string symbol) =>
Expand All @@ -32,7 +32,7 @@ public async Task<IEXResponse<CryptoPriceResponse>> PriceAsync(string symbol) =>
public async Task<IEXResponse<QuoteCryptoResponse>> QuoteAsync(string symbol) =>
await executor.SymbolExecuteAsync<QuoteCryptoResponse>("crypto/[symbol]/quote", symbol);

public SSEClient<QuoteCryptoResponse> SubscribeCryptoQuotes(IEnumerable<string> symbols) =>
public SSEClient<QuoteCryptoResponse> QuoteStream(IEnumerable<string> symbols) =>
executorSSE.SymbolsSubscribeSSE<QuoteCryptoResponse>("cryptoQuotes", symbols);
}
}
6 changes: 3 additions & 3 deletions IEXSharp/Service/Cloud/CoreData/Crypto/ICryptoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ public interface ICryptoService
/// </summary>
/// <param name="symbols"></param>
/// <returns></returns>
SSEClient<CryptoBookResponse> SubscribeCryptoBook(IEnumerable<string> symbols);
SSEClient<CryptoBookResponse> BookStream(IEnumerable<string> symbols);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#cryptocurrency-events"/>
/// Only accessible with SSE Streaming.
/// </summary>
/// <param name="symbols"></param>
/// <returns></returns>
SSEClient<EventCrypto> SubscribeCryptoEvents(IEnumerable<string> symbols);
SSEClient<EventCrypto> EventStream(IEnumerable<string> symbols);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#cryptocurrency-price"/>
Expand All @@ -48,6 +48,6 @@ public interface ICryptoService
/// </summary>
/// <param name="symbols"></param>
/// <returns></returns>
SSEClient<QuoteCryptoResponse> SubscribeCryptoQuotes(IEnumerable<string> symbols);
SSEClient<QuoteCryptoResponse> QuoteStream(IEnumerable<string> symbols);
}
}
2 changes: 1 addition & 1 deletion IEXSharp/Service/Cloud/CoreData/News/INewsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface INewsService
/// </summary>
/// <param name="symbols">One or more stock symbols.</param>
/// <returns></returns>
SSEClient<NewsResponse> SubscribeToNews(IEnumerable<string> symbols);
SSEClient<NewsResponse> NewsStream(IEnumerable<string> symbols);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#historical-news"/>
Expand Down
2 changes: 1 addition & 1 deletion IEXSharp/Service/Cloud/CoreData/News/NewsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public async Task<IEXResponse<IEnumerable<NewsResponse>>> NewsAsync(string symbo
public async Task<IEXResponse<IEnumerable<NewsResponse>>> NewsAsync(string symbol, int last) =>
await executor.SymbolLastExecuteAsync<IEnumerable<NewsResponse>>("stock/[symbol]/news/last/[last]", symbol, last);

public SSEClient<NewsResponse> SubscribeToNews(IEnumerable<string> symbols) =>
public SSEClient<NewsResponse> NewsStream(IEnumerable<string> symbols) =>
executorSSE.SymbolsSubscribeSSE<NewsResponse>("news-stream", symbols);

public async Task<IEXResponse<IEnumerable<NewsResponse>>> HistoricalNewsAsync(TimeSeriesRange? range = null, int? limit = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public interface ISocialSentimentService
/// </summary>
/// <param name="symbols">One or more stock symbols.</param>
/// <returns></returns>
SSEClient<SentimentResponse> SubscribeToSentiment(IEnumerable<string> symbols);
SSEClient<SentimentResponse> SentimentStream(IEnumerable<string> symbols);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#social-sentiment"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal SocialSentimentService(ExecutorREST executor, ExecutorSSE executorSSE)
this.executorSSE = executorSSE;
}

public SSEClient<SentimentResponse> SubscribeToSentiment(IEnumerable<string> symbols) =>
public SSEClient<SentimentResponse> SentimentStream(IEnumerable<string> symbols) =>
executorSSE.SymbolsSubscribeSSE<SentimentResponse>("sentiment", symbols);

public async Task<IEXResponse<IEnumerable<SentimentMinuteResponse>>> SentimentByMinuteAsync(string symbol) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,13 @@ public interface IStockPricesService

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#quote"/>
/// US Stock Quote SSE Stream
/// </summary>
/// <param name="symbols"></param>
/// <param name="UTP"></param>
/// <param name="interval"></param>
/// <returns></returns>
SSEClient<QuoteSSE> SubscribeStockQuotesUS(IEnumerable<string> symbols, bool UTP, StockQuoteSSEInterval interval);
SSEClient<QuoteSSE> QuoteStream(IEnumerable<string> symbols, bool UTP, StockQuoteSSEInterval interval);

/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#volume-by-venue"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public async Task<IEXResponse<string>> QuoteFieldAsync(string symbol, string fie
return await executor.ExecuteAsync<string>(urlPattern, pathNvc, qsb);
}

public SSEClient<QuoteSSE> SubscribeStockQuotesUS(
public SSEClient<QuoteSSE> QuoteStream(
IEnumerable<string> symbols, bool UTP, StockQuoteSSEInterval interval) =>
executorSSE.SymbolsSubscribeSSE<QuoteSSE>(
UTP ? $"stocksUS{interval.GetDescriptionFromEnum()}" : $"stocksUSNoUTP{interval.GetDescriptionFromEnum()}", symbols);
Expand Down
12 changes: 6 additions & 6 deletions IEXSharpTest/Cloud/CoreData/CryptoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public async Task BookAsyncTest(string symbol)
[Test]
[TestCase(new object[] { "BTCUSD" })]
[TestCase(new object[] { "BTCUSD", "ETHUSD" })]
public async Task SubscribeCryptoBookTest(object[] symbols)
public async Task BookStreamTest(object[] symbols)
{
using var sseClient = sandBoxClient.Crypto.SubscribeCryptoBook(symbols.Cast<string>());
using var sseClient = sandBoxClient.Crypto.BookStream(symbols.Cast<string>());
sseClient.Error += (s, e) =>
{
sseClient.Close();
Expand All @@ -56,9 +56,9 @@ public async Task SubscribeCryptoBookTest(object[] symbols)
[Test]
[TestCase(new object[] { "btcusdt" })]
[TestCase(new object[] { "btcusdt", "ethusdt" })]
public async Task CryptoEventSSETest(object[] symbols)
public async Task EventStreamTest(object[] symbols)
{
using var sseClient = sandBoxClient.Crypto.SubscribeCryptoEvents(symbols.Cast<string>());
using var sseClient = sandBoxClient.Crypto.EventStream(symbols.Cast<string>());
sseClient.Error += (s, e) =>
{
sseClient.Close();
Expand Down Expand Up @@ -103,9 +103,9 @@ public async Task QuoteAsyncTest(string symbol)
[Test]
[TestCase(new object[] { "btcusdt" })]
[TestCase(new object[] { "btcusdt", "ethusdt" })]
public async Task CryptoQuoteSSETest(object[] symbols)
public async Task QuoteStreamTest(object[] symbols)
{
using var sseClient = sandBoxClient.Crypto.SubscribeCryptoQuotes(
using var sseClient = sandBoxClient.Crypto.QuoteStream(
symbols.Cast<string>());
sseClient.Error += (s, e) =>
{
Expand Down
4 changes: 2 additions & 2 deletions IEXSharpTest/Cloud/CoreData/NewsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public async Task NewsAsyncTest(string symbol, int last)
[Test]
[TestCase(new object[] { "AAPL" })]
[TestCase(new object[] { "AAPL", "FB" })]
public async Task StreamingNewsTest(object[] symbols)
public async Task NewsStreamTest(object[] symbols)
{
using var sseClient = sandBoxClient.News.SubscribeToNews(symbols.Cast<string>());
using var sseClient = sandBoxClient.News.NewsStream(symbols.Cast<string>());
sseClient.Error += (s, e) =>
{
sseClient.Close();
Expand Down
4 changes: 2 additions & 2 deletions IEXSharpTest/Cloud/CoreData/SocialSentimentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public void Setup()
[Test]
[TestCase(new object[] { "AAPL" })]
[TestCase(new object[] { "AAPL", "FB" })]
public async Task StreamingSentimentTest(object[] symbols)
public async Task SentimentStreamTest(object[] symbols)
{
using var sseClient = sandBoxClient.SocialSentiment.SubscribeToSentiment(symbols.Cast<string>());
using var sseClient = sandBoxClient.SocialSentiment.SentimentStream(symbols.Cast<string>());
sseClient.Error += (s, e) =>
{
sseClient.Close();
Expand Down
2 changes: 1 addition & 1 deletion IEXSharpTest/Cloud/CoreData/StockPricesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public async Task QuoteFieldAsyncTest(string symbol, string field)
[TestCase(new object[] { "spy", "aapl" }, false, StockQuoteSSEInterval.OneSecond)]
public async Task StockQuoteUSSSETest(object[] symbols, bool UTP, StockQuoteSSEInterval interval)
{
using var sseClient = sandBoxClient.StockPrices.SubscribeStockQuotesUS(
using var sseClient = sandBoxClient.StockPrices.QuoteStream(
symbols.Cast<string>(), UTP: UTP, interval: interval);
sseClient.Error += (s, e) =>
{
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ using (var iexCloudClient =
}

```
To use SSE streaming (only included with paid IEX subscription plans). Extended [example in wiki](https://github.com/vslee/IEXSharp/wiki/SSE-Streaming-Example).
To use SSE streaming (only included with paid IEX subscription plans). Extended [example in the wiki](https://github.com/vslee/IEXSharp/wiki/SSE-Streaming-Example).
```c#
using (var sseClient = iexCloudClient.StockPrices.SubscribeStockQuotesUS(symbols: new string[] { "spy", "aapl" },
using (var sseClient = iexCloudClient.StockPrices.QuoteStream(symbols: new string[] { "spy", "aapl" },
UTP: false, interval: StockQuoteSSEInterval.OneSecond))
{
sseClient.Error += (s, e) =>
Expand Down

1 comment on commit 8525264

@JamiePrentice
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, I was meaning to do this next!

Please sign in to comment.