-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #731 - The
OptionFeed
enum added and now it can be specified …
…for latest/snapshot requests. (cherry picked from commit bdce3fd)
- Loading branch information
Showing
12 changed files
with
190 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace Alpaca.Markets; | ||
|
||
/// <summary> | ||
/// Supported options feed for Alpaca REST API. | ||
/// </summary> | ||
[JsonConverter(typeof(StringEnumConverter))] | ||
public enum OptionsFeed | ||
{ | ||
/// <summary> | ||
/// Options Price Reporting Authority. | ||
/// </summary> | ||
[UsedImplicitly] | ||
[EnumMember(Value = "opra")] | ||
Opra, | ||
|
||
/// <summary> | ||
/// Indicative options data. | ||
/// </summary> | ||
[UsedImplicitly] | ||
[EnumMember(Value = "indicative")] | ||
Indicative | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
namespace Alpaca.Markets; | ||
|
||
/// <summary> | ||
/// Encapsulates data for latest options data requests on Alpaca Data API v2. | ||
/// </summary> | ||
public sealed class LatestOptionsDataRequest : Validation.IRequest | ||
{ | ||
private readonly HashSet<String> _symbols = new(StringComparer.Ordinal); | ||
|
||
/// <summary> | ||
/// Creates new instance of <see cref="LatestOptionsDataRequest"/> object. | ||
/// </summary> | ||
/// <param name="symbols">Options symbols list for data retrieval.</param> | ||
/// <exception cref="ArgumentNullException"> | ||
/// The <paramref name="symbols"/> argument is <c>null</c>. | ||
/// </exception> | ||
public LatestOptionsDataRequest( | ||
IEnumerable<String> symbols) => | ||
_symbols.UnionWith(symbols.EnsureNotNull()); | ||
|
||
/// <summary> | ||
/// Gets options symbols list for data retrieval. | ||
/// </summary> | ||
[UsedImplicitly] | ||
public IReadOnlyCollection<String> Symbols => _symbols; | ||
|
||
/// <summary> | ||
/// Gets options feed for data retrieval. | ||
/// </summary> | ||
[UsedImplicitly] | ||
[ExcludeFromCodeCoverage] | ||
public OptionsFeed? OptionsFeed { get; set; } | ||
|
||
internal async ValueTask<UriBuilder> GetUriBuilderAsync( | ||
HttpClient httpClient, | ||
String lastPathSegment) => | ||
new UriBuilder(httpClient.BaseAddress!) | ||
{ | ||
Query = await new QueryBuilder() | ||
.AddParameter("symbols", Symbols.ToList()) | ||
.AddParameter("feed", OptionsFeed) | ||
.AsStringAsync().ConfigureAwait(false) | ||
}.AppendPath(lastPathSegment); | ||
|
||
IEnumerable<RequestValidationException?> Validation.IRequest.GetExceptions() | ||
{ | ||
yield return Symbols.TryValidateSymbolsList(); | ||
yield return Symbols.TryValidateSymbolName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
namespace Alpaca.Markets; | ||
|
||
/// <summary> | ||
/// Encapsulates data for latest options data requests on Alpaca Data API v2. | ||
/// </summary> | ||
public sealed class OptionChainRequest : Validation.IRequest | ||
{ | ||
/// <summary> | ||
/// Creates new instance of <see cref="LatestOptionsDataRequest"/> object. | ||
/// </summary> | ||
/// <param name="underlyingSymbol">Option underlying symbol for data retrieval.</param> | ||
/// <exception cref="ArgumentNullException"> | ||
/// The <paramref name="underlyingSymbol"/> argument is <c>null</c>. | ||
/// </exception> | ||
public OptionChainRequest( | ||
String underlyingSymbol) => | ||
UnderlyingSymbol = underlyingSymbol.EnsureNotNull(); | ||
|
||
/// <summary> | ||
/// Gets options symbols list for data retrieval. | ||
/// </summary> | ||
[UsedImplicitly] | ||
|
||
public String UnderlyingSymbol { get; } | ||
|
||
/// <summary> | ||
/// Gets options feed for data retrieval. | ||
/// </summary> | ||
[UsedImplicitly] | ||
[ExcludeFromCodeCoverage] | ||
public OptionsFeed? OptionsFeed { get; set; } | ||
|
||
internal async ValueTask<UriBuilder> GetUriBuilderAsync( | ||
HttpClient httpClient) => | ||
new UriBuilder(httpClient.BaseAddress!) | ||
{ | ||
Query = await new QueryBuilder() | ||
.AddParameter("feed", OptionsFeed) | ||
.AsStringAsync().ConfigureAwait(false) | ||
}.AppendPath($"snapshots/{UnderlyingSymbol}"); | ||
|
||
IEnumerable<RequestValidationException?> Validation.IRequest.GetExceptions() | ||
{ | ||
yield return UnderlyingSymbol.TryValidateSymbolName(); | ||
} | ||
} |
Oops, something went wrong.