diff --git a/Alpaca.Markets.Extensions.Tests/Alpaca.Markets.Extensions.Tests.csproj b/Alpaca.Markets.Extensions.Tests/Alpaca.Markets.Extensions.Tests.csproj index e6b4a9555..c84b28144 100644 --- a/Alpaca.Markets.Extensions.Tests/Alpaca.Markets.Extensions.Tests.csproj +++ b/Alpaca.Markets.Extensions.Tests/Alpaca.Markets.Extensions.Tests.csproj @@ -3,6 +3,7 @@ net8.0 ..\Alpaca.Markets.snk + true true enable latest diff --git a/Alpaca.Markets.Extensions.Tests/AlpacaCryptoDataClientTest.cs b/Alpaca.Markets.Extensions.Tests/AlpacaCryptoDataClientTest.cs index 4af0a40b5..2f84b6a0b 100644 --- a/Alpaca.Markets.Extensions.Tests/AlpacaCryptoDataClientTest.cs +++ b/Alpaca.Markets.Extensions.Tests/AlpacaCryptoDataClientTest.cs @@ -25,7 +25,7 @@ public async Task GetAverageDailyTradeVolumeAsyncWithIntervalWorks() Crypto, _timeInterval.AsDateInterval()); Assert.Equal(Volume, adtv); - Assert.True(count != 0); + Assert.NotEqual(0u, count); } private static void addPaginatedResponses( diff --git a/Alpaca.Markets.Extensions/Alpaca.Markets.Extensions.csproj b/Alpaca.Markets.Extensions/Alpaca.Markets.Extensions.csproj index 8c296f474..f163b1947 100644 --- a/Alpaca.Markets.Extensions/Alpaca.Markets.Extensions.csproj +++ b/Alpaca.Markets.Extensions/Alpaca.Markets.Extensions.csproj @@ -23,7 +23,7 @@ C# SDK for Alpaca Trade API https://docs.alpaca.markets/ https://github.com/alpacahq/alpaca-trade-api-csharp - © 2018-2023 Alpaca Securities LLC. All rights reserved. + © 2018-2025 Alpaca Securities LLC. All rights reserved. false Aplaca API SDK REST WebSocket trading Extansions for .NET SDK for Alpaca Trade API @@ -49,8 +49,9 @@ true - 7.1.0 + 7.2.0 true + true true AllEnabledByDefault true diff --git a/Alpaca.Markets.Extensions/GlobalSuppressions.cs b/Alpaca.Markets.Extensions/GlobalSuppressions.cs index 8ba0c77d0..771556d51 100644 --- a/Alpaca.Markets.Extensions/GlobalSuppressions.cs +++ b/Alpaca.Markets.Extensions/GlobalSuppressions.cs @@ -1,7 +1,5 @@ // This file is used by Code Analysis to maintain SuppressMessage attributes that are applied to this project. -global using System.Diagnostics; - #if NETFRAMEWORK global using System.Net.Http; #endif diff --git a/Alpaca.Markets.Extensions/Pagination/AlpacaOptionsDataClientExtensions.cs b/Alpaca.Markets.Extensions/Pagination/AlpacaOptionsDataClientExtensions.cs index cf366a332..2d7b33355 100644 --- a/Alpaca.Markets.Extensions/Pagination/AlpacaOptionsDataClientExtensions.cs +++ b/Alpaca.Markets.Extensions/Pagination/AlpacaOptionsDataClientExtensions.cs @@ -140,7 +140,7 @@ private static OptionSnapshotRequest getRequestWithoutPageToken( OptionSnapshotRequest request) => new(request.Symbols) { - //Pagination = { Size = Pagination.MaxPageSize }, + Pagination = { Size = request.Pagination.Size }, OptionsFeed = request.OptionsFeed }; @@ -172,7 +172,7 @@ private static OptionChainRequest getRequestWithoutPageToken( StrikePriceGreaterThanOrEqualTo = request.StrikePriceGreaterThanOrEqualTo, StrikePriceLessThanOrEqualTo = request.StrikePriceLessThanOrEqualTo, ExpirationDateEqualTo = request.ExpirationDateEqualTo, - Pagination = { Size = Pagination.MaxPageSize }, + Pagination = { Size = request.Pagination.Size }, OptionType = request.OptionType, RootSymbol = request.RootSymbol }; diff --git a/Alpaca.Markets.Extensions/Pagination/AlpacaTradingClientExtensions.cs b/Alpaca.Markets.Extensions/Pagination/AlpacaTradingClientExtensions.cs index 31c43a5af..d98a70223 100644 --- a/Alpaca.Markets.Extensions/Pagination/AlpacaTradingClientExtensions.cs +++ b/Alpaca.Markets.Extensions/Pagination/AlpacaTradingClientExtensions.cs @@ -179,7 +179,7 @@ private static OptionContractsRequest getRequestForFirstPage( StrikePriceGreaterThanOrEqualTo = request.StrikePriceGreaterThanOrEqualTo, StrikePriceLessThanOrEqualTo = request.StrikePriceLessThanOrEqualTo, ExpirationDateEqualTo = request.ExpirationDateEqualTo, - Pagination = { Size = Pagination.MaxPageSize }, + Pagination = { Size = request.Pagination.Size }, AssetStatus = request.AssetStatus, OptionStyle = request.OptionStyle, OptionType = request.OptionType, diff --git a/Alpaca.Markets.Extensions/README.md b/Alpaca.Markets.Extensions/README.md index 36a6b4961..f782584c7 100644 --- a/Alpaca.Markets.Extensions/README.md +++ b/Alpaca.Markets.Extensions/README.md @@ -13,7 +13,7 @@ See full online documentation [here](https://olegra.github.io/Alpaca.Markets/api 1. Create a new console application in a new, empty folder by running `dotnet new console`. 2. Add a reference for Alpaca .NET SDK with `dotnet add package Alpaca.Markets`. -3. Replace content of the auto-generated `Programm.cs` file with this code snippet: +3. Replace content of the auto-generated `Program.cs` file with this code snippet: ```cs using System; using Alpaca.Markets; diff --git a/Alpaca.Markets.Extensions/Reconnection/ClientWithReconnectBase.cs b/Alpaca.Markets.Extensions/Reconnection/ClientWithReconnectBase.cs index 29d3e9e4e..0b567ad5c 100644 --- a/Alpaca.Markets.Extensions/Reconnection/ClientWithReconnectBase.cs +++ b/Alpaca.Markets.Extensions/Reconnection/ClientWithReconnectBase.cs @@ -96,8 +96,21 @@ protected virtual ValueTask OnReconnection( CancellationToken cancellationToken) => new(); // DO nothing by default for auto-resubscribed clients. - private async void handleSocketClosed() => - await handleSocketClosedAsync().ConfigureAwait(false); + + [SuppressMessage( + "Design", "CA1031:Do not catch general exception types", + Justification = "Expected behavior - we report exceptions via OnError event.")] + private async void handleSocketClosed() + { + try + { + await handleSocketClosedAsync().ConfigureAwait(false); + } + catch (Exception exception) + { + handleOnError(exception); + } + } [SuppressMessage( "Design", "CA1031:Do not catch general exception types", @@ -178,6 +191,7 @@ await OnReconnection(_cancellationTokenSource.Token) [SuppressMessage( "Design", "CA1031:Do not catch general exception types", Justification = "Expected behavior - we report exceptions via OnError event.")] + // ReSharper disable once AsyncVoidMethod private async void handleOnError( Exception exception) { diff --git a/Alpaca.Markets.Extensions/Subscriptions/DisposableAlpacaDataSubscription.cs b/Alpaca.Markets.Extensions/Subscriptions/DisposableAlpacaDataSubscription.cs index 3b6f39f28..60c7e7892 100644 --- a/Alpaca.Markets.Extensions/Subscriptions/DisposableAlpacaDataSubscription.cs +++ b/Alpaca.Markets.Extensions/Subscriptions/DisposableAlpacaDataSubscription.cs @@ -39,8 +39,20 @@ public event Action? Received remove => _subscription.Received -= value; } - public async void Dispose() => - await DisposeAsync().ConfigureAwait(false); + [SuppressMessage( + "Design", "CA1031:Do not catch general exception types", + Justification = "Expected behavior - we report exceptions via OnError event.")] + public async void Dispose() + { + try + { + await DisposeAsync().ConfigureAwait(false); + } + catch (Exception exception) + { + Trace.TraceInformation(exception.Message); + } + } public async ValueTask DisposeAsync() { diff --git a/Alpaca.Markets.Tests/Alpaca.Markets.Tests.csproj b/Alpaca.Markets.Tests/Alpaca.Markets.Tests.csproj index 5bf0fd727..6c9747000 100644 --- a/Alpaca.Markets.Tests/Alpaca.Markets.Tests.csproj +++ b/Alpaca.Markets.Tests/Alpaca.Markets.Tests.csproj @@ -3,6 +3,7 @@ net8.0 ..\Alpaca.Markets.snk + true true enable latest diff --git a/Alpaca.Markets.Tests/AlpacaTradingClientTest.Account.cs b/Alpaca.Markets.Tests/AlpacaTradingClientTest.Account.cs index bb80c0211..f56b5b02f 100644 --- a/Alpaca.Markets.Tests/AlpacaTradingClientTest.Account.cs +++ b/Alpaca.Markets.Tests/AlpacaTradingClientTest.Account.cs @@ -9,7 +9,9 @@ public sealed partial class AlpacaTradingClientTest private const Decimal Price = 1234.56M; [Fact] +#pragma warning disable IDE0079 // Remove unnecessary suppression [SuppressMessage("ReSharper", "StringLiteralTypo")] +#pragma warning restore IDE0079 // Remove unnecessary suppression public async Task GetAccountAsyncWorks() { const Decimal cash = 10_000M; @@ -67,11 +69,11 @@ public async Task GetAccountAsyncWorks() Assert.Equal(transfer, account.AccruedFees); Assert.Equal(cash, account.OptionsBuyingPower); - Assert.True(account.LastMaintenanceMargin != 0M); - Assert.True(account.MaintenanceMargin != 0M); - Assert.True(account.TradableCash != 0M); - Assert.True(account.LastEquity != 0M); - Assert.True(account.Sma != 0M); + Assert.NotEqual(0M, account.LastMaintenanceMargin); + Assert.NotEqual(0M, account.MaintenanceMargin); + Assert.NotEqual(0M, account.TradableCash); + Assert.NotEqual(0M, account.LastEquity); + Assert.NotEqual(0M, account.Sma); Assert.NotNull(account.AccountNumber); diff --git a/Alpaca.Markets.Tests/AlpacaTradingClientTest.Assets.cs b/Alpaca.Markets.Tests/AlpacaTradingClientTest.Assets.cs index ac3e03aa6..1c95075a2 100644 --- a/Alpaca.Markets.Tests/AlpacaTradingClientTest.Assets.cs +++ b/Alpaca.Markets.Tests/AlpacaTradingClientTest.Assets.cs @@ -67,7 +67,9 @@ private static JObject createAsset( new JProperty("name", symbol), new JProperty("id", assetId)); +#pragma warning disable IDE0079 [SuppressMessage("ReSharper", "ParameterOnlyUsedForPreconditionCheck.Local")] +#pragma warning restore IDE0079 private static void validateAsset( IAsset asset, Guid assetId, @@ -91,6 +93,6 @@ private static void validateAsset( Assert.NotNull(asset.MaintenanceMarginRequirement); Assert.Single(asset.Attributes); - Assert.Equal(AssetAttributes.PtpNoException, asset.Attributes.First()); + Assert.Equal(AssetAttributes.PtpNoException, asset.Attributes[0]); } } diff --git a/Alpaca.Markets.Tests/AlpacaTradingClientTest.Options.cs b/Alpaca.Markets.Tests/AlpacaTradingClientTest.Options.cs index dc6b032c2..5af355acb 100644 --- a/Alpaca.Markets.Tests/AlpacaTradingClientTest.Options.cs +++ b/Alpaca.Markets.Tests/AlpacaTradingClientTest.Options.cs @@ -89,7 +89,9 @@ private static JObject createOptionContract( new JProperty("name", symbol), new JProperty("size", 100)); +#pragma warning disable IDE0079 [SuppressMessage("ReSharper", "ParameterOnlyUsedForPreconditionCheck.Local")] +#pragma warning restore IDE0079 private static void validateOptionContract( IOptionContract optionContract, Guid contractId, diff --git a/Alpaca.Markets.Tests/AlpacaTradingClientTest.Positions.cs b/Alpaca.Markets.Tests/AlpacaTradingClientTest.Positions.cs index 01d005399..ec0e954e9 100644 --- a/Alpaca.Markets.Tests/AlpacaTradingClientTest.Positions.cs +++ b/Alpaca.Markets.Tests/AlpacaTradingClientTest.Positions.cs @@ -113,7 +113,9 @@ public async Task ExerciseOptionsPositionBySymbolAsyncWorks() Assert.True(await mock.Client.ExerciseOptionsPositionBySymbolAsync(Stock)); } +#pragma warning disable IDE0079 // Remove unnecessary suppression [SuppressMessage("ReSharper", "StringLiteralTypo")] +#pragma warning restore IDE0079 // Remove unnecessary suppression private static JObject createPosition() => new( new JProperty("unrealized_intraday_plpc", ProfitLossPercent), @@ -145,17 +147,17 @@ private static void validatePosition( Assert.NotEqual(Guid.Empty, position.AssetId); - Assert.True(position.AssetChangePercent != 0M); - Assert.True(position.AverageEntryPrice != 0M); - Assert.True(position.AssetCurrentPrice!= 0M); - Assert.True(position.AssetLastPrice != 0M); - Assert.True(position.MarketValue != 0M); - Assert.True(position.CostBasis != 0M); - - Assert.True(position.UnrealizedProfitLoss != 0M); - Assert.True(position.UnrealizedProfitLossPercent != 0M); - Assert.True(position.IntradayUnrealizedProfitLoss != 0M); - Assert.True(position.IntradayUnrealizedProfitLossPercent != 0M); + Assert.NotEqual(0M, position.AssetChangePercent); + Assert.NotEqual(0M, position.AverageEntryPrice); + Assert.NotEqual(0M, position.AssetCurrentPrice); + Assert.NotEqual(0M, position.AssetLastPrice); + Assert.NotEqual(0M, position.MarketValue); + Assert.NotEqual(0M, position.CostBasis); + + Assert.NotEqual(0M, position.UnrealizedProfitLoss); + Assert.NotEqual(0M, position.UnrealizedProfitLossPercent); + Assert.NotEqual(0M, position.IntradayUnrealizedProfitLoss); + Assert.NotEqual(0M, position.IntradayUnrealizedProfitLossPercent); } private static JArray getDeletePositionsResponse() => diff --git a/Alpaca.Markets.Tests/AlpacaTradingClientTest.Watchlists.cs b/Alpaca.Markets.Tests/AlpacaTradingClientTest.Watchlists.cs index 21073b7b2..9e8182ab5 100644 --- a/Alpaca.Markets.Tests/AlpacaTradingClientTest.Watchlists.cs +++ b/Alpaca.Markets.Tests/AlpacaTradingClientTest.Watchlists.cs @@ -55,7 +55,7 @@ public async Task CreateWatchListAsyncWorks() mock.AddPost(WatchlistsUrl, createWatchList()); var watchList = await mock.Client.CreateWatchListAsync(new NewWatchListRequest( - Guid.NewGuid().ToString("D"), new [] { Stock, Crypto })); + Guid.NewGuid().ToString("D"), [Stock, Crypto])); validateWatchList(watchList); } @@ -68,7 +68,7 @@ public async Task UpdateWatchListByIdAsyncWorks() mock.AddPut(WatchListsWildcardUrl, createWatchList()); var watchList = await mock.Client.UpdateWatchListByIdAsync(new UpdateWatchListRequest( - Guid.NewGuid(), Guid.NewGuid().ToString("D"), new [] { Stock, Crypto })); + Guid.NewGuid(), Guid.NewGuid().ToString("D"), [Stock, Crypto])); validateWatchList(watchList); } diff --git a/Alpaca.Markets.Tests/AlpacaTradingClientTest.cs b/Alpaca.Markets.Tests/AlpacaTradingClientTest.cs index 965fa60a3..778145048 100644 --- a/Alpaca.Markets.Tests/AlpacaTradingClientTest.cs +++ b/Alpaca.Markets.Tests/AlpacaTradingClientTest.cs @@ -126,12 +126,11 @@ public async Task GetRateLimitValuesWorks() return; IEnumerable> GetHeaders() => - new KeyValuePair[] - { - new("X-Ratelimit-Limit", "100"), - new("X-Ratelimit-Remaining", "99"), - new("X-Ratelimit-Reset", - resetTime.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture)) - }; + [ + new("X-Ratelimit-Limit", "100"), + new("X-Ratelimit-Remaining", "99"), + new("X-Ratelimit-Reset", + resetTime.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture)) + ]; } } diff --git a/Alpaca.Markets.Tests/DefaultValuesTest.cs b/Alpaca.Markets.Tests/DefaultValuesTest.cs index bdbbebc87..91f4b91d5 100644 --- a/Alpaca.Markets.Tests/DefaultValuesTest.cs +++ b/Alpaca.Markets.Tests/DefaultValuesTest.cs @@ -98,4 +98,24 @@ public void RestClientErrorExceptionWorks() Assert.Equal(message, withInnerException.Message); Assert.Equal(defaultValue, withInnerException.InnerException); } + + [Fact] + public void RequestValidationExceptionWorks() + { + var defaultValue = new RequestValidationException(); + + Assert.NotNull(defaultValue.Message); + Assert.Null(defaultValue.InnerException); + + var message = Guid.NewGuid().ToString("N"); + var withMessage = new RequestValidationException(message); + + Assert.Equal(message, withMessage.Message); + Assert.Null(withMessage.InnerException); + + var withInnerException = new RequestValidationException(message, defaultValue); + + Assert.Equal(message, withInnerException.Message); + Assert.Equal(defaultValue, withInnerException.InnerException); + } } diff --git a/Alpaca.Markets.Tests/HistoricalDataHelpers.cs b/Alpaca.Markets.Tests/HistoricalDataHelpers.cs index 314b50621..e2635870c 100644 --- a/Alpaca.Markets.Tests/HistoricalDataHelpers.cs +++ b/Alpaca.Markets.Tests/HistoricalDataHelpers.cs @@ -2,6 +2,7 @@ namespace Alpaca.Markets.Tests; +#pragma warning disable IDE0079 // Remove unnecessary suppression [SuppressMessage("ReSharper", "ParameterOnlyUsedForPreconditionCheck.Global")] [SuppressMessage("ReSharper", "ParameterOnlyUsedForPreconditionCheck.Local")] #pragma warning restore IDE0079 // Remove unnecessary suppression @@ -199,9 +200,9 @@ public static Boolean Validate( Assert.InRange(bar.Open, bar.Low, bar.High); Assert.True(bar.TimeUtc <= DateTime.UtcNow); - Assert.True(bar.TradeCount != 0); - Assert.True(bar.Volume != 0M); - Assert.True(bar.Vwap != 0M); + Assert.NotEqual(0UL, bar.TradeCount); + Assert.NotEqual(0M, bar.Volume); + Assert.NotEqual(0M, bar.Vwap); return true; } diff --git a/Alpaca.Markets.Tests/MockClientsFactory.cs b/Alpaca.Markets.Tests/MockClientsFactory.cs index ac78ca743..5a20daf09 100644 --- a/Alpaca.Markets.Tests/MockClientsFactory.cs +++ b/Alpaca.Markets.Tests/MockClientsFactory.cs @@ -4,7 +4,9 @@ namespace Alpaca.Markets.Tests; +#pragma warning disable IDE0079 // Remove unnecessary suppression [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")] +#pragma warning restore IDE0079 // Remove unnecessary suppression public sealed class MockClientsFactoryFixture { private readonly SecurityKey _secretKey = new SecretKey( diff --git a/Alpaca.Markets.Tests/RequestValidationTest.cs b/Alpaca.Markets.Tests/RequestValidationTest.cs index 17ea3965c..4d21418e1 100644 --- a/Alpaca.Markets.Tests/RequestValidationTest.cs +++ b/Alpaca.Markets.Tests/RequestValidationTest.cs @@ -16,7 +16,7 @@ public void HistoricalRequestBaseNoSymbolsValidationWorks() => [Fact] public void HistoricalRequestBaseEmptySymbolValidationWorks() => - validate(new HistoricalCryptoBarsRequest(new [] { String.Empty }, _interval, BarTimeFrame.Day)); + validate(new HistoricalCryptoBarsRequest([String.Empty], _interval, BarTimeFrame.Day)); [Fact] public void HistoricalRequestBaseEmptyPageValidationWorks() => @@ -25,7 +25,7 @@ public void HistoricalRequestBaseEmptyPageValidationWorks() => [Fact] public void NewsArticlesRequestEmptySymbolValidationWorks() => - validate(new NewsArticlesRequest(new [] { String.Empty })); + validate(new NewsArticlesRequest([String.Empty])); [Fact] public void NewsArticlesRequestBigPageValidationWorks() => @@ -46,7 +46,7 @@ public void NewWatchListRequestEmptyNameValidationWorks() => [Fact] public void NewWatchListRequestEmptySymbolValidationWorks() => - validate(new NewWatchListRequest(Guid.NewGuid().ToString("D"), new [] { String.Empty})); + validate(new NewWatchListRequest(Guid.NewGuid().ToString("D"), [String.Empty])); [Fact] public void UpdateWatchListRequestEmptyNameValidationWorks() => @@ -55,7 +55,7 @@ public void UpdateWatchListRequestEmptyNameValidationWorks() => [Fact] public void UpdateWatchListRequestEmptySymbolValidationWorks() => validate(new UpdateWatchListRequest(Guid.NewGuid(), - Guid.NewGuid().ToString("D"), new [] { String.Empty})); + Guid.NewGuid().ToString("D"), [String.Empty])); [Fact] public void ChangeWatchListRequestEmptyNameValidationWorks() => diff --git a/Alpaca.Markets/Alpaca.Markets.csproj b/Alpaca.Markets/Alpaca.Markets.csproj index 962154bdd..dac9c12ad 100644 --- a/Alpaca.Markets/Alpaca.Markets.csproj +++ b/Alpaca.Markets/Alpaca.Markets.csproj @@ -23,7 +23,7 @@ C# SDK for Alpaca Trade API https://docs.alpaca.markets/ https://github.com/alpacahq/alpaca-trade-api-csharp - © 2018-2023 Alpaca Securities LLC. All rights reserved. + © 2018-2025 Alpaca Securities LLC. All rights reserved. false Aplaca API SDK REST WebSocket trading Apache-2.0 @@ -49,8 +49,9 @@ true - 7.1.0 + 7.2.0 true + true true AllEnabledByDefault true diff --git a/Alpaca.Markets/AlpacaStreamingClient.cs b/Alpaca.Markets/AlpacaStreamingClient.cs index 1828749ce..198c2755d 100644 --- a/Alpaca.Markets/AlpacaStreamingClient.cs +++ b/Alpaca.Markets/AlpacaStreamingClient.cs @@ -31,16 +31,27 @@ internal AlpacaStreamingClient( /// public event Action? OnTradeUpdate; + + [SuppressMessage( + "Design", "CA1031:Do not catch general exception types", + Justification = "Expected behavior - we report exceptions via OnError event.")] protected override async void OnOpened() { - await SendAsJsonStringAsync(new JsonAuthRequest + try { - Action = JsonAction.Authenticate, - Data = Configuration.SecurityId - .GetAuthenticationData() - }).ConfigureAwait(false); + await SendAsJsonStringAsync(new JsonAuthRequest + { + Action = JsonAction.Authenticate, + Data = Configuration.SecurityId + .GetAuthenticationData() + }).ConfigureAwait(false); - base.OnOpened(); + base.OnOpened(); + } + catch (Exception exception) + { + HandleError(exception); + } } [SuppressMessage( diff --git a/Alpaca.Markets/CompatibilitySuppressions.xml b/Alpaca.Markets/CompatibilitySuppressions.xml index 69fe54503..f140f4eb7 100644 --- a/Alpaca.Markets/CompatibilitySuppressions.xml +++ b/Alpaca.Markets/CompatibilitySuppressions.xml @@ -1457,27 +1457,6 @@ lib/netstandard2.1/Alpaca.Markets.dll true - - CP0006 - M:Alpaca.Markets.IAlpacaDataClient.ListCorporateActionsAsync(Alpaca.Markets.CorporateActionsRequest,System.Threading.CancellationToken) - lib/net6.0/Alpaca.Markets.dll - lib/netstandard2.1/Alpaca.Markets.dll - true - - - CP0006 - M:Alpaca.Markets.IAlpacaDataClient.ListCorporateActionsAsync(Alpaca.Markets.CorporateActionsRequest,System.Threading.CancellationToken) - lib/netstandard2.0/Alpaca.Markets.dll - lib/netstandard2.0/Alpaca.Markets.dll - true - - - CP0006 - M:Alpaca.Markets.IAlpacaDataClient.ListCorporateActionsAsync(Alpaca.Markets.CorporateActionsRequest,System.Threading.CancellationToken) - lib/netstandard2.1/Alpaca.Markets.dll - lib/netstandard2.1/Alpaca.Markets.dll - true - CP0008 T:Alpaca.Markets.AccountActivityType @@ -1541,6 +1520,13 @@ lib/netstandard2.1/Alpaca.Markets.dll true + + CP0008 + T:Alpaca.Markets.CorporateActionFilterType + lib/net6.0/Alpaca.Markets.dll + lib/netstandard2.1/Alpaca.Markets.dll + true + CP0008 T:Alpaca.Markets.CorporateActionSubType @@ -1977,60 +1963,4 @@ lib/netstandard2.1/Alpaca.Markets.dll lib/net8.0/Alpaca.Markets.dll - - CP0011 - F:Alpaca.Markets.AccountActivityType.CryptoFee - lib/net462/Alpaca.Markets.dll - lib/net462/Alpaca.Markets.dll - true - - - CP0011 - F:Alpaca.Markets.AccountActivityType.FeeInUsd - lib/net462/Alpaca.Markets.dll - lib/net462/Alpaca.Markets.dll - true - - - CP0011 - F:Alpaca.Markets.AccountActivityType.CryptoFee - lib/net6.0/Alpaca.Markets.dll - lib/netstandard2.1/Alpaca.Markets.dll - true - - - CP0011 - F:Alpaca.Markets.AccountActivityType.FeeInUsd - lib/net6.0/Alpaca.Markets.dll - lib/netstandard2.1/Alpaca.Markets.dll - true - - - CP0011 - F:Alpaca.Markets.AccountActivityType.CryptoFee - lib/netstandard2.0/Alpaca.Markets.dll - lib/netstandard2.0/Alpaca.Markets.dll - true - - - CP0011 - F:Alpaca.Markets.AccountActivityType.FeeInUsd - lib/netstandard2.0/Alpaca.Markets.dll - lib/netstandard2.0/Alpaca.Markets.dll - true - - - CP0011 - F:Alpaca.Markets.AccountActivityType.CryptoFee - lib/netstandard2.1/Alpaca.Markets.dll - lib/netstandard2.1/Alpaca.Markets.dll - true - - - CP0011 - F:Alpaca.Markets.AccountActivityType.FeeInUsd - lib/netstandard2.1/Alpaca.Markets.dll - lib/netstandard2.1/Alpaca.Markets.dll - true - \ No newline at end of file diff --git a/Alpaca.Markets/Exceptions/RequestValidationException.cs b/Alpaca.Markets/Exceptions/RequestValidationException.cs index e3fc904e3..be0c50848 100644 --- a/Alpaca.Markets/Exceptions/RequestValidationException.cs +++ b/Alpaca.Markets/Exceptions/RequestValidationException.cs @@ -8,7 +8,6 @@ public sealed class RequestValidationException : Exception /// /// Creates new instance of class. /// - [ExcludeFromCodeCoverage] public RequestValidationException() { } @@ -17,7 +16,6 @@ public RequestValidationException() /// Creates new instance of class with specified error message. /// /// The message that describes the error. - [ExcludeFromCodeCoverage] public RequestValidationException( String message) : base(message) @@ -30,7 +28,6 @@ public RequestValidationException( /// /// The message that describes the error. /// The exception that is the cause of this exception. - [ExcludeFromCodeCoverage] public RequestValidationException( String message, Exception inner) diff --git a/Alpaca.Markets/Messages/JsonOptionSnapshotsData.cs b/Alpaca.Markets/Messages/JsonOptionSnapshotsData.cs index c09b4ad76..9966b7477 100644 --- a/Alpaca.Markets/Messages/JsonOptionSnapshotsData.cs +++ b/Alpaca.Markets/Messages/JsonOptionSnapshotsData.cs @@ -8,7 +8,7 @@ internal sealed class JsonOptionsSnapshotData : IDictionaryPage { [DebuggerBrowsable(DebuggerBrowsableState.Never)] [JsonProperty(PropertyName = "snapshots", Required = Required.Default)] - public Dictionary ItemsList { get; [ExcludeFromCodeCoverage] set; } = new(); + public Dictionary ItemsList { get; [ExcludeFromCodeCoverage] set; } = []; [JsonProperty(PropertyName = "next_page_token", Required = Required.Default)] public String? NextPageToken { get; set; } diff --git a/Alpaca.Markets/Parameters/HistoricalAuctionsRequest.cs b/Alpaca.Markets/Parameters/HistoricalAuctionsRequest.cs index 65dc84631..5ea824a1a 100644 --- a/Alpaca.Markets/Parameters/HistoricalAuctionsRequest.cs +++ b/Alpaca.Markets/Parameters/HistoricalAuctionsRequest.cs @@ -21,7 +21,7 @@ public HistoricalAuctionsRequest( String symbol, DateTime from, DateTime into) - : this(new[] { symbol.EnsureNotNull() }, from, into) + : this([symbol.EnsureNotNull()], from, into) { } @@ -36,7 +36,7 @@ public HistoricalAuctionsRequest( public HistoricalAuctionsRequest( String symbol, Interval timeInterval) - : this(new[] { symbol.EnsureNotNull() }, timeInterval) + : this([symbol.EnsureNotNull()], timeInterval) { } @@ -49,7 +49,7 @@ public HistoricalAuctionsRequest( /// public HistoricalAuctionsRequest( String symbol) - : this(new[] { symbol.EnsureNotNull() }) + : this([symbol.EnsureNotNull()]) { } diff --git a/Alpaca.Markets/Parameters/HistoricalBarsRequest.cs b/Alpaca.Markets/Parameters/HistoricalBarsRequest.cs index a7685a9a4..1c487eb74 100644 --- a/Alpaca.Markets/Parameters/HistoricalBarsRequest.cs +++ b/Alpaca.Markets/Parameters/HistoricalBarsRequest.cs @@ -22,7 +22,7 @@ public HistoricalBarsRequest( DateTime from, DateTime into, BarTimeFrame timeFrame) - : this(new[] { symbol.EnsureNotNull() }, from, into, timeFrame) + : this([symbol.EnsureNotNull()], from, into, timeFrame) { } diff --git a/Alpaca.Markets/Parameters/HistoricalCryptoBarsRequest.cs b/Alpaca.Markets/Parameters/HistoricalCryptoBarsRequest.cs index c29addb08..b6437097f 100644 --- a/Alpaca.Markets/Parameters/HistoricalCryptoBarsRequest.cs +++ b/Alpaca.Markets/Parameters/HistoricalCryptoBarsRequest.cs @@ -22,7 +22,7 @@ public HistoricalCryptoBarsRequest( DateTime from, DateTime into, BarTimeFrame timeFrame) - : this(new[] { symbol.EnsureNotNull() }, from, into, timeFrame) + : this([symbol.EnsureNotNull()], from, into, timeFrame) { } @@ -39,7 +39,7 @@ public HistoricalCryptoBarsRequest( String symbol, BarTimeFrame timeFrame, Interval timeInterval) - : this(new[] { symbol.EnsureNotNull() }, timeInterval, timeFrame) + : this([symbol.EnsureNotNull()], timeInterval, timeFrame) { } @@ -54,7 +54,7 @@ public HistoricalCryptoBarsRequest( public HistoricalCryptoBarsRequest( String symbol, BarTimeFrame timeFrame) - : this(new[] { symbol.EnsureNotNull() }, timeFrame) + : this([symbol.EnsureNotNull()], timeFrame) { } diff --git a/Alpaca.Markets/Parameters/HistoricalCryptoQuotesRequest.cs b/Alpaca.Markets/Parameters/HistoricalCryptoQuotesRequest.cs index a5e7692c1..6be0fd9c9 100644 --- a/Alpaca.Markets/Parameters/HistoricalCryptoQuotesRequest.cs +++ b/Alpaca.Markets/Parameters/HistoricalCryptoQuotesRequest.cs @@ -21,7 +21,7 @@ public HistoricalCryptoQuotesRequest( String symbol, DateTime from, DateTime into) - : this(new[] { symbol.EnsureNotNull() }, from, into) + : this([symbol.EnsureNotNull()], from, into) { } @@ -36,7 +36,7 @@ public HistoricalCryptoQuotesRequest( public HistoricalCryptoQuotesRequest( String symbol, Interval timeInterval) - : this(new[] { symbol.EnsureNotNull() }, timeInterval) + : this([symbol.EnsureNotNull()], timeInterval) { } @@ -49,7 +49,7 @@ public HistoricalCryptoQuotesRequest( /// public HistoricalCryptoQuotesRequest( String symbol) - : this(new[] { symbol.EnsureNotNull() }) + : this([symbol.EnsureNotNull()]) { } diff --git a/Alpaca.Markets/Parameters/HistoricalCryptoTradesRequest.cs b/Alpaca.Markets/Parameters/HistoricalCryptoTradesRequest.cs index 8a0876066..e5219fbbe 100644 --- a/Alpaca.Markets/Parameters/HistoricalCryptoTradesRequest.cs +++ b/Alpaca.Markets/Parameters/HistoricalCryptoTradesRequest.cs @@ -21,7 +21,7 @@ public HistoricalCryptoTradesRequest( String symbol, DateTime from, DateTime into) - : this(new[] { symbol.EnsureNotNull() }, from, into) + : this([symbol.EnsureNotNull()], from, into) { } @@ -36,7 +36,7 @@ public HistoricalCryptoTradesRequest( public HistoricalCryptoTradesRequest( String symbol, Interval timeInterval) - : this(new[] { symbol.EnsureNotNull() }, timeInterval) + : this([symbol.EnsureNotNull()], timeInterval) { } @@ -49,7 +49,7 @@ public HistoricalCryptoTradesRequest( /// public HistoricalCryptoTradesRequest( String symbol) - : this(new[] { symbol.EnsureNotNull() }) + : this([symbol.EnsureNotNull()]) { } diff --git a/Alpaca.Markets/Parameters/HistoricalOptionBarsRequest.cs b/Alpaca.Markets/Parameters/HistoricalOptionBarsRequest.cs index a2ce5714a..8a9414bf2 100644 --- a/Alpaca.Markets/Parameters/HistoricalOptionBarsRequest.cs +++ b/Alpaca.Markets/Parameters/HistoricalOptionBarsRequest.cs @@ -130,4 +130,4 @@ HistoricalOptionBarsRequest IHistoricalRequest timeInterval) - : this(new[] { symbol.EnsureNotNull() }, timeInterval) + : this([symbol.EnsureNotNull()], timeInterval) { } @@ -49,7 +49,7 @@ public HistoricalOptionTradesRequest( /// public HistoricalOptionTradesRequest( String symbol) - : this(new[] { symbol.EnsureNotNull() }) + : this([symbol.EnsureNotNull()]) { } @@ -110,4 +110,4 @@ HistoricalOptionTradesRequest IHistoricalRequest timeInterval) - : this(new[] { symbol.EnsureNotNull() }, timeInterval) + : this([symbol.EnsureNotNull()], timeInterval) { } @@ -49,7 +49,7 @@ public HistoricalQuotesRequest( /// public HistoricalQuotesRequest( String symbol) - : this(new[] { symbol.EnsureNotNull() }) + : this([symbol.EnsureNotNull()]) { } diff --git a/Alpaca.Markets/Parameters/HistoricalTradesRequest.cs b/Alpaca.Markets/Parameters/HistoricalTradesRequest.cs index 4d5d5b23b..5bd74f303 100644 --- a/Alpaca.Markets/Parameters/HistoricalTradesRequest.cs +++ b/Alpaca.Markets/Parameters/HistoricalTradesRequest.cs @@ -21,7 +21,7 @@ public HistoricalTradesRequest( String symbol, DateTime from, DateTime into) - : this(new[] { symbol.EnsureNotNull() }, from, into) + : this([symbol.EnsureNotNull()], from, into) { } @@ -36,7 +36,7 @@ public HistoricalTradesRequest( public HistoricalTradesRequest( String symbol, Interval timeInterval) - : this(new[] { symbol.EnsureNotNull() }, timeInterval) + : this([symbol.EnsureNotNull()], timeInterval) { } @@ -49,7 +49,7 @@ public HistoricalTradesRequest( /// public HistoricalTradesRequest( String symbol) - : this(new[] { symbol.EnsureNotNull() }) + : this([symbol.EnsureNotNull()]) { } diff --git a/Alpaca.Markets/README.md b/Alpaca.Markets/README.md index dbec7cab5..866dca7a3 100644 --- a/Alpaca.Markets/README.md +++ b/Alpaca.Markets/README.md @@ -12,7 +12,7 @@ This package contains C#/.NET SDK for [Alpaca Trade API](https://docs.alpaca.mar 1. Create a new console application in a new, empty folder by running `dotnet new console`. 2. Add a reference for Alpaca .NET SDK with `dotnet add package Alpaca.Markets`. -3. Replace content of the auto-generated `Programm.cs` file with this code snippet: +3. Replace content of the auto-generated `Program.cs` file with this code snippet: ```cs using System; using Alpaca.Markets; diff --git a/Alpaca.Markets/Throttling/ThrottleParameters.cs b/Alpaca.Markets/Throttling/ThrottleParameters.cs index 825fe5c5a..ab450a948 100644 --- a/Alpaca.Markets/Throttling/ThrottleParameters.cs +++ b/Alpaca.Markets/Throttling/ThrottleParameters.cs @@ -128,12 +128,16 @@ public ThrottleParameters( IEnumerable retryHttpStatuses) { MaxRetryAttempts = maxRetryAttempts; - _retrySocketErrorCodes = new HashSet( + _retrySocketErrorCodes = + [ // ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract - retrySocketErrorCodes ?? _defaultSocketErrorCodes); - _retryHttpStatuses = new HashSet( + ..retrySocketErrorCodes ?? _defaultSocketErrorCodes + ]; + _retryHttpStatuses = + [ // ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract - retryHttpStatuses ?? _defaultHttpStatuses); + ..retryHttpStatuses ?? _defaultHttpStatuses + ]; } /// diff --git a/Portable.Helpers/GlobalSuppressions.cs b/Portable.Helpers/GlobalSuppressions.cs index d48fec4e3..0305175c3 100644 --- a/Portable.Helpers/GlobalSuppressions.cs +++ b/Portable.Helpers/GlobalSuppressions.cs @@ -1,8 +1,9 @@ // This file is used by Code Analysis to maintain SuppressMessage attributes that are applied to this project. -global using JetBrains.Annotations; global using System.Diagnostics.CodeAnalysis; global using System.Runtime.CompilerServices; +global using JetBrains.Annotations; +global using System.Diagnostics; global using System.Net.Sockets; [assembly: CLSCompliant(true)] diff --git a/README.md b/README.md index 36afe8cf3..b14940c68 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ Use the `Environments.Paper.GetAlpacaDataStreamingClient(...)` factory method fo ### Build instructions -1. Install the latest version of the [.NET 8.0 SDK](https://dotnet.microsoft.com/download) for your OS. +1. Install the latest version of the [.NET 9.0 SDK](https://dotnet.microsoft.com/download) for your OS. 2. Clone the local version of this repository or your fork (if you want to make changes). 3. Build the packages using the `dotnet build` command running in the root directory of the cloned repo. diff --git a/UsageExamples/UsageExamples.csproj b/UsageExamples/UsageExamples.csproj index f99aa70ba..ca8231ee7 100644 --- a/UsageExamples/UsageExamples.csproj +++ b/UsageExamples/UsageExamples.csproj @@ -2,7 +2,7 @@ Exe - net48;net8.0 + net4.8;net8.0 true link enable @@ -10,6 +10,7 @@ + true true