Files
QuanTAlib/Docs/Comparing_w_TALIB.ipynb
T
2022-04-19 22:34:42 -07:00

3.6 KiB

In [ ]:
#r "nuget: TALib.NETCore, 0.4.4"    
#r "nuget: QuanTAlib, 0.1.10-beta" 

using QuanTAlib;
using TALib;
Installed Packages
  • QuanTAlib, 0.1.10-beta
  • TALib.NETCore, 0.4.4
In [ ]:
YAHOO_Feed aapl = new(2020,"AAPL");
TSeries data = aapl.Close;

data.Count()
(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?)
In [ ]:
int period = 10;

//QuanTAlib SMA algorithm
SMA_Series e = new(data, period, false);  

// direct call to SMA from TA-LIB - with stitching NaNs in front
int outBegIdx, outNbElement;
double[] output = new double[data.Count];
double[] nans = new double[period];
double[] ta_temp = new double[data.Count-period+1];
Array.Fill(nans, double.NaN);
Core.Sma(data.v.ToArray(), 0, data.Count-1, ta_temp, out outBegIdx, out outNbElement, period); //TA-LIB SMA method
nans.CopyTo(output,0);
ta_temp.CopyTo(output,period-1);
In [ ]:
// comparing the tail of QuanTAlib and TA-LIB
Console.Write($"QuanTAlib\t TA-LIB\n");
for (int i=data.Count-10; i<data.Count-1; i++) 
    Console.Write($"{e[i].v:f2}\t\t {output[i]:f2}\n");

Console.Write($"\n{e.Count()}\t\t {output.Length}\n");
QuantLib	 TA-LIB
164.31		 164.31
166.81		 166.81
169.20		 169.20
171.01		 171.01
172.41		 172.41
173.45		 173.45
174.75		 174.75
175.38		 175.38
175.54		 175.54

1394		 1394