SWIG Wrapper for TA-Lib
=======================
vi:set tw=77:
This directory tree contains files needed to build a SWIG wrapper to
TA-Lib. SWIG is a software development tool for building scripting language
interfaces to C and C++ programs. It supports a number of target languages:
including Guile, Java, Mzscheme, Ocaml, Perl, Pike, PHP, Python, Ruby, and
Tcl. More information can be found at http://www.swig.org
I had two goals while making this wrapper:
1. To stay as close as possible to the original TA-LIB C interface
2. To make the interface as much convenient (and "Perlish") and robust
as possible.
Those two objectives were often not compatible, what results in many elements
being wrapped in two or more ways; choose your own perferences. In a few
cases, those objectives were conflicting; then the Perl way took precedence
over being literally identical to the TA-LIB C way.
Although SWIG is capable of generating wrappers to many languages, makefiles
in this directory tree support Perl only. Taking Perl as example, one can
extend it to other laungages, if needed.
First Thing
===========
If you are a Win32 user, and you are using Perl 5.8.0, you will find in
the TA-Lib MSVC package the pre-compiled binaries. You can then directly
jump to the section "Using TA-Lib in Perl".
Others will need to build their own binaries. Follow the step starting
with the "Installation" section.
Installation
============
To build the wrapper, you need to have SWIG installed at your system. Get it
from http://www.swig.org. The swig executable must be present on your search
path. Verify it at command prompt:
> swig -version
This project is tested with SWIG version 1.3.21. It should work also with
higher versions within the 1.3.x familly. If you have a lower SWIG version,
better upgrade.
Obviously, you need also perl installed at your system (Perl5). The project
is tested with perl v5.6.1 and v5.8.4. It should work with newer perl
releases as well.
Further, you need a C/C++ compiler, the same as used to compile the perl
executable you use. At the end, we will be building perl modules. If you
use ActivePerl on Windows (from ActiveState), you most probably need Visual
C++ version 6.0. If you use Linux, you probably need gcc, etc. To find it
out, try:
> perl -V
Building the Perl module
========================
Build can be done using MSVC with either the nmake utility or using the IDE.
IDE - Microsoft Developer Studio
--------------------------------
First, make sure that the proper ta-lib library is already build in
ta-lib/c/lib. The wrapper links only with Release Multithreaded DLL variant
(because of necessary compatibility with Perl build), so you need
ta_libc_cdr.lib
Open workspace swig\ide\msvc\perl\perl.dsw and hit Build All. You can
alternatively use "nmake" in that same directory.
make - Linux/gcc
----------------
First, make sure that the proper ta-lib library is already build in
ta-lib/c/lib. The wrapper links only with Release Multithreaded Static
variant so you need have libta_libc_cmr.a.
cd swig/make/perl/linux/g++
make
Using ta-lib in Perl
====================
The generated perl modules are placed in ta-lib/swig/lib/perl, so make sure
that this directory is placed in your Perl lib search path. Alternatively,
copy the modules to the appropriate places in your system, where local/site
modules belong. Another alternative is to use "use lib" pragma in your perl
scripts.
The module name is Finance::TA. The C identifier names are retained literally,
so you can use the C API spec. In case of doubt, look at examples in
ta-lib/swig/src/demo/perl and - even better - at the test scripts in
ta-lib/swig/src/tools/test_perl. The test scripts tend to be complete so there
is an example for every function, constant, or type.
The module covers all TA-LIB functions, a few exceptions exist.
In general, the following usage rules apply:
* structs are turned to Perl classes, so can be created using 'new'
* access to struct fields are provided through tied variables
e.g.
print $history->{period};
* Ouput parameters are returned as elements in the return list
e.g.
$ts = new TA_Timestamp;
TA_SetDate($ts, 2004, 2, 29);
@ret = TA_GetDate($ts);
# @ret == ($TA_SUCCESS, 2004, 2, 29);
* Null pointers are represented by undef
There are some exceptions and there are easier ways of doing things:
* There is no need to call &TA_Initialize. The module initializes itself on
'use' with default parameters. Call &TA_Initialize if you need to provide
your own init params.
* There is no need to call &TA_Shutdown, ever. The module shuts itself down
on 'END'. Calling &TA_Initialize on already initialized library
automatically invokes &TA_Shutdown first. If you call &TA_Shutdown, make
sure that there are no defined "TA" variables around. Some objects make
calls to TA-LIB in their destructors.
* Instead of doing
$rci = new TA_RetCodeInfo;
TA_SetRetCodeInfo($retCode, $rci);
you may prefer:
$rci = new TA_RetCodeInfo($retCode);
* As a bonus to Perl programmers, the constructor of TA_Timestamp allows for
initializing the date and time:
$ts = new TA_Timestamp(2004, 2, 29, 9, 11, 59);
$ts = new TA_Timestamp(2004, 2, 29); # time set to zero
But There's More Than One Way To Do It.
$ts = new TA_Timestamp("2004-02-29 09:11:59");
$ts = new TA_Timestamp("2004-02-29");
To be parsed, all numbers have to be two-digit (except the year). Superfluous
characters are ignored. Dash separators for date, colons for time.
* Some other TA_Timestamp goodies: synthesized attributes (data members):
$y = $ts->{year};
$m = $ts->{month};
$s = $ts->{day};
$ts->{hours} = 12;
$ts->{minutes} = 30;
$ts->{seconds} = 59;
* Do not call &TA_HistoryAlloc and &TA_HistoryFree directly. Simply use
&TA_History::new. The parameters to &new are the same as to
TA_HistoryAlloc().
E.g.:
my $haParam = new TA_HistoryAllocParam; # my $haParam = {}; works too
$haParam->{category} = "US.NASDAQ.STOCKS";
$haParam->{symbol} = "LNUX";
$haParam->{period} = $TA_DAILY;
$haParam->{field} = $TA_ALL;
my $hist = new TA_History($udBase, $haParam);
if ($hist->{retCode} == $TA_SUCCESS) {
...
}
Alternatively:
my $hist = $udBase->History($haParam);
if ($hist->{retCode} == $TA_SUCCESS) {
...
}
Alternatively:
my $hist = $udBase->History({
category => "US.NASDAQ.STOCKS",
symbol => "LNUX",
period => $TA_DAILY,
field => $TA_ALL,
});
* Note that TA_History objects are read-only.
* The TA_History member arrays are made available as references to Perl
arrays. Examples:
print $hist->{close}[0], "\n";
$close_series = $hist->{close};
print $$close_series[0], "\n";
print "@$close_series\n";
* Note that each access to a tied member variable is going through the
thunk code from Perl to C and back, so for the sake of performance,
consider copying the history arrays to Perl arrays.
Eg.
# slow
for ($i = 0; $i < $history->{nbBars}; $i++) {
print $history->{close}[$i], "\n";
}
# fast
@close = @{ $history->{close} };
for $close (@close) {
print $close, "\n";
}
* If you do this for the timestamp array, note that the Perl array contains
only the references to C Timestamp structs, not the object themselves.
The C structs fall under the authority of C hence are not reference-counted.
This means that if you undef the history, the references to timestamps become
garbage.
* Insead of doing:
$retCode = TA_UDBaseAlloc(\$udBase);
TA_UDBaseFree($udBase)
you may strongly prefer:
$udBase = new TA_UDBase;
In the former case, you have to call &T
没有合适的资源?快使用搜索试试~ 我知道了~
ta-lib依赖,windows-64位
共1153个文件
makefile:255个
obj:247个
c:232个
需积分: 1 0 下载量 144 浏览量
2023-12-07
17:41:13
上传
评论
收藏 19.08MB ZIP 举报
温馨提示
ta-lib依赖,windows-64位,ta_lib 无法解析的外部命令。 TA-Lib_x64-master.zip和ta-libx64.zip结合版
资源推荐
资源详情
资源评论
收起资源包目录
ta-lib依赖,windows-64位 (1153个子文件)
Makefile.am 3KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 381B
Makefile.am 364B
Makefile.am 319B
Makefile.am 189B
Makefile.am 86B
Makefile.am 63B
ta_func_api.c 889KB
ta_frame.c 192KB
gen_code.c 159KB
trio.c 128KB
ta_gDataHigh.c 60KB
ta_gDataLow.c 59KB
ta_gDataClose.c 59KB
ta_gDataOpen.c 58KB
table_c.c 50KB
ta_SAREXT.c 47KB
test_util.c 46KB
ta_MACD.c 38KB
ta_abstract.c 37KB
ta_STOCH.c 37KB
ta_MACDEXT.c 35KB
test_ma.c 35KB
ta_STOCHF.c 32KB
ta_ADX.c 31KB
ta_HT_TRENDMODE.c 31KB
ta_BBANDS.c 31KB
ta_MAMA.c 29KB
ta_APO.c 29KB
ta_SAR.c 29KB
ta_CDLADVANCEBLOCK.c 29KB
ta_MINUS_DI.c 29KB
ta_PLUS_DI.c 28KB
test_minmax.c 28KB
ta_ULTOSC.c 28KB
test_stoch.c 28KB
ta_DX.c 28KB
ta_HT_SINE.c 27KB
ta_HT_DCPHASE.c 27KB
test_candlestick.c 26KB
ta_STOCHRSI.c 26KB
ta_TRIMA.c 26KB
ta_CDL3WHITESOLDIERS.c 26KB
ta_HT_TRENDLINE.c 25KB
ta_CDLABANDONEDBABY.c 24KB
ta_CDL3STARSINSOUTH.c 24KB
ta_MAVP.c 24KB
ta_MFI.c 24KB
ta_RSI.c 24KB
test_adx.c 24KB
ta_CMO.c 24KB
test_per_hlcv.c 24KB
ta_CDLSTALLEDPATTERN.c 24KB
ta_CDLHIKKAKEMOD.c 23KB
test_per_hl.c 23KB
ta_HT_PHASOR.c 23KB
ta_MINUS_DM.c 23KB
ta_PLUS_DM.c 23KB
ta_CDLMATHOLD.c 23KB
ta_STDDEV.c 23KB
ta_VAR.c 23KB
ta_T3.c 22KB
ta_HT_DCPERIOD.c 22KB
ta_EMA.c 22KB
ta_CDLMORNINGDOJISTAR.c 22KB
ta_CDLEVENINGDOJISTAR.c 22KB
ta_CDLIDENTICAL3CROWS.c 22KB
ta_MA.c 22KB
ta_CDLRISEFALL3METHODS.c 22KB
test_abstract.c 22KB
ta_CDLMORNINGSTAR.c 21KB
ta_CDLEVENINGSTAR.c 21KB
ta_ADOSC.c 21KB
ta_BETA.c 21KB
ta_DEMA.c 21KB
table_m.c 21KB
ta_TEMA.c 21KB
ta_NATR.c 21KB
test_macd.c 21KB
ta_CDL3LINESTRIKE.c 21KB
ta_CDLKICKINGBYLENGTH.c 21KB
ta_KAMA.c 20KB
ta_CDLCONCEALBABYSWALL.c 20KB
ta_TRIX.c 20KB
ta_CDLSEPARATINGLINES.c 20KB
ta_CDL3BLACKCROWS.c 20KB
ta_CDLHANGINGMAN.c 20KB
ta_CDLKICKING.c 20KB
ta_ATR.c 20KB
test_mom.c 20KB
ta_CDLHAMMER.c 20KB
ta_CDLDARKCLOUDCOVER.c 19KB
ta_CDLTASUKIGAP.c 19KB
test_per_hlc.c 19KB
ta_CDLGAPSIDESIDEWHITE.c 19KB
ta_CDLHIKKAKE.c 19KB
ta_CDLRICKSHAWMAN.c 19KB
ta_CDLUPSIDEGAP2CROWS.c 19KB
共 1153 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
资源评论
烤鸭的世界我们不懂
- 粉丝: 4372
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功