diff --git a/.editorconfig b/.editorconfig index 478516fbe..795cdde3b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -106,8 +106,9 @@ csharp_style_prefer_method_group_conversion = true:silent csharp_style_prefer_top_level_statements = true:silent csharp_style_prefer_primary_constructors = true:suggestion -# Expression-bodied Members +# Expression-bodied members csharp_style_expression_bodied_methods = true:silent +csharp_style_expression_bodied_operators = true:silent csharp_style_expression_bodied_properties = true:silent csharp_style_expression_bodied_indexers = true:silent csharp_style_expression_bodied_accessors = true:silent @@ -146,3 +147,9 @@ csharp_new_line_before_finally = true csharp_new_line_before_members_in_object_initializers = false csharp_new_line_before_members_in_anonymous_types = false csharp_new_line_between_query_expression_clauses = false + +# Diagnostic analyzer suppressions +dotnet_diagnostic.IDE0058.severity = none # Unused expression value, use _ discard variable + +# remove this when no-longer supporting pre-9.0 frameworks +dotnet_diagnostic.IDE0330.severity = none # Prefer 'System.Threading.Lock' diff --git a/.github/workflows/deploy-package.yml b/.github/workflows/deploy-package.yml index e3d15e657..3f226014b 100644 --- a/.github/workflows/deploy-package.yml +++ b/.github/workflows/deploy-package.yml @@ -123,7 +123,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: "8.x" + dotnet-version: "9.x" dotnet-quality: "ga" - name: Setup NuGet diff --git a/.github/workflows/lint-pull-request.yml b/.github/workflows/lint-pull-request.yml index 8fb6295e2..1d78109ba 100644 --- a/.github/workflows/lint-pull-request.yml +++ b/.github/workflows/lint-pull-request.yml @@ -47,7 +47,7 @@ jobs: if: always() && (steps.lint_pr_title.outputs.error_message != null) with: header: pr-title-lint-error - message: > + message: | ### Hey there and thank you for opening this pull request! 👋🏞 It looks like your proposed **_Pull request title_** needs to be adjusted. diff --git a/.github/workflows/test-codeql.yml b/.github/workflows/test-codeql.yml new file mode 100644 index 000000000..99a0a94ef --- /dev/null +++ b/.github/workflows/test-codeql.yml @@ -0,0 +1,52 @@ +name: "CodeQL" + +on: + push: + branches: [ "main", "v3" ] + + pull_request: + branches: [ "main", "v3" ] + + schedule: + - cron: '37 14 * * 3' + +jobs: + + analyze: + name: analyze + runs-on: 'ubuntu-latest' + + permissions: + security-events: write + packages: read + actions: read + contents: read + + steps: + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: csharp + build-mode: manual + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.x + dotnet-quality: "ga" + + - name: Build library + run: > + dotnet build + --configuration Release + --property:ContinuousIntegrationBuild=true + -warnAsError + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:csharp" diff --git a/.github/workflows/test-examples.yml b/.github/workflows/test-examples.yml index 4b81db50c..0735a40af 100644 --- a/.github/workflows/test-examples.yml +++ b/.github/workflows/test-examples.yml @@ -25,7 +25,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: "8.x" + dotnet-version: "9.x" dotnet-quality: "ga" - name: Build examples diff --git a/.github/workflows/test-indicators.yml b/.github/workflows/test-indicators.yml index ada36f373..f69d693c2 100644 --- a/.github/workflows/test-indicators.yml +++ b/.github/workflows/test-indicators.yml @@ -20,12 +20,18 @@ jobs: strategy: matrix: os: [windows-latest, ubuntu-latest, macos-latest] - dotnet-version: ["6.x", "8.x"] + dotnet-version: ["9.x"] + # TODO: restore when runners have 9.x on all + # ["2.1.x", "6.x", "9.x"] env: # identifying primary configuration so only one reports coverage - IS_PRIMARY: ${{ matrix.os == 'ubuntu-latest' && matrix.dotnet-version == '8.x' }} + IS_PRIMARY: ${{ matrix.os == 'ubuntu-latest' && matrix.dotnet-version == '9.x' }} + + # .NET SDK versions in the matrix that support `ga` quality spec + # versions before 5.x do not support it + SUPPORT_GA: ${{ contains(fromJson('["6.x", "9.x"]'), matrix.dotnet-version) }} steps: diff --git a/.github/workflows/test-performance.yml b/.github/workflows/test-performance.yml index 8f014c325..b114df45e 100644 --- a/.github/workflows/test-performance.yml +++ b/.github/workflows/test-performance.yml @@ -33,7 +33,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: "8.x" + dotnet-version: "9.x" dotnet-quality: "ga" - name: Build library diff --git a/.github/workflows/test-website-a11y.yml b/.github/workflows/test-website-a11y.yml index a92abccc3..c00dd6d8c 100644 --- a/.github/workflows/test-website-a11y.yml +++ b/.github/workflows/test-website-a11y.yml @@ -25,7 +25,7 @@ jobs: uses: ruby/setup-ruby@v1 with: working-directory: docs - ruby-version: 3.2 + ruby-version: 3.3 - name: Install GEMs working-directory: docs diff --git a/.github/workflows/test-website-links.yml b/.github/workflows/test-website-links.yml index 19cddb540..10319897e 100644 --- a/.github/workflows/test-website-links.yml +++ b/.github/workflows/test-website-links.yml @@ -25,7 +25,7 @@ jobs: uses: ruby/setup-ruby@v1 with: working-directory: docs - ruby-version: 3.2 + ruby-version: 3.3 - name: Install GEMs working-directory: docs diff --git a/docs/examples/Backtest/Backtest.csproj b/docs/examples/Backtest/Backtest.csproj index 8630a4433..911edb610 100644 --- a/docs/examples/Backtest/Backtest.csproj +++ b/docs/examples/Backtest/Backtest.csproj @@ -2,12 +2,12 @@ Exe - net8.0 + net9.0 enable - + diff --git a/docs/examples/ConsoleApp/ConsoleApp.csproj b/docs/examples/ConsoleApp/ConsoleApp.csproj index 8630a4433..911edb610 100644 --- a/docs/examples/ConsoleApp/ConsoleApp.csproj +++ b/docs/examples/ConsoleApp/ConsoleApp.csproj @@ -2,12 +2,12 @@ Exe - net8.0 + net9.0 enable - + diff --git a/docs/examples/CustomIndicators/CustomIndicatorsLibrary.csproj b/docs/examples/CustomIndicators/CustomIndicatorsLibrary.csproj index fd0f13607..b7dd009bc 100644 --- a/docs/examples/CustomIndicators/CustomIndicatorsLibrary.csproj +++ b/docs/examples/CustomIndicators/CustomIndicatorsLibrary.csproj @@ -1,12 +1,12 @@ - net8.0 + net9.0 enable - + diff --git a/docs/examples/CustomIndicatorsUsage/CustomIndicatorsUsage.csproj b/docs/examples/CustomIndicatorsUsage/CustomIndicatorsUsage.csproj index 3a1896172..3099a2d1b 100644 --- a/docs/examples/CustomIndicatorsUsage/CustomIndicatorsUsage.csproj +++ b/docs/examples/CustomIndicatorsUsage/CustomIndicatorsUsage.csproj @@ -2,12 +2,12 @@ Exe - net8.0 + net9.0 enable - + diff --git a/docs/examples/ObserveStream/ObserveStream.csproj b/docs/examples/ObserveStream/ObserveStream.csproj index 8c1656c90..b00a69c7f 100644 --- a/docs/examples/ObserveStream/ObserveStream.csproj +++ b/docs/examples/ObserveStream/ObserveStream.csproj @@ -2,12 +2,12 @@ Exe - net8.0 + net9.0 enable - + diff --git a/docs/examples/Skender.Stock.Indicators-Examples.zip b/docs/examples/Skender.Stock.Indicators-Examples.zip index 96fed5aaa..bf1788815 100644 Binary files a/docs/examples/Skender.Stock.Indicators-Examples.zip and b/docs/examples/Skender.Stock.Indicators-Examples.zip differ diff --git a/docs/examples/UseQuoteApi/UseQuoteApi.csproj b/docs/examples/UseQuoteApi/UseQuoteApi.csproj index 77a280915..44a2c3f2c 100644 --- a/docs/examples/UseQuoteApi/UseQuoteApi.csproj +++ b/docs/examples/UseQuoteApi/UseQuoteApi.csproj @@ -2,13 +2,13 @@ Exe - net8.0 + net9.0 enable - - + + diff --git a/docs/pages/home.md b/docs/pages/home.md index b82ad38e3..81126bf66 100644 --- a/docs/pages/home.md +++ b/docs/pages/home.md @@ -69,7 +69,7 @@ See the [guide]({{site.baseurl}}/guide/#content) and the [full list of indicator Our [NuGet library](https://www.nuget.org/packages/Skender.Stock.Indicators) directly targets all current frameworks for peak performance. -- .NET 8.0, 6.0 +- .NET 9.0, 8.0, 6.0 The compiled library package is [Common Language Specification (CLS) compliant](https://docs.microsoft.com/en-us/dotnet/standard/common-type-system) and can be used in other programming languages, including Python and everything in the .NET universe. diff --git a/docs/pages/performance.md b/docs/pages/performance.md index 319015dcc..669e4d9c1 100644 --- a/docs/pages/performance.md +++ b/docs/pages/performance.md @@ -6,113 +6,109 @@ relative_path: pages/performance.md layout: page --- -# {{ page.title }} for v2.4.11 +# {{ page.title }} for v2.6.0 These are the execution times for the current indicators using two years of historical daily stock quotes (502 periods) with default or typical parameters. ``` bash -BenchmarkDotNet v0.13.9, Windows 10 -Intel Core i7-7700HQ CPU 2.80GHz (Kaby Lake), 1 CPU, 8 logical and 4 physical cores -.NET SDK 7.0.402 - [Host] : .NET 7.0.12 (7.0.1223.47720), X64 RyuJIT AVX2 +BenchmarkDotNet v0.14.0, Ubuntu 22.04.5 LTS (Jammy Jellyfish) +AMD EPYC 7763, 1 CPU, 4 logical and 2 physical cores +.NET SDK 9.0.100 + [Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2 ``` - -## indicators - -| Method | Mean | Error | StdDev | Median | -|------------------- |-------------:|----------:|----------:|-------------:| -| GetAdl | 59.039 Ξs | 0.5747 Ξs | 0.5094 Ξs | 58.952 Ξs | -| GetAdlWithSma | 69.657 Ξs | 0.6687 Ξs | 0.5584 Ξs | 69.452 Ξs | -| GetAdx | 71.841 Ξs | 1.2287 Ξs | 2.5099 Ξs | 70.816 Ξs | -| GetAlligator | 69.392 Ξs | 0.3080 Ξs | 0.2572 Ξs | 69.406 Ξs | -| GetAlma | 58.394 Ξs | 1.1506 Ξs | 2.4769 Ξs | 57.207 Ξs | -| GetAroon | 118.119 Ξs | 0.2383 Ξs | 0.2112 Ξs | 118.115 Ξs | -| GetAtr | 61.479 Ξs | 0.2266 Ξs | 0.2120 Ξs | 61.404 Ξs | -| GetAtrStop | 88.143 Ξs | 0.2664 Ξs | 0.2362 Ξs | 88.111 Ξs | -| GetAwesome | 71.855 Ξs | 0.2753 Ξs | 0.2440 Ξs | 71.754 Ξs | -| GetBeta | 200.507 Ξs | 0.7199 Ξs | 0.6382 Ξs | 200.542 Ξs | -| GetBetaUp | 212.544 Ξs | 2.6352 Ξs | 2.2005 Ξs | 211.601 Ξs | -| GetBetaDown | 208.804 Ξs | 0.4363 Ξs | 0.4081 Ξs | 208.922 Ξs | -| GetBetaAll | 442.614 Ξs | 4.1229 Ξs | 3.4428 Ξs | 441.238 Ξs | -| GetBollingerBands | 103.036 Ξs | 0.3631 Ξs | 0.3396 Ξs | 102.982 Ξs | -| GetBop | 63.915 Ξs | 0.1023 Ξs | 0.0798 Ξs | 63.937 Ξs | -| GetCci | 76.254 Ξs | 0.3576 Ξs | 0.3170 Ξs | 76.169 Ξs | -| GetChaikinOsc | 83.022 Ξs | 0.2467 Ξs | 0.2060 Ξs | 83.036 Ξs | -| GetChandelier | 99.088 Ξs | 0.1846 Ξs | 0.1636 Ξs | 99.079 Ξs | -| GetChop | 108.540 Ξs | 0.3124 Ξs | 0.2769 Ξs | 108.419 Ξs | -| GetCmf | 123.722 Ξs | 0.2383 Ξs | 0.2113 Ξs | 123.686 Ξs | -| GetCmo | 89.577 Ξs | 0.2785 Ξs | 0.2326 Ξs | 89.559 Ξs | -| GetConnorsRsi | 183.793 Ξs | 0.2919 Ξs | 0.2588 Ξs | 183.831 Ξs | -| GetCorrelation | 159.692 Ξs | 0.3176 Ξs | 0.2815 Ξs | 159.742 Ξs | -| GetDema | 50.569 Ξs | 0.1348 Ξs | 0.1195 Ξs | 50.529 Ξs | -| GetDoji | 102.564 Ξs | 0.2502 Ξs | 0.2089 Ξs | 102.621 Ξs | -| GetDonchian | 296.274 Ξs | 1.7686 Ξs | 1.6543 Ξs | 296.023 Ξs | -| GetDpo | 87.126 Ξs | 0.4292 Ξs | 0.3805 Ξs | 87.049 Ξs | -| GetElderRay | 97.718 Ξs | 0.3713 Ξs | 0.3101 Ξs | 97.690 Ξs | -| GetEma | 52.313 Ξs | 0.0998 Ξs | 0.0885 Ξs | 52.286 Ξs | -| GetEmaStream | 9.583 Ξs | 0.0318 Ξs | 0.0297 Ξs | 9.582 Ξs | -| GetEpma | 90.369 Ξs | 0.1802 Ξs | 0.1504 Ξs | 90.345 Ξs | -| GetFcb | 323.945 Ξs | 1.1806 Ξs | 1.0466 Ξs | 323.639 Ξs | -| GetFisherTransform | 86.202 Ξs | 1.0737 Ξs | 1.6071 Ξs | 85.535 Ξs | -| GetForceIndex | 58.920 Ξs | 0.0919 Ξs | 0.0815 Ξs | 58.917 Ξs | -| GetFractal | 88.772 Ξs | 0.2520 Ξs | 0.2104 Ξs | 88.747 Ξs | -| GetGator | 105.737 Ξs | 0.2060 Ξs | 0.1927 Ξs | 105.707 Ξs | -| GetHeikinAshi | 149.540 Ξs | 0.2668 Ξs | 0.2495 Ξs | 149.501 Ξs | -| GetHma | 169.999 Ξs | 0.4300 Ξs | 0.3590 Ξs | 169.946 Ξs | -| GetHtTrendline | 117.775 Ξs | 0.1738 Ξs | 0.1451 Ξs | 117.750 Ξs | -| GetHurst | 1,022.251 Ξs | 3.0030 Ξs | 2.8090 Ξs | 1,021.373 Ξs | -| GetIchimoku | 825.739 Ξs | 3.0491 Ξs | 2.7030 Ξs | 825.078 Ξs | -| GetKama | 63.739 Ξs | 0.1591 Ξs | 0.1410 Ξs | 63.773 Ξs | -| GetKlinger | 69.183 Ξs | 0.3546 Ξs | 0.3317 Ξs | 69.165 Ξs | -| GetKeltner | 108.516 Ξs | 0.6956 Ξs | 0.6506 Ξs | 108.764 Ξs | -| GetKvo | 69.480 Ξs | 0.2219 Ξs | 0.1967 Ξs | 69.388 Ξs | -| GetMacd | 86.834 Ξs | 0.4236 Ξs | 0.3962 Ξs | 86.724 Ξs | -| GetMaEnvelopes | 81.267 Ξs | 0.4835 Ξs | 0.4038 Ξs | 81.160 Ξs | -| GetMama | 107.137 Ξs | 0.2352 Ξs | 0.2200 Ξs | 107.119 Ξs | -| GetMarubozu | 130.650 Ξs | 0.4685 Ξs | 0.4383 Ξs | 130.462 Ξs | -| GetMfi | 85.911 Ξs | 0.1860 Ξs | 0.1649 Ξs | 85.939 Ξs | -| GetObv | 59.423 Ξs | 0.1679 Ξs | 0.1488 Ξs | 59.375 Ξs | -| GetObvWithSma | 71.693 Ξs | 0.1535 Ξs | 0.1436 Ξs | 71.684 Ξs | -| GetParabolicSar | 63.203 Ξs | 0.2489 Ξs | 0.2328 Ξs | 63.175 Ξs | -| GetPivotPoints | 73.940 Ξs | 0.2168 Ξs | 0.2028 Ξs | 73.889 Ξs | -| GetPivots | 162.539 Ξs | 0.4111 Ξs | 0.3845 Ξs | 162.302 Ξs | -| GetPmo | 69.433 Ξs | 0.3262 Ξs | 0.3051 Ξs | 69.365 Ξs | -| GetPrs | 93.780 Ξs | 0.1971 Ξs | 0.1844 Ξs | 93.757 Ξs | -| GetPrsWithSma | 103.931 Ξs | 0.7102 Ξs | 0.6296 Ξs | 103.713 Ξs | -| GetPvo | 79.227 Ξs | 1.3457 Ξs | 2.0951 Ξs | 78.449 Ξs | -| GetRenko | 92.727 Ξs | 0.2168 Ξs | 0.1922 Ξs | 92.715 Ξs | -| GetRenkoAtr | 97.115 Ξs | 0.2640 Ξs | 0.2340 Ξs | 97.109 Ξs | -| GetRoc | 58.376 Ξs | 0.0813 Ξs | 0.0721 Ξs | 58.378 Ξs | -| GetRocWb | 77.738 Ξs | 0.1986 Ξs | 0.1857 Ξs | 77.695 Ξs | -| GetRocWithSma | 68.037 Ξs | 0.2058 Ξs | 0.1719 Ξs | 67.987 Ξs | -| GetRollingPivots | 337.463 Ξs | 0.6625 Ξs | 0.5873 Ξs | 337.428 Ξs | -| GetRsi | 51.189 Ξs | 0.1106 Ξs | 0.1035 Ξs | 51.233 Ξs | -| GetSlope | 90.432 Ξs | 0.1067 Ξs | 0.0891 Ξs | 90.453 Ξs | -| GetSma | 55.180 Ξs | 0.0809 Ξs | 0.0717 Ξs | 55.166 Ξs | -| GetSmaAnalysis | 78.865 Ξs | 0.2377 Ξs | 0.2224 Ξs | 78.806 Ξs | -| GetSmi | 63.542 Ξs | 0.2992 Ξs | 0.2799 Ξs | 63.493 Ξs | -| GetSmma | 49.599 Ξs | 0.1641 Ξs | 0.1370 Ξs | 49.628 Ξs | -| GetStarcBands | 109.124 Ξs | 0.2264 Ξs | 0.1767 Ξs | 109.061 Ξs | -| GetStc | 123.629 Ξs | 0.4272 Ξs | 0.3787 Ξs | 123.626 Ξs | -| GetStdDev | 102.272 Ξs | 0.2176 Ξs | 0.2035 Ξs | 102.199 Ξs | -| GetStdDevWithSma | 117.003 Ξs | 0.2509 Ξs | 0.2225 Ξs | 116.955 Ξs | -| GetStdDevChannels | 107.457 Ξs | 3.1051 Ξs | 9.1555 Ξs | 100.293 Ξs | -| GetStoch | 99.240 Ξs | 0.1936 Ξs | 0.1716 Ξs | 99.205 Ξs | -| GetStochSMMA | 83.248 Ξs | 0.2030 Ξs | 0.1585 Ξs | 83.232 Ξs | -| GetStochRsi | 112.795 Ξs | 0.2191 Ξs | 0.2049 Ξs | 112.787 Ξs | -| GetSuperTrend | 88.710 Ξs | 0.2540 Ξs | 0.2251 Ξs | 88.710 Ξs | -| GetT3 | 56.609 Ξs | 0.0885 Ξs | 0.0785 Ξs | 56.584 Ξs | -| GetTema | 51.801 Ξs | 0.1635 Ξs | 0.1530 Ξs | 51.750 Ξs | -| GetTr | 58.327 Ξs | 0.1389 Ξs | 0.1160 Ξs | 58.332 Ξs | -| GetTrix | 57.605 Ξs | 0.0856 Ξs | 0.0801 Ξs | 57.636 Ξs | -| GetTrixWithSma | 60.952 Ξs | 0.1461 Ξs | 0.1295 Ξs | 60.969 Ξs | -| GetTsi | 57.475 Ξs | 0.1275 Ξs | 0.1065 Ξs | 57.464 Ξs | -| GetUlcerIndex | 223.441 Ξs | 0.9974 Ξs | 0.9796 Ξs | 223.031 Ξs | -| GetUltimate | 85.577 Ξs | 0.2859 Ξs | 0.2232 Ξs | 85.546 Ξs | -| GetVolatilityStop | 104.920 Ξs | 1.6186 Ξs | 1.2637 Ξs | 104.525 Ξs | -| GetVortex | 69.805 Ξs | 0.1676 Ξs | 0.1485 Ξs | 69.825 Ξs | -| GetVwap | 59.109 Ξs | 0.1576 Ξs | 0.1397 Ξs | 59.096 Ξs | -| GetVwma | 71.345 Ξs | 0.2088 Ξs | 0.1954 Ξs | 71.267 Ξs | -| GetWilliamsR | 100.541 Ξs | 0.1775 Ξs | 0.1386 Ξs | 100.536 Ξs | -| GetWma | 62.707 Ξs | 0.1868 Ξs | 0.1656 Ξs | 62.660 Ξs | -| GetZigZag | 165.914 Ξs | 0.3932 Ξs | 0.3678 Ξs | 165.698 Ξs | +| Method | Mean | Error | StdDev | +|------------------- |----------:|-----------:|---------:| +| GetAdl | 34.89 Ξs | 2.409 Ξs | 0.132 Ξs | +| GetAdx | 42.48 Ξs | 2.417 Ξs | 0.132 Ξs | +| GetAlligator | 32.84 Ξs | 0.380 Ξs | 0.021 Ξs | +| GetAlma | 27.08 Ξs | 0.524 Ξs | 0.029 Ξs | +| GetAroon | 54.64 Ξs | 0.722 Ξs | 0.040 Ξs | +| GetAtr | 36.40 Ξs | 4.916 Ξs | 0.269 Ξs | +| GetAtrStop | 52.84 Ξs | 5.843 Ξs | 0.320 Ξs | +| GetAwesome | 48.42 Ξs | 0.809 Ξs | 0.044 Ξs | +| GetBeta | 164.01 Ξs | 23.671 Ξs | 1.297 Ξs | +| GetBetaUp | 128.36 Ξs | 8.187 Ξs | 0.449 Ξs | +| GetBetaDown | 133.49 Ξs | 5.559 Ξs | 0.305 Ξs | +| GetBetaAll | 357.86 Ξs | 10.892 Ξs | 0.597 Ξs | +| GetBollingerBands | 69.14 Ξs | 2.992 Ξs | 0.164 Ξs | +| GetBop | 37.33 Ξs | 3.893 Ξs | 0.213 Ξs | +| GetCci | 46.97 Ξs | 3.619 Ξs | 0.198 Ξs | +| GetChaikinOsc | 55.48 Ξs | 2.268 Ξs | 0.124 Ξs | +| GetChandelier | 53.86 Ξs | 6.396 Ξs | 0.351 Ξs | +| GetChop | 59.92 Ξs | 0.953 Ξs | 0.052 Ξs | +| GetCmf | 70.13 Ξs | 7.516 Ξs | 0.412 Ξs | +| GetCmo | 33.04 Ξs | 2.522 Ξs | 0.138 Ξs | +| GetConnorsRsi | 109.98 Ξs | 2.155 Ξs | 0.118 Ξs | +| GetCorrelation | 96.95 Ξs | 7.741 Ξs | 0.424 Ξs | +| GetDema | 22.99 Ξs | 1.052 Ξs | 0.058 Ξs | +| GetDoji | 69.18 Ξs | 5.349 Ξs | 0.293 Ξs | +| GetDonchian | 204.30 Ξs | 10.312 Ξs | 0.565 Ξs | +| GetDpo | 48.21 Ξs | 1.477 Ξs | 0.081 Ξs | +| GetDynamic | 39.30 Ξs | 1.816 Ξs | 0.100 Ξs | +| GetElderRay | 53.86 Ξs | 4.422 Ξs | 0.242 Ξs | +| GetEma | 22.31 Ξs | 1.314 Ξs | 0.072 Ξs | +| GetEpma | 55.52 Ξs | 3.782 Ξs | 0.207 Ξs | +| GetFcb | 217.82 Ξs | 6.294 Ξs | 0.345 Ξs | +| GetFisherTransform | 52.84 Ξs | 1.077 Ξs | 0.059 Ξs | +| GetForceIndex | 32.86 Ξs | 2.649 Ξs | 0.145 Ξs | +| GetFractal | 48.06 Ξs | 5.058 Ξs | 0.277 Ξs | +| GetGator | 59.64 Ξs | 9.488 Ξs | 0.520 Ξs | +| GetHeikinAshi | 109.37 Ξs | 1.923 Ξs | 0.105 Ξs | +| GetHma | 99.47 Ξs | 5.452 Ξs | 0.299 Ξs | +| GetHtTrendline | 84.69 Ξs | 18.501 Ξs | 1.014 Ξs | +| GetHurst | 838.65 Ξs | 127.955 Ξs | 7.014 Ξs | +| GetIchimoku | 640.07 Ξs | 44.858 Ξs | 2.459 Ξs | +| GetKama | 30.06 Ξs | 4.795 Ξs | 0.263 Ξs | +| GetKlinger | 43.21 Ξs | 2.307 Ξs | 0.126 Ξs | +| GetKeltner | 64.88 Ξs | 21.930 Ξs | 1.202 Ξs | +| GetKvo | 43.35 Ξs | 3.056 Ξs | 0.168 Ξs | +| GetMacd | 46.94 Ξs | 4.013 Ξs | 0.220 Ξs | +| GetMaEnvelopes | 43.99 Ξs | 1.648 Ξs | 0.090 Ξs | +| GetMama | 75.49 Ξs | 1.308 Ξs | 0.072 Ξs | +| GetMarubozu | 78.81 Ξs | 3.513 Ξs | 0.193 Ξs | +| GetMfi | 43.31 Ξs | 1.323 Ξs | 0.073 Ξs | +| GetObv | 33.07 Ξs | 1.152 Ξs | 0.063 Ξs | +| GetObvWithSma | 42.54 Ξs | 1.500 Ξs | 0.082 Ξs | +| GetParabolicSar | 36.18 Ξs | 0.569 Ξs | 0.031 Ξs | +| GetPivotPoints | 45.84 Ξs | 2.456 Ξs | 0.135 Ξs | +| GetPivots | 87.39 Ξs | 1.025 Ξs | 0.056 Ξs | +| GetPmo | 39.11 Ξs | 1.240 Ξs | 0.068 Ξs | +| GetPrs | 40.60 Ξs | 2.618 Ξs | 0.144 Ξs | +| GetPrsWithSma | 43.07 Ξs | 1.737 Ξs | 0.095 Ξs | +| GetPvo | 44.81 Ξs | 2.604 Ξs | 0.143 Ξs | +| GetRenko | 59.82 Ξs | 3.289 Ξs | 0.180 Ξs | +| GetRenkoAtr | 67.58 Ξs | 24.816 Ξs | 1.360 Ξs | +| GetRoc | 24.04 Ξs | 1.218 Ξs | 0.067 Ξs | +| GetRocWb | 40.13 Ξs | 3.526 Ξs | 0.193 Ξs | +| GetRocWithSma | 30.52 Ξs | 2.540 Ξs | 0.139 Ξs | +| GetRollingPivots | 243.31 Ξs | 37.635 Ξs | 2.063 Ξs | +| GetRsi | 25.91 Ξs | 0.812 Ξs | 0.044 Ξs | +| GetSlope | 56.35 Ξs | 9.701 Ξs | 0.532 Ξs | +| GetSma | 24.90 Ξs | 2.631 Ξs | 0.144 Ξs | +| GetSmaAnalysis | 42.43 Ξs | 0.780 Ξs | 0.043 Ξs | +| GetSmi | 37.50 Ξs | 1.633 Ξs | 0.089 Ξs | +| GetSmma | 23.26 Ξs | 2.726 Ξs | 0.149 Ξs | +| GetStarcBands | 71.22 Ξs | 27.014 Ξs | 1.481 Ξs | +| GetStc | 82.32 Ξs | 4.596 Ξs | 0.252 Ξs | +| GetStdDev | 71.29 Ξs | 1.644 Ξs | 0.090 Ξs | +| GetStdDevWithSma | 76.73 Ξs | 1.728 Ξs | 0.095 Ξs | +| GetStdDevChannels | 66.38 Ξs | 8.307 Ξs | 0.455 Ξs | +| GetStoch | 51.89 Ξs | 3.650 Ξs | 0.200 Ξs | +| GetStochSMMA | 50.08 Ξs | 3.252 Ξs | 0.178 Ξs | +| GetStochRsi | 61.82 Ξs | 3.847 Ξs | 0.211 Ξs | +| GetSuperTrend | 54.21 Ξs | 11.806 Ξs | 0.647 Ξs | +| GetT3 | 26.51 Ξs | 0.176 Ξs | 0.010 Ξs | +| GetTema | 23.74 Ξs | 1.415 Ξs | 0.078 Ξs | +| GetTr | 33.63 Ξs | 5.232 Ξs | 0.287 Ξs | +| GetTrix | 26.56 Ξs | 1.217 Ξs | 0.067 Ξs | +| GetTrixWithSma | 30.39 Ξs | 1.462 Ξs | 0.080 Ξs | +| GetTsi | 29.67 Ξs | 6.213 Ξs | 0.341 Ξs | +| GetUlcerIndex | 95.21 Ξs | 2.543 Ξs | 0.139 Ξs | +| GetUltimate | 58.52 Ξs | 2.435 Ξs | 0.133 Ξs | +| GetVolatilityStop | 61.17 Ξs | 22.487 Ξs | 1.233 Ξs | +| GetVortex | 43.12 Ξs | 1.817 Ξs | 0.100 Ξs | +| GetVwap | 33.56 Ξs | 1.656 Ξs | 0.091 Ξs | +| GetVwma | 42.38 Ξs | 1.098 Ξs | 0.060 Ξs | +| GetWilliamsR | 52.27 Ξs | 0.135 Ξs | 0.007 Ξs | +| GetWma | 31.98 Ξs | 2.411 Ξs | 0.132 Ξs | +| GetZigZag | 99.35 Ξs | 5.101 Ξs | 0.280 Ξs | diff --git a/src/Indicators.csproj b/src/Indicators.csproj index 77a2751c7..3d4896b3b 100644 --- a/src/Indicators.csproj +++ b/src/Indicators.csproj @@ -1,8 +1,8 @@ - net8.0;net6.0 - 12.0 + net9.0;net8.0;net6.0 + 13.0 Dave Skender Stock Indicators for .NET diff --git a/src/_common/Math/Numerical.cs b/src/_common/Math/Numerical.cs index 30a7a1a6b..f55dcf473 100644 --- a/src/_common/Math/Numerical.cs +++ b/src/_common/Math/Numerical.cs @@ -1,5 +1,7 @@ namespace Skender.Stock.Indicators; +#pragma warning disable IDE0072 // Missing cases in switch statement + /// /// Provides numerical utility methods. /// @@ -126,6 +128,7 @@ internal static TimeSpan ToTimeSpan(this PeriodSize periodSize) PeriodSize.FourHours => TimeSpan.FromHours(4), PeriodSize.Day => TimeSpan.FromDays(1), PeriodSize.Week => TimeSpan.FromDays(7), + // intentionally skipping Month _ => TimeSpan.Zero }; diff --git a/src/_common/Observables/StreamHub.cs b/src/_common/Observables/StreamHub.cs index 62f419350..5f9ae3a89 100644 --- a/src/_common/Observables/StreamHub.cs +++ b/src/_common/Observables/StreamHub.cs @@ -1,5 +1,7 @@ namespace Skender.Stock.Indicators; +#pragma warning disable IDE0010 // Missing cases in switch expression + // STREAM HUB (BASE/CACHE) /// diff --git a/src/_common/Use (QuotePart)/QuotePart.StaticSeries.cs b/src/_common/Use (QuotePart)/QuotePart.StaticSeries.cs index be46657c7..c564fc344 100644 --- a/src/_common/Use (QuotePart)/QuotePart.StaticSeries.cs +++ b/src/_common/Use (QuotePart)/QuotePart.StaticSeries.cs @@ -30,6 +30,7 @@ public static IReadOnlyList ToQuotePart( { result.Add(quotes[i].ToQuotePart(candlePart)); } + return result; } diff --git a/src/_common/Use (QuotePart)/QuotePart.Utilities.cs b/src/_common/Use (QuotePart)/QuotePart.Utilities.cs index 487cc7173..13b8fa3dd 100644 --- a/src/_common/Use (QuotePart)/QuotePart.Utilities.cs +++ b/src/_common/Use (QuotePart)/QuotePart.Utilities.cs @@ -66,13 +66,12 @@ internal static IReadOnlyList ToPreferredList( { ArgumentNullException.ThrowIfNull(items); - if (items is IReadOnlyList quotes) - { - return quotes.ToQuotePart(candlePart); - } - else - { - return items.Cast().ToList(); - } + return items is IReadOnlyList quotes + + ? quotes.ToQuotePart(candlePart) + + : (IReadOnlyList)items + .Cast() + .ToList(); } } diff --git a/src/a-d/Adx/Adx.StaticSeries.cs b/src/a-d/Adx/Adx.StaticSeries.cs index 177da87e9..8cb232ad5 100644 --- a/src/a-d/Adx/Adx.StaticSeries.cs +++ b/src/a-d/Adx/Adx.StaticSeries.cs @@ -26,7 +26,7 @@ public static IReadOnlyList ToAdx( /// The number of periods to look back for the ADX calculation. /// A list of ADX results. private static List CalcAdx( - this IReadOnlyList source, + this List source, int lookbackPeriods = 14) { // check parameter arguments diff --git a/src/a-d/Aroon/Aroon.StaticSeries.cs b/src/a-d/Aroon/Aroon.StaticSeries.cs index c06a150de..7e5a5a1de 100644 --- a/src/a-d/Aroon/Aroon.StaticSeries.cs +++ b/src/a-d/Aroon/Aroon.StaticSeries.cs @@ -26,7 +26,7 @@ public static IReadOnlyList ToAroon( /// The number of periods to look back. /// A list of Aroon results. private static List CalcAroon( - this IReadOnlyList source, + this List source, int lookbackPeriods) { // check parameter arguments diff --git a/src/a-d/Atr/Atr.StaticSeries.cs b/src/a-d/Atr/Atr.StaticSeries.cs index 3223af8c6..7a7756625 100644 --- a/src/a-d/Atr/Atr.StaticSeries.cs +++ b/src/a-d/Atr/Atr.StaticSeries.cs @@ -27,7 +27,7 @@ public static IReadOnlyList ToAtr( /// The number of periods to look back for ATR calculation. /// A list of ATR results. internal static List CalcAtr( - this IReadOnlyList source, + this List source, int lookbackPeriods) { // check parameter arguments diff --git a/src/a-d/AtrStop/AtrStop.StaticSeries.cs b/src/a-d/AtrStop/AtrStop.StaticSeries.cs index abcb8e033..00593a8d6 100644 --- a/src/a-d/AtrStop/AtrStop.StaticSeries.cs +++ b/src/a-d/AtrStop/AtrStop.StaticSeries.cs @@ -32,7 +32,7 @@ public static IReadOnlyList ToAtrStop( /// The type of price to use for the calculation. /// A list of ATR Trailing Stop results. private static List CalcAtrStop( - this IReadOnlyList source, + this List source, int lookbackPeriods, double multiplier, EndType endType) diff --git a/src/a-d/Bop/Bop.StaticSeries.cs b/src/a-d/Bop/Bop.StaticSeries.cs index 447a538b0..0c4dc1edf 100644 --- a/src/a-d/Bop/Bop.StaticSeries.cs +++ b/src/a-d/Bop/Bop.StaticSeries.cs @@ -26,7 +26,7 @@ public static IReadOnlyList ToBop( /// The number of periods to use for smoothing. /// A list of containing the BOP calculation results. private static List CalcBop( - this IReadOnlyList source, + this List source, int smoothPeriods) { // check parameter arguments diff --git a/src/a-d/Cci/Cci.StaticSeries.cs b/src/a-d/Cci/Cci.StaticSeries.cs index cea770a61..d4042cb00 100644 --- a/src/a-d/Cci/Cci.StaticSeries.cs +++ b/src/a-d/Cci/Cci.StaticSeries.cs @@ -26,7 +26,7 @@ public static IReadOnlyList ToCci( /// The number of periods to use for the lookback window. /// A list of containing the CCI calculation results. private static List CalcCci( - this IReadOnlyList source, + this List source, int lookbackPeriods) { // check parameter arguments diff --git a/src/a-d/Chandelier/Chandelier.StaticSeries.cs b/src/a-d/Chandelier/Chandelier.StaticSeries.cs index 4aa7190ec..8d90b0d13 100644 --- a/src/a-d/Chandelier/Chandelier.StaticSeries.cs +++ b/src/a-d/Chandelier/Chandelier.StaticSeries.cs @@ -32,7 +32,7 @@ public static IReadOnlyList ToChandelier( /// The type of Chandelier Exit to calculate (Long or Short). /// A list of containing the Chandelier Exit calculation results. private static List CalcChandelier( - this IReadOnlyList source, + this List source, int lookbackPeriods, double multiplier, ChandelierType type) @@ -44,7 +44,7 @@ private static List CalcChandelier( int length = source.Count; List results = new(length); - IReadOnlyList atrResult + List atrResult = source.CalcAtr(lookbackPeriods); // roll through source values diff --git a/src/a-d/Chop/Chop.StaticSeries.cs b/src/a-d/Chop/Chop.StaticSeries.cs index 08ef400db..b4c75ced2 100644 --- a/src/a-d/Chop/Chop.StaticSeries.cs +++ b/src/a-d/Chop/Chop.StaticSeries.cs @@ -26,7 +26,7 @@ public static IReadOnlyList ToChop( /// The number of periods to use for the lookback window. /// A list of containing the CHOP calculation results. private static List CalcChop( - this IReadOnlyList source, + this List source, int lookbackPeriods) { // check parameter arguments diff --git a/src/a-d/ConnorsRsi/ConnorsRsi.StaticSeries.cs b/src/a-d/ConnorsRsi/ConnorsRsi.StaticSeries.cs index 232fee056..61f2807b1 100644 --- a/src/a-d/ConnorsRsi/ConnorsRsi.StaticSeries.cs +++ b/src/a-d/ConnorsRsi/ConnorsRsi.StaticSeries.cs @@ -32,7 +32,7 @@ public static IReadOnlyList ToConnorsRsi( int startPeriod = Math.Max(rsiPeriods, Math.Max(streakPeriods, rankPeriods)) + 2; - IReadOnlyList streakInfo + List streakInfo = source.CalcStreak(rsiPeriods, rankPeriods); // RSI of streak diff --git a/src/a-d/Correlation/Correlation.StaticSeries.cs b/src/a-d/Correlation/Correlation.StaticSeries.cs index ea240eb8f..fe17eac94 100644 --- a/src/a-d/Correlation/Correlation.StaticSeries.cs +++ b/src/a-d/Correlation/Correlation.StaticSeries.cs @@ -111,9 +111,9 @@ internal static CorrResult PeriodCorrelation( double avgB2 = sumB2 / length; double avgAb = sumAb / length; - double varA = avgA2 - avgA * avgA; - double varB = avgB2 - avgB * avgB; - double cov = avgAb - avgA * avgB; + double varA = avgA2 - (avgA * avgA); + double varB = avgB2 - (avgB * avgB); + double cov = avgAb - (avgA * avgB); double divisor = Math.Sqrt(varA * varB); double? corr = divisor == 0 diff --git a/src/a-d/Dema/Dema.Utilities.cs b/src/a-d/Dema/Dema.Utilities.cs index 32e4c3c68..aab6aa415 100644 --- a/src/a-d/Dema/Dema.Utilities.cs +++ b/src/a-d/Dema/Dema.Utilities.cs @@ -17,7 +17,7 @@ public static IReadOnlyList RemoveWarmupPeriods( .ToList() .FindIndex(x => x.Dema != null) + 1; - return results.Remove(2 * n + 100); + return results.Remove((2 * n) + 100); } /// diff --git a/src/e-k/ElderRay/ElderRay.StaticSeries.cs b/src/e-k/ElderRay/ElderRay.StaticSeries.cs index 8378ea384..e4dcf1158 100644 --- a/src/e-k/ElderRay/ElderRay.StaticSeries.cs +++ b/src/e-k/ElderRay/ElderRay.StaticSeries.cs @@ -28,7 +28,7 @@ public static IReadOnlyList ToElderRay( /// The number of periods to look back for the calculation. /// A list of Elder Ray results. private static List CalcElderRay( - this IReadOnlyList source, + this List source, int lookbackPeriods) { // check parameter arguments diff --git a/src/e-k/Ema/Ema.Utilities.cs b/src/e-k/Ema/Ema.Utilities.cs index 67f29dc96..e8ce233fb 100644 --- a/src/e-k/Ema/Ema.Utilities.cs +++ b/src/e-k/Ema/Ema.Utilities.cs @@ -16,7 +16,7 @@ public static double Increment( double k, double lastEma, double newPrice) - => lastEma + k * (newPrice - lastEma); + => lastEma + (k * (newPrice - lastEma)); /// /// Increments the EMA value using the lookback periods. @@ -45,7 +45,7 @@ public static double Increment( double k, double? lastEma, double newPrice) - => lastEma + k * (newPrice - lastEma); + => lastEma + (k * (newPrice - lastEma)); /// /// Removes the recommended warmup periods from the EMA results. diff --git a/src/e-k/ForceIndex/ForceIndex.StaticSeries.cs b/src/e-k/ForceIndex/ForceIndex.StaticSeries.cs index 7803f1baf..f0dd087ba 100644 --- a/src/e-k/ForceIndex/ForceIndex.StaticSeries.cs +++ b/src/e-k/ForceIndex/ForceIndex.StaticSeries.cs @@ -30,7 +30,7 @@ public static IReadOnlyList ToForceIndex( /// Thrown when the source list is null. /// Thrown when the lookback periods are invalid. private static List CalcForceIndex( - this IReadOnlyList source, + this List source, int lookbackPeriods) { // check parameter arguments diff --git a/src/e-k/Hurst/Hurst.StaticSeries.cs b/src/e-k/Hurst/Hurst.StaticSeries.cs index c79c7d8d3..3bb286804 100644 --- a/src/e-k/Hurst/Hurst.StaticSeries.cs +++ b/src/e-k/Hurst/Hurst.StaticSeries.cs @@ -46,7 +46,7 @@ public static IReadOnlyList ToHurst( T ps = source[p]; // return values - values[x] = l != 0 ? ps.Value / l - 1 : double.NaN; + values[x] = l != 0 ? (ps.Value / l) - 1 : double.NaN; l = ps.Value; x++; @@ -105,7 +105,7 @@ private static double CalcHurstWindow(double[] values) // starting index position used to skip // observations to enforce same-sized chunks - int startIndex = totalSize - chunkSize * chunkQty; + int startIndex = totalSize - (chunkSize * chunkQty); // analyze chunks in set for (int chunkNum = 1; chunkNum <= chunkQty; chunkNum++) diff --git a/src/e-k/Keltner/Keltner.StaticSeries.cs b/src/e-k/Keltner/Keltner.StaticSeries.cs index 9c617636d..f5c09424c 100644 --- a/src/e-k/Keltner/Keltner.StaticSeries.cs +++ b/src/e-k/Keltner/Keltner.StaticSeries.cs @@ -33,7 +33,7 @@ public static IReadOnlyList ToKeltner( /// The number of periods for the ATR. /// A list of Keltner Channel results. private static List CalcKeltner( - this IReadOnlyList source, + this List source, int emaPeriods, double multiplier, int atrPeriods) @@ -48,7 +48,7 @@ private static List CalcKeltner( IReadOnlyList emaResults = source.ToEma(emaPeriods); - IReadOnlyList atrResults + List atrResults = source.CalcAtr(atrPeriods); int lookbackPeriods = Math.Max(emaPeriods, atrPeriods); diff --git a/src/e-k/Kvo/Kvo.StaticSeries.cs b/src/e-k/Kvo/Kvo.StaticSeries.cs index e50ab3b37..dc5b6eaed 100644 --- a/src/e-k/Kvo/Kvo.StaticSeries.cs +++ b/src/e-k/Kvo/Kvo.StaticSeries.cs @@ -33,7 +33,7 @@ public static IReadOnlyList ToKvo( /// The number of periods for the signal line. /// A list of KVO results. private static List CalcKvo( - this IReadOnlyList source, + this List source, int fastPeriods, int slowPeriods, int signalPeriods) diff --git a/src/m-r/MaEnvelopes/MaEnvelopes.StaticSeries.cs b/src/m-r/MaEnvelopes/MaEnvelopes.StaticSeries.cs index 3c068db21..8b173392c 100644 --- a/src/m-r/MaEnvelopes/MaEnvelopes.StaticSeries.cs +++ b/src/m-r/MaEnvelopes/MaEnvelopes.StaticSeries.cs @@ -2,6 +2,8 @@ namespace Skender.Stock.Indicators; +#pragma warning disable IDE0072 // Missing cases in switch statement + /// /// Provides methods for calculating Moving Average Envelopes for a series of quotes. /// @@ -49,7 +51,7 @@ public static IReadOnlyList ToMaEnvelopes( string.Format( CultureInfo.InvariantCulture, "Moving Average Envelopes does not support {0}.", - Enum.GetName(typeof(MaType), movingAverageType))) + Enum.GetName(movingAverageType))) }; return results.ToList(); diff --git a/src/m-r/Mfi/Mfi.StaticSeries.cs b/src/m-r/Mfi/Mfi.StaticSeries.cs index cb52a3dd6..dff8503a5 100644 --- a/src/m-r/Mfi/Mfi.StaticSeries.cs +++ b/src/m-r/Mfi/Mfi.StaticSeries.cs @@ -28,7 +28,7 @@ public static IReadOnlyList ToMfi( /// The number of periods to use for the MFI calculation. /// A list of containing the MFI values. private static List CalcMfi( - this IReadOnlyList source, + this List source, int lookbackPeriods) { // check parameter arguments @@ -92,7 +92,7 @@ private static List CalcMfi( if (sumNegMFs != 0) { double mfRatio = sumPosMFs / sumNegMFs; - mfi = 100 - 100 / (1 + mfRatio); + mfi = 100 - (100 / (1 + mfRatio)); } // handle no negative case diff --git a/src/m-r/Obv/Obv.StaticSeries.cs b/src/m-r/Obv/Obv.StaticSeries.cs index 0c68de5c4..beda06744 100644 --- a/src/m-r/Obv/Obv.StaticSeries.cs +++ b/src/m-r/Obv/Obv.StaticSeries.cs @@ -23,7 +23,7 @@ public static IReadOnlyList ToObv( /// The list of quotes. /// A list of OBV results. private static List CalcObv( - this IReadOnlyList source) + this List source) { // initialize int length = source.Count; diff --git a/src/m-r/ParabolicSar/ParabolicSar.StaticSeries.cs b/src/m-r/ParabolicSar/ParabolicSar.StaticSeries.cs index d6d1c465f..b9c936f15 100644 --- a/src/m-r/ParabolicSar/ParabolicSar.StaticSeries.cs +++ b/src/m-r/ParabolicSar/ParabolicSar.StaticSeries.cs @@ -58,7 +58,7 @@ public static IReadOnlyList GetParabolicSar( /// The initial acceleration factor for the SAR calculation. /// A list of containing the SAR values. private static List CalcParabolicSar( - this IReadOnlyList source, + this List source, double accelerationStep, double maxAccelerationFactor, double initialFactor) diff --git a/src/m-r/PivotPoints/PivotPoints.StaticSeries.cs b/src/m-r/PivotPoints/PivotPoints.StaticSeries.cs index 04b2021e9..0c9c2bc07 100644 --- a/src/m-r/PivotPoints/PivotPoints.StaticSeries.cs +++ b/src/m-r/PivotPoints/PivotPoints.StaticSeries.cs @@ -1,5 +1,7 @@ namespace Skender.Stock.Indicators; +#pragma warning disable IDE0072 // Missing cases in switch statement + /// /// Provides methods for calculating pivot points from a series of quotes. /// @@ -138,6 +140,7 @@ internal static WindowPoint GetPivotPoint( /// The size of the window. /// The window number. private static int GetWindowNumber(DateTime d, PeriodSize windowSize) + => windowSize switch { PeriodSize.Month => d.Month, @@ -152,9 +155,9 @@ private static int GetWindowNumber(DateTime d, PeriodSize windowSize) nameof(windowSize), windowSize, string.Format( invariantCulture, - "Pivot Points does not support PeriodSize of {0}. " + - "See documentation for valid options.", - Enum.GetName(typeof(PeriodSize), windowSize))) + "Pivot Points does not support PeriodSize of {0}. " + + "See documentation for valid options.", + Enum.GetName(windowSize))) }; /// diff --git a/src/m-r/Pivots/Pivots.StaticSeries.cs b/src/m-r/Pivots/Pivots.StaticSeries.cs index 88adfefa3..82fe7e67f 100644 --- a/src/m-r/Pivots/Pivots.StaticSeries.cs +++ b/src/m-r/Pivots/Pivots.StaticSeries.cs @@ -37,7 +37,7 @@ public static IReadOnlyList ToPivots( decimal?[] lowLine = new decimal?[length]; PivotTrend?[] lowTrend = new PivotTrend?[length]; - IReadOnlyList<(decimal? highPoint, decimal? lowPoint)> fractals + List<(decimal? highPoint, decimal? lowPoint)> fractals = quotes .ToFractal(leftSpan, rightSpan, endType) .Select(f => (f.FractalBear, f.FractalBull)) @@ -84,7 +84,7 @@ public static IReadOnlyList ToPivots( for (int t = (int)lastHighIndex + 1; t <= i; t++) { highTrend[t] = trend; - highLine[t] = highPoint + incr * (t - i); + highLine[t] = highPoint + (incr * (t - i)); } } @@ -111,7 +111,7 @@ public static IReadOnlyList ToPivots( for (int t = (int)lastLowIndex + 1; t <= i; t++) { lowTrend[t] = trend; - lowLine[t] = lowPoint + incr * (t - i); + lowLine[t] = lowPoint + (incr * (t - i)); } } diff --git a/src/m-r/Pmo/Pmo.StaticSeries.cs b/src/m-r/Pmo/Pmo.StaticSeries.cs index 7ae23d266..0c4de006c 100644 --- a/src/m-r/Pmo/Pmo.StaticSeries.cs +++ b/src/m-r/Pmo/Pmo.StaticSeries.cs @@ -61,6 +61,7 @@ public static IReadOnlyList ToPmo( { sum += rc[p]; } + rocEma = sum / timePeriods; } else @@ -81,6 +82,7 @@ public static IReadOnlyList ToPmo( { sum += re[p]; } + pmo = sum / smoothPeriods; } else diff --git a/src/m-r/Rsi/Rsi.StaticSeries.cs b/src/m-r/Rsi/Rsi.StaticSeries.cs index 265e8db5d..1dd976e1f 100644 --- a/src/m-r/Rsi/Rsi.StaticSeries.cs +++ b/src/m-r/Rsi/Rsi.StaticSeries.cs @@ -72,20 +72,20 @@ public static IReadOnlyList ToRsi( avgLoss = sumLoss / lookbackPeriods; rsi = !double.IsNaN(avgGain / avgLoss) - ? avgLoss > 0 ? 100 - 100 / (1 + avgGain / avgLoss) : 100 + ? avgLoss > 0 ? 100 - (100 / (1 + (avgGain / avgLoss))) : 100 : null; } // calculate RSI normally else if (i > lookbackPeriods) { - avgGain = (avgGain * (lookbackPeriods - 1) + gain[i]) / lookbackPeriods; - avgLoss = (avgLoss * (lookbackPeriods - 1) + loss[i]) / lookbackPeriods; + avgGain = ((avgGain * (lookbackPeriods - 1)) + gain[i]) / lookbackPeriods; + avgLoss = ((avgLoss * (lookbackPeriods - 1)) + loss[i]) / lookbackPeriods; if (avgLoss > 0) { double rs = avgGain / avgLoss; - rsi = 100 - 100 / (1 + rs); + rsi = 100 - (100 / (1 + rs)); } else { diff --git a/src/s-z/Sma/Sma.Utilities.cs b/src/s-z/Sma/Sma.Utilities.cs index 7792a9b1c..2fa961f49 100644 --- a/src/s-z/Sma/Sma.Utilities.cs +++ b/src/s-z/Sma/Sma.Utilities.cs @@ -93,6 +93,7 @@ internal static double[] Increment(this double[] prices, int period) { sum += prices[i + j]; } + sum += Vector.Dot(sumVector, Vector.One); sma[i] = sum / period; diff --git a/src/s-z/Smi/Smi.StaticSeries.cs b/src/s-z/Smi/Smi.StaticSeries.cs index 2856f4549..411cba077 100644 --- a/src/s-z/Smi/Smi.StaticSeries.cs +++ b/src/s-z/Smi/Smi.StaticSeries.cs @@ -39,7 +39,7 @@ public static IReadOnlyList ToSmi( /// The number of periods for the signal line smoothing. /// A list of SMI results. private static List CalcSmi( - this IReadOnlyList source, + this List source, int lookbackPeriods, int firstSmoothPeriods, int secondSmoothPeriods, @@ -94,7 +94,7 @@ private static List CalcSmi( } } - double sm = q.Close - 0.5d * (hH + lL); + double sm = q.Close - (0.5d * (hH + lL)); double hl = hH - lL; // initialize last EMA values @@ -108,12 +108,12 @@ private static List CalcSmi( } // first smoothing - double smEma1 = lastSmEma1 + k1 * (sm - lastSmEma1); - double hlEma1 = lastHlEma1 + k1 * (hl - lastHlEma1); + double smEma1 = lastSmEma1 + (k1 * (sm - lastSmEma1)); + double hlEma1 = lastHlEma1 + (k1 * (hl - lastHlEma1)); // second smoothing - double smEma2 = lastSmEma2 + k2 * (smEma1 - lastSmEma2); - double hlEma2 = lastHlEma2 + k2 * (hlEma1 - lastHlEma2); + double smEma2 = lastSmEma2 + (k2 * (smEma1 - lastSmEma2)); + double hlEma2 = lastHlEma2 + (k2 * (hlEma1 - lastHlEma2)); // stochastic momentum index smi = 100 * (smEma2 / (0.5 * hlEma2)); @@ -126,7 +126,7 @@ private static List CalcSmi( } // signal line - signal = lastSignal + kS * (smi - lastSignal); + signal = lastSignal + (kS * (smi - lastSignal)); // carryover values lastSmEma1 = smEma1; diff --git a/src/s-z/StarcBands/StarcBands.StaticSeries.cs b/src/s-z/StarcBands/StarcBands.StaticSeries.cs index df5a21f4e..89900f95f 100644 --- a/src/s-z/StarcBands/StarcBands.StaticSeries.cs +++ b/src/s-z/StarcBands/StarcBands.StaticSeries.cs @@ -32,7 +32,7 @@ public static IReadOnlyList ToStarcBands( /// The number of periods for the ATR calculation. /// A list of containing the STARC Bands values. private static List CalcStarcBands( - this IReadOnlyList source, + this List source, int smaPeriods, double multiplier, int atrPeriods) diff --git a/src/s-z/Stc/Stc.StaticSeries.cs b/src/s-z/Stc/Stc.StaticSeries.cs index 266c69ad9..8a19a9c5c 100644 --- a/src/s-z/Stc/Stc.StaticSeries.cs +++ b/src/s-z/Stc/Stc.StaticSeries.cs @@ -32,7 +32,7 @@ public static IReadOnlyList ToStc( List results = new(length); // get stochastic of macd - IReadOnlyList stochMacd = source + List stochMacd = source .ToMacd(fastPeriods, slowPeriods, 1) .Select(x => new QuoteD( x.Timestamp, 0, diff --git a/src/s-z/Stoch/Stoch.StaticSeries.cs b/src/s-z/Stoch/Stoch.StaticSeries.cs index d99c58f10..30ffd03b7 100644 --- a/src/s-z/Stoch/Stoch.StaticSeries.cs +++ b/src/s-z/Stoch/Stoch.StaticSeries.cs @@ -1,5 +1,7 @@ namespace Skender.Stock.Indicators; +#pragma warning disable IDE0010 // Missing cases in switch expression + /// /// Provides methods for calculating the Stochastic Oscillator. /// @@ -68,7 +70,7 @@ public static IReadOnlyList ToStoch( /// The type of moving average to use. /// A list of StochResult containing the oscillator values. internal static List CalcStoch( - this IReadOnlyList source, + this List source, int lookbackPeriods, int signalPeriods, int smoothPeriods, @@ -244,6 +246,7 @@ internal static List CalcStoch( Signal: signal.NaN2Null(), PercentJ: ((kFactor * oscillator) - (dFactor * signal)).NaN2Null())); } + return results; } } diff --git a/src/s-z/SuperTrend/SuperTrend.StaticSeries.cs b/src/s-z/SuperTrend/SuperTrend.StaticSeries.cs index b84ab9717..f695291a8 100644 --- a/src/s-z/SuperTrend/SuperTrend.StaticSeries.cs +++ b/src/s-z/SuperTrend/SuperTrend.StaticSeries.cs @@ -29,7 +29,7 @@ public static IReadOnlyList ToSuperTrend( /// The multiplier for the ATR. /// A list of SuperTrend results. private static List CalcSuperTrend( - this IReadOnlyList source, + this List source, int lookbackPeriods, double multiplier) { @@ -61,8 +61,8 @@ private static List CalcSuperTrend( double? prevClose = source[i - 1].Close; // potential bands - double? upperEval = mid + multiplier * atr; - double? lowerEval = mid - multiplier * atr; + double? upperEval = mid + (multiplier * atr); + double? lowerEval = mid - (multiplier * atr); // initial values if (i == lookbackPeriods) diff --git a/src/s-z/T3/T3.StaticSeries.cs b/src/s-z/T3/T3.StaticSeries.cs index c11f21d83..e0671673c 100644 --- a/src/s-z/T3/T3.StaticSeries.cs +++ b/src/s-z/T3/T3.StaticSeries.cs @@ -32,9 +32,9 @@ public static IReadOnlyList ToT3( double a = volumeFactor; double c1 = -a * a * a; - double c2 = 3 * a * a + 3 * a * a * a; - double c3 = -6 * a * a - 3 * a - 3 * a * a * a; - double c4 = 1 + 3 * a + a * a * a + 3 * a * a; + double c2 = (3 * a * a) + (3 * a * a * a); + double c3 = (-6 * a * a) - (3 * a) - (3 * a * a * a); + double c4 = 1 + (3 * a) + (a * a * a) + (3 * a * a); double e1 = double.NaN; double e2 = double.NaN; @@ -65,7 +65,7 @@ public static IReadOnlyList ToT3( // T3 moving average results.Add(new( Timestamp: s.Timestamp, - T3: (c1 * e6 + c2 * e5 + c3 * e4 + c4 * e3).NaN2Null())); + T3: ((c1 * e6) + (c2 * e5) + (c3 * e4) + (c4 * e3)).NaN2Null())); } return results; diff --git a/src/s-z/Tema/Tema.Utilities.cs b/src/s-z/Tema/Tema.Utilities.cs index d497fe72e..b19f9ec68 100644 --- a/src/s-z/Tema/Tema.Utilities.cs +++ b/src/s-z/Tema/Tema.Utilities.cs @@ -17,7 +17,7 @@ public static IReadOnlyList RemoveWarmupPeriods( .ToList() .FindIndex(x => x.Tema != null) + 1; - return results.Remove(3 * n + 100); + return results.Remove((3 * n) + 100); } /// diff --git a/src/s-z/Tr/Tr.StaticSeries.cs b/src/s-z/Tr/Tr.StaticSeries.cs index 738b93000..56420639c 100644 --- a/src/s-z/Tr/Tr.StaticSeries.cs +++ b/src/s-z/Tr/Tr.StaticSeries.cs @@ -23,7 +23,7 @@ public static IReadOnlyList ToTr( /// The list of quotes. /// A list of True Range (TR) results. private static List CalcTr( - this IReadOnlyList source) + this List source) { // initialize int length = source.Count; diff --git a/src/s-z/Trix/Trix.Utilities.cs b/src/s-z/Trix/Trix.Utilities.cs index 268b89d7b..2f8d76cd9 100644 --- a/src/s-z/Trix/Trix.Utilities.cs +++ b/src/s-z/Trix/Trix.Utilities.cs @@ -17,7 +17,7 @@ public static IReadOnlyList RemoveWarmupPeriods( .ToList() .FindIndex(x => x.Trix != null); - return results.Remove(3 * n + 100); + return results.Remove((3 * n) + 100); } /// diff --git a/src/s-z/Ultimate/Ultimate.StaticSeries.cs b/src/s-z/Ultimate/Ultimate.StaticSeries.cs index d07ce18ba..ef52ffa02 100644 --- a/src/s-z/Ultimate/Ultimate.StaticSeries.cs +++ b/src/s-z/Ultimate/Ultimate.StaticSeries.cs @@ -33,7 +33,7 @@ public static IReadOnlyList ToUltimate( /// The number of long lookback periods. /// A list of UltimateResult containing the Ultimate Oscillator values. private static List CalcUltimate( - this IReadOnlyList source, + this List source, int shortPeriods, int middlePeriods, int longPeriods) @@ -98,7 +98,7 @@ private static List CalcUltimate( double avg2 = sumTr2 == 0 ? double.NaN : sumBp2 / sumTr2; double avg3 = sumTr3 == 0 ? double.NaN : sumBp3 / sumTr3; - ultimate = (100d * (4d * avg1 + 2d * avg2 + avg3) / 7d).NaN2Null(); + ultimate = (100d * ((4d * avg1) + (2d * avg2) + avg3) / 7d).NaN2Null(); } else { diff --git a/src/s-z/VolatilityStop/VolatilityStop.StaticSeries.cs b/src/s-z/VolatilityStop/VolatilityStop.StaticSeries.cs index 4dc7fd302..103671f02 100644 --- a/src/s-z/VolatilityStop/VolatilityStop.StaticSeries.cs +++ b/src/s-z/VolatilityStop/VolatilityStop.StaticSeries.cs @@ -30,7 +30,7 @@ public static IReadOnlyList ToVolatilityStop( /// The multiplier for the Average True Range. /// A list of VolatilityStopResult containing the Volatility Stop values. private static List CalcVolatilityStop( - this IReadOnlyList source, + this List source, int lookbackPeriods, double multiplier) { diff --git a/src/s-z/Vortex/Vortex.StaticSeries.cs b/src/s-z/Vortex/Vortex.StaticSeries.cs index 41fd22df1..489530f8b 100644 --- a/src/s-z/Vortex/Vortex.StaticSeries.cs +++ b/src/s-z/Vortex/Vortex.StaticSeries.cs @@ -27,7 +27,7 @@ public static IReadOnlyList ToVortex( /// The number of lookback periods. /// A list of VortexResult containing the Vortex indicator values. private static List CalcVortex( - this IReadOnlyList source, + this List source, int lookbackPeriods) { // check parameter arguments diff --git a/src/s-z/Vwap/Vwap.StaticSeries.cs b/src/s-z/Vwap/Vwap.StaticSeries.cs index 856c536e9..94915137b 100644 --- a/src/s-z/Vwap/Vwap.StaticSeries.cs +++ b/src/s-z/Vwap/Vwap.StaticSeries.cs @@ -27,7 +27,7 @@ public static IReadOnlyList ToVwap( /// The optional start date for the VWAP calculation. If not provided, the calculation starts from the first quote. /// A list of VwapResult containing the VWAP values. private static List CalcVwap( - this IReadOnlyList source, + this List source, DateTime? startDate = null) { // check parameter arguments diff --git a/src/s-z/Vwma/Vwma.StaticSeries.cs b/src/s-z/Vwma/Vwma.StaticSeries.cs index 578f4b9a6..1bb337830 100644 --- a/src/s-z/Vwma/Vwma.StaticSeries.cs +++ b/src/s-z/Vwma/Vwma.StaticSeries.cs @@ -27,7 +27,7 @@ public static IReadOnlyList ToVwma( /// The number of lookback periods. /// A list of VwmaResult containing the VWMA values. private static List CalcVwma( - this IReadOnlyList source, + this List source, int lookbackPeriods) { // check parameter arguments diff --git a/src/s-z/WilliamsR/WilliamsR.StaticSeries.cs b/src/s-z/WilliamsR/WilliamsR.StaticSeries.cs index e171cb3a2..9551f8cb4 100644 --- a/src/s-z/WilliamsR/WilliamsR.StaticSeries.cs +++ b/src/s-z/WilliamsR/WilliamsR.StaticSeries.cs @@ -27,7 +27,7 @@ public static IReadOnlyList ToWilliamsR( /// The number of lookback periods. /// A list of WilliamsResult containing the Williams %R values. private static List CalcWilliamsR( - this IReadOnlyList source, + this List source, int lookbackPeriods) { // check parameter arguments diff --git a/tests/.editorconfig b/tests/.editorconfig index d23bcbe4e..2f260e70f 100644 --- a/tests/.editorconfig +++ b/tests/.editorconfig @@ -3,3 +3,7 @@ root = false [*.cs] dotnet_diagnostic.CA1303.severity = none # Do not pass literals as localized parameters + +# workaround for bug +# https://github.com/dotnet/roslyn/issues/41640 +dotnet_diagnostic.IDE0005.severity = none diff --git a/tests/Directory.Packages.props b/tests/Directory.Packages.props index 4c332fa76..6b9636fa0 100644 --- a/tests/Directory.Packages.props +++ b/tests/Directory.Packages.props @@ -8,10 +8,10 @@ - + - - - + + + diff --git a/tests/external/application/GlobalSuppressions.cs b/tests/external/application/GlobalSuppressions.cs new file mode 100644 index 000000000..7f28ca9b7 --- /dev/null +++ b/tests/external/application/GlobalSuppressions.cs @@ -0,0 +1,43 @@ +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage( + "Maintainability", + "CA1510:Use ArgumentNullException throw helper", + Justification = "Does not support .NET Standard.")] + +[assembly: SuppressMessage( + "Maintainability", + "CA1515:Consider making public types internal", + Justification = "Test projects use public class types.")] + +[assembly: SuppressMessage( + "Naming", + "CA1720:Identifier contains type name", + Justification = "Not really an issue.", + Scope = "member", + Target = "~F:Skender.Stock.Indicators.ChandelierType.Long")] + +[assembly: SuppressMessage("Naming", + "CA1720:Identifier contains type name" + , Justification = "Not really an issue.", + Scope = "type", + Target = "~T:Skender.Stock.Indicators.ChandelierType")] + +[assembly: SuppressMessage( + "Naming", + "CA1720:Identifier contains type name", + Justification = "Not really an issue.", + Scope = "member", + Target = "~F:Skender.Stock.Indicators.ChandelierType.Short")] + +[assembly: SuppressMessage( + "Maintainability", + "CA1510:Use ArgumentNullException throw helper", + Justification = "Can only use with .NET 6 or later. We support .NET Framework and .NET Standard.")] + +[assembly: SuppressMessage( + "Naming", + "CA1716:Identifiers should not match keywords", + Justification = "Temporary, during deprecation period.", + Scope = "member", + Target = "~P:Skender.Stock.Indicators.ISeries.Date")] diff --git a/tests/external/application/GlobalUsings.cs b/tests/external/application/GlobalUsings.cs index f72ae9eb8..fcebf7318 100644 --- a/tests/external/application/GlobalUsings.cs +++ b/tests/external/application/GlobalUsings.cs @@ -1,2 +1 @@ global using Skender.Stock.Indicators; -global using Test.Data; diff --git a/tests/external/application/Program.cs b/tests/external/application/Program.cs index c5a305fee..b0171ca8f 100644 --- a/tests/external/application/Program.cs +++ b/tests/external/application/Program.cs @@ -18,6 +18,7 @@ private static void Main(string[] args) case "A": go.QuoteHub(); break; case "B": go.EmaHub(); break; case "C": go.MultipleSubscribers(); break; + default: break; } } } diff --git a/tests/external/application/Test.Application.csproj b/tests/external/application/Test.Application.csproj index 1f9ae6243..3a6685979 100644 --- a/tests/external/application/Test.Application.csproj +++ b/tests/external/application/Test.Application.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 Exe enable diff --git a/tests/external/integration/GlobalSuppressions.cs b/tests/external/integration/GlobalSuppressions.cs new file mode 100644 index 000000000..74d0e9c17 --- /dev/null +++ b/tests/external/integration/GlobalSuppressions.cs @@ -0,0 +1,11 @@ +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage( + "Maintainability", + "CA1515:Consider making public types internal", + Justification = "Test projects use public class types.")] + +[assembly: SuppressMessage( + "Security", + "CA5394:Do not use insecure randomness", + Justification = "Okay for test rig, non-production code.")] diff --git a/tests/external/integration/Tests.Integration.csproj b/tests/external/integration/Tests.Integration.csproj index 52eb61c5e..be51fd444 100644 --- a/tests/external/integration/Tests.Integration.csproj +++ b/tests/external/integration/Tests.Integration.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 false enable diff --git a/tests/external/integration/WilliamsR.Tests.cs b/tests/external/integration/WilliamsR.Tests.cs index 149d5dedd..200bbb160 100644 --- a/tests/external/integration/WilliamsR.Tests.cs +++ b/tests/external/integration/WilliamsR.Tests.cs @@ -13,7 +13,7 @@ public async Task Issue1127() .GetQuotes("A", 365 * 3) .ConfigureAwait(false); - IReadOnlyList quotes = feedQuotes.ToList(); + List quotes = feedQuotes.ToList(); int length = quotes.Count; // get indicators diff --git a/tests/external/public-api/GlobalSuppressions.cs b/tests/external/public-api/GlobalSuppressions.cs new file mode 100644 index 000000000..03782e35e --- /dev/null +++ b/tests/external/public-api/GlobalSuppressions.cs @@ -0,0 +1,6 @@ +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage( + "Maintainability", + "CA1515:Consider making public types internal", + Justification = "Test projects use public class types.")] diff --git a/tests/external/public-api/Tests.PublicApi.csproj b/tests/external/public-api/Tests.PublicApi.csproj index 0469a9624..3c37ec3a2 100644 --- a/tests/external/public-api/Tests.PublicApi.csproj +++ b/tests/external/public-api/Tests.PublicApi.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 false enable diff --git a/tests/external/public-api/customizable/Custom.Indicator.Tests.cs b/tests/external/public-api/customizable/Custom.Indicator.Tests.cs index abe0ae097..d4fc7157d 100644 --- a/tests/external/public-api/customizable/Custom.Indicator.Tests.cs +++ b/tests/external/public-api/customizable/Custom.Indicator.Tests.cs @@ -1,4 +1,3 @@ -using System.Collections.ObjectModel; using System.Globalization; using Sut; @@ -157,6 +156,6 @@ public void Removed() // bad lookback period [TestMethod] public void Exceptions() - => Assert.ThrowsException(() - => quotes.GetIndicator(0)); + => Assert.ThrowsException( + () => quotes.GetIndicator(0)); } diff --git a/tests/external/public-api/customizable/Custom.Results.Tests.cs b/tests/external/public-api/customizable/Custom.Results.Tests.cs index ea8f1ccc3..e86e1676b 100644 --- a/tests/external/public-api/customizable/Custom.Results.Tests.cs +++ b/tests/external/public-api/customizable/Custom.Results.Tests.cs @@ -11,7 +11,8 @@ public class CustomResults private static readonly CultureInfo EnglishCulture = new("en-US", false); - private static readonly IReadOnlyList quotes = Data.GetDefault(); + private static readonly IReadOnlyList quotes = + Data.GetDefault(); [TestMethod] public void CustomSeriesClass() diff --git a/tests/external/public-api/customizable/Sut.CustomItems.cs b/tests/external/public-api/customizable/Sut.CustomItems.cs index 2715bb860..898fc4e0b 100644 --- a/tests/external/public-api/customizable/Sut.CustomItems.cs +++ b/tests/external/public-api/customizable/Sut.CustomItems.cs @@ -1,5 +1,3 @@ -using System.Collections.ObjectModel; - namespace Sut; // SUBJECT UNDER TEST (SUT) diff --git a/tests/indicators/GlobalSuppressions.cs b/tests/indicators/GlobalSuppressions.cs index 400f328ca..d58d716e0 100644 --- a/tests/indicators/GlobalSuppressions.cs +++ b/tests/indicators/GlobalSuppressions.cs @@ -1,6 +1,16 @@ using System.Diagnostics.CodeAnalysis; +[assembly: SuppressMessage( + "Maintainability", + "CA1515:Consider making public types internal", + Justification = "Test projects use public class types.")] + [assembly: SuppressMessage( "Security", "CA5394:Do not use insecure randomness", Justification = "Okay for test rig, non-production code.")] + +[assembly: SuppressMessage( + "Performance", + "CA1859:Use concrete types when possible for improved performance", + Justification = "Test data reflects API interface type.")] diff --git a/tests/indicators/Tests.Indicators.csproj b/tests/indicators/Tests.Indicators.csproj index da997a20b..416687f33 100644 --- a/tests/indicators/Tests.Indicators.csproj +++ b/tests/indicators/Tests.Indicators.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 false enable diff --git a/tests/indicators/_common/Generics/Seek.Tests.cs b/tests/indicators/_common/Generics/Seek.Tests.cs index bcd1a673e..efe5f2f58 100644 --- a/tests/indicators/_common/Generics/Seek.Tests.cs +++ b/tests/indicators/_common/Generics/Seek.Tests.cs @@ -6,7 +6,7 @@ public class Seeking : TestBase [TestMethod] public void Find() { - var emaResults = Quotes.ToEma(20); + IReadOnlyList emaResults = Quotes.ToEma(20); // find specific date DateTime findDate = DateTime.ParseExact("2018-12-31", "yyyy-MM-dd", invariantCulture); diff --git a/tests/indicators/_common/Generics/Sorting.Tests.cs b/tests/indicators/_common/Generics/Sorting.Tests.cs index 4bb16536b..3bc57dc75 100644 --- a/tests/indicators/_common/Generics/Sorting.Tests.cs +++ b/tests/indicators/_common/Generics/Sorting.Tests.cs @@ -1,5 +1,3 @@ -using System.Collections.ObjectModel; - namespace Utilities; [TestClass] diff --git a/tests/indicators/_common/Math/Numerical.Tests.cs b/tests/indicators/_common/Math/Numerical.Tests.cs index fc1f3e212..a73f22112 100644 --- a/tests/indicators/_common/Math/Numerical.Tests.cs +++ b/tests/indicators/_common/Math/Numerical.Tests.cs @@ -20,9 +20,8 @@ public void StdDev() [TestMethod] public void StdDevNull() - { - Assert.ThrowsException(() => Numerical.StdDev(null)); - } + => Assert.ThrowsException( + () => Numerical.StdDev(null)); [TestMethod] public void Slope() @@ -34,21 +33,18 @@ public void Slope() [TestMethod] public void SlopeXnull() - { - Assert.ThrowsException(() => Numerical.Slope(null, _x)); - } + => Assert.ThrowsException( + () => Numerical.Slope(null, _x)); [TestMethod] public void SlopeYnull() - { - Assert.ThrowsException(() => Numerical.Slope(_x, null)); - } + => Assert.ThrowsException( + () => Numerical.Slope(_x, null)); [TestMethod] public void SlopeMismatch() - { - Assert.ThrowsException(() => Numerical.Slope(_x, _y)); - } + => Assert.ThrowsException( + () => Numerical.Slope(_x, _y)); [TestMethod] public void RoundDownDate() diff --git a/tests/indicators/_common/Observables/StreamHub.Stackoverflow.Tests.cs b/tests/indicators/_common/Observables/StreamHub.Stackoverflow.Tests.cs index ea2414bf7..a0bcab519 100644 --- a/tests/indicators/_common/Observables/StreamHub.Stackoverflow.Tests.cs +++ b/tests/indicators/_common/Observables/StreamHub.Stackoverflow.Tests.cs @@ -48,6 +48,7 @@ public void FatLongStack() int resultQty = results.Count; Console.WriteLine($"Hub: {resultQty} - {label}"); if (irregular) { continue; } + resultQty.Should().Be(qtyQuotes); } @@ -74,6 +75,7 @@ public void FatLongStack() int resultQty = results.Count; Console.WriteLine($"Cut: {resultQty} - {label}"); if (irregular) { continue; } + resultQty.Should().Be(cutoff); } } @@ -132,6 +134,7 @@ public void ManyChainDepths() int resultQty = results.Count; Console.WriteLine($"Hub: {resultQty} - {label}"); if (irregular) { continue; } + resultQty.Should().Be(qtyQuotes); } @@ -156,6 +159,7 @@ public void ManyChainDepths() int resultQty = results.Count; Console.WriteLine($"Cut: {resultQty} - {label}"); if (irregular) { continue; } + resultQty.Should().Be(cutoff); } } @@ -216,6 +220,7 @@ public void ManySubscribers() int resultQty = results.Count; Console.WriteLine($"Hub: {resultQty} - {label}"); if (irregular) { continue; } + resultQty.Should().Be(qtyQuotes); } @@ -242,6 +247,7 @@ public void ManySubscribers() int resultQty = results.Count; Console.WriteLine($"Cut: {resultQty} - {label}"); if (irregular) { continue; } + resultQty.Should().Be(cutoff); } } diff --git a/tests/indicators/_common/Quotes/Quote.Validation.Tests.cs b/tests/indicators/_common/Quotes/Quote.Validation.Tests.cs index c1c54cac1..7cb393874 100644 --- a/tests/indicators/_common/Quotes/Quote.Validation.Tests.cs +++ b/tests/indicators/_common/Quotes/Quote.Validation.Tests.cs @@ -1,5 +1,3 @@ -using System.Globalization; - namespace Utilities; // quote validation @@ -92,7 +90,7 @@ InvalidQuotesException dx = Assert.ThrowsException( () => dupQuotes.Validate()); - dx.Message.Should().Contain("Duplicate date found on 2017-01-06T00:00:00.0000000."); + _ = dx.Message.Should().Contain("Duplicate date found on 2017-01-06T00:00:00.0000000."); } [TestMethod] @@ -111,7 +109,7 @@ InvalidQuotesException dx = Assert.ThrowsException( () => unorderedQuotes.Validate()); - dx.Message.Should() + _ = dx.Message.Should() .Contain("Quotes are out of sequence on 2017-01-05T00:00:00.0000000."); } } diff --git a/tests/indicators/a-d/Adx/Adx.StaticSeries.Tests.cs b/tests/indicators/a-d/Adx/Adx.StaticSeries.Tests.cs index c89d64a17..1e584a5f0 100644 --- a/tests/indicators/a-d/Adx/Adx.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/Adx/Adx.StaticSeries.Tests.cs @@ -145,10 +145,9 @@ public void Removed() Assert.AreEqual(34.2987, last.Adx.Round(4)); } + // bad lookback period [TestMethod] - public void Exceptions() => - - // bad lookback period - Assert.ThrowsException(() => - Quotes.ToAdx(1)); + public void Exceptions() + => Assert.ThrowsException( + () => Quotes.ToAdx(1)); } diff --git a/tests/indicators/a-d/Alligator/Alligator.StaticSeries.Tests.cs b/tests/indicators/a-d/Alligator/Alligator.StaticSeries.Tests.cs index e8c682b40..9deba5eba 100644 --- a/tests/indicators/a-d/Alligator/Alligator.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/Alligator/Alligator.StaticSeries.Tests.cs @@ -122,35 +122,35 @@ public void Equality() public void Exceptions() { // bad jaw lookback periods - Assert.ThrowsException(() => - Quotes.ToAlligator(13, 8, 13)); + Assert.ThrowsException( + () => Quotes.ToAlligator(13, 8, 13)); // bad teeth lookback periods - Assert.ThrowsException(() => - Quotes.ToAlligator(13, 8, 8, 5, 8)); + Assert.ThrowsException( + () => Quotes.ToAlligator(13, 8, 8, 5, 8)); // bad lips lookback periods - Assert.ThrowsException(() => - Quotes.ToAlligator(13, 8, 8, 5, 0)); + Assert.ThrowsException( + () => Quotes.ToAlligator(13, 8, 8, 5, 0)); // bad jaw offset periods - Assert.ThrowsException(() => - Quotes.ToAlligator(13, 0)); + Assert.ThrowsException( + () => Quotes.ToAlligator(13, 0)); // bad teeth offset periods - Assert.ThrowsException(() => - Quotes.ToAlligator(13, 8, 8, 0)); + Assert.ThrowsException( + () => Quotes.ToAlligator(13, 8, 8, 0)); // bad lips offset periods - Assert.ThrowsException(() => - Quotes.ToAlligator(13, 8, 8, 5, 5, 0)); + Assert.ThrowsException( + () => Quotes.ToAlligator(13, 8, 8, 5, 5, 0)); // bad jaw + offset periods - Assert.ThrowsException(() => - Quotes.ToAlligator(13, 8, 12, 11)); + Assert.ThrowsException( + () => Quotes.ToAlligator(13, 8, 12, 11)); // bad teeth + offset periods - Assert.ThrowsException(() => - Quotes.ToAlligator(13, 8, 8, 5, 7, 7)); + Assert.ThrowsException( + () => Quotes.ToAlligator(13, 8, 8, 5, 7, 7)); } } diff --git a/tests/indicators/a-d/Alma/Alma.StaticSeries.Tests.cs b/tests/indicators/a-d/Alma/Alma.StaticSeries.Tests.cs index d9ccb1884..f7579624b 100644 --- a/tests/indicators/a-d/Alma/Alma.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/Alma/Alma.StaticSeries.Tests.cs @@ -130,15 +130,15 @@ public void Removed() public void Exceptions() { // bad lookback period - Assert.ThrowsException(() => - Quotes.ToAlma(0, 1, 5)); + Assert.ThrowsException( + () => Quotes.ToAlma(0, 1, 5)); // bad offset - Assert.ThrowsException(() => - Quotes.ToAlma(15, 1.1, 3)); + Assert.ThrowsException( + () => Quotes.ToAlma(15, 1.1, 3)); // bad sigma - Assert.ThrowsException(() => - Quotes.ToAlma(10, 0.5, 0)); + Assert.ThrowsException( + () => Quotes.ToAlma(10, 0.5, 0)); } } diff --git a/tests/indicators/a-d/Aroon/Aroon.StaticSeries.Tests.cs b/tests/indicators/a-d/Aroon/Aroon.StaticSeries.Tests.cs index db6dcba18..b0d193b2b 100644 --- a/tests/indicators/a-d/Aroon/Aroon.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/Aroon/Aroon.StaticSeries.Tests.cs @@ -96,6 +96,6 @@ public void Removed() // bad lookback period [TestMethod] public void Exceptions() - => Assert.ThrowsException(() - => Quotes.ToAroon(0)); + => Assert.ThrowsException( + () => Quotes.ToAroon(0)); } diff --git a/tests/indicators/a-d/Atr/Atr.StaticSeries.Tests.cs b/tests/indicators/a-d/Atr/Atr.StaticSeries.Tests.cs index 0682f0fc3..5fd782c79 100644 --- a/tests/indicators/a-d/Atr/Atr.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/Atr/Atr.StaticSeries.Tests.cs @@ -114,7 +114,7 @@ public void Removed() // bad lookback period [TestMethod] - public void Exceptions() => - Assert.ThrowsException(() => - Quotes.ToAtr(1)); + public void Exceptions() + => Assert.ThrowsException( + () => Quotes.ToAtr(1)); } diff --git a/tests/indicators/a-d/AtrStop/AtrStop.StaticSeries.Tests.cs b/tests/indicators/a-d/AtrStop/AtrStop.StaticSeries.Tests.cs index 091b89486..45428b5f5 100644 --- a/tests/indicators/a-d/AtrStop/AtrStop.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/AtrStop/AtrStop.StaticSeries.Tests.cs @@ -158,11 +158,11 @@ public void Removed() public void Exceptions() { // bad lookback period - Assert.ThrowsException(() - => Quotes.ToAtrStop(1)); + Assert.ThrowsException( + () => Quotes.ToAtrStop(1)); // bad multiplier - Assert.ThrowsException(() - => Quotes.ToAtrStop(7, 0)); + Assert.ThrowsException( + () => Quotes.ToAtrStop(7, 0)); } } diff --git a/tests/indicators/a-d/Awesome/Awesome.StaticSeries.Tests.cs b/tests/indicators/a-d/Awesome/Awesome.StaticSeries.Tests.cs index 92982f51e..5c81b109d 100644 --- a/tests/indicators/a-d/Awesome/Awesome.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/Awesome/Awesome.StaticSeries.Tests.cs @@ -107,11 +107,11 @@ public void Removed() public void Exceptions() { // bad fast period - Assert.ThrowsException(() => - Quotes.ToAwesome(0)); + Assert.ThrowsException( + () => Quotes.ToAwesome(0)); // bad slow period - Assert.ThrowsException(() => - Quotes.ToAwesome(25, 25)); + Assert.ThrowsException( + () => Quotes.ToAwesome(25, 25)); } } diff --git a/tests/indicators/a-d/Beta/Beta.StaticSeries.Tests.cs b/tests/indicators/a-d/Beta/Beta.StaticSeries.Tests.cs index c8214d024..f89f2fb1c 100644 --- a/tests/indicators/a-d/Beta/Beta.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/Beta/Beta.StaticSeries.Tests.cs @@ -259,13 +259,13 @@ public void NoMatch() public void Exceptions() { // bad lookback period - Assert.ThrowsException(() - => Quotes.ToBeta(OtherQuotes, 0)); + Assert.ThrowsException( + () => Quotes.ToBeta(OtherQuotes, 0)); // bad evaluation quotes IReadOnlyList eval = Data.GetCompare(300).ToList(); - Assert.ThrowsException(() - => Quotes.ToBeta(eval, 30)); + Assert.ThrowsException( + () => Quotes.ToBeta(eval, 30)); } } diff --git a/tests/indicators/a-d/BollingerBands/BollingerBands.StaticSeries.Tests.cs b/tests/indicators/a-d/BollingerBands/BollingerBands.StaticSeries.Tests.cs index a0fa51e21..d8b4dfaba 100644 --- a/tests/indicators/a-d/BollingerBands/BollingerBands.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/BollingerBands/BollingerBands.StaticSeries.Tests.cs @@ -116,11 +116,11 @@ public void Removed() public void Exceptions() { // bad lookback period - Assert.ThrowsException(() => - Quotes.ToBollingerBands(1)); + Assert.ThrowsException( + () => Quotes.ToBollingerBands(1)); // bad standard deviation - Assert.ThrowsException(() => - Quotes.ToBollingerBands(2, 0)); + Assert.ThrowsException( + () => Quotes.ToBollingerBands(2, 0)); } } diff --git a/tests/indicators/a-d/Bop/Bop.StaticSeries.Tests.cs b/tests/indicators/a-d/Bop/Bop.StaticSeries.Tests.cs index 7169a2238..0a11df25d 100644 --- a/tests/indicators/a-d/Bop/Bop.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/Bop/Bop.StaticSeries.Tests.cs @@ -86,9 +86,9 @@ public void Removed() Assert.AreEqual(-0.292788, last.Bop.Round(6)); } - // bad smoothing period + // bad lookback period [TestMethod] public void Exceptions() - => Assert.ThrowsException(() - => Quotes.ToBop(0)); + => Assert.ThrowsException( + () => Quotes.ToBop(0)); } diff --git a/tests/indicators/a-d/Cci/Cci.StaticSeries.Tests.cs b/tests/indicators/a-d/Cci/Cci.StaticSeries.Tests.cs index c4550ed6a..33f78ba54 100644 --- a/tests/indicators/a-d/Cci/Cci.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/Cci/Cci.StaticSeries.Tests.cs @@ -70,6 +70,6 @@ public void Removed() // bad lookback period [TestMethod] public void Exceptions() - => Assert.ThrowsException(() - => Quotes.ToCci(0)); + => Assert.ThrowsException( + () => Quotes.ToCci(0)); } diff --git a/tests/indicators/a-d/ChaikinOsc/ChaikinOsc.StaticSeries.Tests.cs b/tests/indicators/a-d/ChaikinOsc/ChaikinOsc.StaticSeries.Tests.cs index 613c34cb6..c71a6a4eb 100644 --- a/tests/indicators/a-d/ChaikinOsc/ChaikinOsc.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/ChaikinOsc/ChaikinOsc.StaticSeries.Tests.cs @@ -83,11 +83,11 @@ public void Removed() public void Exceptions() { // bad fast lookback - Assert.ThrowsException(() => - Quotes.ToChaikinOsc(0)); + Assert.ThrowsException( + () => Quotes.ToChaikinOsc(0)); // bad slow lookback - Assert.ThrowsException(() => - Quotes.ToChaikinOsc(10, 5)); + Assert.ThrowsException( + () => Quotes.ToChaikinOsc(10, 5)); } } diff --git a/tests/indicators/a-d/Chandelier/Chandelier.StaticSeries.Tests.cs b/tests/indicators/a-d/Chandelier/Chandelier.StaticSeries.Tests.cs index 92b8663d0..6ce0eb609 100644 --- a/tests/indicators/a-d/Chandelier/Chandelier.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/Chandelier/Chandelier.StaticSeries.Tests.cs @@ -83,15 +83,15 @@ public void Removed() public void Exceptions() { // bad lookback period - Assert.ThrowsException(() => - Quotes.ToChandelier(0)); + Assert.ThrowsException( + () => Quotes.ToChandelier(0)); // bad multiplier - Assert.ThrowsException(() => - Quotes.ToChandelier(25, 0)); + Assert.ThrowsException( + () => Quotes.ToChandelier(25, 0)); // bad type - Assert.ThrowsException(() => - Quotes.ToChandelier(25, 2, (ChandelierType)int.MaxValue)); + Assert.ThrowsException( + () => Quotes.ToChandelier(25, 2, (ChandelierType)int.MaxValue)); } } diff --git a/tests/indicators/a-d/Chop/Chop.StaticSeries.Tests.cs b/tests/indicators/a-d/Chop/Chop.StaticSeries.Tests.cs index 0563157d0..9caa31c51 100644 --- a/tests/indicators/a-d/Chop/Chop.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/Chop/Chop.StaticSeries.Tests.cs @@ -91,6 +91,6 @@ public void Removed() // bad lookback period [TestMethod] public void Exceptions() - => Assert.ThrowsException(() - => Quotes.ToChop(1)); + => Assert.ThrowsException( + () => Quotes.ToChop(1)); } diff --git a/tests/indicators/a-d/Cmf/Cmf.StaticSeries.Tests.cs b/tests/indicators/a-d/Cmf/Cmf.StaticSeries.Tests.cs index f6c5814c0..bccec88e7 100644 --- a/tests/indicators/a-d/Cmf/Cmf.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/Cmf/Cmf.StaticSeries.Tests.cs @@ -93,6 +93,6 @@ public void Removed() // bad lookback period [TestMethod] public void Exceptions() - => Assert.ThrowsException(() - => Quotes.ToCmf(0)); + => Assert.ThrowsException( + () => Quotes.ToCmf(0)); } diff --git a/tests/indicators/a-d/Cmo/Cmo.StaticSeries.Tests.cs b/tests/indicators/a-d/Cmo/Cmo.StaticSeries.Tests.cs index 866f2b762..c4804c804 100644 --- a/tests/indicators/a-d/Cmo/Cmo.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/Cmo/Cmo.StaticSeries.Tests.cs @@ -104,6 +104,6 @@ public void Removed() // bad lookback period [TestMethod] public void Exceptions() - => Assert.ThrowsException(() - => Quotes.ToCmo(0)); + => Assert.ThrowsException( + () => Quotes.ToCmo(0)); } diff --git a/tests/indicators/a-d/ConnorsRsi/ConnorsRsi.StaticSeries.Tests.cs b/tests/indicators/a-d/ConnorsRsi/ConnorsRsi.StaticSeries.Tests.cs index 3e1c6e07c..38d7be2b6 100644 --- a/tests/indicators/a-d/ConnorsRsi/ConnorsRsi.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/ConnorsRsi/ConnorsRsi.StaticSeries.Tests.cs @@ -119,15 +119,15 @@ public void Removed() public void Exceptions() { // bad RSI period - Assert.ThrowsException(() => - Quotes.ToConnorsRsi(1)); + Assert.ThrowsException( + () => Quotes.ToConnorsRsi(1)); // bad Streak period - Assert.ThrowsException(() => - Quotes.ToConnorsRsi(3, 1)); + Assert.ThrowsException( + () => Quotes.ToConnorsRsi(3, 1)); // bad Rank period - Assert.ThrowsException(() => - Quotes.ToConnorsRsi(3, 2, 1)); + Assert.ThrowsException( + () => Quotes.ToConnorsRsi(3, 2, 1)); } } diff --git a/tests/indicators/a-d/Correlation/Correlation.StaticSeries.Tests.cs b/tests/indicators/a-d/Correlation/Correlation.StaticSeries.Tests.cs index 5502f29db..5239eb367 100644 --- a/tests/indicators/a-d/Correlation/Correlation.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/Correlation/Correlation.StaticSeries.Tests.cs @@ -118,16 +118,16 @@ public void Removed() public void Exceptions() { // bad lookback period - Assert.ThrowsException(() => - Quotes.ToCorrelation(OtherQuotes, 0)); + Assert.ThrowsException( + () => Quotes.ToCorrelation(OtherQuotes, 0)); // bad eval quotes IReadOnlyList eval = Data.GetCompare(300); - Assert.ThrowsException(() => - Quotes.ToCorrelation(eval, 30)); + Assert.ThrowsException( + () => Quotes.ToCorrelation(eval, 30)); // mismatched quotes - Assert.ThrowsException(() => - MismatchQuotes.ToCorrelation(OtherQuotes, 20)); + Assert.ThrowsException( + () => MismatchQuotes.ToCorrelation(OtherQuotes, 20)); } } diff --git a/tests/indicators/a-d/Doji/Doji.StaticSeries.Tests.cs b/tests/indicators/a-d/Doji/Doji.StaticSeries.Tests.cs index 6b0622535..a3fe97ef7 100644 --- a/tests/indicators/a-d/Doji/Doji.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/Doji/Doji.StaticSeries.Tests.cs @@ -76,10 +76,10 @@ public void Condense() public void Exceptions() { // bad maximum change value - Assert.ThrowsException(() => - Quotes.ToDoji(-0.00001)); + Assert.ThrowsException( + () => Quotes.ToDoji(-0.00001)); - Assert.ThrowsException(() => - Quotes.ToDoji(0.50001)); + Assert.ThrowsException( + () => Quotes.ToDoji(0.50001)); } } diff --git a/tests/indicators/e-k/Ichimoku/Ichimoku.StaticSeries.Tests.cs b/tests/indicators/e-k/Ichimoku/Ichimoku.StaticSeries.Tests.cs index fd077faa0..d4fbeacf2 100644 --- a/tests/indicators/e-k/Ichimoku/Ichimoku.StaticSeries.Tests.cs +++ b/tests/indicators/e-k/Ichimoku/Ichimoku.StaticSeries.Tests.cs @@ -97,25 +97,25 @@ public void Condense() public void Exceptions() { // bad signal period - Assert.ThrowsException(() => - Quotes.ToIchimoku(0)); + Assert.ThrowsException( + () => Quotes.ToIchimoku(0)); // bad short span period - Assert.ThrowsException(() => - Quotes.ToIchimoku(9, 0)); + Assert.ThrowsException( + () => Quotes.ToIchimoku(9, 0)); // bad long span period - Assert.ThrowsException(() => - Quotes.ToIchimoku(9, 26, 26)); + Assert.ThrowsException( + () => Quotes.ToIchimoku(9, 26, 26)); // invalid offsets - Assert.ThrowsException(() => - Quotes.GetIchimoku(9, 26, 52, -1)); + Assert.ThrowsException( + () => Quotes.GetIchimoku(9, 26, 52, -1)); - Assert.ThrowsException(() => - Quotes.GetIchimoku(9, 26, 52, -1, 12)); + Assert.ThrowsException( + () => Quotes.GetIchimoku(9, 26, 52, -1, 12)); - Assert.ThrowsException(() => - Quotes.GetIchimoku(9, 26, 52, 12, -1)); + Assert.ThrowsException( + () => Quotes.GetIchimoku(9, 26, 52, 12, -1)); } } diff --git a/tests/indicators/e-k/Kama/Kama.StaticSeries.Tests.cs b/tests/indicators/e-k/Kama/Kama.StaticSeries.Tests.cs index bbd19115c..5084d3239 100644 --- a/tests/indicators/e-k/Kama/Kama.StaticSeries.Tests.cs +++ b/tests/indicators/e-k/Kama/Kama.StaticSeries.Tests.cs @@ -128,15 +128,15 @@ public void Removed() public void Exceptions() { // bad ER period - Assert.ThrowsException(() => - Quotes.ToKama(0)); + Assert.ThrowsException( + () => Quotes.ToKama(0)); // bad fast period - Assert.ThrowsException(() => - Quotes.ToKama(10, 0)); + Assert.ThrowsException( + () => Quotes.ToKama(10, 0)); // bad slow period - Assert.ThrowsException(() => - Quotes.ToKama(10, 5, 5)); + Assert.ThrowsException( + () => Quotes.ToKama(10, 5, 5)); } } diff --git a/tests/indicators/e-k/Keltner/Keltner.StaticSeries.Tests.cs b/tests/indicators/e-k/Keltner/Keltner.StaticSeries.Tests.cs index ce3dc3c2f..4ad018e4d 100644 --- a/tests/indicators/e-k/Keltner/Keltner.StaticSeries.Tests.cs +++ b/tests/indicators/e-k/Keltner/Keltner.StaticSeries.Tests.cs @@ -107,15 +107,15 @@ public void Removed() public void Exceptions() { // bad EMA period - Assert.ThrowsException(() => - Quotes.ToKeltner(1)); + Assert.ThrowsException( + () => Quotes.ToKeltner(1)); // bad ATR period - Assert.ThrowsException(() => - Quotes.ToKeltner(20, 2, 1)); + Assert.ThrowsException( + () => Quotes.ToKeltner(20, 2, 1)); // bad multiplier - Assert.ThrowsException(() => - Quotes.ToKeltner(20, 0)); + Assert.ThrowsException( + () => Quotes.ToKeltner(20, 0)); } } diff --git a/tests/indicators/e-k/Kvo/Kvo.StaticSeries.Tests.cs b/tests/indicators/e-k/Kvo/Kvo.StaticSeries.Tests.cs index 34dccb79f..6bbd46fe2 100644 --- a/tests/indicators/e-k/Kvo/Kvo.StaticSeries.Tests.cs +++ b/tests/indicators/e-k/Kvo/Kvo.StaticSeries.Tests.cs @@ -98,15 +98,15 @@ public void Removed() public void Exceptions() { // bad fast period - Assert.ThrowsException(() => - Quotes.ToKvo(2)); + Assert.ThrowsException( + () => Quotes.ToKvo(2)); // bad slow period - Assert.ThrowsException(() => - Quotes.ToKvo(20, 20)); + Assert.ThrowsException( + () => Quotes.ToKvo(20, 20)); // bad signal period - Assert.ThrowsException(() => - Quotes.ToKvo(34, 55, 0)); + Assert.ThrowsException( + () => Quotes.ToKvo(34, 55, 0)); } } diff --git a/tests/indicators/m-r/MaEnvelopes/MaEnvelopes.StaticSeries.Tests.cs b/tests/indicators/m-r/MaEnvelopes/MaEnvelopes.StaticSeries.Tests.cs index 13aa3ddd7..207c04d87 100644 --- a/tests/indicators/m-r/MaEnvelopes/MaEnvelopes.StaticSeries.Tests.cs +++ b/tests/indicators/m-r/MaEnvelopes/MaEnvelopes.StaticSeries.Tests.cs @@ -330,12 +330,12 @@ public void Condense() public void Exceptions() { // bad offset period - Assert.ThrowsException(() => - Quotes.ToMaEnvelopes(14, 0)); + Assert.ThrowsException( + () => Quotes.ToMaEnvelopes(14, 0)); // bad MA period - Assert.ThrowsException(() => - Quotes.ToMaEnvelopes(14, 5, MaType.KAMA)); + Assert.ThrowsException( + () => Quotes.ToMaEnvelopes(14, 5, MaType.KAMA)); // note: insufficient quotes is tested elsewhere } diff --git a/tests/indicators/m-r/Macd/Macd.StaticSeries.Tests.cs b/tests/indicators/m-r/Macd/Macd.StaticSeries.Tests.cs index 63f78539e..8ee8d2c31 100644 --- a/tests/indicators/m-r/Macd/Macd.StaticSeries.Tests.cs +++ b/tests/indicators/m-r/Macd/Macd.StaticSeries.Tests.cs @@ -123,15 +123,15 @@ public void Removed() public void Exceptions() { // bad fast period - Assert.ThrowsException(() => - Quotes.ToMacd(0)); + Assert.ThrowsException( + () => Quotes.ToMacd(0)); // bad slow periods must be larger than faster period - Assert.ThrowsException(() => - Quotes.ToMacd(12, 12)); + Assert.ThrowsException( + () => Quotes.ToMacd(12, 12)); // bad signal period - Assert.ThrowsException(() => - Quotes.ToMacd(12, 26, -1)); + Assert.ThrowsException( + () => Quotes.ToMacd(12, 26, -1)); } } diff --git a/tests/indicators/m-r/Mama/Mama.StaticSeries.Tests.cs b/tests/indicators/m-r/Mama/Mama.StaticSeries.Tests.cs index bdb748645..299226319 100644 --- a/tests/indicators/m-r/Mama/Mama.StaticSeries.Tests.cs +++ b/tests/indicators/m-r/Mama/Mama.StaticSeries.Tests.cs @@ -123,15 +123,15 @@ public void Removed() public void Exceptions() { // bad fast period (same as slow period) - Assert.ThrowsException(() => - Quotes.ToMama(0.5, 0.5)); + Assert.ThrowsException( + () => Quotes.ToMama(0.5, 0.5)); // bad fast period (cannot be 1 or more) - Assert.ThrowsException(() => - Quotes.ToMama(1, 0.5)); + Assert.ThrowsException( + () => Quotes.ToMama(1, 0.5)); // bad slow period - Assert.ThrowsException(() => - Quotes.ToMama(0.5, 0)); + Assert.ThrowsException( + () => Quotes.ToMama(0.5, 0)); } } diff --git a/tests/indicators/m-r/Marubozu/Marubozu.StaticSeries.Tests.cs b/tests/indicators/m-r/Marubozu/Marubozu.StaticSeries.Tests.cs index 66ba37050..0b6b24e89 100644 --- a/tests/indicators/m-r/Marubozu/Marubozu.StaticSeries.Tests.cs +++ b/tests/indicators/m-r/Marubozu/Marubozu.StaticSeries.Tests.cs @@ -76,10 +76,10 @@ public void Condense() public void Exceptions() { // bad minimum body percent values - Assert.ThrowsException(() => - Quotes.ToMarubozu(79.9)); + Assert.ThrowsException( + () => Quotes.ToMarubozu(79.9)); - Assert.ThrowsException(() => - Quotes.ToMarubozu(100.1)); + Assert.ThrowsException( + () => Quotes.ToMarubozu(100.1)); } } diff --git a/tests/indicators/m-r/ParabolicSar/ParabolicSar.StaticSeries.Tests.cs b/tests/indicators/m-r/ParabolicSar/ParabolicSar.StaticSeries.Tests.cs index e8eea6afa..7780e35d8 100644 --- a/tests/indicators/m-r/ParabolicSar/ParabolicSar.StaticSeries.Tests.cs +++ b/tests/indicators/m-r/ParabolicSar/ParabolicSar.StaticSeries.Tests.cs @@ -152,19 +152,19 @@ public void Removed() public void Exceptions() { // bad acceleration step - Assert.ThrowsException(() => - Quotes.ToParabolicSar(0, 1)); + Assert.ThrowsException( + () => Quotes.ToParabolicSar(0, 1)); // insufficient acceleration step - Assert.ThrowsException(() => - Quotes.ToParabolicSar(0.02, 0)); + Assert.ThrowsException( + () => Quotes.ToParabolicSar(0.02, 0)); // step larger than factor - Assert.ThrowsException(() => - Quotes.ToParabolicSar(6, 2)); + Assert.ThrowsException( + () => Quotes.ToParabolicSar(6, 2)); // insufficient initial factor - Assert.ThrowsException(() => - Quotes.GetParabolicSar(0.02, 0.5, 0)); + Assert.ThrowsException( + () => Quotes.GetParabolicSar(0.02, 0.5, 0)); } } diff --git a/tests/indicators/m-r/Pivots/Pivots.StaticSeries.Tests.cs b/tests/indicators/m-r/Pivots/Pivots.StaticSeries.Tests.cs index ef3c9385f..80ef3b7c7 100644 --- a/tests/indicators/m-r/Pivots/Pivots.StaticSeries.Tests.cs +++ b/tests/indicators/m-r/Pivots/Pivots.StaticSeries.Tests.cs @@ -121,15 +121,15 @@ public void Condense() public void Exceptions() { // bad left span - Assert.ThrowsException(() => - Quotes.ToPivots(1)); + Assert.ThrowsException( + () => Quotes.ToPivots(1)); // bad right span - Assert.ThrowsException(() => - Quotes.ToPivots(2, 1)); + Assert.ThrowsException( + () => Quotes.ToPivots(2, 1)); // bad lookback window - Assert.ThrowsException(() => - Quotes.ToPivots(20, 10, 20, EndType.Close)); + Assert.ThrowsException( + () => Quotes.ToPivots(20, 10, 20, EndType.Close)); } } diff --git a/tests/indicators/m-r/Pmo/Pmo.StaticSeries.Tests.cs b/tests/indicators/m-r/Pmo/Pmo.StaticSeries.Tests.cs index 97f15b910..cfcf235f6 100644 --- a/tests/indicators/m-r/Pmo/Pmo.StaticSeries.Tests.cs +++ b/tests/indicators/m-r/Pmo/Pmo.StaticSeries.Tests.cs @@ -100,15 +100,15 @@ public void Removed() public void Exceptions() { // bad time period - Assert.ThrowsException(() => - Quotes.ToPmo(1)); + Assert.ThrowsException( + () => Quotes.ToPmo(1)); // bad smoothing period - Assert.ThrowsException(() => - Quotes.ToPmo(5, 0)); + Assert.ThrowsException( + () => Quotes.ToPmo(5, 0)); // bad signal period - Assert.ThrowsException(() => - Quotes.ToPmo(5, 5, 0)); + Assert.ThrowsException( + () => Quotes.ToPmo(5, 5, 0)); } } diff --git a/tests/indicators/m-r/Prs/Prs.StaticSeries.Tests.cs b/tests/indicators/m-r/Prs/Prs.StaticSeries.Tests.cs index debcc99da..2abcfc44b 100644 --- a/tests/indicators/m-r/Prs/Prs.StaticSeries.Tests.cs +++ b/tests/indicators/m-r/Prs/Prs.StaticSeries.Tests.cs @@ -91,19 +91,19 @@ public override void NoQuotes() public void Exceptions() { // bad lookback period - Assert.ThrowsException(() => - OtherQuotes.ToPrs(Quotes, 0)); + Assert.ThrowsException( + () => OtherQuotes.ToPrs(Quotes, 0)); // insufficient quotes - Assert.ThrowsException(() => - Data.GetCompare(13).ToPrs(Quotes, 14)); + Assert.ThrowsException( + () => Data.GetCompare(13).ToPrs(Quotes, 14)); // insufficient eval quotes - Assert.ThrowsException(() => - Data.GetCompare(300).ToPrs(Quotes, 14)); + Assert.ThrowsException( + () => Data.GetCompare(300).ToPrs(Quotes, 14)); // mismatch quotes - Assert.ThrowsException(() => - OtherQuotes.ToPrs(MismatchQuotes, 14)); + Assert.ThrowsException( + () => OtherQuotes.ToPrs(MismatchQuotes, 14)); } } diff --git a/tests/indicators/m-r/Pvo/Pvo.StaticSeries.Tests.cs b/tests/indicators/m-r/Pvo/Pvo.StaticSeries.Tests.cs index 6b5e8123d..ad6cbce57 100644 --- a/tests/indicators/m-r/Pvo/Pvo.StaticSeries.Tests.cs +++ b/tests/indicators/m-r/Pvo/Pvo.StaticSeries.Tests.cs @@ -105,15 +105,15 @@ public void Removed() public void Exceptions() { // bad fast period - Assert.ThrowsException(() => - Quotes.ToPvo(0)); + Assert.ThrowsException( + () => Quotes.ToPvo(0)); // bad slow periods must be larger than faster period - Assert.ThrowsException(() => - Quotes.ToPvo(12, 12)); + Assert.ThrowsException( + () => Quotes.ToPvo(12, 12)); // bad signal period - Assert.ThrowsException(() => - Quotes.ToPvo(12, 26, -1)); + Assert.ThrowsException( + () => Quotes.ToPvo(12, 26, -1)); } } diff --git a/tests/indicators/m-r/Roc/Roc.StaticSeries.Tests.cs b/tests/indicators/m-r/Roc/Roc.StaticSeries.Tests.cs index 1042bca94..24af56d18 100644 --- a/tests/indicators/m-r/Roc/Roc.StaticSeries.Tests.cs +++ b/tests/indicators/m-r/Roc/Roc.StaticSeries.Tests.cs @@ -99,9 +99,8 @@ public void Removed() Assert.AreEqual(-8.2482, last.Roc.Round(4)); } - [TestMethod] - public void Exceptions() => - // bad lookback period - Assert.ThrowsException(() => - Quotes.ToRoc(0)); + [TestMethod] // bad lookback period + public void Exceptions() + => Assert.ThrowsException( + () => Quotes.ToRoc(0)); } diff --git a/tests/indicators/m-r/RocWb/RocWb.StaticSeries.Tests.cs b/tests/indicators/m-r/RocWb/RocWb.StaticSeries.Tests.cs index 65bd3dd2e..0b85e2138 100644 --- a/tests/indicators/m-r/RocWb/RocWb.StaticSeries.Tests.cs +++ b/tests/indicators/m-r/RocWb/RocWb.StaticSeries.Tests.cs @@ -144,15 +144,15 @@ public void Removed() public void Exceptions() { // bad lookback period - Assert.ThrowsException(() => - Quotes.ToRocWb(0, 3, 12)); + Assert.ThrowsException( + () => Quotes.ToRocWb(0, 3, 12)); // bad EMA period - Assert.ThrowsException(() => - Quotes.ToRocWb(14, 0, 14)); + Assert.ThrowsException( + () => Quotes.ToRocWb(14, 0, 14)); // bad STDDEV period - Assert.ThrowsException(() => - Quotes.ToRocWb(15, 3, 16)); + Assert.ThrowsException( + () => Quotes.ToRocWb(15, 3, 16)); } } diff --git a/tests/indicators/m-r/RollingPivots/RollingPivots.StaticSeries.Tests.cs b/tests/indicators/m-r/RollingPivots/RollingPivots.StaticSeries.Tests.cs index 7874751ca..2942312c0 100644 --- a/tests/indicators/m-r/RollingPivots/RollingPivots.StaticSeries.Tests.cs +++ b/tests/indicators/m-r/RollingPivots/RollingPivots.StaticSeries.Tests.cs @@ -421,11 +421,11 @@ public void Removed() public void Exceptions() { // bad window period - Assert.ThrowsException(() => - Quotes.ToRollingPivots(0, 10)); + Assert.ThrowsException( + () => Quotes.ToRollingPivots(0, 10)); // bad offset period - Assert.ThrowsException(() => - Quotes.ToRollingPivots(10, -1)); + Assert.ThrowsException( + () => Quotes.ToRollingPivots(10, -1)); } } diff --git a/tests/indicators/s-z/Smi/Smi.StaticSeries.Tests.cs b/tests/indicators/s-z/Smi/Smi.StaticSeries.Tests.cs index 5dc184c73..491fb1611 100644 --- a/tests/indicators/s-z/Smi/Smi.StaticSeries.Tests.cs +++ b/tests/indicators/s-z/Smi/Smi.StaticSeries.Tests.cs @@ -132,19 +132,19 @@ public void Removed() public void Exceptions() { // bad lookback period - Assert.ThrowsException(() => - Quotes.ToSmi(0, 5, 5, 5)); + Assert.ThrowsException( + () => Quotes.ToSmi(0, 5, 5, 5)); // bad first smooth period - Assert.ThrowsException(() => - Quotes.ToSmi(14, 0, 5, 5)); + Assert.ThrowsException( + () => Quotes.ToSmi(14, 0, 5, 5)); // bad second smooth period - Assert.ThrowsException(() => - Quotes.ToSmi(14, 3, 0, 5)); + Assert.ThrowsException( + () => Quotes.ToSmi(14, 3, 0, 5)); // bad signal - Assert.ThrowsException(() => - Quotes.ToSmi(9, 3, 1, 0)); + Assert.ThrowsException( + () => Quotes.ToSmi(9, 3, 1, 0)); } } diff --git a/tests/indicators/s-z/StarcBands/StarcBands.StaticSeries.Tests.cs b/tests/indicators/s-z/StarcBands/StarcBands.StaticSeries.Tests.cs index 86030fed3..32c7915f3 100644 --- a/tests/indicators/s-z/StarcBands/StarcBands.StaticSeries.Tests.cs +++ b/tests/indicators/s-z/StarcBands/StarcBands.StaticSeries.Tests.cs @@ -116,15 +116,15 @@ public void Removed() public void Exceptions() { // bad EMA period - Assert.ThrowsException(() => - Quotes.ToStarcBands(1)); + Assert.ThrowsException( + () => Quotes.ToStarcBands(1)); // bad ATR period - Assert.ThrowsException(() => - Quotes.ToStarcBands(20, 2, 1)); + Assert.ThrowsException( + () => Quotes.ToStarcBands(20, 2, 1)); // bad multiplier - Assert.ThrowsException(() => - Quotes.ToStarcBands(20, 0)); + Assert.ThrowsException( + () => Quotes.ToStarcBands(20, 0)); } } diff --git a/tests/indicators/s-z/Stc/Stc.StaticSeries.Tests.cs b/tests/indicators/s-z/Stc/Stc.StaticSeries.Tests.cs index 9cf0fbb6b..60d6f5f05 100644 --- a/tests/indicators/s-z/Stc/Stc.StaticSeries.Tests.cs +++ b/tests/indicators/s-z/Stc/Stc.StaticSeries.Tests.cs @@ -126,15 +126,15 @@ public void Removed() public void Exceptions() { // bad fast period - Assert.ThrowsException(() => - Quotes.ToStc(9, 0, 26)); + Assert.ThrowsException( + () => Quotes.ToStc(9, 0, 26)); // bad slow periods must be larger than faster period - Assert.ThrowsException(() => - Quotes.ToStc(9, 12, 12)); + Assert.ThrowsException( + () => Quotes.ToStc(9, 12, 12)); // bad signal period - Assert.ThrowsException(() => - Quotes.ToStc(-1, 12, 26)); + Assert.ThrowsException( + () => Quotes.ToStc(-1, 12, 26)); } } diff --git a/tests/indicators/s-z/StdDev/StdDev.StaticSeries.Tests.cs b/tests/indicators/s-z/StdDev/StdDev.StaticSeries.Tests.cs index c4fbc30b0..e21eb6fcf 100644 --- a/tests/indicators/s-z/StdDev/StdDev.StaticSeries.Tests.cs +++ b/tests/indicators/s-z/StdDev/StdDev.StaticSeries.Tests.cs @@ -118,10 +118,8 @@ public void Removed() Assert.AreEqual(0.524312, last.ZScore.Round(6)); } - [TestMethod] - public void Exceptions() => - - // bad lookback period - Assert.ThrowsException(() => - Quotes.ToStdDev(1)); + [TestMethod] // bad lookback period + public void Exceptions() + => Assert.ThrowsException( + () => Quotes.ToStdDev(1)); } diff --git a/tests/indicators/s-z/StdDevChannels/StdDevChannels.StaticSeries.Tests.cs b/tests/indicators/s-z/StdDevChannels/StdDevChannels.StaticSeries.Tests.cs index dc145f82b..74e00565a 100644 --- a/tests/indicators/s-z/StdDevChannels/StdDevChannels.StaticSeries.Tests.cs +++ b/tests/indicators/s-z/StdDevChannels/StdDevChannels.StaticSeries.Tests.cs @@ -75,7 +75,7 @@ public void FullHistory() Assert.AreEqual(502, results.Count(x => x.Centerline != null)); Assert.AreEqual(502, results.Count(x => x.UpperChannel != null)); Assert.AreEqual(502, results.Count(x => x.LowerChannel != null)); - Assert.AreEqual(501, results.Count(x => x.BreakPoint == false)); + Assert.AreEqual(501, results.Count(x => !x.BreakPoint)); // sample value StdDevChannelsResult r1 = results[0]; @@ -183,11 +183,11 @@ public void Removed() public void Exceptions() { // bad lookback period - Assert.ThrowsException(() => - Quotes.ToStdDevChannels(0)); + Assert.ThrowsException( + () => Quotes.ToStdDevChannels(0)); // bad standard deviations - Assert.ThrowsException(() => - Quotes.ToStdDevChannels(20, 0)); + Assert.ThrowsException( + () => Quotes.ToStdDevChannels(20, 0)); } } diff --git a/tests/indicators/s-z/Stoch/Stoch.StaticSeries.Tests.cs b/tests/indicators/s-z/Stoch/Stoch.StaticSeries.Tests.cs index 6e8fe7a1b..10f9ea6f1 100644 --- a/tests/indicators/s-z/Stoch/Stoch.StaticSeries.Tests.cs +++ b/tests/indicators/s-z/Stoch/Stoch.StaticSeries.Tests.cs @@ -263,27 +263,27 @@ public void Boundary() public void Exceptions() { // bad lookback period - Assert.ThrowsException(() => - Quotes.ToStoch(0)); + Assert.ThrowsException( + () => Quotes.ToStoch(0)); // bad signal period - Assert.ThrowsException(() => - Quotes.ToStoch(14, 0)); + Assert.ThrowsException( + () => Quotes.ToStoch(14, 0)); // bad smoothing period - Assert.ThrowsException(() => - Quotes.ToStoch(14, 3, 0)); + Assert.ThrowsException( + () => Quotes.ToStoch(14, 3, 0)); // bad kFactor - Assert.ThrowsException(() => - Quotes.ToStoch(9, 3, 1, 0, 2, MaType.SMA)); + Assert.ThrowsException( + () => Quotes.ToStoch(9, 3, 1, 0, 2, MaType.SMA)); // bad dFactor - Assert.ThrowsException(() => - Quotes.ToStoch(9, 3, 1, 3, 0, MaType.SMA)); + Assert.ThrowsException( + () => Quotes.ToStoch(9, 3, 1, 3, 0, MaType.SMA)); // bad MA type - Assert.ThrowsException(() => - Quotes.ToStoch(9, 3, 3, 3, 2, MaType.ALMA)); + Assert.ThrowsException( + () => Quotes.ToStoch(9, 3, 3, 3, 2, MaType.ALMA)); } } diff --git a/tests/indicators/s-z/StochRsi/StochRsi.StaticSeries.Tests.cs b/tests/indicators/s-z/StochRsi/StochRsi.StaticSeries.Tests.cs index 2efbd0983..a612a1e8d 100644 --- a/tests/indicators/s-z/StochRsi/StochRsi.StaticSeries.Tests.cs +++ b/tests/indicators/s-z/StochRsi/StochRsi.StaticSeries.Tests.cs @@ -158,19 +158,19 @@ public void Removed() public void Exceptions() { // bad RSI period - Assert.ThrowsException(() => - Quotes.ToStochRsi(0, 14, 3)); + Assert.ThrowsException( + () => Quotes.ToStochRsi(0, 14, 3)); // bad STO period - Assert.ThrowsException(() => - Quotes.ToStochRsi(14, 0, 3, 3)); + Assert.ThrowsException( + () => Quotes.ToStochRsi(14, 0, 3, 3)); // bad STO signal period - Assert.ThrowsException(() => - Quotes.ToStochRsi(14, 14, 0)); + Assert.ThrowsException( + () => Quotes.ToStochRsi(14, 14, 0)); // bad STO smoothing period - Assert.ThrowsException(() => - Quotes.ToStochRsi(14, 14, 3, 0)); + Assert.ThrowsException( + () => Quotes.ToStochRsi(14, 14, 3, 0)); } } diff --git a/tests/indicators/s-z/SuperTrend/SuperTrend.StaticSeries.Tests.cs b/tests/indicators/s-z/SuperTrend/SuperTrend.StaticSeries.Tests.cs index 3b652b756..5fa458b91 100644 --- a/tests/indicators/s-z/SuperTrend/SuperTrend.StaticSeries.Tests.cs +++ b/tests/indicators/s-z/SuperTrend/SuperTrend.StaticSeries.Tests.cs @@ -127,11 +127,11 @@ public void Removed() public void Exceptions() { // bad lookback period - Assert.ThrowsException(() => - Quotes.ToSuperTrend(1)); + Assert.ThrowsException( + () => Quotes.ToSuperTrend(1)); // bad multiplier - Assert.ThrowsException(() => - Quotes.ToSuperTrend(7, 0)); + Assert.ThrowsException( + () => Quotes.ToSuperTrend(7, 0)); } } diff --git a/tests/indicators/s-z/T3/T3.StaticSeries.Tests.cs b/tests/indicators/s-z/T3/T3.StaticSeries.Tests.cs index 5cb40775b..da27804e2 100644 --- a/tests/indicators/s-z/T3/T3.StaticSeries.Tests.cs +++ b/tests/indicators/s-z/T3/T3.StaticSeries.Tests.cs @@ -93,11 +93,11 @@ public override void NoQuotes() public void Exceptions() { // bad lookback period - Assert.ThrowsException(() => - Quotes.ToT3(0)); + Assert.ThrowsException( + () => Quotes.ToT3(0)); // bad volume factor - Assert.ThrowsException(() => - Quotes.ToT3(25, 0)); + Assert.ThrowsException( + () => Quotes.ToT3(25, 0)); } } diff --git a/tests/indicators/s-z/Tema/Tema.StaticSeries.Tests.cs b/tests/indicators/s-z/Tema/Tema.StaticSeries.Tests.cs index 23e39b123..e6f90e02c 100644 --- a/tests/indicators/s-z/Tema/Tema.StaticSeries.Tests.cs +++ b/tests/indicators/s-z/Tema/Tema.StaticSeries.Tests.cs @@ -92,7 +92,7 @@ public void Removed() .RemoveWarmupPeriods(); // assertions - Assert.AreEqual(502 - (3 * 20 + 100), results.Count); + Assert.AreEqual(502 - ((3 * 20) + 100), results.Count); TemaResult last = results[^1]; Assert.AreEqual(238.7690, last.Tema.Round(4)); diff --git a/tests/indicators/s-z/Trix/Trix.StaticSeries.Tests.cs b/tests/indicators/s-z/Trix/Trix.StaticSeries.Tests.cs index 626d544b5..2b3ab3750 100644 --- a/tests/indicators/s-z/Trix/Trix.StaticSeries.Tests.cs +++ b/tests/indicators/s-z/Trix/Trix.StaticSeries.Tests.cs @@ -97,7 +97,7 @@ public void Removed() .RemoveWarmupPeriods(); // assertions - Assert.AreEqual(502 - (3 * 20 + 100), results.Count); + Assert.AreEqual(502 - ((3 * 20) + 100), results.Count); TrixResult last = results[^1]; Assert.AreEqual(263.3216, last.Ema3.Round(4)); diff --git a/tests/indicators/s-z/Tsi/Tsi.StaticSeries.Tests.cs b/tests/indicators/s-z/Tsi/Tsi.StaticSeries.Tests.cs index ec96ba655..c029e60b8 100644 --- a/tests/indicators/s-z/Tsi/Tsi.StaticSeries.Tests.cs +++ b/tests/indicators/s-z/Tsi/Tsi.StaticSeries.Tests.cs @@ -125,15 +125,15 @@ public void Removed() public void Exceptions() { // bad lookback period - Assert.ThrowsException(() => - Quotes.ToTsi(0)); + Assert.ThrowsException( + () => Quotes.ToTsi(0)); // bad smoothing period - Assert.ThrowsException(() => - Quotes.ToTsi(25, 0)); + Assert.ThrowsException( + () => Quotes.ToTsi(25, 0)); // bad signal period - Assert.ThrowsException(() => - Quotes.ToTsi(25, 13, -1)); + Assert.ThrowsException( + () => Quotes.ToTsi(25, 13, -1)); } } diff --git a/tests/indicators/s-z/Ultimate/Ultimate.StaticSeries.Tests.cs b/tests/indicators/s-z/Ultimate/Ultimate.StaticSeries.Tests.cs index 8571195da..bd7bd4039 100644 --- a/tests/indicators/s-z/Ultimate/Ultimate.StaticSeries.Tests.cs +++ b/tests/indicators/s-z/Ultimate/Ultimate.StaticSeries.Tests.cs @@ -77,15 +77,15 @@ public void Removed() public void Exceptions() { // bad short period - Assert.ThrowsException(() => - Quotes.ToUltimate(0)); + Assert.ThrowsException( + () => Quotes.ToUltimate(0)); // bad middle period - Assert.ThrowsException(() => - Quotes.ToUltimate(7, 6)); + Assert.ThrowsException( + () => Quotes.ToUltimate(7, 6)); // bad long period - Assert.ThrowsException(() => - Quotes.ToUltimate(7, 14, 11)); + Assert.ThrowsException( + () => Quotes.ToUltimate(7, 14, 11)); } } diff --git a/tests/indicators/s-z/VolatilityStop/VolatilityStop.StaticSeries.Tests.cs b/tests/indicators/s-z/VolatilityStop/VolatilityStop.StaticSeries.Tests.cs index 66687b868..57d369369 100644 --- a/tests/indicators/s-z/VolatilityStop/VolatilityStop.StaticSeries.Tests.cs +++ b/tests/indicators/s-z/VolatilityStop/VolatilityStop.StaticSeries.Tests.cs @@ -114,11 +114,11 @@ public void Removed() public void Exceptions() { // bad lookback period - Assert.ThrowsException(() => - Quotes.ToVolatilityStop(1)); + Assert.ThrowsException( + () => Quotes.ToVolatilityStop(1)); // bad multiplier - Assert.ThrowsException(() => - Quotes.ToVolatilityStop(20, 0)); + Assert.ThrowsException( + () => Quotes.ToVolatilityStop(20, 0)); } } diff --git a/tests/indicators/s-z/Vwap/Vwap.StaticSeries.Tests.cs b/tests/indicators/s-z/Vwap/Vwap.StaticSeries.Tests.cs index cb07abc66..d8e5e4941 100644 --- a/tests/indicators/s-z/Vwap/Vwap.StaticSeries.Tests.cs +++ b/tests/indicators/s-z/Vwap/Vwap.StaticSeries.Tests.cs @@ -129,7 +129,7 @@ public void Exceptions() DateTime startDate = DateTime.ParseExact("2000-12-15", "yyyy-MM-dd", invariantCulture); - Assert.ThrowsException(() => - Quotes.ToVwap(startDate)); + Assert.ThrowsException( + () => Quotes.ToVwap(startDate)); } } diff --git a/tests/other/GlobalSuppressions.cs b/tests/other/GlobalSuppressions.cs new file mode 100644 index 000000000..03782e35e --- /dev/null +++ b/tests/other/GlobalSuppressions.cs @@ -0,0 +1,6 @@ +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage( + "Maintainability", + "CA1515:Consider making public types internal", + Justification = "Test projects use public class types.")] diff --git a/tests/performance/GlobalSuppressions.cs b/tests/performance/GlobalSuppressions.cs index 76695c9cc..3f8807f6f 100644 --- a/tests/performance/GlobalSuppressions.cs +++ b/tests/performance/GlobalSuppressions.cs @@ -5,6 +5,11 @@ "CA1051:Do not declare visible instance fields", Justification = "Required for BenchmarkDotNet")] +[assembly: SuppressMessage( + "Maintainability", + "CA1515:Consider making public types internal", + Justification = "Test projects use public class types.")] + [assembly: SuppressMessage( "Performance", "CA1822:Mark members as static", diff --git a/tests/performance/Tests.Performance.csproj b/tests/performance/Tests.Performance.csproj index 3124d795b..974a936ca 100644 --- a/tests/performance/Tests.Performance.csproj +++ b/tests/performance/Tests.Performance.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 Exe Performance.Program diff --git a/tests/simulate/GlobalSuppressions.cs b/tests/simulate/GlobalSuppressions.cs new file mode 100644 index 000000000..7f28ca9b7 --- /dev/null +++ b/tests/simulate/GlobalSuppressions.cs @@ -0,0 +1,43 @@ +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage( + "Maintainability", + "CA1510:Use ArgumentNullException throw helper", + Justification = "Does not support .NET Standard.")] + +[assembly: SuppressMessage( + "Maintainability", + "CA1515:Consider making public types internal", + Justification = "Test projects use public class types.")] + +[assembly: SuppressMessage( + "Naming", + "CA1720:Identifier contains type name", + Justification = "Not really an issue.", + Scope = "member", + Target = "~F:Skender.Stock.Indicators.ChandelierType.Long")] + +[assembly: SuppressMessage("Naming", + "CA1720:Identifier contains type name" + , Justification = "Not really an issue.", + Scope = "type", + Target = "~T:Skender.Stock.Indicators.ChandelierType")] + +[assembly: SuppressMessage( + "Naming", + "CA1720:Identifier contains type name", + Justification = "Not really an issue.", + Scope = "member", + Target = "~F:Skender.Stock.Indicators.ChandelierType.Short")] + +[assembly: SuppressMessage( + "Maintainability", + "CA1510:Use ArgumentNullException throw helper", + Justification = "Can only use with .NET 6 or later. We support .NET Framework and .NET Standard.")] + +[assembly: SuppressMessage( + "Naming", + "CA1716:Identifiers should not match keywords", + Justification = "Temporary, during deprecation period.", + Scope = "member", + Target = "~P:Skender.Stock.Indicators.ISeries.Date")] diff --git a/tests/simulate/Test.Simulation.csproj b/tests/simulate/Test.Simulation.csproj index 1ebfaa471..b9f7b92ef 100644 --- a/tests/simulate/Test.Simulation.csproj +++ b/tests/simulate/Test.Simulation.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 Exe enable