mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-07-28 01:37:43 +00:00
pull request changes
This commit is contained in:
@@ -26,8 +26,7 @@ jobs:
|
||||
- name: Setup .NET SDK
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: '9.x'
|
||||
dotnet-quality: 'preview'
|
||||
dotnet-version: '8.x'
|
||||
|
||||
- name: Install JDK11 for Sonar Scanner
|
||||
uses: actions/setup-java@v3
|
||||
@@ -80,8 +79,7 @@ jobs:
|
||||
- name: Setup .NET SDK
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: '9.x'
|
||||
dotnet-quality: 'preview'
|
||||
dotnet-version: '8.x'
|
||||
|
||||
- name: Install dotnet tools
|
||||
run: |
|
||||
@@ -136,8 +134,7 @@ jobs:
|
||||
- name: Setup .NET SDK
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: '9.x'
|
||||
dotnet-quality: 'preview'
|
||||
dotnet-version: '8.x'
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
@@ -153,6 +150,7 @@ jobs:
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3
|
||||
|
||||
# converting SARIF action not working yet.
|
||||
#SecurityCodeScan:
|
||||
# runs-on: windows-latest
|
||||
# steps:
|
||||
@@ -171,7 +169,7 @@ jobs:
|
||||
# uses: actions/setup-dotnet@v3
|
||||
# with:
|
||||
# dotnet-version: |
|
||||
# 9.x
|
||||
# 8.x
|
||||
# 3.1.x
|
||||
# dotnet-quality: 'preview'
|
||||
#
|
||||
@@ -229,8 +227,7 @@ jobs:
|
||||
- name: Setup .NET SDK
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: '9.x'
|
||||
dotnet-quality: 'preview'
|
||||
dotnet-version: '8.x'
|
||||
|
||||
- name: Install GitVersion
|
||||
uses: gittools/actions/gitversion/setup@v0
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<ProjectReference Include="..\lib\quantalib.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using Xunit;
|
||||
|
||||
namespace QuanTAlib;
|
||||
|
||||
public class EventingTests
|
||||
|
||||
@@ -289,7 +289,6 @@ public class SkenderTests
|
||||
{
|
||||
for (int run = 0; run < iterations; run++)
|
||||
{
|
||||
//period = rnd.Next(50) + 5;
|
||||
Mama ma = new(fastLimit: 0.5, slowLimit: 0.05);
|
||||
TSeries QL = new();
|
||||
foreach (TBar item in feed)
|
||||
@@ -336,12 +335,12 @@ public class SkenderTests
|
||||
TSeries QL = new();
|
||||
foreach (TBar item in bars) { QL.Add(ma.Calc(item)); }
|
||||
|
||||
var SK = quotes.GetAtr(lookbackPeriods: period).Select(i => i.Atr.Null2NaN()!);
|
||||
Assert.Equal(QL.Length, QL.Length);
|
||||
var atrValues = quotes.GetAtr(lookbackPeriods: period).Select(i => i.Atr.Null2NaN()!);
|
||||
const int AdditionalPeriods = 500;
|
||||
|
||||
for (int i = QL.Length - 1; i > period + 500; i--)
|
||||
for (int i = QL.Length - 1; i > period + AdditionalPeriods; i--)
|
||||
{
|
||||
Assert.InRange(SK.ElementAt(i) - QL[i].Value, -range, range);
|
||||
Assert.InRange(atrValues.ElementAt(i) - QL[i].Value, -range, range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+25
-26
@@ -22,54 +22,53 @@ public class Rma : AbstractBase
|
||||
_alpha = 1.0 / _period; // Wilder's smoothing factor
|
||||
Name = $"Rma({_period})";
|
||||
Init();
|
||||
}
|
||||
}
|
||||
|
||||
public Rma(object source, int period) : this(period)
|
||||
{
|
||||
public Rma(object source, int period) : this(period)
|
||||
{
|
||||
var pubEvent = source.GetType().GetEvent("Pub");
|
||||
pubEvent?.AddEventHandler(source, new ValueSignal(Sub));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
_lastRMA = 0;
|
||||
_savedLastRMA = 0;
|
||||
}
|
||||
|
||||
protected override void ManageState(bool isNew)
|
||||
{
|
||||
if (isNew)
|
||||
{
|
||||
_savedLastRMA = _lastRMA;
|
||||
_lastValidValue = Input.Value;
|
||||
_index++;
|
||||
}
|
||||
else
|
||||
|
||||
protected override void ManageState(bool isNew)
|
||||
{
|
||||
if (!isNew)
|
||||
{
|
||||
_lastRMA = _savedLastRMA;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
protected override double Calculation()
|
||||
{
|
||||
_savedLastRMA = _lastRMA;
|
||||
_lastValidValue = Input.Value;
|
||||
_index++;
|
||||
}
|
||||
|
||||
protected override double Calculation()
|
||||
{
|
||||
ManageState(Input.IsNew);
|
||||
|
||||
double rma;
|
||||
|
||||
if (_index == 1)
|
||||
{
|
||||
rma = Input.Value;
|
||||
return Input.Value;
|
||||
}
|
||||
else if (_index <= _period)
|
||||
|
||||
if (_index <= _period)
|
||||
{
|
||||
// Simple average during initial period
|
||||
rma = (_lastRMA * (_index - 1) + Input.Value) / _index;
|
||||
return (_lastRMA * (_index - 1) + Input.Value) / _index;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Wilder's smoothing method
|
||||
rma = _alpha * (Input.Value - _lastRMA) + _lastRMA;
|
||||
|
||||
// Wilder's smoothing method
|
||||
return _alpha * (Input.Value - _lastRMA) + _lastRMA;
|
||||
}
|
||||
|
||||
_lastRMA = rma;
|
||||
|
||||
Reference in New Issue
Block a user