new: EQUITY_Series

Add new EQUITY_Series and updates to docs, Calculations, Indicators, Strategies, Tests, and .github/workflows
This commit is contained in:
Miha Kralj
2023-04-07 16:50:19 -07:00
parent cb5fe2dc86
commit 34997cd0d6
11 changed files with 741 additions and 110 deletions
+6 -7
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Title>QuanTAlib</Title>
<Version>0.2.0</Version>
<Product>Library of TA Calculations, Charts and Strategies for Quantower</Product>
<Description>Quantitative Technical Analysis Library in C# for Quantower</Description>
<RepositoryType>git</RepositoryType>
@@ -31,6 +31,9 @@
</PackageTags>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageLicenseFile></PackageLicenseFile>
<AssemblyVersion>0.2.1.0</AssemblyVersion>
<FileVersion>0.2.1.0</FileVersion>
<InformationalVersion>0.2.1-dev.2+Branch.dev.Sha.cb5fe2dc86a78fe9358da810d17952c82299ed3d</InformationalVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>full</DebugType>
@@ -51,7 +54,7 @@
<PackageIconUrl>https://raw.githubusercontent.com/mihakralj/QuanTAlib/main/.github/QuanTAlib2.png</PackageIconUrl>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<CodeAnalysisRuleSet>..\.sonarlint\mihakralj_quantalibcsharp.ruleset</CodeAnalysisRuleSet>
<Version />
<Version>0.2.1-dev.2</Version>
</PropertyGroup>
<ItemGroup>
<AdditionalFiles Include="..\.sonarlint\mihakralj_quantalib\CSharp\SonarLint.xml" Link="SonarLint.xml" />
@@ -66,9 +69,5 @@
<Visible>False</Visible>
<PackagePath></PackagePath>
</None>
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
+58
View File
@@ -0,0 +1,58 @@
namespace QuanTAlib;
using System;
/* <summary>
EQUITY - Generates P&L portfolio based on trades signals and equity prices
</summary> */
//base prices: bars.close
//trade signals: trades
//optional: long, short, long&short
//optional: warmup period: warmup
public class EQUITY_Series : Single_TSeries_Indicator {
int trade_state = 0;
readonly int _warmup = 0;
double eq_value = 0;
readonly TSeries _prices;
readonly bool _long, _short;
public EQUITY_Series(TSeries trades, TSeries prices, bool Long = true, bool Short = false, int Warmup = 0) : base(trades, period: 0, useNaN: false) {
_prices = prices;
_long = Long;
_short = Short;
_warmup = Warmup;
if (base._data.Count > 0) { base.Add(base._data); }
}
public override void Add((System.DateTime t, double v) TValue, bool update) {
if (this.Count != 0)
eq_value = this[this.Count - 1].v;
//buy signal
if (TValue.v == 1 && this.Count > _warmup) {
//we are not in-market and we can do long trades
if (_short) { trade_state = 0; }
if (_long) { trade_state = 1; }
}
//sell signal
if (TValue.v == -1 && this.Count > _warmup) {
//we are in-market and we can do long trades
if (_long) { trade_state = 0; }
if (_short) { trade_state = -1; }
}
if (trade_state == 1) {
eq_value = this[this.Count - 1].v + (_prices[this.Count].v - _prices[this.Count - 1].v);
}
if (trade_state == -1) {
eq_value = this[this.Count - 1].v + (_prices[this.Count - 1].v - _prices[this.Count].v);
}
base.Add((TValue.t, eq_value), update, _NaN);
}
}
+1 -1
View File
@@ -25,7 +25,7 @@ HWMA[i] = F[i] + V[i] + 0.5 * A[i]
</summary> */
public class HWMA_Series : Single_TSeries_Indicator {
double _nA, _nB, _nC;
readonly double _nA, _nB, _nC;
double _pF, _pV, _pA;
double _ppF, _ppV, _ppA;
+2 -1
View File
@@ -25,7 +25,8 @@ public class MAMA_Series : Single_TSeries_Indicator
if (base._data.Count > 0) { base.Add(base._data); }
}
private double sumPr, jI, jQ, fastl, slowl;
private double sumPr, jI, jQ;
readonly double fastl, slowl;
private (double i, double i1, double i2, double i3, double i4, double i5, double i6, double io) pr, i1, q1, sm, dt;
private (double i, double i1, double io) i2, q2, re, im, pd, ph, mama, fama;
public TSeries Fama { get; }