diff --git a/Source/Feeds/Alphavantage_Feed.cs b/Source/Feeds/Alphavantage_Feed.cs index 3c06d21a..046b9fa3 100644 --- a/Source/Feeds/Alphavantage_Feed.cs +++ b/Source/Feeds/Alphavantage_Feed.cs @@ -1,124 +1,125 @@ -namespace QuanTAlib; -using System; -using System.Text.Json; - -/* -Alphavantage - Free API to collect quotes for stock, Forex and crypto. It requires a (free) API key - Get API key at https://www.alphavantage.co/support/#api-key - Parameters: - Symbol: stock ("AAPL"), crypto ("BTC") or forex pair (divided by dash: "USD-EUR") - Extended: if true, return 2,000 rows. if false, return 100 rows - Interval: enum with options of Month, Week, Day, Hour, Min30, Min15, Min5, Min1 - APIkey: unique Alphavantage API key - - */ - -public class Alphavantage_Feed : TBars -{ - public enum Interval { Month, Week, Day, Hour, Min30, Min15, Min5, Min1} - public Alphavantage_Feed(string Symbol = "IBM", bool Extended = false, Interval Interval = Interval.Day, string APIkey = "demo") - { - - string outputsize = "compact"; - if (Extended) { outputsize = "full"; } - System.Net.Http.HttpClient client = new(); - JsonElement json = new(); - var tokens = Symbol.Split('-'); - if (tokens.Length > 1) - { - string req = "https://www.alphavantage.co/query?function=FX" + GetInterval(Interval) + "&from_symbol=" + tokens[0] + "&to_symbol=" + tokens[1] + "&outputsize=" + outputsize + "&apikey=" + APIkey; - var msg = client.GetStringAsync(req).Result; - var jres = JsonSerializer.Deserialize(msg).RootElement; - switch (Interval) - { - case Interval.Month: jres.TryGetProperty("Time Series FX (Monthly)", out json); break; - case Interval.Week: jres.TryGetProperty("Time Series FX (Weekly)", out json); break; - case Interval.Day: jres.TryGetProperty("Time Series FX (Daily)", out json); break; - case Interval.Hour: jres.TryGetProperty("Time Series FX (60min)", out json); break; - case Interval.Min30: jres.TryGetProperty("Time Series FX (30min)", out json); break; - case Interval.Min15: jres.TryGetProperty("Time Series FX (15min)", out json); break; - case Interval.Min5: jres.TryGetProperty("Time Series FX (5min)", out json); break; - case Interval.Min1: jres.TryGetProperty("Time Series FX (1min)", out json); break; - } - - } - if (json.ValueKind == JsonValueKind.Undefined) - { - string req = "https://www.alphavantage.co/query?function=TIME_SERIES" + GetInterval(Interval) + "&symbol=" + Symbol + "&outputsize=" + outputsize + "&apikey=" + APIkey; - var msg = client.GetStringAsync(req).Result; - var jres = JsonSerializer.Deserialize(msg).RootElement; - switch (Interval) - { - case Interval.Month: jres.TryGetProperty("Monthly Time Series", out json); break; - case Interval.Week: jres.TryGetProperty("Weekly Time Series", out json); break; - case Interval.Day: jres.TryGetProperty("Time Series (Daily)", out json); break; - case Interval.Hour: jres.TryGetProperty("Time Series (60min)", out json); break; - case Interval.Min30: jres.TryGetProperty("Time Series (30min)", out json); break; - case Interval.Min15: jres.TryGetProperty("Time Series (15min)", out json); break; - case Interval.Min5: jres.TryGetProperty("Time Series (5min)", out json); break; - case Interval.Min1: jres.TryGetProperty("Time Series (1min)", out json); break; - } - } - if (json.ValueKind == JsonValueKind.Undefined) - { - string req; - if ((int)Interval < 3) { req = "https://www.alphavantage.co/query?function=DIGITAL_CURRENCY" + GetInterval(Interval) + "&symbol=" + Symbol + "&market=USD&&outputsize=" + outputsize + "&apikey=" + APIkey; } - else { req = "https://www.alphavantage.co/query?function=CRYPTO" + GetInterval(Interval) + "&symbol=" + Symbol + "&market=USD&&outputsize=" + outputsize + "&apikey=" + APIkey; } - var msg = client.GetStringAsync(req).Result; - var jres = JsonSerializer.Deserialize(msg).RootElement; - switch (Interval) - { - case Interval.Month: jres.TryGetProperty("Time Series (Digital Currency Monthly)", out json); break; - case Interval.Week: jres.TryGetProperty("Time Series (Digital Currency Weekly)", out json); break; - case Interval.Day: jres.TryGetProperty("Time Series (Digital Currency Daily)", out json); break; - case Interval.Hour: jres.TryGetProperty("Time Series Crypto (60min)", out json); break; - case Interval.Min30: jres.TryGetProperty("Time Series Crypto (30min)", out json); break; - case Interval.Min15: jres.TryGetProperty("Time Series Crypto (15min)", out json); break; - case Interval.Min5: jres.TryGetProperty("Time Series Crypto (5min)", out json); break; - case Interval.Min1: jres.TryGetProperty("Time Series Crypto (1min)", out json); break; - } - } - if (json.ValueKind != JsonValueKind.Undefined) - { - foreach (var val in json.EnumerateObject()) { base.Add(GetOHLC(val)); } - } - - } - private static (DateTime t, double o, double h, double l, double c, double v) GetOHLC(JsonProperty json) - { - double o, h, l, c, v; - o = h = l = c = v = 0; - DateTime date = Convert.ToDateTime(json.Name); - foreach (var val in json.Value.EnumerateObject()) - { - switch (val.Name) - { - case "1. open": o = Convert.ToDouble(val.Value.ToString()); break; - case "1b. open (USD)": o = Convert.ToDouble(val.Value.ToString()); break; - case "2. high": h = Convert.ToDouble(val.Value.ToString()); break; - case "2b. high (USD)": h = Convert.ToDouble(val.Value.ToString()); break; - case "3. low": l = Convert.ToDouble(val.Value.ToString()); break; - case "3b. low (USD)": l = Convert.ToDouble(val.Value.ToString()); break; - case "4. close": c = Convert.ToDouble(val.Value.ToString()); break; - case "4b. close (USD)": c = Convert.ToDouble(val.Value.ToString()); break; - case "5. adjusted close": c = Convert.ToDouble(val.Value.ToString()); break; - case "5. volume": v = Convert.ToDouble(val.Value.ToString()); break; - case "6. volume": v = Convert.ToDouble(val.Value.ToString()); break; - } - } - return (date, o, h, l, c, v); - } - - private static string GetInterval(Interval interval = Interval.Day) => interval switch - { - Interval.Month => "_MONTHLY", - Interval.Week => "_WEEKLY", - Interval.Day => "_DAILY", - Interval.Hour => "_INTRADAY&interval=60min", - Interval.Min30 => "_INTRADAY&interval=30min", - Interval.Min15 => "_INTRADAY&interval=15min", - Interval.Min5 => "_INTRADAY&interval=5min", - Interval.Min1 => "_INTRADAY&interval=1min", - _ => "_DAILY" - }; -} \ No newline at end of file +namespace QuanTAlib; +using System; +using System.Text.Json; + +/* +Alphavantage - Free API to collect quotes for stock, Forex and crypto. It requires a (free) API key + Get API key at https://www.alphavantage.co/support/#api-key + Parameters: + Symbol: stock ("AAPL"), crypto ("BTC") or forex pair (divided by dash: "USD-EUR") + Extended: if true, return 2,000 rows. if false, return 100 rows + Interval: enum with options of Month, Week, Day, Hour, Min30, Min15, Min5, Min1 + APIkey: unique Alphavantage API key + + */ + +public class Alphavantage_Feed : TBars +{ + public enum Interval { Month, Week, Day, Hour, Min30, Min15, Min5, Min1} + public Alphavantage_Feed(string Symbol = "IBM", bool Extended = false, Interval Interval = Interval.Day, string APIkey = "demo") + { + + string outputsize = "compact"; + if (Extended) { outputsize = "full"; } + System.Net.Http.HttpClient client = new(); + JsonElement json = new(); + var tokens = Symbol.Split('-'); + if (tokens.Length > 1) + { + string req = "https://www.alphavantage.co/query?function=FX" + GetInterval(Interval) + "&from_symbol=" + tokens[0] + "&to_symbol=" + tokens[1] + "&outputsize=" + outputsize + "&apikey=" + APIkey; + var msg = client.GetStringAsync(req).Result; + var jres = JsonSerializer.Deserialize(msg).RootElement; + switch (Interval) + { + case Interval.Month: jres.TryGetProperty("Time Series FX (Monthly)", out json); break; + case Interval.Week: jres.TryGetProperty("Time Series FX (Weekly)", out json); break; + case Interval.Day: jres.TryGetProperty("Time Series FX (Daily)", out json); break; + case Interval.Hour: jres.TryGetProperty("Time Series FX (60min)", out json); break; + case Interval.Min30: jres.TryGetProperty("Time Series FX (30min)", out json); break; + case Interval.Min15: jres.TryGetProperty("Time Series FX (15min)", out json); break; + case Interval.Min5: jres.TryGetProperty("Time Series FX (5min)", out json); break; + case Interval.Min1: jres.TryGetProperty("Time Series FX (1min)", out json); break; + } + + } + if (json.ValueKind == JsonValueKind.Undefined) + { + string req = "https://www.alphavantage.co/query?function=TIME_SERIES" + GetInterval(Interval) + "&symbol=" + Symbol + "&outputsize=" + outputsize + "&apikey=" + APIkey; + var msg = client.GetStringAsync(req).Result; + var jres = JsonSerializer.Deserialize(msg).RootElement; + switch (Interval) + { + case Interval.Month: jres.TryGetProperty("Monthly Time Series", out json); break; + case Interval.Week: jres.TryGetProperty("Weekly Time Series", out json); break; + case Interval.Day: jres.TryGetProperty("Time Series (Daily)", out json); break; + case Interval.Hour: jres.TryGetProperty("Time Series (60min)", out json); break; + case Interval.Min30: jres.TryGetProperty("Time Series (30min)", out json); break; + case Interval.Min15: jres.TryGetProperty("Time Series (15min)", out json); break; + case Interval.Min5: jres.TryGetProperty("Time Series (5min)", out json); break; + case Interval.Min1: jres.TryGetProperty("Time Series (1min)", out json); break; + } + } + if (json.ValueKind == JsonValueKind.Undefined) + { + string req; + if ((int)Interval < 3) { req = "https://www.alphavantage.co/query?function=DIGITAL_CURRENCY" + GetInterval(Interval) + "&symbol=" + Symbol + "&market=USD&&outputsize=" + outputsize + "&apikey=" + APIkey; } + else { req = "https://www.alphavantage.co/query?function=CRYPTO" + GetInterval(Interval) + "&symbol=" + Symbol + "&market=USD&&outputsize=" + outputsize + "&apikey=" + APIkey; } + var msg = client.GetStringAsync(req).Result; + var jres = JsonSerializer.Deserialize(msg).RootElement; + switch (Interval) + { + case Interval.Month: jres.TryGetProperty("Time Series (Digital Currency Monthly)", out json); break; + case Interval.Week: jres.TryGetProperty("Time Series (Digital Currency Weekly)", out json); break; + case Interval.Day: jres.TryGetProperty("Time Series (Digital Currency Daily)", out json); break; + case Interval.Hour: jres.TryGetProperty("Time Series Crypto (60min)", out json); break; + case Interval.Min30: jres.TryGetProperty("Time Series Crypto (30min)", out json); break; + case Interval.Min15: jres.TryGetProperty("Time Series Crypto (15min)", out json); break; + case Interval.Min5: jres.TryGetProperty("Time Series Crypto (5min)", out json); break; + case Interval.Min1: jres.TryGetProperty("Time Series Crypto (1min)", out json); break; + } + } + if (json.ValueKind != JsonValueKind.Undefined) + { + foreach (var val in json.EnumerateObject()) { base.Add(GetOHLC(val)); } + } + + } + private static (DateTime t, double o, double h, double l, double c, double v) GetOHLC(JsonProperty json) + { + double o, h, l, c, v; + o = h = l = c = v = 0; + DateTime date = Convert.ToDateTime(json.Name); + foreach (var val in json.Value.EnumerateObject()) + { + switch (val.Name) + { + case "1. open": o = Convert.ToDouble(val.Value.ToString()); break; + case "1b. open (USD)": o = Convert.ToDouble(val.Value.ToString()); break; + case "2. high": h = Convert.ToDouble(val.Value.ToString()); break; + case "2b. high (USD)": h = Convert.ToDouble(val.Value.ToString()); break; + case "3. low": l = Convert.ToDouble(val.Value.ToString()); break; + case "3b. low (USD)": l = Convert.ToDouble(val.Value.ToString()); break; + case "4. close": c = Convert.ToDouble(val.Value.ToString()); break; + case "4b. close (USD)": c = Convert.ToDouble(val.Value.ToString()); break; + case "5. adjusted close": c = Convert.ToDouble(val.Value.ToString()); break; + case "5. volume": v = Convert.ToDouble(val.Value.ToString()); break; + case "6. volume": v = Convert.ToDouble(val.Value.ToString()); break; + } + } + return (date, o, h, l, c, v); + } + + private static string GetInterval(Interval interval = Interval.Day) => interval switch + { + Interval.Month => "_MONTHLY", + Interval.Week => "_WEEKLY", + Interval.Day => "_DAILY", + Interval.Hour => "_INTRADAY&interval=60min", + Interval.Min30 => "_INTRADAY&interval=30min", + Interval.Min15 => "_INTRADAY&interval=15min", + Interval.Min5 => "_INTRADAY&interval=5min", + Interval.Min1 => "_INTRADAY&interval=1min", + _ => "_DAILY" + }; +} + diff --git a/Source/Feeds/GBM_Feed.cs b/Source/Feeds/GBM_Feed.cs index 0e950683..07ed6005 100644 --- a/Source/Feeds/GBM_Feed.cs +++ b/Source/Feeds/GBM_Feed.cs @@ -1,60 +1,60 @@ -namespace QuanTAlib; -using System; - -/* -GBM - Geometric Brownian Motion is a random simulator of market movement, returning List - GBM can be used for testing indicators, validation and Monte Carlo simulations of strategies. - - Sample usage: - GBM-Random data = new(); // generates 1 year (252) list of bars - GBM-Random data = new(Bars: 1000); // generates 1,000 bars - GBM-Random data = new(Bars: 252, Volatility: 0.05, Drift: 0.0005, Seed: 100.0) - - Parameters - Bars: number of bars (quotes) requested - Volatility: how dymamic/volatile the series should be; default is 1 - Drift: incremental drift due to annual interest rate; default is 5% - Seed: starting value of the random series; should not be 0 - - */ - -public class GBM_Feed : TBars -{ - double seed; - readonly double drift, volatility; - public GBM_Feed(int Bars = 252, double Volatility = 1.0, double Drift = 0.05, double Seed = 100.0) { - seed = Seed; - volatility = Volatility*0.01; - drift = Drift*0.01; - for (int i = 0; i OCMin)? 2*OCMin-Low : Low; - - double Volume = GBM_value(seed*10, volatility*2, Drift:0); - - base.Add((timestamp, Open, High, Low, Close, Volume), update); - seed = Close; - } - - private static double GBM_value (double Seed, double Volatility, double Drift) { - Random rnd = new((int)(DateTime.UtcNow.Ticks)); - double U1 = 1.0-rnd.NextDouble(); - double U2 = 1.0-rnd.NextDouble(); - double Z = Math.Sqrt(-2.0 * Math.Log(U1)) * Math.Sin(2.0 * Math.PI * U2); - return Seed * Math.Exp( Drift - (Volatility*Volatility*0.5) + Volatility * Z); - } +namespace QuanTAlib; +using System; + +/* +GBM - Geometric Brownian Motion is a random simulator of market movement, returning List + GBM can be used for testing indicators, validation and Monte Carlo simulations of strategies. + + Sample usage: + GBM-Random data = new(); // generates 1 year (252) list of bars + GBM-Random data = new(Bars: 1000); // generates 1,000 bars + GBM-Random data = new(Bars: 252, Volatility: 0.05, Drift: 0.0005, Seed: 100.0) + + Parameters + Bars: number of bars (quotes) requested + Volatility: how dymamic/volatile the series should be; default is 1 + Drift: incremental drift due to annual interest rate; default is 5% + Seed: starting value of the random series; should not be 0 + + */ + +public class GBM_Feed : TBars +{ + double seed; + readonly double drift, volatility; + public GBM_Feed(int Bars = 252, double Volatility = 1.0, double Drift = 0.05, double Seed = 100.0) { + seed = Seed; + volatility = Volatility*0.01; + drift = Drift*0.01; + for (int i = 0; i OCMin)? 2*OCMin-Low : Low; + + double Volume = GBM_value(seed*10, volatility*2, Drift:0); + + base.Add((timestamp, Open, High, Low, Close, Volume), update); + seed = Close; + } + + private static double GBM_value (double Seed, double Volatility, double Drift) { + Random rnd = new((int)(DateTime.UtcNow.Ticks)); + double U1 = 1.0-rnd.NextDouble(); + double U2 = 1.0-rnd.NextDouble(); + double Z = Math.Sqrt(-2.0 * Math.Log(U1)) * Math.Sin(2.0 * Math.PI * U2); + return Seed * Math.Exp( Drift - (Volatility*Volatility*0.5) + Volatility * Z); + } } \ No newline at end of file diff --git a/Source/Indicators/ALMA_Series.cs b/Source/Indicators/ALMA_Series.cs index 9d819c8f..f91267e6 100644 --- a/Source/Indicators/ALMA_Series.cs +++ b/Source/Indicators/ALMA_Series.cs @@ -1,68 +1,68 @@ -namespace QuanTAlib; -using System; - -/* -ALMA: Arnaud Legoux Moving Average - The ALMA moving average uses the curve of the Normal (Gauss) distribution, which - can be shifted from 0 to 1. This allows regulating the smoothness and high - sensitivity of the indicator. Sigma is another parameter that is responsible for - the shape of the curve coefficients. This moving average reduces lag of the data - in conjunction with smoothing to reduce noise. - - -Sources: - https://phemex.com/academy/what-is-arnaud-legoux-moving-averages - https://www.prorealcode.com/prorealtime-indicators/alma-arnaud-legoux-moving-average/ - - */ - -public class ALMA_Series : Single_TSeries_Indicator -{ - private readonly System.Collections.Generic.List _buffer = new(); - private readonly double[] _weight; - private double _norm; - private readonly double _offset, _sigma; - - public ALMA_Series(TSeries source, int period, double offset = 0.85, double sigma = 6.0, bool useNaN = false) - : base(source, period, useNaN) - { - _offset = offset; - _sigma = sigma; - _weight = new double[period]; - - if (this._data.Count > 0) { base.Add(this._data); } - } - - public override void Add((System.DateTime t, double v) TValue, bool update) - { - if (update) { this._buffer[this._buffer.Count - 1] = TValue.v; } - else { this._buffer.Add(TValue.v); } - if (this._buffer.Count > this._p) { this._buffer.RemoveAt(0); } - - if (this._buffer.Count <= _p) { calc_weights(); } - - double _weightedSum = 0; - for (int i = 0; i < this._buffer.Count; i++) { _weightedSum += _weight[i] * _buffer[i]; } - double _alma = _weightedSum / _norm; - - var ret = (TValue.t, this.Count < this._p - 1 && this._NaN ? double.NaN : _alma); - base.Add(ret, update); - } - - private void calc_weights() - { - int _len = this._buffer.Count; - _norm = 0; - double _m = _offset * (_len - 1); - double _s = _len / _sigma; - for (int i = 0; i < _len; i++) - { - double _wt = Math.Exp(-((i - _m) * (i - _m)) / (2 * _s * _s)); - _weight[i] = _wt; - _norm += _wt; - } - } - -} - - +namespace QuanTAlib; +using System; + +/* +ALMA: Arnaud Legoux Moving Average + The ALMA moving average uses the curve of the Normal (Gauss) distribution, which + can be shifted from 0 to 1. This allows regulating the smoothness and high + sensitivity of the indicator. Sigma is another parameter that is responsible for + the shape of the curve coefficients. This moving average reduces lag of the data + in conjunction with smoothing to reduce noise. + + +Sources: + https://phemex.com/academy/what-is-arnaud-legoux-moving-averages + https://www.prorealcode.com/prorealtime-indicators/alma-arnaud-legoux-moving-average/ + + */ + +public class ALMA_Series : Single_TSeries_Indicator +{ + private readonly System.Collections.Generic.List _buffer = new(); + private readonly double[] _weight; + private double _norm; + private readonly double _offset, _sigma; + + public ALMA_Series(TSeries source, int period, double offset = 0.85, double sigma = 6.0, bool useNaN = false) + : base(source, period, useNaN) + { + _offset = offset; + _sigma = sigma; + _weight = new double[period]; + + if (this._data.Count > 0) { base.Add(this._data); } + } + + public override void Add((System.DateTime t, double v) TValue, bool update) + { + if (update) { this._buffer[this._buffer.Count - 1] = TValue.v; } + else { this._buffer.Add(TValue.v); } + if (this._buffer.Count > this._p) { this._buffer.RemoveAt(0); } + + if (this._buffer.Count <= _p) { calc_weights(); } + + double _weightedSum = 0; + for (int i = 0; i < this._buffer.Count; i++) { _weightedSum += _weight[i] * _buffer[i]; } + double _alma = _weightedSum / _norm; + + var ret = (TValue.t, this.Count < this._p - 1 && this._NaN ? double.NaN : _alma); + base.Add(ret, update); + } + + private void calc_weights() + { + int _len = this._buffer.Count; + _norm = 0; + double _m = _offset * (_len - 1); + double _s = _len / _sigma; + for (int i = 0; i < _len; i++) + { + double _wt = Math.Exp(-((i - _m) * (i - _m)) / (2 * _s * _s)); + _weight[i] = _wt; + _norm += _wt; + } + } + +} + + diff --git a/Source/Indicators/test.cs b/Source/Indicators/test.cs new file mode 100644 index 00000000..574e120e --- /dev/null +++ b/Source/Indicators/test.cs @@ -0,0 +1,2 @@ +//class with customer record +public class customer \ No newline at end of file diff --git a/Source/QuanTAlib.csproj b/Source/QuanTAlib.csproj index 699f9ff3..f5c5c2a2 100644 --- a/Source/QuanTAlib.csproj +++ b/Source/QuanTAlib.csproj @@ -1,72 +1,72 @@ - - - - 0.1.14 - - - QuanTAlib - Library of Technical Indicators for .NET - Quantitative Technical Analysis library for both real-time (streaming) and historical data analysis - git - https://github.com/mihakralj/QuanTAlib - true - Miha Kralj - Miha Kralj - readme.md - net7.0;net6.0;netstandard2.0 - disable - preview - disable - true - en-US - QuanTAlib - QuanTAlib - True - AnyCPU - False - embedded - True - True - - Indicators;Stock;Market;Technical;Analysis;Algorithmic;Trading;Trade;Trend;Momentum;Finance;Algorithm;Algo; - AlgoTrading;Financial;Strategy;Chart;Charting;Oscillator;Overlay;Equity;Bitcoin;Crypto;Cryptocurrency;Forex; - Quantitative;Historical;Quotes; - - Apache-2.0 - - false - - - full - True - 7 - True - anycpu - - - - True - 7 - True - anycpu - - - QuanTAlib2.png - https://raw.githubusercontent.com/mihakralj/QuanTAlib/main/.github/QuanTAlib2.png - True - - - - True - - - - True - False - - - - - - + + + + 0.1.14 + + + QuanTAlib + Library of Technical Indicators for .NET + Quantitative Technical Analysis library for both real-time (streaming) and historical data analysis + git + https://github.com/mihakralj/QuanTAlib + true + Miha Kralj + Miha Kralj + readme.md + net7.0;net6.0;netstandard2.0 + disable + preview + disable + true + en-US + QuanTAlib + QuanTAlib + True + AnyCPU + False + embedded + True + True + + Indicators;Stock;Market;Technical;Analysis;Algorithmic;Trading;Trade;Trend;Momentum;Finance;Algorithm;Algo; + AlgoTrading;Financial;Strategy;Chart;Charting;Oscillator;Overlay;Equity;Bitcoin;Crypto;Cryptocurrency;Forex; + Quantitative;Historical;Quotes; + + Apache-2.0 + + false + + + full + True + 7 + True + anycpu + + + + True + 7 + True + anycpu + + + QuanTAlib2.png + https://raw.githubusercontent.com/mihakralj/QuanTAlib/main/.github/QuanTAlib2.png + True + + + + True + + + + True + False + + + + + + \ No newline at end of file diff --git a/docs/.nojekyll b/docs/.nojekyll index 8b137891..e69de29b 100644 --- a/docs/.nojekyll +++ b/docs/.nojekyll @@ -1 +0,0 @@ - diff --git a/docs/macd_example.ipynb b/docs/macd_example.ipynb index 04a4d6ff..85891ea2 100644 --- a/docs/macd_example.ipynb +++ b/docs/macd_example.ipynb @@ -1,190 +1,190 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "dotnet_interactive": { - "language": "csharp" - }, - "vscode": { - "languageId": "dotnet-interactive.csharp" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "
Installed Packages
  • Plotly.NET, 2.0.0
  • Plotly.NET.Interactive, 2.0.0
  • QuanTAlib, 0.1.13
" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/markdown": [ - "Loading extensions from `Plotly.NET.Interactive.dll`" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "// This is .NET Interactive Notebook. It can run in VS.Code with .NET interactive extension installed\n", - "\n", - "#r \"nuget: Plotly.NET, 2.0.0\"\n", - "#r \"nuget: Plotly.NET.Interactive, 2.0.0\"\n", - "#r \"nuget: QuanTAlib\"\n", - "\n", - "using Plotly.NET;\n", - "using Plotly.NET.LayoutObjects;\n", - "using QuanTAlib;" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "dotnet_interactive": { - "language": "csharp" - }, - "vscode": { - "languageId": "dotnet-interactive.csharp" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "
380
" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "// defining the MACD model through clasess that connect to each other with Events\n", - "\n", - "RND_Feed tsla = new(380);\n", - "TSeries close = tsla.Close; // close will get data from YAHOO tsla feed\n", - "EMA_Series slow = new(close,26); // slow gets data from slow through pub-sub eventing\n", - "EMA_Series fast = new(close,12); // fast gets data from slow (via eventing)\n", - "SUB_Series macd = new(fast,slow); // macd is a SUBtraction of fast-slow\n", - "EMA_Series signal = new(macd,9); // signal is EMA of macd\n", - "SUB_Series histogram = new(macd, signal); // histogran is SUBtraction macd-signal\n", - "\n", - "slow.Count" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "dotnet_interactive": { - "language": "csharp" - }, - "vscode": { - "languageId": "dotnet-interactive.csharp" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "
indexvalue
0
99.6
1
100.93
2
100.36
3
96.83
4
95.39
5
96.34
6
97.6
7
98.7
8
100.11
9
101.38
10
101.09
11
100.31
12
97.19
13
96.13
14
93.34
15
91.46
16
91.65
17
91.63
18
90.39
19
91.69
(360 more)
" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "tsla.Open.v" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "dotnet_interactive": { - "language": "csharp" - }, - "vscode": { - "languageId": "dotnet-interactive.csharp" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "\r\n", - "
\r\n", - "
\r\n", - "\r\n", - "\r\n", - " \r\n", - "
(tsla.Open.v, tsla.High.v, tsla.Low.v, tsla.Close.v, tsla.Open.t, \"candles\");\n", - "var ch1 = Chart2D.Chart.Line(macd.t,macd.v,false,\"macd\").WithLineStyle(Width: 2, Color: Color.fromString(\"red\"));\n", - "var ch2 = Chart2D.Chart.Line(signal.t,signal.v,false,\"signal\").WithLineStyle(Width: 1.5, Color: Color.fromString(\"green\"));\n", - "//GenericChart.GenericChart hist = Chart2D.Chart.Column(histogram.t,histogram.v).WithLineStyle(Width: 1.5, Color: Color.fromString(\"green\"));\n", - "\n", - "var chart = Chart.Combine(new []{candles,ch1,ch2}).WithSize(1200,400).WithMargin(Margin.init(1,1,60,1,1,false)).WithTitle(\"MACD using EMA\");\n", - "\n", - "chart" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": ".NET (C#)", - "language": "C#", - "name": ".net-csharp" - }, - "language_info": { - "file_extension": ".cs", - "mimetype": "text/x-csharp", - "name": "C#", - "pygments_lexer": "csharp", - "version": "9.0" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "vscode": { + "languageId": "dotnet-interactive.csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
  • Plotly.NET, 2.0.0
  • Plotly.NET.Interactive, 2.0.0
  • QuanTAlib, 0.1.13
" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "Loading extensions from `Plotly.NET.Interactive.dll`" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "// This is .NET Interactive Notebook. It can run in VS.Code with .NET interactive extension installed\n", + "\n", + "#r \"nuget: Plotly.NET, 2.0.0\"\n", + "#r \"nuget: Plotly.NET.Interactive, 2.0.0\"\n", + "#r \"nuget: QuanTAlib\"\n", + "\n", + "using Plotly.NET;\n", + "using Plotly.NET.LayoutObjects;\n", + "using QuanTAlib;" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "vscode": { + "languageId": "dotnet-interactive.csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
380
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "// defining the MACD model through clasess that connect to each other with Events\n", + "\n", + "RND_Feed tsla = new(380);\n", + "TSeries close = tsla.Close; // close will get data from YAHOO tsla feed\n", + "EMA_Series slow = new(close,26); // slow gets data from slow through pub-sub eventing\n", + "EMA_Series fast = new(close,12); // fast gets data from slow (via eventing)\n", + "SUB_Series macd = new(fast,slow); // macd is a SUBtraction of fast-slow\n", + "EMA_Series signal = new(macd,9); // signal is EMA of macd\n", + "SUB_Series histogram = new(macd, signal); // histogran is SUBtraction macd-signal\n", + "\n", + "slow.Count" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "vscode": { + "languageId": "dotnet-interactive.csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
indexvalue
0
99.6
1
100.93
2
100.36
3
96.83
4
95.39
5
96.34
6
97.6
7
98.7
8
100.11
9
101.38
10
101.09
11
100.31
12
97.19
13
96.13
14
93.34
15
91.46
16
91.65
17
91.63
18
90.39
19
91.69
(360 more)
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "tsla.Open.v" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "vscode": { + "languageId": "dotnet-interactive.csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "\r\n", + "
\r\n", + "
\r\n", + "\r\n", + "\r\n", + " \r\n", + "
(tsla.Open.v, tsla.High.v, tsla.Low.v, tsla.Close.v, tsla.Open.t, \"candles\");\n", + "var ch1 = Chart2D.Chart.Line(macd.t,macd.v,false,\"macd\").WithLineStyle(Width: 2, Color: Color.fromString(\"red\"));\n", + "var ch2 = Chart2D.Chart.Line(signal.t,signal.v,false,\"signal\").WithLineStyle(Width: 1.5, Color: Color.fromString(\"green\"));\n", + "//GenericChart.GenericChart hist = Chart2D.Chart.Column(histogram.t,histogram.v).WithLineStyle(Width: 1.5, Color: Color.fromString(\"green\"));\n", + "\n", + "var chart = Chart.Combine(new []{candles,ch1,ch2}).WithSize(1200,400).WithMargin(Margin.init(1,1,60,1,1,false)).WithTitle(\"MACD using EMA\");\n", + "\n", + "chart" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/x-csharp", + "name": "C#", + "pygments_lexer": "csharp", + "version": "9.0" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +}