Skip to content

Commit

Permalink
fix: Merge main into v3 (#1142)
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Skender <[email protected]>
  • Loading branch information
DaveSkender committed Jan 3, 2024
1 parent e38b43b commit ad39bc9
Show file tree
Hide file tree
Showing 140 changed files with 103 additions and 507 deletions.
29 changes: 16 additions & 13 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ charset = utf-8
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
max_line_length = 150
Expand All @@ -15,7 +16,9 @@ max_line_length = 150
csharp_indent_block_contents = true

# IDE0161 Convert to file-scoped namespace
csharp_style_namespace_declarations= file_scoped:suggestion
csharp_style_namespace_declarations = file_scoped:suggestion
csharp_using_directive_placement = outside_namespace:warning
dotnet_style_namespace_match_folder = false:none

# CA1051: Do not declare visible instance fields
dotnet_diagnostic.CA1051.severity = silent
Expand All @@ -25,7 +28,7 @@ dotnet_diagnostic.CA1303.severity = none

# CA1720: Identifier contains type name
dotnet_diagnostic.CA1720.severity = silent
dotnet_diagnostic.IDE0090.severity= suggestion
dotnet_diagnostic.IDE0090.severity = suggestion
dotnet_diagnostic.SA1413.severity = silent
dotnet_diagnostic.SA1200.severity = silent

Expand All @@ -49,7 +52,6 @@ dotnet_diagnostic.SA1117.severity = none

# SA1118: Parameter should not span multiple lines
dotnet_diagnostic.SA1118.severity = silent
csharp_using_directive_placement = outside_namespace:warning

# SA1202: Elements should be ordered by access
dotnet_diagnostic.SA1202.severity = silent
Expand Down Expand Up @@ -79,15 +81,15 @@ dotnet_diagnostic.SA1602.severity = silent
dotnet_diagnostic.SA1633.severity = none

# Misc IDE
dotnet_diagnostic.IDE0055.severity=suggestion
dotnet_diagnostic.IDE0059.severity=suggestion
dotnet_diagnostic.IDE0060.severity=suggestion
dotnet_diagnostic.IDE0062.severity=suggestion
dotnet_diagnostic.IDE0063.severity=suggestion
dotnet_diagnostic.IDE0065.severity=suggestion
dotnet_diagnostic.IDE0066.severity=suggestion
dotnet_diagnostic.IDE0071.severity=suggestion
dotnet_diagnostic.IDE0047.severity=suggestion
dotnet_diagnostic.IDE0055.severity = suggestion
dotnet_diagnostic.IDE0059.severity = suggestion
dotnet_diagnostic.IDE0060.severity = suggestion
dotnet_diagnostic.IDE0062.severity = suggestion
dotnet_diagnostic.IDE0063.severity = suggestion
dotnet_diagnostic.IDE0065.severity = suggestion
dotnet_diagnostic.IDE0066.severity = suggestion
dotnet_diagnostic.IDE0071.severity = suggestion
dotnet_diagnostic.IDE0047.severity = suggestion
csharp_indent_labels = no_change
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:suggestion
Expand Down Expand Up @@ -137,6 +139,8 @@ csharp_style_prefer_primary_constructors = true:suggestion

# IDE0058: Expression value is never used
dotnet_diagnostic.IDE0058.severity = none
dotnet_diagnostic.IDE0077.severity = warning
dotnet_diagnostic.IDE0100.severity = suggestion

[*.{cs,vb}]
tab_width = 4
Expand Down Expand Up @@ -216,6 +220,5 @@ dotnet_style_qualification_for_field = false:silent
dotnet_style_qualification_for_property = false:silent
dotnet_style_qualification_for_method = false:silent
dotnet_style_qualification_for_event = false:silent
dotnet_style_namespace_match_folder= false:silent
dotnet_style_allow_multiple_blank_lines_experimental = false:suggestion
dotnet_style_allow_statement_immediately_after_block_experimental = false:suggestion
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 @@ -72,3 +72,11 @@ jobs:
coverage-path: ./test-indicators/**/coverage.cobertura.xml
coverage-type: cobertura
coverage-threshold: 95

- 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
7 changes: 1 addition & 6 deletions src/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

using System.Diagnostics.CodeAnalysis;

[assembly: SuppressMessage(
Expand Down Expand Up @@ -68,4 +63,4 @@
"Naming",
"CA1716:Identifiers should not match keywords",
Justification = "The microsoft OnError implementation uses reserved word Error",
Scope = "member", Target = "~M:Skender.Stock.Indicators.TupleObserver.OnError(System.Exception)")]
Scope = "member", Target = "~M:Skender.Stock.Indicators.TupleObserver.OnError(System.Exception)")]
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 @@ -72,4 +72,4 @@ public enum SyncType
AppendOnly,
RemoveOnly,
FullMatch
}
}
8 changes: 3 additions & 5 deletions src/_common/Math/NullMath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,15 @@ 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? 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
4 changes: 2 additions & 2 deletions src/_common/Observables/ChainProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public abstract class ChainProvider
// initialize
protected ChainProvider()
{
observers = new();
ProtectedChain = new();
observers = [];
ProtectedChain = [];
Warmup = true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/_common/Observables/QuoteProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public class QuoteProvider : IObservable<Quote>
// initialize
public QuoteProvider()
{
observers = new();
ProtectedQuotes = new();
observers = [];
ProtectedQuotes = [];
}

// properties
Expand Down
4 changes: 2 additions & 2 deletions src/_common/Observables/TupleProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public abstract class TupleProvider
// initialize
protected TupleProvider()
{
observers = new();
ProtectedTuples = new();
observers = [];
ProtectedTuples = [];
}

// properties
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
3 changes: 0 additions & 3 deletions src/_common/Quotes/Quote.Exceptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;

namespace Skender.Stock.Indicators;

public class InvalidQuotesException : ArgumentOutOfRangeException
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
4 changes: 2 additions & 2 deletions src/_common/Results/Result.Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static IEnumerable<TResult> Condense<TResult>(

resultsList
.RemoveAll(match:
x => x.Value is null or (double and double.NaN));
x => x.Value is null or (not null and double.NaN));

return resultsList.ToSortedList();
}
Expand All @@ -45,7 +45,7 @@ public static IEnumerable<TResult> Condense<TResult>(

for (int i = first; i < reList.Count; i++)
{
IReusableResult? r = reList[i];
IReusableResult r = reList[i];
prices.Add(new(r.Date, r.Value.Null2NaN()));
}

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 @@ -21,7 +21,7 @@
<typeparam name="TResult">Any reusable result type.</typeparam>
<param name="reusable">Indicator results to evaluate.</param>
<returns>Collection of tuple time series of
results with specified handline of nulls, without pruning.</returns>
results with specified handling of nulls, without pruning.</returns>
</type>
<type name="Prune">
<summary> Removes the recommended quantity of results from the beginning of the results list
Expand Down
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 @@ -27,4 +27,4 @@ public static IEnumerable<DpoResult> GetDpo(
int lookbackPeriods) => priceTuples
.ToSortedList()
.CalcDpo(lookbackPeriods);
}
}
Loading

0 comments on commit ad39bc9

Please sign in to comment.