diff --git a/.github/GitVersion.yml b/.github/GitVersion.yml new file mode 100644 index 00000000..3f47e036 --- /dev/null +++ b/.github/GitVersion.yml @@ -0,0 +1,20 @@ +mode: ContinuousDeployment +branches: + main: + regex: ^main$ + is-release-branch: true + is-mainline: true + prevent-increment-of-merged-branch-version: true + track-merge-target: false + increment: inherit + develop: + regex: ^dev$ + is-release-branch: false + prevent-increment-of-merged-branch-version: false + track-merge-target: true +ignore: + sha: [] +major-version-bump-message: '\+semver:\s?(feature|major)' +minor-version-bump-message: '\+semver:\s?(new|update|minor)' +no-bump-message: '\+semver:\s?(skip|none|fix)' + diff --git a/.github/workflows/main_automation.yml b/.github/workflows/main_automation.yml index a196194f..9a76241f 100644 --- a/.github/workflows/main_automation.yml +++ b/.github/workflows/main_automation.yml @@ -28,6 +28,19 @@ jobs: with: java-version: 1.11 + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v0 + with: + versionSpec: '6.x' + includePrerelease: true + - name: Determine Version + uses: gittools/actions/gitversion/execute@v0 + with: + useConfigFile: true + configFilePath: .\.github\GitVersion.yml + additionalArguments: '/verbosity Diagnostic' + + - name: Install JetBrains run: dotnet tool install JetBrains.dotCover.GlobalTool --global - name: Install Sonar Scanner @@ -39,7 +52,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - #run: dotnet sonarscanner begin /o:"mihakralj" /k:"mihakralj_QuanTAlib" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths="./coverage.xml" run: dotnet sonarscanner begin /o:"mihakralj" /k:"mihakralj_QuanTAlib" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" @@ -68,18 +80,16 @@ jobs: run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" - name: Codacy coverage reporter - if: ${{ github.ref == 'refs/heads/dev' }} uses: codacy/codacy-coverage-reporter-action@v1 with: project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} coverage-reports: ./coveragereport.xml - name: Release - if: ${{ github.ref == 'refs/heads/main' }} uses: marvinpinto/action-automatic-releases@latest with: repo_token: "${{ secrets.GITHUB_TOKEN }}" - automatic_release_tag: "latest" + automatic_release_tag: latest prerelease: true title: "Latest Build" files: | diff --git a/Calculations/Basics/ABOVE_Series.cs b/Calculations/Basics/ABOVE_Series.cs new file mode 100644 index 00000000..93fb6457 --- /dev/null +++ b/Calculations/Basics/ABOVE_Series.cs @@ -0,0 +1,39 @@ +namespace QuanTAlib; +using System; + +/* +OVER - Generates +1 if A is above B, -1 if A is below B and 0 if A=B + +Remarks: + OVER.Cross generates 1 when A breaks B from below and -1 when A breaks B from above + + */ + +public class OVER_Series : Pair_TSeries_Indicator { + public TSeries Cross = new(); + private double _previous = double.NaN; + public OVER_Series(TSeries d1, TSeries d2) : base(d1, d2) { + if (base._d1.Count > 0 && base._d2.Count > 0) { for (int i = 0; i < base._d1.Count; i++) { this.Add(base._d1[i], base._d2[i], false); } } + } + public OVER_Series(TSeries d1, double dd2) : base(d1, dd2) { + if (base._d1.Count > 0) { for (int i = 0; i < base._d1.Count; i++) { this.Add(base._d1[i], (base._d1[i].t, dd2), false); } } + } + public OVER_Series(double dd1, TSeries d2) : base(dd1, d2) { + if (base._d2.Count > 0) { for (int i = 0; i < base._d2.Count; i++) { this.Add((base._d2[i].t, dd1), base._d2[i], false); } } + } + + public override void Add((System.DateTime t, double v) TValue1, (System.DateTime t, double v) TValue2, bool update) { + (System.DateTime t, double v) over = ((TValue1.t > TValue2.t) ? TValue1.t : TValue2.t, TValue1.v > TValue2.v ? 1 : TValue1.v < TValue2.v ? -1 : 0); + if (update) { this.Cross[^1] = over; } + else { this.Cross.Add(over); } + + (System.DateTime t, double v) result = ((TValue1.t > TValue2.t) ? TValue1.t : TValue2.t, + ((_previous == over.v) || (_previous != 0) || Double.IsNaN(_previous)) ? 0 : (_previous < over.v) ? 1 : -1); + _previous = over.v; + + if (update) { base[^1] = result; } + else { base.Add(result); } + + } +} + diff --git a/Calculations/Calculations.csproj b/Calculations/Calculations.csproj index 39229ef1..7ea69e5e 100644 --- a/Calculations/Calculations.csproj +++ b/Calculations/Calculations.csproj @@ -2,7 +2,7 @@ QuanTAlib - 0.1.32 + $(GitVersion_NuGetVersionV2) Library of TA Calculations, Charts and Strategies for Quantower Quantitative Technical Analysis Library in C# for Quantower git diff --git a/GitVersion.yml b/GitVersion.yml deleted file mode 100644 index 528a7543..00000000 --- a/GitVersion.yml +++ /dev/null @@ -1,21 +0,0 @@ -mode: Mainline -branches: - main: - regex: ^main$ - increment: Patch - is-mainline: true - is-release-branch: true - source-branches: [ 'dev' ] - prevent-increment-of-merged-branch-version: true - tag: '' - dev: - regex: ^dev$ - increment: Patch - is-mainline: false - is-release-branch: false - source-branches: [] - prevent-increment-of-merged-branch-version: false - tracks-release-branches: true - track-merge-target: true - tag: dev -tag-prefix: '' \ No newline at end of file