Skip to content

Commit

Permalink
Merge branch 'main' into v3-increments
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveSkender committed Jan 3, 2024
2 parents 40b1f4f + 0d3e8b4 commit 24fce98
Show file tree
Hide file tree
Showing 130 changed files with 73 additions and 462 deletions.
6 changes: 3 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ dotnet_sort_system_directives_first = true

dotnet_style_operator_placement_when_wrapping = beginning_of_line
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
dotnet_style_namespace_match_folder = false:silent
dotnet_style_namespace_match_folder = false:none
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
Expand All @@ -90,11 +90,11 @@ dotnet_style_prefer_collection_expression = true:suggestion

[*.cs]
csharp_indent_labels = one_less_than_current
csharp_using_directive_placement = outside_namespace:suggestion
csharp_using_directive_placement = outside_namespace:warning
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_static_local_function = true:suggestion
csharp_prefer_braces = true:suggestion
csharp_style_namespace_declarations = file_scoped:silent
csharp_style_namespace_declarations = file_scoped:suggestion
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/build-indicators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
--logger trx
--results-directory ./test-other
- name: Update tests summary
- name: Post tests summary
uses: bibipkins/[email protected]
if: ${{ github.event_name == 'pull_request' && (success() || (failure() && (steps.test-library.conclusion == 'failure' || steps.test-other.conclusion == 'failure'))) }}
with:
Expand All @@ -71,3 +71,11 @@ jobs:
results-path: ./test-indicators/**/*.trx
coverage-path: ./test-indicators/**/coverage.cobertura.xml
coverage-type: cobertura

- name: Post coverage to Codacy
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: ./test-indicators/**/coverage.cobertura.xml
# or a comma-separated list for multiple reports
# coverage-reports: <PATH_TO_REPORT>, <PATH_TO_REPORT>
4 changes: 2 additions & 2 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Deploy website
on: [workflow_dispatch]

concurrency:
group: cloudflare-pages
group: docs-website

env:
JEKYLL_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest

environment:
name: cloudflare-pages
name: docs-website

steps:
- name: Checkout source
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/semantic-pr-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:

jobs:
main:
name: Validate PR title
name: validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
Expand Down Expand Up @@ -52,12 +52,12 @@ jobs:
It looks like your proposed **_Pull request title_** needs to be adjusted.
>🚩 **ERROR:** ${{ steps.lint_pr_title.outputs.error_message }}
>🚩 **Error** » ${{ steps.lint_pr_title.outputs.error_message }}
#### Pull request title naming convention
Our PR title name taxonomy is `type: Subject`, where **type** is typically
*feat*, *fix*, or *chore* and **subject** is a noun that starts with a capitalized letter.
*feat*, *fix*, or *chore*, and **subject** is a phrase (proper noun) that starts with a capitalized letter.
The *chore* type usually has a subject that starts with an action verb like *Add* or *Update*.
Examples: `feat: Admin portal login`, `fix: Divide by zero bug in SMA`, and `chore: Update user docs`.
See the [Conventional Commits specification](https://www.conventionalcommits.org) for more information.
Expand Down
18 changes: 9 additions & 9 deletions docs/GemFile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ GEM
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
addressable (2.8.5)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
base64 (0.2.0)
bigdecimal (3.1.4)
bigdecimal (3.1.5)
coffee-script (2.4.1)
coffee-script-source
execjs
Expand All @@ -41,7 +41,7 @@ GEM
ethon (0.16.0)
ffi (>= 1.15.0)
execjs (2.9.1)
faraday (2.7.11)
faraday (2.8.1)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
Expand Down Expand Up @@ -227,7 +227,7 @@ GEM
gemoji (~> 3.0)
html-pipeline (~> 2.2)
jekyll (>= 3.0, < 5.0)
json (2.6.3)
json (2.7.1)
json-minify (0.0.3)
json (> 0)
kramdown (2.3.2)
Expand All @@ -245,9 +245,9 @@ GEM
jekyll-seo-tag (~> 2.1)
minitest (5.20.0)
mutex_m (0.2.0)
nokogiri (1.15.4-x64-mingw-ucrt)
nokogiri (1.15.5-x64-mingw-ucrt)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux)
nokogiri (1.15.5-x86_64-linux)
racc (~> 1.4)
octokit (4.25.1)
faraday (>= 1, < 3)
Expand Down Expand Up @@ -277,16 +277,16 @@ GEM
unf (~> 0.1.4)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
typhoeus (1.4.0)
typhoeus (1.4.1)
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.9)
unf_ext (0.0.9-x64-mingw-ucrt)
unf_ext (0.0.9.1)
unf_ext (0.0.9.1-x64-mingw-ucrt)
unicode-display_width (1.8.0)
wdm (0.1.1)
webrick (1.8.1)
Expand Down
5 changes: 0 additions & 5 deletions src/Indicators.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReleaseNotes>https://github.com/DaveSkender/Stock.Indicators/releases</PackageReleaseNotes>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageLicenseFile></PackageLicenseFile>
<PackageIcon>icon.png</PackageIcon>

<IncludeSymbols>true</IncludeSymbols>
Expand All @@ -60,19 +59,15 @@
<ItemGroup>
<None Include="..\README.md">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
<None Include="..\LICENSE">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
<None Include="..\NOTICE">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
<None Include="icon.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/_common/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ public enum Act
UpdateOld,
Delete,
DoNothing
}
}
8 changes: 3 additions & 5 deletions src/_common/Math/NullMath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,20 @@ public static decimal Round(this decimal value, int digits)
=> Math.Round(value, digits);

public static double Null2NaN(this double? value)
=> (value is null)
? double.NaN
: (double)value;
=> value ?? double.NaN;

public static double Null2NaN(this decimal? value)
=> (value is null)
? double.NaN
: (double)value;

public static double? NaN2Null(this double? value)
=> (value is double and double.NaN)
=> (value is not null and double.NaN)
? null
: value;

public static double? NaN2Null(this double value)
=> (value is double and double.NaN)
=> double.IsNaN(value)
? null
: value;
}
8 changes: 3 additions & 5 deletions src/_common/Math/Numerix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,18 @@ public static double Slope(double[] x, double[] y)

// least squares method
double sumSqX = 0;
double sumSqY = 0;
double sumSqXY = 0;
double sumSqXy = 0;

for (int i = 0; i < length; i++)
{
double devX = x[i] - avgX;
double devY = y[i] - avgY;

sumSqX += devX * devX;
sumSqY += devY * devY;
sumSqXY += devX * devY;
sumSqXy += devX * devY;
}

double slope = sumSqXY / sumSqX;
double slope = sumSqXy / sumSqX;

return slope;
}
Expand Down
6 changes: 0 additions & 6 deletions src/_common/Quotes/Quote.Aggregates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ public static IEnumerable<Quote> Aggregate<TQuote>(
TimeSpan timeSpan)
where TQuote : IQuote
{
// handle no quotes scenario
if (quotes == null || !quotes.Any())
{
return new List<Quote>();
}

if (timeSpan <= TimeSpan.Zero)
{
throw new ArgumentOutOfRangeException(nameof(timeSpan), timeSpan,
Expand Down
4 changes: 1 addition & 3 deletions src/_common/Quotes/Quote.Validation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ public static IEnumerable<TQuote> Validate<TQuote>(

// check for duplicates
DateTime lastDate = DateTime.MinValue;
for (int i = 0; i < quotesList.Count; i++)
foreach (var q in quotesList)
{
TQuote q = quotesList[i];

if (lastDate == q.Date)
{
throw new InvalidQuotesException(
Expand Down
2 changes: 1 addition & 1 deletion src/_common/Results/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@
Invalid parameter value provided.
</exception>
</type>
</info>
</info>
2 changes: 1 addition & 1 deletion src/a-d/Dpo/Dpo.Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ public static IEnumerable<DpoResult> GetDpo(
int lookbackPeriods) => priceTuples
.ToSortedList()
.CalcDpo(lookbackPeriods);
}
}
2 changes: 1 addition & 1 deletion src/e-k/Epma/Epma.Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ public static IEnumerable<EpmaResult> GetEpma(
int lookbackPeriods) => priceTuples
.ToSortedList()
.CalcEpma(lookbackPeriods);
}
}
2 changes: 1 addition & 1 deletion src/e-k/Hma/Hma.Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ public static IEnumerable<HmaResult> GetHma(
int lookbackPeriods) => priceTuples
.ToSortedList()
.CalcHma(lookbackPeriods);
}
}
2 changes: 1 addition & 1 deletion src/m-r/ParabolicSar/ParabolicSar.Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ internal static List<ParabolicSarResult> CalcParabolicSar(
// roll through quotes
for (int i = 0; i < length; i++)
{
QuoteD? q = qdList[i];
QuoteD q = qdList[i];

ParabolicSarResult r = new() { Date = q.Date };
results.Add(r);
Expand Down
2 changes: 1 addition & 1 deletion src/m-r/PivotPoints/PivotPoints.Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ internal static TPivotPoint GetPivotPointWoodie<TPivotPoint>(
}

// pivot type lookup
internal static TPivotPoint? GetPivotPoint<TPivotPoint>(
internal static TPivotPoint GetPivotPoint<TPivotPoint>(
PivotPointType pointType, decimal open, decimal high, decimal low, decimal close)
where TPivotPoint : IPivotPoint, new()
=> pointType switch
Expand Down
20 changes: 10 additions & 10 deletions src/m-r/RollingPivots/RollingPivots.Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ internal static List<RollingPivotsResult> CalcRollingPivots<TQuote>(
}

// pivot points
RollingPivotsResult? wp = GetPivotPoint<RollingPivotsResult>(
RollingPivotsResult wp = GetPivotPoint<RollingPivotsResult>(
pointType, q.Open, windowHigh, windowLow, windowClose);

r.PP = wp?.PP;
r.S1 = wp?.S1;
r.S2 = wp?.S2;
r.S3 = wp?.S3;
r.S4 = wp?.S4;
r.R1 = wp?.R1;
r.R2 = wp?.R2;
r.R3 = wp?.R3;
r.R4 = wp?.R4;
r.PP = wp.PP;
r.S1 = wp.S1;
r.S2 = wp.S2;
r.S3 = wp.S3;
r.S4 = wp.S4;
r.R1 = wp.R1;
r.R2 = wp.R2;
r.R3 = wp.R3;
r.R4 = wp.R4;
}

results.Add(r);
Expand Down
2 changes: 1 addition & 1 deletion src/s-z/Sma/Sma.Analysis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static IEnumerable<SmaAnalysis> CalcSmaAnalysis(
int lookbackPeriods)
{
// initialize
List<SmaAnalysis>? results = tpList
List<SmaAnalysis> results = tpList
.CalcSma(lookbackPeriods)
.Select(x => new SmaAnalysis()
{
Expand Down
2 changes: 1 addition & 1 deletion src/s-z/Tema/Tema.Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ public static IEnumerable<TemaResult> GetTema(
int lookbackPeriods) => priceTuples
.ToSortedList()
.CalcTema(lookbackPeriods);
}
}
3 changes: 3 additions & 0 deletions tests/indicators/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
global using Microsoft.VisualStudio.TestTools.UnitTesting;
global using Skender.Stock.Indicators;
global using Tests.Common;
2 changes: 0 additions & 2 deletions tests/indicators/_Initialize.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.Globalization;
using System.Runtime.CompilerServices;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Skender.Stock.Indicators;

// GLOBALS & INITIALIZATION OF TEST DATA

Expand Down
3 changes: 0 additions & 3 deletions tests/indicators/_common/Candles/Candles.Tests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Skender.Stock.Indicators;

namespace Tests.Common;

[TestClass]
Expand Down
3 changes: 0 additions & 3 deletions tests/indicators/_common/Generics/Pruning.Tests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Skender.Stock.Indicators;

namespace Tests.Common;

[TestClass]
Expand Down
3 changes: 0 additions & 3 deletions tests/indicators/_common/Generics/Seek.Tests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Skender.Stock.Indicators;

namespace Tests.Common;

[TestClass]
Expand Down
2 changes: 0 additions & 2 deletions tests/indicators/_common/Generics/Sort.Tests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.ObjectModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Skender.Stock.Indicators;

namespace Tests.Common;

Expand Down
2 changes: 0 additions & 2 deletions tests/indicators/_common/Generics/Transforms.Tests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.ObjectModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Skender.Stock.Indicators;

namespace Tests.Common;

Expand Down
Loading

0 comments on commit 24fce98

Please sign in to comment.