mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-19 19:18:05 +00:00
new: EQUITY_Series
Add new EQUITY_Series and updates to docs, Calculations, Indicators, Strategies, Tests, and .github/workflows
This commit is contained in:
@@ -34,6 +34,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
useConfigFile: true
|
useConfigFile: true
|
||||||
configFilePath: /a/QuanTAlib/QuanTAlib/GitVersion.yml
|
configFilePath: /a/QuanTAlib/QuanTAlib/GitVersion.yml
|
||||||
|
additionalArguments: '/updateassemblyinfo /ensureassemblyinfo'
|
||||||
|
|
||||||
- name: Display GitVersion variables (without prefix)
|
- name: Display GitVersion variables (without prefix)
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Title>QuanTAlib</Title>
|
<Title>QuanTAlib</Title>
|
||||||
|
<Version>0.2.0</Version>
|
||||||
<Product>Library of TA Calculations, Charts and Strategies for Quantower</Product>
|
<Product>Library of TA Calculations, Charts and Strategies for Quantower</Product>
|
||||||
<Description>Quantitative Technical Analysis Library in C# for Quantower</Description>
|
<Description>Quantitative Technical Analysis Library in C# for Quantower</Description>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
@@ -31,6 +31,9 @@
|
|||||||
</PackageTags>
|
</PackageTags>
|
||||||
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
|
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
|
||||||
<PackageLicenseFile></PackageLicenseFile>
|
<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>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
@@ -51,7 +54,7 @@
|
|||||||
<PackageIconUrl>https://raw.githubusercontent.com/mihakralj/QuanTAlib/main/.github/QuanTAlib2.png</PackageIconUrl>
|
<PackageIconUrl>https://raw.githubusercontent.com/mihakralj/QuanTAlib/main/.github/QuanTAlib2.png</PackageIconUrl>
|
||||||
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
||||||
<CodeAnalysisRuleSet>..\.sonarlint\mihakralj_quantalibcsharp.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>..\.sonarlint\mihakralj_quantalibcsharp.ruleset</CodeAnalysisRuleSet>
|
||||||
<Version />
|
<Version>0.2.1-dev.2</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AdditionalFiles Include="..\.sonarlint\mihakralj_quantalib\CSharp\SonarLint.xml" Link="SonarLint.xml" />
|
<AdditionalFiles Include="..\.sonarlint\mihakralj_quantalib\CSharp\SonarLint.xml" Link="SonarLint.xml" />
|
||||||
@@ -66,9 +69,5 @@
|
|||||||
<Visible>False</Visible>
|
<Visible>False</Visible>
|
||||||
<PackagePath></PackagePath>
|
<PackagePath></PackagePath>
|
||||||
</None>
|
</None>
|
||||||
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,7 +25,7 @@ HWMA[i] = F[i] + V[i] + 0.5 * A[i]
|
|||||||
</summary> */
|
</summary> */
|
||||||
|
|
||||||
public class HWMA_Series : Single_TSeries_Indicator {
|
public class HWMA_Series : Single_TSeries_Indicator {
|
||||||
double _nA, _nB, _nC;
|
readonly double _nA, _nB, _nC;
|
||||||
double _pF, _pV, _pA;
|
double _pF, _pV, _pA;
|
||||||
double _ppF, _ppV, _ppA;
|
double _ppF, _ppV, _ppA;
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ public class MAMA_Series : Single_TSeries_Indicator
|
|||||||
if (base._data.Count > 0) { base.Add(base._data); }
|
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 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;
|
private (double i, double i1, double io) i2, q2, re, im, pd, ph, mama, fama;
|
||||||
public TSeries Fama { get; }
|
public TSeries Fama { get; }
|
||||||
|
|||||||
+6
-4
@@ -6,13 +6,15 @@ branches:
|
|||||||
is-mainline: true
|
is-mainline: true
|
||||||
prevent-increment-of-merged-branch-version: true
|
prevent-increment-of-merged-branch-version: true
|
||||||
track-merge-target: false
|
track-merge-target: false
|
||||||
increment: inherit
|
increment: Patch
|
||||||
source-branches: [ 'develop' ]
|
source-branches: [ 'develop' ]
|
||||||
is-release-branch: true
|
is-release-branch: true
|
||||||
is-mainline: true
|
is-mainline: true
|
||||||
continuous-delivery-fallback-tag: ''
|
label: ''
|
||||||
|
#continuous-delivery-fallback-tag: ''
|
||||||
develop:
|
develop:
|
||||||
regex: ^dev$
|
regex: ^dev$
|
||||||
|
increment: Patch
|
||||||
is-release-branch: false
|
is-release-branch: false
|
||||||
prevent-increment-of-merged-branch-version: false
|
prevent-increment-of-merged-branch-version: false
|
||||||
track-merge-target: true
|
track-merge-target: true
|
||||||
@@ -20,10 +22,10 @@ branches:
|
|||||||
is-release-branch: false
|
is-release-branch: false
|
||||||
tracks-release-branches: true
|
tracks-release-branches: true
|
||||||
is-mainline: false
|
is-mainline: false
|
||||||
tag: dev
|
label: dev
|
||||||
ignore:
|
ignore:
|
||||||
sha: []
|
sha: []
|
||||||
major-version-bump-message: '\+semver:\s?(feature|major)'
|
major-version-bump-message: '\+semver:\s?(feature|major)'
|
||||||
minor-version-bump-message: '\+semver:\s?(new|update|minor)'
|
minor-version-bump-message: '\+semver:\s?(new|update|minor|add)'
|
||||||
no-bump-message: '\+semver:\s?(skip|none|fix)'
|
no-bump-message: '\+semver:\s?(skip|none|fix)'
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<LangVersion>preview</LangVersion>
|
<LangVersion>preview</LangVersion>
|
||||||
@@ -13,6 +12,10 @@
|
|||||||
<Nullable>disable</Nullable>
|
<Nullable>disable</Nullable>
|
||||||
<SignAssembly>False</SignAssembly>
|
<SignAssembly>False</SignAssembly>
|
||||||
<CodeAnalysisRuleSet>..\.sonarlint\mihakralj_quantalibcsharp.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>..\.sonarlint\mihakralj_quantalibcsharp.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<AssemblyVersion>0.2.1.0</AssemblyVersion>
|
||||||
|
<FileVersion>0.2.1.0</FileVersion>
|
||||||
|
<InformationalVersion>0.2.1-dev.2+Branch.dev.Sha.cb5fe2dc86a78fe9358da810d17952c82299ed3d</InformationalVersion>
|
||||||
|
<Version>0.2.1-dev.2</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<Optimize>True</Optimize>
|
<Optimize>True</Optimize>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<LangVersion>preview</LangVersion>
|
<LangVersion>preview</LangVersion>
|
||||||
@@ -13,6 +12,10 @@
|
|||||||
<Nullable>disable</Nullable>
|
<Nullable>disable</Nullable>
|
||||||
<SignAssembly>False</SignAssembly>
|
<SignAssembly>False</SignAssembly>
|
||||||
<CodeAnalysisRuleSet>..\.sonarlint\mihakralj_quantalibcsharp.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>..\.sonarlint\mihakralj_quantalibcsharp.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<AssemblyVersion>0.2.1.0</AssemblyVersion>
|
||||||
|
<FileVersion>0.2.1.0</FileVersion>
|
||||||
|
<InformationalVersion>0.2.1-dev.2+Branch.dev.Sha.cb5fe2dc86a78fe9358da810d17952c82299ed3d</InformationalVersion>
|
||||||
|
<Version>0.2.1-dev.2</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<Optimize>True</Optimize>
|
<Optimize>True</Optimize>
|
||||||
|
|||||||
+7
-5
@@ -6,11 +6,15 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
<Platforms>AnyCPU;x64</Platforms>
|
<Platforms>AnyCPU;x64</Platforms>
|
||||||
|
<AssemblyVersion>0.2.1.0</AssemblyVersion>
|
||||||
|
<FileVersion>0.2.1.0</FileVersion>
|
||||||
|
<InformationalVersion>0.2.1-dev.2+Branch.dev.Sha.cb5fe2dc86a78fe9358da810d17952c82299ed3d</InformationalVersion>
|
||||||
|
<Version>0.2.1-dev.2</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Python.Included" Version="3.11.2" />
|
<PackageReference Include="Python.Included" Version="3.11.2" />
|
||||||
<PackageReference Include="pythonnet" Version="3.1.0-preview2023-03-04" />
|
<PackageReference Include="pythonnet" Version="3.1.0-preview2023-03-04" />
|
||||||
<PackageReference Include="xunit" Version="2.4.2" />
|
<PackageReference Include="xunit" Version="2.4.2" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
@@ -21,11 +25,9 @@
|
|||||||
<PackageReference Include="Tulip.NETCore" Version="0.8.0.1" />
|
<PackageReference Include="Tulip.NETCore" Version="0.8.0.1" />
|
||||||
<PackageReference Include="System.Text.Json" Version="8.0.0-preview.2.23128.3" />
|
<PackageReference Include="System.Text.Json" Version="8.0.0-preview.2.23128.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Calculations\Calculations.csproj" />
|
<ProjectReference Include="..\Calculations\Calculations.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="Python.Included" />
|
<None Remove="Python.Included" />
|
||||||
<None Remove="pythonnet" />
|
<None Remove="pythonnet" />
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+260
-87
@@ -2,14 +2,7 @@
|
|||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"dotnet_interactive": {
|
|
||||||
"language": "csharp"
|
|
||||||
},
|
|
||||||
"polyglot_notebook": {
|
|
||||||
"kernelName": "csharp"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"source": [
|
"source": [
|
||||||
"# Quick Start\n",
|
"# Quick Start\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -24,16 +17,39 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 1,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"dotnet_interactive": {
|
"dotnet_interactive": {
|
||||||
"language": "csharp"
|
"language": "csharp"
|
||||||
},
|
|
||||||
"vscode": {
|
|
||||||
"languageId": "polyglot-notebook"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/html": [
|
||||||
|
"<div><div></div><div></div><div></div></div>"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "display_data"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"index\t data\t\t sma(data)\t ema(sma(data))\t wma(ema(sma(data)))\n",
|
||||||
|
"0\t 2023-03-27\t 158.28\t\t 158.28\t\t NaN\n",
|
||||||
|
"1\t 2023-03-28\t 157.97\t\t 158.12\t\t NaN\n",
|
||||||
|
"2\t 2023-03-29\t 158.90\t\t 158.38\t\t NaN\n",
|
||||||
|
"3\t 2023-03-30\t 159.77\t\t 158.73\t\t NaN\n",
|
||||||
|
"4\t 2023-03-31\t 160.79\t\t 159.14\t\t 158.69\n",
|
||||||
|
"5\t 2023-04-03\t 162.37\t\t 160.22\t\t 159.25\n",
|
||||||
|
"6\t 2023-04-04\t 163.97\t\t 161.47\t\t 160.10\n",
|
||||||
|
"7\t 2023-04-05\t 164.56\t\t 162.50\t\t 161.07\n",
|
||||||
|
"8\t 2023-04-06\t 165.02\t\t 163.34\t\t 162.04\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"#r \"nuget:QuanTAlib;\"\n",
|
"#r \"nuget:QuanTAlib;\"\n",
|
||||||
"using QuanTAlib;\n",
|
"using QuanTAlib;\n",
|
||||||
@@ -51,14 +67,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"dotnet_interactive": {
|
|
||||||
"language": "csharp"
|
|
||||||
},
|
|
||||||
"polyglot_notebook": {
|
|
||||||
"kernelName": "csharp"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"source": [
|
"source": [
|
||||||
"## Understanding QuanTAlib data model\n",
|
"## Understanding QuanTAlib data model\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -67,16 +76,54 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 2,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"dotnet_interactive": {
|
"dotnet_interactive": {
|
||||||
"language": "csharp"
|
"language": "csharp"
|
||||||
},
|
|
||||||
"vscode": {
|
|
||||||
"languageId": "polyglot-notebook"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/html": [
|
||||||
|
"<table><thead><tr><th><i>index</i></th><th>value</th></tr></thead><tbody><tr><td>0</td><td><details class=\"dni-treeview\"><summary><span class=\"dni-code-hint\"><code>(4/7/2023 12:00:00 AM, 105.3)</code></span></summary><div><table><thead><tr></tr></thead><tbody><tr><td>Item1</td><td><span>2023-04-07 00:00:00Z</span></td></tr><tr><td>Item2</td><td><div class=\"dni-plaintext\"><pre>105.3</pre></div></td></tr></tbody></table></div></details></td></tr><tr><td>1</td><td><details class=\"dni-treeview\"><summary><span class=\"dni-code-hint\"><code>(4/7/2023 2:34:48 PM, 293.1)</code></span></summary><div><table><thead><tr></tr></thead><tbody><tr><td>Item1</td><td><span>2023-04-07 14:34:48Z</span></td></tr><tr><td>Item2</td><td><div class=\"dni-plaintext\"><pre>293.1</pre></div></td></tr></tbody></table></div></details></td></tr><tr><td>2</td><td><details class=\"dni-treeview\"><summary><span class=\"dni-code-hint\"><code>(4/7/2023 2:34:48 PM, 0)</code></span></summary><div><table><thead><tr></tr></thead><tbody><tr><td>Item1</td><td><span>2023-04-07 14:34:48Z</span></td></tr><tr><td>Item2</td><td><div class=\"dni-plaintext\"><pre>0</pre></div></td></tr></tbody></table></div></details></td></tr><tr><td>3</td><td><details class=\"dni-treeview\"><summary><span class=\"dni-code-hint\"><code>(4/4/2023 2:34:48 PM, 10)</code></span></summary><div><table><thead><tr></tr></thead><tbody><tr><td>Item1</td><td><span>2023-04-04 14:34:48Z</span></td></tr><tr><td>Item2</td><td><div class=\"dni-plaintext\"><pre>10</pre></div></td></tr></tbody></table></div></details></td></tr></tbody></table><style>\r\n",
|
||||||
|
".dni-code-hint {\r\n",
|
||||||
|
" font-style: italic;\r\n",
|
||||||
|
" overflow: hidden;\r\n",
|
||||||
|
" white-space: nowrap;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
".dni-treeview {\r\n",
|
||||||
|
" white-space: nowrap;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
".dni-treeview td {\r\n",
|
||||||
|
" vertical-align: top;\r\n",
|
||||||
|
" text-align: start;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"details.dni-treeview {\r\n",
|
||||||
|
" padding-left: 1em;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"table td {\r\n",
|
||||||
|
" text-align: start;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"table tr { \r\n",
|
||||||
|
" vertical-align: top; \r\n",
|
||||||
|
" margin: 0em 0px;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"table tr td pre \r\n",
|
||||||
|
"{ \r\n",
|
||||||
|
" vertical-align: top !important; \r\n",
|
||||||
|
" margin: 0em 0px !important;\r\n",
|
||||||
|
"} \r\n",
|
||||||
|
"table th {\r\n",
|
||||||
|
" text-align: start;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"</style>"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "display_data"
|
||||||
|
}
|
||||||
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"var item1 = (DateTime.Today, 105.3); // (DateTime, Value) tuple\n",
|
"var item1 = (DateTime.Today, 105.3); // (DateTime, Value) tuple\n",
|
||||||
"double item2 = 293.1; // a simple double\n",
|
"double item2 = 293.1; // a simple double\n",
|
||||||
@@ -92,60 +139,122 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"dotnet_interactive": {
|
|
||||||
"language": "csharp"
|
|
||||||
},
|
|
||||||
"polyglot_notebook": {
|
|
||||||
"kernelName": "csharp"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"source": [
|
"source": [
|
||||||
"TSeries list can display only values (without timestamps) or only timestamps (without values) by using `.v` or `.t` properties"
|
"TSeries list can display only values (without timestamps) or only timestamps (without values) by using `.v` or `.t` properties"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 3,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"dotnet_interactive": {
|
"dotnet_interactive": {
|
||||||
"language": "csharp"
|
"language": "csharp"
|
||||||
},
|
|
||||||
"vscode": {
|
|
||||||
"languageId": "polyglot-notebook"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/html": [
|
||||||
|
"<div class=\"dni-plaintext\"><pre>[ 105.3, 293.1, 0, 10 ]</pre></div><style>\r\n",
|
||||||
|
".dni-code-hint {\r\n",
|
||||||
|
" font-style: italic;\r\n",
|
||||||
|
" overflow: hidden;\r\n",
|
||||||
|
" white-space: nowrap;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
".dni-treeview {\r\n",
|
||||||
|
" white-space: nowrap;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
".dni-treeview td {\r\n",
|
||||||
|
" vertical-align: top;\r\n",
|
||||||
|
" text-align: start;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"details.dni-treeview {\r\n",
|
||||||
|
" padding-left: 1em;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"table td {\r\n",
|
||||||
|
" text-align: start;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"table tr { \r\n",
|
||||||
|
" vertical-align: top; \r\n",
|
||||||
|
" margin: 0em 0px;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"table tr td pre \r\n",
|
||||||
|
"{ \r\n",
|
||||||
|
" vertical-align: top !important; \r\n",
|
||||||
|
" margin: 0em 0px !important;\r\n",
|
||||||
|
"} \r\n",
|
||||||
|
"table th {\r\n",
|
||||||
|
" text-align: start;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"</style>"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "display_data"
|
||||||
|
}
|
||||||
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"data.v"
|
"data.v"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"dotnet_interactive": {
|
|
||||||
"language": "csharp"
|
|
||||||
},
|
|
||||||
"polyglot_notebook": {
|
|
||||||
"kernelName": "csharp"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"source": [
|
"source": [
|
||||||
"The last element on the list can be accessed by .Last() or by [^1] - and using `.t` (time) and `.v` (value) properties. Also, casting a TSeries into (double) will return the value of the last element"
|
"The last element on the list can be accessed by .Last() or by [^1] - and using `.t` (time) and `.v` (value) properties. Also, casting a TSeries into (double) will return the value of the last element"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 4,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"dotnet_interactive": {
|
"dotnet_interactive": {
|
||||||
"language": "csharp"
|
"language": "csharp"
|
||||||
},
|
|
||||||
"vscode": {
|
|
||||||
"languageId": "polyglot-notebook"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/html": [
|
||||||
|
"<div class=\"dni-plaintext\"><pre>10</pre></div><style>\r\n",
|
||||||
|
".dni-code-hint {\r\n",
|
||||||
|
" font-style: italic;\r\n",
|
||||||
|
" overflow: hidden;\r\n",
|
||||||
|
" white-space: nowrap;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
".dni-treeview {\r\n",
|
||||||
|
" white-space: nowrap;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
".dni-treeview td {\r\n",
|
||||||
|
" vertical-align: top;\r\n",
|
||||||
|
" text-align: start;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"details.dni-treeview {\r\n",
|
||||||
|
" padding-left: 1em;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"table td {\r\n",
|
||||||
|
" text-align: start;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"table tr { \r\n",
|
||||||
|
" vertical-align: top; \r\n",
|
||||||
|
" margin: 0em 0px;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"table tr td pre \r\n",
|
||||||
|
"{ \r\n",
|
||||||
|
" vertical-align: top !important; \r\n",
|
||||||
|
" margin: 0em 0px !important;\r\n",
|
||||||
|
"} \r\n",
|
||||||
|
"table th {\r\n",
|
||||||
|
" text-align: start;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"</style>"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "display_data"
|
||||||
|
}
|
||||||
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"bool IsTheSame = data.Last().v == data[^1].v;\n",
|
"bool IsTheSame = data.Last().v == data[^1].v;\n",
|
||||||
"double lastvalue = data;\n",
|
"double lastvalue = data;\n",
|
||||||
@@ -155,30 +264,61 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"dotnet_interactive": {
|
|
||||||
"language": "csharp"
|
|
||||||
},
|
|
||||||
"polyglot_notebook": {
|
|
||||||
"kernelName": "csharp"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"source": [
|
"source": [
|
||||||
"All indicators are just modified TSeries classes; they get all required input during class construction (source of the datafeed, period...) and they automatically subscribe to events of the datafeed. Whenever datafeed gets a new value, indicator will calculate its own value. Indicators are also event publishers, so other indicators can subscribe to their results, chaining indicators together:"
|
"All indicators are just modified TSeries classes; they get all required input during class construction (source of the datafeed, period...) and they automatically subscribe to events of the datafeed. Whenever datafeed gets a new value, indicator will calculate its own value. Indicators are also event publishers, so other indicators can subscribe to their results, chaining indicators together:"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 5,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"dotnet_interactive": {
|
"dotnet_interactive": {
|
||||||
"language": "csharp"
|
"language": "csharp"
|
||||||
},
|
|
||||||
"vscode": {
|
|
||||||
"languageId": "polyglot-notebook"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/html": [
|
||||||
|
"<div class=\"dni-plaintext\"><pre>[ Infinity, 0.6666666666666666, 0.3333333333333333, 0.2, 0.14285714285714285, 0.1111111111111111, 0.09090909090909091, 0.07692307692307693, 0.06666666666666667, 0.058823529411764705, 0.25 ]</pre></div><style>\r\n",
|
||||||
|
".dni-code-hint {\r\n",
|
||||||
|
" font-style: italic;\r\n",
|
||||||
|
" overflow: hidden;\r\n",
|
||||||
|
" white-space: nowrap;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
".dni-treeview {\r\n",
|
||||||
|
" white-space: nowrap;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
".dni-treeview td {\r\n",
|
||||||
|
" vertical-align: top;\r\n",
|
||||||
|
" text-align: start;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"details.dni-treeview {\r\n",
|
||||||
|
" padding-left: 1em;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"table td {\r\n",
|
||||||
|
" text-align: start;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"table tr { \r\n",
|
||||||
|
" vertical-align: top; \r\n",
|
||||||
|
" margin: 0em 0px;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"table tr td pre \r\n",
|
||||||
|
"{ \r\n",
|
||||||
|
" vertical-align: top !important; \r\n",
|
||||||
|
" margin: 0em 0px !important;\r\n",
|
||||||
|
"} \r\n",
|
||||||
|
"table th {\r\n",
|
||||||
|
" text-align: start;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"</style>"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "display_data"
|
||||||
|
}
|
||||||
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"TSeries t1 = new() {0,1,2,3,4,5,6,7,8,9}; // t1 is loaded with data and activated as a publisher\n",
|
"TSeries t1 = new() {0,1,2,3,4,5,6,7,8,9}; // t1 is loaded with data and activated as a publisher\n",
|
||||||
"EMA_Series t2 = new(t1, 3); // t2 will auto-load all history of t1 and wait for events from t1\n",
|
"EMA_Series t2 = new(t1, 3); // t2 will auto-load all history of t1 and wait for events from t1\n",
|
||||||
@@ -194,14 +334,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"dotnet_interactive": {
|
|
||||||
"language": "csharp"
|
|
||||||
},
|
|
||||||
"polyglot_notebook": {
|
|
||||||
"kernelName": "csharp"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"source": [
|
"source": [
|
||||||
"# MACD compounded indicator\n",
|
"# MACD compounded indicator\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -210,16 +343,54 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 6,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"dotnet_interactive": {
|
"dotnet_interactive": {
|
||||||
"language": "csharp"
|
"language": "csharp"
|
||||||
},
|
|
||||||
"vscode": {
|
|
||||||
"languageId": "polyglot-notebook"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/html": [
|
||||||
|
"<div class=\"dni-plaintext\"><pre>[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.000974358974349343, -0.03456027049873228, -0.13792617985566447, -0.4729486712049916, -0.825402881197467, -0.8902360596814031, -0.9360607784903126, -0.7333381872239422 ... (79 more) ]</pre></div><style>\r\n",
|
||||||
|
".dni-code-hint {\r\n",
|
||||||
|
" font-style: italic;\r\n",
|
||||||
|
" overflow: hidden;\r\n",
|
||||||
|
" white-space: nowrap;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
".dni-treeview {\r\n",
|
||||||
|
" white-space: nowrap;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
".dni-treeview td {\r\n",
|
||||||
|
" vertical-align: top;\r\n",
|
||||||
|
" text-align: start;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"details.dni-treeview {\r\n",
|
||||||
|
" padding-left: 1em;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"table td {\r\n",
|
||||||
|
" text-align: start;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"table tr { \r\n",
|
||||||
|
" vertical-align: top; \r\n",
|
||||||
|
" margin: 0em 0px;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"table tr td pre \r\n",
|
||||||
|
"{ \r\n",
|
||||||
|
" vertical-align: top !important; \r\n",
|
||||||
|
" margin: 0em 0px !important;\r\n",
|
||||||
|
"} \r\n",
|
||||||
|
"table th {\r\n",
|
||||||
|
" text-align: start;\r\n",
|
||||||
|
"}\r\n",
|
||||||
|
"</style>"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "display_data"
|
||||||
|
}
|
||||||
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"Yahoo_Feed aapl = new(\"AAPL\", 100);\n",
|
"Yahoo_Feed aapl = new(\"AAPL\", 100);\n",
|
||||||
"TSeries close = aapl.Close; // close will get data from history\n",
|
"TSeries close = aapl.Close; // close will get data from history\n",
|
||||||
@@ -239,29 +410,31 @@
|
|||||||
"language": "C#",
|
"language": "C#",
|
||||||
"name": ".net-csharp"
|
"name": ".net-csharp"
|
||||||
},
|
},
|
||||||
|
"language_info": {
|
||||||
|
"name": "polyglot-notebook"
|
||||||
|
},
|
||||||
"polyglot_notebook": {
|
"polyglot_notebook": {
|
||||||
"kernelInfo": {
|
"kernelInfo": {
|
||||||
"defaultKernelName": "csharp",
|
"defaultKernelName": "csharp",
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"aliases": [
|
"aliases": [
|
||||||
"c#",
|
"C#",
|
||||||
"C#"
|
"c#"
|
||||||
],
|
],
|
||||||
"languageName": "C#",
|
"languageName": "C#",
|
||||||
"name": "csharp"
|
"name": "csharp"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"aliases": [
|
|
||||||
"frontend"
|
|
||||||
],
|
|
||||||
"languageName": null,
|
|
||||||
"name": "vscode"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"languageName": "KQL",
|
"languageName": "KQL",
|
||||||
"name": "kql"
|
"name": "kql"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"aliases": [
|
||||||
|
"frontend"
|
||||||
|
],
|
||||||
|
"name": "vscode"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user