From 2bc0d3f0eaff6d505e0d69a8a179ce83df6b85cd Mon Sep 17 00:00:00 2001 From: Miha Kralj Date: Wed, 20 Apr 2022 22:10:21 -0700 Subject: [PATCH] readme --- Docs/readme.md | 74 +++++++++++++++++++------------------- Source/Basics/ZL_Series.cs | 35 ++++++++++++++++++ Source/QuanTAlib.csproj | 7 ++-- 3 files changed, 77 insertions(+), 39 deletions(-) create mode 100644 Source/Basics/ZL_Series.cs diff --git a/Docs/readme.md b/Docs/readme.md index 0df8ddc3..d6504d39 100644 --- a/Docs/readme.md +++ b/Docs/readme.md @@ -1,37 +1,37 @@ -# QuanTAlib - quantitative technical indicators for Quantower and other C#-based trading platorms - -![GitHub last commit](https://img.shields.io/github/last-commit/mihakralj/QuanTAlib) -[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=mihakralj_QuanTAlib&metric=ncloc)](https://sonarcloud.io/summary/overall?id=mihakralj_QuanTAlib) -[![Codacy grade](https://img.shields.io/codacy/grade/b1f9109222234c87bce45f1fd4c63aee?style=flat-square)](https://app.codacy.com/gh/mihakralj/QuanTAlib/dashboard) -[![codecov](https://codecov.io/gh/mihakralj/QuanTAlib/branch/main/graph/badge.svg?style=flat-square&token=YNMJRGKMTJ?style=flat-square)](https://codecov.io/gh/mihakralj/QuanTAlib) -[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=mihakralj_QuanTAlib&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=mihakralj_QuanTAlib) - -[![Nuget](https://img.shields.io/nuget/v/QuanTAlib?style=flat-square)](https://www.nuget.org/packages/QuanTAlib/) -[![Nuget](https://img.shields.io/nuget/dt/QuanTAlib?style=flat-square)](https://www.nuget.org/packages/QuanTAlib/) -[![GitHub watchers](https://img.shields.io/github/watchers/mihakralj/QuanTAlib?style=flat-square)](https://github.com/mihakralj/QuanTAlib/watchers) - -[![.NET7.0](https://img.shields.io/badge/.NET-7.0-yellow?style=flat-square)](https://dotnet.microsoft.com/en-us/download/dotnet/7.0) -[![.NET6.0](https://img.shields.io/badge/.NET-6.0-blue?style=flat-square)](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) -[![.NET4.8](https://img.shields.io/badge/.NET-4.8-blue?style=flat-square)](https://dotnet.microsoft.com/en-us/download/dotnet-framework/net48) -[![GitHub license](https://img.shields.io/github/license/mihakralj/QuanTAlib?style=flat-square)](Docs/LICENSE) - - -Quantitative TA Library (**QuanTAlib**) is an easy-to-use C# library for quantitative technical analysis with base algorithms, charts, signals and strategies useful for trading securities with [Quantower](https://www.quantower.com/) and other C#-based trading platforms. - -**QuanTAlib** is written with some specific design criteria in mind - this is a list of reasons why there is '_yet another C# TA library_': - -- Written in native C# - no code conversion from TA-LIB or other imported/converted TA libraries -- No usage of Decimal datatypes, LINQ, interface abstractions, or static classes (all for performance reasons) -- Supports both **historical data analysis** (working on bulk of historical arrays) and **real-time analysis** (adding one data item at the time without the need to re-calculate the whole history) -- Separation of calculations (**algos**) and visualizations (**charts**) -- Handle early data right - no hiding of poor calculations with NaN values (unless explicitly requested), data is as valid as mathematically possible from the first value -- Preservation of time-value integrity of each data throughout the calculation chain (each data point has a timestamp) -- Usage of events - each data series is an event publisher, each indicator is a subscriber - this allows seamless data flow between indicators without the need of plumbing (see [MACD example](https://github.com/mihakralj/QuanTAlib/blob/main/Docs/macd_example.ipynb) to understand how events allow chaining of indicators) - -QuanTAlib does not provide OHLCV quotes - but it can easily connect to any data feeds. There are some data feed classess -available (**RND_Feed** for random OHLCV, **YAHOO_Feed** for Yahoo Finance daily stock data) - -See [Getting Started](https://github.com/mihakralj/QuanTAlib/blob/main/Docs/getting_started.ipynb) .NET interactive notebook to get a feel how library works. Developers can use QuanTAlib in .NET interactive or in console apps, but the best -usage of the library is withing C#-enabled trading platforms - see **QuanTower_Charts** folder for Quantower examples. - -[**List of available and planned indicators**](https://github.com/mihakralj/QuanTAlib/blob/main/Docs/coverage.md). **So. Much. To. Do...** +# QuanTAlib - quantitative technical indicators for Quantower and other C#-based trading platorms + + +[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=mihakralj_QuanTAlib&metric=ncloc)](https://sonarcloud.io/summary/overall?id=mihakralj_QuanTAlib) +[![Codacy grade](https://img.shields.io/codacy/grade/b1f9109222234c87bce45f1fd4c63aee?style=flat-square)](https://app.codacy.com/gh/mihakralj/QuanTAlib/dashboard) +[![codecov](https://codecov.io/gh/mihakralj/QuanTAlib/branch/main/graph/badge.svg?style=flat-square&token=YNMJRGKMTJ?style=flat-square)](https://codecov.io/gh/mihakralj/QuanTAlib) +[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=mihakralj_QuanTAlib&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=mihakralj_QuanTAlib) +[![CodeFactor](https://www.codefactor.io/repository/github/mihakralj/quantalib/badge/main)](https://www.codefactor.io/repository/github/mihakralj/quantalib/overview/main) + +[![Nuget](https://img.shields.io/nuget/v/QuanTAlib?style=flat-square)](https://www.nuget.org/packages/QuanTAlib/) +![GitHub last commit](https://img.shields.io/github/last-commit/mihakralj/QuanTAlib) +[![Nuget](https://img.shields.io/nuget/dt/QuanTAlib?style=flat-square)](https://www.nuget.org/packages/QuanTAlib/) +[![GitHub watchers](https://img.shields.io/github/watchers/mihakralj/QuanTAlib?style=flat-square)](https://github.com/mihakralj/QuanTAlib/watchers) + +[![.NET7.0](https://img.shields.io/badge/.NET-7.0%20%7C%206.0%20%7C%204.8-blue?style=flat-square](https://dotnet.microsoft.com/en-us/download/dotnet/7.0) +[![GitHub license](https://img.shields.io/github/license/mihakralj/QuanTAlib?style=flat-square)](Docs/LICENSE) + + +Quantitative TA Library (**QuanTAlib**) is an easy-to-use C# library for quantitative technical analysis with base algorithms, charts, signals and strategies useful for trading securities with [Quantower](https://www.quantower.com/) and other C#-based trading platforms. + +**QuanTAlib** is written with some specific design criteria in mind - this is a list of reasons why there is '_yet another C# TA library_': + +- Written in native C# - no code conversion from TA-LIB or other imported/converted TA libraries +- No usage of Decimal datatypes, LINQ, interface abstractions, or static classes (all for performance reasons) +- Supports both **historical data analysis** (working on bulk of historical arrays) and **real-time analysis** (adding one data item at the time without the need to re-calculate the whole history) +- Separation of calculations (**algos**) and visualizations (**charts**) +- Handle early data right - no hiding of poor calculations with NaN values (unless explicitly requested), data is as valid as mathematically possible from the first value +- Preservation of time-value integrity of each data throughout the calculation chain (each data point has a timestamp) +- Usage of events - each data series is an event publisher, each indicator is a subscriber - this allows seamless data flow between indicators without the need of plumbing (see [MACD example](https://github.com/mihakralj/QuanTAlib/blob/main/Docs/macd_example.ipynb) to understand how events allow chaining of indicators) + +QuanTAlib does not provide OHLCV quotes - but it can easily connect to any data feeds. There are some data feed classess +available (**RND_Feed** for random OHLCV, **YAHOO_Feed** for Yahoo Finance daily stock data) + +See [Getting Started](https://github.com/mihakralj/QuanTAlib/blob/main/Docs/getting_started.ipynb) .NET interactive notebook to get a feel how library works. Developers can use QuanTAlib in .NET interactive or in console apps, but the best +usage of the library is withing C#-enabled trading platforms - see **QuanTower_Charts** folder for Quantower examples. + +[**List of available and planned indicators**](https://github.com/mihakralj/QuanTAlib/blob/main/Docs/coverage.md). **So. Much. To. Do...** diff --git a/Source/Basics/ZL_Series.cs b/Source/Basics/ZL_Series.cs new file mode 100644 index 00000000..9eaa7ea7 --- /dev/null +++ b/Source/Basics/ZL_Series.cs @@ -0,0 +1,35 @@ +namespace QuanTAlib; +using System; + +/* +ZL: Zero Lag + Data is de-lagged by removing the data from “lag” days ago, thus removing + (or attempting to) the cumulative effect of the moving average. + +Calculation: + Lag = (Period-1)/2 + ZL = Data + (Data - Data(Lag days ago) ) + +Sources: + https://mudrex.com/blog/zero-lag-ema-trading-strategy/ + + */ + +public class ZL_Series : Single_TSeries_Indicator +{ + public ZL_Series(TSeries source, int period, bool useNaN = false) : base(source, period:period, useNaN:useNaN) { + if (this._data.Count > 0) { base.Add(this._data); } + } + + public override void Add((DateTime t, double v) TValue, bool update) + { + int _lag = (int)((_p-1) * 0.5); + _lag = (_data.Count-_lag < 0) ? 0 : _data.Count-_lag; + + double _zl = TValue.v + (TValue.v - _data[_lag].v); + + var ret = (TValue.t, (base.Count==0 && base._NaN) ? double.NaN : _zl ); + base.Add(ret, update); + + } +} \ No newline at end of file diff --git a/Source/QuanTAlib.csproj b/Source/QuanTAlib.csproj index 2d29fbca..92cac419 100644 --- a/Source/QuanTAlib.csproj +++ b/Source/QuanTAlib.csproj @@ -51,11 +51,14 @@ - images\icon.png + QuanTAlib2.png https://raw.githubusercontent.com/mihakralj/QuanTAlib/main/.github/QuanTAlib2.png + False + C:\Dropbox\SSH keys\Certum\MihaKralj_OpenSource.pem + True - +