C/C++ API Documentation
+ + +2.0 How +to build and link to TA-Lib
+ +3.0 Technical Analysis Functions
+ +++ + +
+4.1 Abstraction layer+ +
+4.2 Unstable Period
+4.3 Input Type: float vs. double +
From 1c1eb0e77415b7a0ab0a26e66b6b8db03cfe79da Mon Sep 17 00:00:00 2001 From: <> Date: Thu, 7 Nov 2024 18:10:44 +0000 Subject: [PATCH] Deployed 8d62e0c with MkDocs version: 1.6.1 --- .nojekyll | 0 404.html | 572 ++ CNAME | 1 + about/index.html | 626 ++ api/index.html | 1091 +++ assets/images/download32.png | Bin 0 -> 2395 bytes assets/images/favicon.png | Bin 0 -> 1870 bytes assets/images/home-original.png | Bin 0 -> 261447 bytes assets/images/home.png | Bin 0 -> 261237 bytes assets/javascripts/bundle.83f73b43.min.js | 16 + assets/javascripts/bundle.83f73b43.min.js.map | 7 + assets/javascripts/lunr/min/lunr.ar.min.js | 1 + assets/javascripts/lunr/min/lunr.da.min.js | 18 + assets/javascripts/lunr/min/lunr.de.min.js | 18 + assets/javascripts/lunr/min/lunr.du.min.js | 18 + assets/javascripts/lunr/min/lunr.el.min.js | 1 + assets/javascripts/lunr/min/lunr.es.min.js | 18 + assets/javascripts/lunr/min/lunr.fi.min.js | 18 + assets/javascripts/lunr/min/lunr.fr.min.js | 18 + assets/javascripts/lunr/min/lunr.he.min.js | 1 + assets/javascripts/lunr/min/lunr.hi.min.js | 1 + assets/javascripts/lunr/min/lunr.hu.min.js | 18 + assets/javascripts/lunr/min/lunr.hy.min.js | 1 + assets/javascripts/lunr/min/lunr.it.min.js | 18 + assets/javascripts/lunr/min/lunr.ja.min.js | 1 + assets/javascripts/lunr/min/lunr.jp.min.js | 1 + assets/javascripts/lunr/min/lunr.kn.min.js | 1 + assets/javascripts/lunr/min/lunr.ko.min.js | 1 + assets/javascripts/lunr/min/lunr.multi.min.js | 1 + assets/javascripts/lunr/min/lunr.nl.min.js | 18 + assets/javascripts/lunr/min/lunr.no.min.js | 18 + assets/javascripts/lunr/min/lunr.pt.min.js | 18 + assets/javascripts/lunr/min/lunr.ro.min.js | 18 + assets/javascripts/lunr/min/lunr.ru.min.js | 18 + assets/javascripts/lunr/min/lunr.sa.min.js | 1 + .../lunr/min/lunr.stemmer.support.min.js | 1 + assets/javascripts/lunr/min/lunr.sv.min.js | 18 + assets/javascripts/lunr/min/lunr.ta.min.js | 1 + assets/javascripts/lunr/min/lunr.te.min.js | 1 + assets/javascripts/lunr/min/lunr.th.min.js | 1 + assets/javascripts/lunr/min/lunr.tr.min.js | 18 + assets/javascripts/lunr/min/lunr.vi.min.js | 1 + assets/javascripts/lunr/min/lunr.zh.min.js | 1 + assets/javascripts/lunr/tinyseg.js | 206 + assets/javascripts/lunr/wordcut.js | 6708 +++++++++++++++++ .../workers/search.6ce7567c.min.js | 42 + .../workers/search.6ce7567c.min.js.map | 7 + assets/stylesheets/main.0253249f.min.css | 1 + assets/stylesheets/main.0253249f.min.css.map | 1 + assets/stylesheets/palette.06af60db.min.css | 1 + .../stylesheets/palette.06af60db.min.css.map | 1 + faq/index.html | 667 ++ functions/index.html | 1206 +++ index.html | 664 ++ install/index.html | 654 ++ search/search_index.json | 1 + sitemap.xml | 3 + sitemap.xml.gz | Bin 0 -> 127 bytes wrappers/index.html | 653 ++ 59 files changed, 13415 insertions(+) create mode 100644 .nojekyll create mode 100644 404.html create mode 100644 CNAME create mode 100644 about/index.html create mode 100644 api/index.html create mode 100644 assets/images/download32.png create mode 100644 assets/images/favicon.png create mode 100644 assets/images/home-original.png create mode 100644 assets/images/home.png create mode 100644 assets/javascripts/bundle.83f73b43.min.js create mode 100644 assets/javascripts/bundle.83f73b43.min.js.map create mode 100644 assets/javascripts/lunr/min/lunr.ar.min.js create mode 100644 assets/javascripts/lunr/min/lunr.da.min.js create mode 100644 assets/javascripts/lunr/min/lunr.de.min.js create mode 100644 assets/javascripts/lunr/min/lunr.du.min.js create mode 100644 assets/javascripts/lunr/min/lunr.el.min.js create mode 100644 assets/javascripts/lunr/min/lunr.es.min.js create mode 100644 assets/javascripts/lunr/min/lunr.fi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.fr.min.js create mode 100644 assets/javascripts/lunr/min/lunr.he.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hu.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hy.min.js create mode 100644 assets/javascripts/lunr/min/lunr.it.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ja.min.js create mode 100644 assets/javascripts/lunr/min/lunr.jp.min.js create mode 100644 assets/javascripts/lunr/min/lunr.kn.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ko.min.js create mode 100644 assets/javascripts/lunr/min/lunr.multi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.nl.min.js create mode 100644 assets/javascripts/lunr/min/lunr.no.min.js create mode 100644 assets/javascripts/lunr/min/lunr.pt.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ro.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ru.min.js create mode 100644 assets/javascripts/lunr/min/lunr.sa.min.js create mode 100644 assets/javascripts/lunr/min/lunr.stemmer.support.min.js create mode 100644 assets/javascripts/lunr/min/lunr.sv.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ta.min.js create mode 100644 assets/javascripts/lunr/min/lunr.te.min.js create mode 100644 assets/javascripts/lunr/min/lunr.th.min.js create mode 100644 assets/javascripts/lunr/min/lunr.tr.min.js create mode 100644 assets/javascripts/lunr/min/lunr.vi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.zh.min.js create mode 100644 assets/javascripts/lunr/tinyseg.js create mode 100644 assets/javascripts/lunr/wordcut.js create mode 100644 assets/javascripts/workers/search.6ce7567c.min.js create mode 100644 assets/javascripts/workers/search.6ce7567c.min.js.map create mode 100644 assets/stylesheets/main.0253249f.min.css create mode 100644 assets/stylesheets/main.0253249f.min.css.map create mode 100644 assets/stylesheets/palette.06af60db.min.css create mode 100644 assets/stylesheets/palette.06af60db.min.css.map create mode 100644 faq/index.html create mode 100644 functions/index.html create mode 100644 index.html create mode 100644 install/index.html create mode 100644 search/search_index.json create mode 100644 sitemap.xml create mode 100644 sitemap.xml.gz create mode 100644 wrappers/index.html diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 000000000..e69de29bb diff --git a/404.html b/404.html new file mode 100644 index 000000000..616c2d278 --- /dev/null +++ b/404.html @@ -0,0 +1,572 @@ + + + +
+ + + + + + + + + + + + + + + + + + +2.0 How +to build and link to TA-Lib
+ +3.0 Technical Analysis Functions
+ +++ + +
+4.1 Abstraction layer+ +
+4.2 Unstable Period
+4.3 Input Type: float vs. double +
All functions available to the end-user are documented here.
+ +To use the library in C/C++ project, you just need to #include +"ta_libc.h" and link to the static library corresponding to your type +of application.
+ +All the required header file are in +ta-lib/c/include. Header files in other directories +should never be included by your application directly.
+ +Here is the list of variant of the static library currently supported:
++
Static Library Name | +Use runtime DLL? | +Multithreaded? | +Debug info? | +
---|---|---|---|
ta_libc_csr.lib | +- | +- | +- | +
ta_libc_csd.lib | +- | +- | +Yes | +
ta_libc_cmr.lib | +- | +Yes | +- | +
ta_libc_cmd.lib | +- | +Yes | +Yes | +
ta_libc_cdr.lib | +Yes | +Yes | +- | +
ta_libc_cdd.lib | +Yes | +Yes | +Yes | +
Pre-compiled
+ version of these libraries is part of the MSVC package. If you wish to
+ re-build yourself the static libraries, makefiles can be found in ta-lib/make/<ENV>/win32/msvc.
+ These MSVC makefiles also works with Visual Studio 2005.
+
+ The <ENV> is a 3 letter sub-directories (cmd, cmr, csd, csr, cdd
+ and cdr)
+ allowing to select the "standard library runtime" setting for your
+ application).
+
+Just type "nmake" or "nmake /A" to build all targets.
+The generated targets will be found in ta-lib/c/lib and ta-lib/c/bin.
+
+
To rebuild from scratch do "nmake clean" and then "nmake" again.
+The application without debug info are the speed optimized version. They cannot be trace for debugging though.
+
Visual Studio 2005 project files can be found in
+ ta-lib/c/ide/vs2005
+
If you observe
+ link errors on Windows, verify that the "Use runtime library" setting in the
+ C/C++ Code generation tab is the same as your choice of static libraries.
+
Link errors + will show up if your application does not links with wininet and + odbc32. These are provided with MSVC and Borland and should be found on your + system.
The Git repository +and the Win32 packages contains multiple makefiles generated for multiple +platforms, including Linux. The makefiles are +found in ta-lib/make/<ENV>/linux/g++.
+ +The <ENV> is a 3 letter sub-directories (cmd,cmr,csd,csr) allowing to select an environment of development applicable to your +application (see section 2.1). The cdd and cdr type does not apply to Linux.
+ +Just type "make clean" and "make" to build all targets. +The generated target will be found in ta-lib/c/lib and ta-lib/c/bin.
+You will need to +link to 3 static libraries: ta-abstract, ta-func and ta-common
+ +Download the source code tar.gz package and perform the following as root:
+ + +TA-Lib is installed +as a shared library called "libta-lib" (name will vary depending of your +platform). With gcc you link using the switch "-lta-lib".
+ +When building the +complete source tree, an application called "ta_regtest" is created in the ta-lib/c/bin +directory. This is a suite of tests to validate that the library you did compiled is behaving as expected +within your environment.
+ +Whenever you +re-compile the TA-Lib libraries, it is suggested to re-run ta_regtest. An internet connection is required +since web data fetching is one feature being tested.
+Make sure TA_Initialize +was called once (and only once) prior to any other API functions.
+The individual TA function can be directly called. User who would like to integrate +the TA functions without prior knowledge of their parameters, should consider +the +abstraction +layer interface.
+The source code of all the TA functions is in +ta-lib/c/src/ta_func.
+Direct call could be +done through the interface defined in + +ta-lib/c/include/ta_func.h
+All the TA functions are simple mathematical function. You provides the inputs with an array, and the function simply store the output in a +caller provided output array. The TA functions are NOT allocating +any space for the caller. The +number of data in the output will NEVER exceed the number of elements requested to be calculated (with +the startIdx and endIdx explained below).
+Here is an example:
+We will dissect the TA_MA function allowing to calculate a +simple moving average.
+TA_RetCode TA_MA(
+int startIdx,
+
+int endIdx,
+
+const double inReal[],
+
+int
+optInTimePeriod,
+
+int
+optInMAType,
+
+int
+*outBegIdx,
+
+int *outNbElement,
+
+double outReal[],
+
+)
+
At first it appears that there is a lot of parameters, but do not be +discourage, all functions are consistent and share the same parameter structure. The parameters are provided in +4 sections:
+The output will be calculated only + for the range specified by startIdx to endIdx.
+ One or more data inputs are then specified. In that example there is only one + input. All inputs parameter + name starts with "in".
+ zero or more optional inputs are specified + here. In that example + there is 2 optional inputs. These parameters allows to fine tune the function. If you do not care about a particular optIn + just specify TA_INTEGER_DEFAULT or TA_REAL_DEFAULT (depending of the type).
+ One or more output are finally specified. In that example there is only one + output which is outReal (the parameters outBegIdx and + outNbElement are always specified once before the list of outputs).
This structure of parameters gives a lot of flexibility to make the function +calculate ONLY the portion of required data. It is slightly complex, but it +allows demanding user to manage efficiently the memory and the CPU processing.
+Lets say you wish to calculate a 30 day moving average using closing prices. +The function call could look as follow:
+TA_Real closePrice[400]; +TA_Real out[400]; +TA_Integer outBeg; +TA_Integer outNbElement;+
/* ... initialize your closing price here... */+
retCode = TA_MA( 0, 399, + &closePrice[0], + 30,TA_MAType_SMA, + &outBeg, &outNbElement, &out[0] );+
/* The output is displayed here */ +for( i=0; i < outNbElement; i++ ) + printf( "Day %d = %f\n", outBeg+i, out[i] ); ++
One important aspect +of the output are the outBeg and outNbElement. Even if it was requested to +calculate for the whole range (from 0 to 399), the moving average is not valid +until the 30th day. Consequently, the outBeg will be 29 (zero base) and +the outNbElement will be 400-29 = 371. Meaning only +the first 371 elements of out are valid, and these could be calculated only +starting at the 30th element of the input.
+As an alternative example, if you would have requested to calculate only in +the "125 to 225" range (with startIdx and endIdx), the outBeg will be +125 and outNbElement will be 100. (the "30" minimum required is not an +issue because we dispose of 125 closing price before the start of the requested +range...). As you may have already understand, the "out" array will be +written only for its first 100 elements. The rest will be left untouched.
+Here is another example. In that case we want to calculate a 14 bars exponential moving average +only for 1 price bar in particular (say the last day of 300 price bar):
+TA_Real closePrice[300]; +TA_Real out; +TA_Integer outBeg; +TA_Integer outNbElement;+
/* ... initialize your closing price here... */+
retCode = TA_MA( 299, 299, + &closePrice[0], + 14, TA_MAType_EMA, + &outBeg, &outNbElement, &out );+
In that example: outBeg will be 299, outNbElement will be 1, and only +one value gets written into out.
+In the case that you do not provide enough data to even being able to +calculate at least one value, outNbElement will be 0 and outBeg shall be +ignored.
+If the input and +output of a TA function are of the same type, the caller can re-use the input +buffer for storing one of the output of the TA function. The following example will +work:
+#define BUFFER_SIZE 100 +TA_Real buffer[BUFFER_SIZE]; +... +retCode = TA_MA( 0, BUFFER_SIZE-1, + &buffer[0], + 30, TA_MAType_SMA, + &outBeg, &outNbElement, &buffer[0] );+
Of course, the +input is overwritten, but this capability +diminish needs for temporary memory allocation for certain application. You can +assume this capability is true for all TA functions.
++It is important that the output array is large enough. Depending of your needs, +you might find one of the following method useful to determine the output +allocation size. All these methods are consistent and works with all TA +functions:
+Method | +Description | +
---|---|
Input Matching | +allocationSize = endIdx + 1;
+ Pros: Easy to understand and implement. |
+
Range Matching | +allocationSize = endIdx - startIdx + 1; + + Pros: Easy to implement. + Cons: Allocation slightly larger than needed. Example: for a 30 period SMA, + you will get 29 elements wasted because of the lookback. |
+
Exact Allocation | +lookback = TA_XXXX_Lookback( ... ) ; + temp = max( lookback, startIdx ); + if( temp > endIdx ) + allocationSize = 0; // No output + else + allocationSize = endIdx - temp + 1;
+ Pros: Optimal allocation algorithm. |
+
+
A +function TA_XXXX_Lookback is provided for each TA function. Example: For TA_SMA, +there is a TA_SMA_Lookback.
+The lookback function indicates how many inputs are consume before the first +output can be calculated. Example: A simple moving average (SMA) of period 10 +will have a lookback of 9.
+ +All the TA Function can be called using the interface defined in +ta-lib/c/include/ta_abstract.h
+The abstraction layer is particularly interesting for an application who wishes to support the complete list of TA functions without having
+to re-write new code each time a new function is added to the TA-LIB. If you wish to simply integrate in your application a small number of specific
+function, you may be better to simply call these directly (see previous section).
+
+ Example:
+Lets say you are doing a charting software. When the user select a price bar, a side list offers blindly all the TA functions
+that could be applied to a price bar. The user selects one of these, then a dialog open for allowing to adjust
+the optional parameters (TA-LIB will tell your software which parameter are needed and the
+valid value range for each). Once all the parameter are set, you can call blindly the
+corresponding TA function. The returned information can then also blindly be drawn on the chart (some
+output flags allows to get some hint on how the data shall be drawn). The same "abstract" logic apply to all the TA functions.
+Some TA Functions works only on volume, or can work indifferently with any time series
+data (the open, close, another indicator...) All the applicable functions to the currently selected/available
+data can be determined through this "virtual" interface.
+
+The abstraction layer is a complex, but powerful interface.
Some TA functions provides different results depending of the "starting point" of the data being +involve. This is often referred as a function having memories. An example of such function is the Exponential Moving Average. It is +possible to control the unstable period (the amount of data to strip off) with +TA_SetUnstablePeriod and +TA_GetUnstablePeriod.
+For each technical analysis algorithm, there is one version of the function accepting the input as +array of float and another accepting array of double. The float version has a "TA_S_" suffix e.g. +for TA_MA there is an equivalent TA_S_MA function.
+TA_RetCode TA_MA( int startIdx,
+
+int endIdx,
+
+const double inReal[],
+
+int optInTimePeriod,
+
+
+TA_MAType optInMAType,
+
+int *outBegIdx,
+
+int *outNbElement,
+
+double outReal[] );
+
+TA_RetCode TA_S_MA( int startIdx,
+
+int endIdx,
+
+const float inReal[],
+
+int optInTimePeriod,
+
+TA_MAType optInMAType,
+
+int *outBegIdx,
+
+int *outNbElement,
+
+double outReal[] );
+
Both version do all the +calculation using double e.g. when an element of a float array is accessed, it +is changed to double-precision. Consequently, both function will yield the same result.
+It is typical that +users have their price bar data as float and maintain all their intermediate +calculation as double. Having direct support for both type in TA-Lib is more +memory efficient. With only one type, the user would be potentially forced +to duplicate their input data in a new array of a different type prior to a TA +function call.
+ +%FNxVd*bz>EH2W^s`sYL6~$6
zcXw`hMR}|{2Ap^vUFpxJEII_a4HLV7)9)aY1F_oPNtVmL;Y=OIt7d5XhZ9u{BLs2B
z^xY(9d38KDw}-P?5P5Yo^jP2WNM3qL(Vbf(!*{aEE~`_=>wp_a;#dc&b!7VUwD6n8
z1fQY7j_w>--Z+THaeQL?Bf_*a>v48fGY<`S#3N7AqSq{afub@W?t;u-nQusXyBv;DJvt&j#OiBuFvAsT`twC+O-_e
zs)