This commit is contained in:
Miha Kralj
2022-04-24 13:14:26 -07:00
4 changed files with 196 additions and 247 deletions
+102 -154
View File
@@ -1,154 +1,102 @@
name: Stage/build/test/release/publish name: Stage/build/test/release/publish
on: on:
workflow_dispatch: workflow_dispatch:
push: push:
branches: branches:
- '*' - '*'
pull_request: pull_request:
branches: branches:
- '*' - '*'
jobs: jobs:
build_test: build_test:
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Install .NET 7.0 - name: Install .NET 7.0
uses: actions/setup-dotnet@v1 uses: actions/setup-dotnet@v1
with: with:
dotnet-version: | dotnet-version: |
7.0.x 7.0.x
5.0.x 5.0.x
include-prerelease: true include-prerelease: true
- name: Install JDK11 for Sonar Scanner - name: Install JDK11 for Sonar Scanner
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
java-version: 1.11 java-version: 1.11
- name: Install JetBrains - name: Install JetBrains
run: dotnet tool install JetBrains.dotCover.GlobalTool --global run: dotnet tool install JetBrains.dotCover.GlobalTool --global
- name: Install Sonar Scanner - name: Install Sonar Scanner
run: dotnet tool install dotnet-sonarscanner --global run: dotnet tool install dotnet-sonarscanner --global
- name: Install dotnet-coverage - name: Install dotnet-coverage
run: dotnet tool install dotnet-coverage --global run: dotnet tool install dotnet-coverage --global
- name: Install CodeCov - name: Install CodeCov
run: dotnet tool install --global Codecov.Tool run: dotnet tool install --global Codecov.Tool
- name: Sonar start - name: Sonar start
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_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" /d:sonar.cs.vscoveragexml.reportsPaths="./coverage.xml"
run: dotnet sonarscanner begin /o:"mihakralj" /k:"mihakralj_QuanTAlib" run: dotnet sonarscanner begin /o:"mihakralj" /k:"mihakralj_QuanTAlib"
/d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
/d:sonar.host.url="https://sonarcloud.io" /d:sonar.host.url="https://sonarcloud.io"
/d:sonar.cs.dotcover.reportsPaths=./coveragereport.html /d:sonar.cs.dotcover.reportsPaths=./coveragereport.html
- name: Build Core DLL - name: Build Core DLL
run: dotnet build ./Source/QuanTAlib.csproj --verbosity normal --configuration Debug --nologo run: dotnet build ./Source/QuanTAlib.csproj --verbosity normal --configuration Debug --nologo
- name: Build Quantower DLL - name: Build Quantower DLL
run: dotnet build ./Quantower/Quantower.csproj --verbosity normal --configuration Debug --nologo run: dotnet build ./Quantower/Quantower.csproj --verbosity normal --configuration Debug --nologo
- name: dotnet Test - name: dotnet Test
run: dotnet test ./Tests/Tests.csproj --verbosity normal --configuration Debug --nologo run: dotnet test ./Tests/Tests.csproj --verbosity normal --configuration Debug --nologo
- name: DotCover Test XML - name: DotCover Test XML
run: dotnet dotcover test ./Tests/Tests.csproj --verbosity normal --framework net7.0 --dcReportType=DetailedXML --dcoutput=./coveragereport.xml run: dotnet dotcover test ./Tests/Tests.csproj --verbosity normal --framework net7.0 --dcReportType=DetailedXML --dcoutput=./coveragereport.xml
- name: DotCover Test HTML - name: DotCover Test HTML
run: dotnet dotcover test ./Tests/Tests.csproj --verbosity normal --framework net7.0 --dcReportType=HTML --dcoutput=./coveragereport.html run: dotnet dotcover test ./Tests/Tests.csproj --verbosity normal --framework net7.0 --dcReportType=HTML --dcoutput=./coveragereport.html
# - name: dotnet-coverage # - name: dotnet-coverage
# run: dotnet-coverage collect 'dotnet test' -f xml -o './coverage.xml' # run: dotnet-coverage collect 'dotnet test' -f xml -o './coverage.xml'
- name: Sonar reporter - name: Sonar reporter
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
- name: CodeCov run - name: CodeCov run
run: codecov -f ./coveragereport.xml -v -t ${{ secrets.CODECOV_TOKEN }} run: codecov -f ./coveragereport.xml -v -t ${{ secrets.CODECOV_TOKEN }}
- name: Codacy coverage reporter - name: Codacy coverage reporter
uses: codacy/codacy-coverage-reporter-action@v1 uses: codacy/codacy-coverage-reporter-action@v1
with: with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: ./coveragereport.xml coverage-reports: ./coveragereport.xml
release_publish: - name: Release
runs-on: windows-latest uses: marvinpinto/action-automatic-releases@latest
needs: [build_test] with:
if: ${{ github.ref == 'refs/heads/main' }} repo_token: "${{ secrets.GITHUB_TOKEN }}"
steps: automatic_release_tag: "latest"
- name: Checkout prerelease: true
uses: actions/checkout@v2 title: "Latest Build"
with: files: /Quantower/Settings/Scripts/Indicators/QuanTAlib/*.dll
fetch-depth: 0
- name: Push package to github
- name: Install .NET 7.0 if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/setup-dotnet@v1 run: dotnet nuget push '.\Source\bin\Release\QuanTAlib.*.nupkg'
with: --api-key ${{ secrets.GITHUB_TOKEN }}
dotnet-version: | --source https://nuget.pkg.github.com/mihakralj/index.json
7.0.x # --skip-duplicate
5.0.x
include-prerelease: true - name: Push package to nuget.org
if: ${{ github.ref == 'refs/heads/main' }}
- name: Build Core DLL run: dotnet nuget push '.\Source\bin\Release\QuanTAlib.*.nupkg'
run: dotnet build ./Source/QuanTAlib.csproj --configuration Release --nologo --api-key ${{ secrets.NUGET_DEPLOY_KEY_QUANTLIB }}
- name: Build Quantower DLL --source https://api.nuget.org/v3/index.json
run: dotnet build ./Quantower/Quantower.csproj --configuration Release --nologo --skip-duplicate
- name: Release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
title: "Latest Build"
files: /Quantower/Settings/Scripts/Indicators/QuanTAlib/*.dll
- name: Push package to github
run: dotnet nuget push '.\Source\bin\Release\QuanTAlib.*.nupkg'
--api-key ${{ secrets.GITHUB_TOKEN }}
--source https://nuget.pkg.github.com/mihakralj/index.json
# --skip-duplicate
- name: Push package to nuget.org
run: dotnet nuget push '.\Source\bin\Release\QuanTAlib.*.nupkg'
--api-key ${{ secrets.NUGET_DEPLOY_KEY_QUANTLIB }}
--source https://api.nuget.org/v3/index.json
--skip-duplicate
# - name: Zip DLLs
# uses: thedoctor0/zip-release@master
# with:
# type: 'zip'
# directory: \Quantower\Settings\Scripts\Indicators\QuanTAlib
# filename: QL_Quantower.zip
# - name: Release
# uses: marvinpinto/action-automatic-releases@latest
# with:
# repo_token: "${{ secrets.GITHUB_TOKEN }}"
# automatic_release_tag: "latest"
# prerelease: true
# title: "Pre-release Build"
# files: /Quantower/Settings/Scripts/Indicators/QuanTAlib/*.zip
# - name: Push package to nuget.org
# run: dotnet nuget push '.\Source\bin\Release\QuanTAlib.*.nupkg'
# --api-key ${{ secrets.NUGET_DEPLOY_KEY_QUANTLIB }}
# --source https://api.nuget.org/v3/index.json
# --skip-duplicate
# - name: Push package to github
# run: dotnet nuget push '.\Source\bin\Release\QuanTAlib.*.nupkg'
# --api-key ${{ secrets.GITHUB_TOKEN }}
# --source https://nuget.pkg.github.com/mihakralj/index.json
# --skip-duplicate
+1
View File
@@ -12,6 +12,7 @@
.vscode/ .vscode/
*.deps.json *.deps.json
.Sandbox/ .Sandbox/
.DS_Store
# User-specific files (MonoDevelop/Xamarin Studio) # User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs *.userprefs
+44 -44
View File
@@ -1,46 +1,46 @@
using System.Drawing; using System.Drawing;
using TradingPlatform.BusinessLayer; using TradingPlatform.BusinessLayer;
namespace QuanTAlib; namespace QuanTAlib;
public class ATR_chart : Indicator public class ATR_chart : Indicator
{ {
#region Parameters #region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)] [InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private readonly int Period = 10; private readonly int Period = 10;
#endregion Parameters #endregion Parameters
private TBars bars; private TBars bars;
/////// ///////
private ATR_Series indicator; private ATR_Series indicator;
/////// ///////
public ATR_chart() public ATR_chart()
{ {
this.SeparateWindow = true; this.SeparateWindow = true;
this.Name = "ATR - Average True Range"; this.Name = "ATR - Average True Range";
this.Description = "Average True Range description"; this.Description = "Average True Range description";
this.AddLineSeries("ATR", Color.RoyalBlue, 3, LineStyle.Solid); this.AddLineSeries("ATR", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName = "ATR (" + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars, period: this.Period, useNaN: false);
} }
protected override void OnUpdate(UpdateArgs args) protected override void OnInit()
{ {
bool update = !(args.Reason == UpdateReason.NewBar || this.ShortName = "ATR (" + this.Period + ")";
args.Reason == UpdateReason.HistoricalBar); this.bars = new();
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open), this.indicator = new(source: bars, period: this.Period, useNaN: false);
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low), }
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update); protected override void OnUpdate(UpdateArgs args)
double result = this.indicator[this.indicator.Count - 1].v; {
this.SetValue(result); bool update = !(args.Reason == UpdateReason.NewBar ||
} args.Reason == UpdateReason.HistoricalBar);
} this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result);
}
}
+49 -49
View File
@@ -1,49 +1,49 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net48</TargetFramework> <TargetFramework>net48</TargetFramework>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<Platforms>AnyCPU</Platforms> <Platforms>AnyCPU</Platforms>
<AlgoType>Indicator</AlgoType> <AlgoType>Indicator</AlgoType>
<AssemblyName>Quantower_QTAlib</AssemblyName> <AssemblyName>Quantower_QTAlib</AssemblyName>
<RootNamespace>QuanTAlib</RootNamespace> <RootNamespace>QuanTAlib</RootNamespace>
<DebugType>embedded</DebugType> <DebugType>embedded</DebugType>
<LangVersion>preview</LangVersion> <LangVersion>preview</LangVersion>
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<Nullable>disable</Nullable> <Nullable>disable</Nullable>
<SignAssembly>False</SignAssembly> <SignAssembly>False</SignAssembly>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Optimize>True</Optimize> <Optimize>True</Optimize>
<WarningLevel>3</WarningLevel> <WarningLevel>3</WarningLevel>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<PlatformTarget>anycpu</PlatformTarget> <PlatformTarget>anycpu</PlatformTarget>
<DebugType>full</DebugType> <DebugType>full</DebugType>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>embedded</DebugType> <DebugType>embedded</DebugType>
<Optimize>True</Optimize> <Optimize>True</Optimize>
<WarningLevel>3</WarningLevel> <WarningLevel>3</WarningLevel>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<PlatformTarget>anycpu</PlatformTarget> <PlatformTarget>anycpu</PlatformTarget>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\Source\**\*.cs" Exclude="..\Source\obj\**" > <Compile Include="..\Source\**\*.cs" Exclude="..\Source\obj\**" >
<Link>QuanTAlib\%(RecursiveDir)%(Filename)%(Extension)</Link> <Link>QuanTAlib\%(RecursiveDir)%(Filename)%(Extension)</Link>
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<Target Name="CopyCustomContent" AfterTargets="AfterBuild"> <Target Name="CopyCustomContent" AfterTargets="AfterBuild">
<Copy SourceFiles=".\bin\$(Configuration)\net48\Quantower_QTAlib.dll" DestinationFolder="\Quantower\Settings\Scripts\Indicators\QuanTAlib" /> <Copy SourceFiles=".\bin\$(Configuration)\net48\Quantower_QTAlib.dll" DestinationFolder="\Quantower\Settings\Scripts\Indicators\QuanTAlib" />
</Target> </Target>
<ItemGroup> <ItemGroup>
<Reference Include="TradingPlatform.BusinessLayer"> <Reference Include="TradingPlatform.BusinessLayer">
<HintPath>.\dll\TradingPlatform.BusinessLayer.dll</HintPath> <HintPath>.\dll\TradingPlatform.BusinessLayer.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
</Project> </Project>