Skip to content

Commit

Permalink
Issue #731 - The OptionsContractRequest.UnderlyingSymbol mandatory …
Browse files Browse the repository at this point in the history
…property was replaced with the `OptionsContractRequest.UnderlyingSymbols` optional property.

(cherry picked from commit a8c5713)
  • Loading branch information
OlegRa committed Apr 14, 2024
1 parent b8935b8 commit 89ce624
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
29 changes: 23 additions & 6 deletions Alpaca.Markets/Parameters/OptionContractsRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,36 @@
/// </summary>
public sealed class OptionContractsRequest : Validation.IRequest
{
private readonly HashSet<String> _underlyingSymbols = new(StringComparer.Ordinal);

/// <summary>
/// Creates new instance of <see cref="OptionContractsRequest"/> object.
/// </summary>
public OptionContractsRequest()
{
}

/// <summary>
/// Creates new instance of <see cref="OptionContractsRequest"/> object.
/// </summary>
/// <param name="underlyingSymbol">The symbol of the underlying asset for filtering.</param>
public OptionContractsRequest(
String underlyingSymbol) =>
UnderlyingSymbol = underlyingSymbol.EnsureNotNull();

_underlyingSymbols.Add(underlyingSymbol.EnsureNotNull());

/// <summary>
/// Creates new instance of <see cref="OptionContractsRequest"/> object.
/// </summary>
/// <param name="underlyingSymbols">The symbols list of the underlying asset for filtering.</param>
public OptionContractsRequest(
IEnumerable<String> underlyingSymbols) =>
_underlyingSymbols.UnionWith(underlyingSymbols.EnsureNotNull());

/// <summary>
/// Gets the symbol of the underlying asset for filtering.
/// Gets the symbols list of the underlying asset for filtering.
/// </summary>
[UsedImplicitly]
public String UnderlyingSymbol { get; }
public IReadOnlyCollection<String> UnderlyingSymbols => _underlyingSymbols;

/// <summary>
/// Gets or sets filter by the asset status. By default, only active contracts are returned.
Expand Down Expand Up @@ -85,7 +102,7 @@ internal async ValueTask<UriBuilder> GetUriBuilderAsync(
{
Path = "v2/options/contracts",
Query = await Pagination.QueryBuilder
.AddParameter("underlying_symbol", UnderlyingSymbol)
.AddParameter("underlying_symbols", UnderlyingSymbols)
.AddParameter("status", AssetStatus)
.AddParameter("expiration_date", ExpirationDateEqualTo)
.AddParameter("expiration_date_gte", ExpirationDateGreaterThanOrEqualTo)
Expand All @@ -102,7 +119,7 @@ internal async ValueTask<UriBuilder> GetUriBuilderAsync(
IEnumerable<RequestValidationException?> Validation.IRequest.GetExceptions()
{
yield return Pagination.TryValidatePageSize(Pagination.MaxPageSize);
yield return UnderlyingSymbol.TryValidateSymbolName();
yield return UnderlyingSymbols.TryValidateSymbolName();
yield return RootSymbol?.TryValidateSymbolName();

if (ExpirationDateEqualTo.HasValue && (
Expand Down
1 change: 0 additions & 1 deletion Alpaca.Markets/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,6 @@ Alpaca.Markets.OptionContractsRequest.StrikePriceGreaterThanOrEqualTo.get -> dec
Alpaca.Markets.OptionContractsRequest.StrikePriceGreaterThanOrEqualTo.set -> void
Alpaca.Markets.OptionContractsRequest.StrikePriceLessThanOrEqualTo.get -> decimal?
Alpaca.Markets.OptionContractsRequest.StrikePriceLessThanOrEqualTo.set -> void
Alpaca.Markets.OptionContractsRequest.UnderlyingSymbol.get -> string!
Alpaca.Markets.OptionsTradingLevel
Alpaca.Markets.OptionsTradingLevel.CoveredCallCashSecuredPut = 1 -> Alpaca.Markets.OptionsTradingLevel
Alpaca.Markets.OptionsTradingLevel.Disabled = 0 -> Alpaca.Markets.OptionsTradingLevel
Expand Down
3 changes: 3 additions & 0 deletions Alpaca.Markets/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
#nullable enable
Alpaca.Markets.OptionContractsRequest.OptionContractsRequest() -> void
Alpaca.Markets.OptionContractsRequest.OptionContractsRequest(System.Collections.Generic.IEnumerable<string!>! underlyingSymbols) -> void
Alpaca.Markets.OptionContractsRequest.UnderlyingSymbols.get -> System.Collections.Generic.IReadOnlyCollection<string!>!

0 comments on commit 89ce624

Please sign in to comment.