{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "dotnet_interactive": { "language": "csharp" }, "vscode": { "languageId": "dotnet-interactive.csharp" } }, "outputs": [ { "data": { "text/html": [ "
Installed Packages
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "#r \"nuget: TALib.NETCore, 0.4.4\" \n", "#r \"nuget: QuanTAlib, 0.1.10-beta\" \n", "\n", "using QuanTAlib;\n", "using TALib;\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "dotnet_interactive": { "language": "csharp" }, "vscode": { "languageId": "dotnet-interactive.csharp" } }, "outputs": [ { "ename": "Error", "evalue": "(1,1): error CS0246: The type or namespace name 'YAHOO_Feed' could not be found (are you missing a using directive or an assembly reference?)", "output_type": "error", "traceback": [ "(1,1): error CS0246: The type or namespace name 'YAHOO_Feed' could not be found (are you missing a using directive or an assembly reference?)" ] } ], "source": [ "YAHOO_Feed aapl = new(2020,\"AAPL\");\n", "TSeries data = aapl.Close;\n", "\n", "data.Count()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "dotnet_interactive": { "language": "csharp" }, "vscode": { "languageId": "dotnet-interactive.csharp" } }, "outputs": [], "source": [ "int period = 10;\n", "\n", "//QuanTAlib SMA algorithm\n", "SMA_Series e = new(data, period, false); \n", "\n", "// direct call to SMA from TA-LIB - with stitching NaNs in front\n", "int outBegIdx, outNbElement;\n", "double[] output = new double[data.Count];\n", "double[] nans = new double[period];\n", "double[] ta_temp = new double[data.Count-period+1];\n", "Array.Fill(nans, double.NaN);\n", "Core.Sma(data.v.ToArray(), 0, data.Count-1, ta_temp, out outBegIdx, out outNbElement, period); //TA-LIB SMA method\n", "nans.CopyTo(output,0);\n", "ta_temp.CopyTo(output,period-1);\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "dotnet_interactive": { "language": "csharp" }, "vscode": { "languageId": "dotnet-interactive.csharp" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "QuantLib\t TA-LIB\n", "164.31\t\t 164.31\n", "166.81\t\t 166.81\n", "169.20\t\t 169.20\n", "171.01\t\t 171.01\n", "172.41\t\t 172.41\n", "173.45\t\t 173.45\n", "174.75\t\t 174.75\n", "175.38\t\t 175.38\n", "175.54\t\t 175.54\n", "\n", "1394\t\t 1394\n" ] } ], "source": [ "// comparing the tail of QuanTAlib and TA-LIB\n", "Console.Write($\"QuanTAlib\\t TA-LIB\\n\");\n", "for (int i=data.Count-10; i