Skip to content

Commit

Permalink
Cleaned up code a bit with help of R# solution analysis.
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegRa committed Mar 4, 2024
1 parent a2161f9 commit a1ca437
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 17 deletions.
12 changes: 7 additions & 5 deletions Alpaca.Markets.Tests/AlpacaTradingClientTest.Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 3 additions & 1 deletion Alpaca.Markets.Tests/AlpacaTradingClientTest.Assets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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]);
}
}
2 changes: 2 additions & 0 deletions Alpaca.Markets.Tests/AlpacaTradingClientTest.Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,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,
Expand Down
8 changes: 5 additions & 3 deletions Alpaca.Markets.Tests/HistoricalDataHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

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
internal static class HistoricalDataHelpers
{
private static readonly String _condition = Guid.NewGuid().ToString("D");
Expand Down Expand Up @@ -189,9 +191,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;
}
Expand Down
2 changes: 2 additions & 0 deletions Alpaca.Markets.Tests/MockClientsFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 1 addition & 3 deletions Alpaca.Markets/Messages/JsonOptionQuote.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Newtonsoft.Json.Linq;

namespace Alpaca.Markets;
namespace Alpaca.Markets;

[DebuggerDisplay("{DebuggerDisplay,nq}", Type = nameof(IQuote))]
[SuppressMessage(
Expand Down
6 changes: 3 additions & 3 deletions Alpaca.Markets/Parameters/HistoricalOptionBarsRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public HistoricalOptionBarsRequest(
String symbol,
BarTimeFrame timeFrame,
Interval<DateTime> timeInterval)
: this(new[] { symbol.EnsureNotNull() }, timeInterval, timeFrame)
: this([ symbol.EnsureNotNull() ], timeInterval, timeFrame)
{
}

Expand Down Expand Up @@ -127,7 +127,7 @@ internal override QueryBuilder AddParameters(
HistoricalOptionBarsRequest IHistoricalRequest<HistoricalOptionBarsRequest, IBar>.GetValidatedRequestWithoutPageToken() =>
new HistoricalOptionBarsRequest(Symbols, TimeInterval, TimeFrame)
{
SortDirection = SortDirection,
SortDirection = SortDirection
}
.WithPageSize(this.GetPageSize());
}
}
4 changes: 2 additions & 2 deletions Alpaca.Markets/Parameters/HistoricalOptionTradesRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public HistoricalOptionTradesRequest(
HistoricalOptionTradesRequest IHistoricalRequest<HistoricalOptionTradesRequest, ITrade>.GetValidatedRequestWithoutPageToken() =>
new HistoricalOptionTradesRequest(Symbols, TimeInterval)
{
SortDirection = SortDirection,
SortDirection = SortDirection
}
.WithPageSize(this.GetPageSize());
}
}

0 comments on commit a1ca437

Please sign in to comment.