├── .gitignore ├── .travis.yml ├── LICENSE.TXT ├── README.md ├── pom.xml └── src ├── main └── java │ └── com │ └── tictactec │ └── ta │ └── lib │ ├── CandleSetting.java │ ├── CandleSettingType.java │ ├── Compatibility.java │ ├── Core.java │ ├── CoreAnnotated.java │ ├── FuncUnstId.java │ ├── MAType.java │ ├── MInteger.java │ ├── MoneyFlow.java │ ├── RangeType.java │ ├── RetCode.java │ └── meta │ ├── CoreMetaData.java │ ├── CoreMetaDataCompatibility.java │ ├── CoreMetaInfo.java │ ├── PriceHolder.java │ ├── PriceInputParameter.java │ ├── TaFuncClosure.java │ ├── TaFuncMetaInfo.java │ ├── TaFuncService.java │ ├── TaFuncSignature.java │ ├── TaGrpService.java │ ├── annotation │ ├── FuncFlags.java │ ├── FuncInfo.java │ ├── InputFlags.java │ ├── InputParameterInfo.java │ ├── InputParameterType.java │ ├── IntegerList.java │ ├── IntegerRange.java │ ├── OptInputFlags.java │ ├── OptInputParameterInfo.java │ ├── OptInputParameterType.java │ ├── OutputFlags.java │ ├── OutputParameterInfo.java │ ├── OutputParameterType.java │ ├── RealList.java │ └── RealRange.java │ └── helpers │ └── SimpleHelper.java └── test └── java ├── AllTests.java ├── CombinationGenerator.java ├── CoreTest.java ├── InputData.java ├── MIntegerTest.java ├── TestAbstract.java ├── TestAbstractClosure.java ├── TestCoreMetaData.java └── TestData.java /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .idea 3 | *.iml 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | 3 | jdk: 4 | - oraclejdk7 5 | - openjdk7 6 | - openjdk6 7 | -------------------------------------------------------------------------------- /LICENSE.TXT: -------------------------------------------------------------------------------- 1 | TA-Lib Copyright (c) 1999-2007, Mario Fortier 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or 5 | without modification, are permitted provided that the following 6 | conditions are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the 14 | distribution. 15 | 16 | - Neither name of author nor the names of its contributors 17 | may be used to endorse or promote products derived from this 18 | software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TA-Lib: Technical Analysis Library 2 | 3 | ## Multi-Platform Tools for Market Analysis 4 | TA-Lib is widely used by trading software developers requiring to perform technical analysis of financial market data. 5 | 6 | * Includes 200 indicators such as ADX, MACD, RSI, Stochastic, Bollinger Bands etc... ([more info](http://ta-lib.org/function.html)) 7 | * Candlestick pattern recognition 8 | * Open-source API for C/C++, Java, Perl, Python and 100% Managed .NET (**This git repository is a Java-only mirror with Maven support**) 9 | 10 | ## Free Open-Source Library 11 | TA-Lib is available under a BSD License allowing it to be integrated in your own open-source or commercial application. ([more info](http://ta-lib.org/hdr_dev.html)) 12 | 13 | ## Commercial Application 14 | TA-Lib is also available as an easy to install Excel Add-Ins. [Try it for free](http://ta-lib.org/hdr_dw.html)! 15 | 16 | ## Use with Maven 17 | 18 | [![Build Status](https://travis-ci.org/BYVoid/TA-Lib.png?branch=travis)](https://travis-ci.org/BYVoid/TA-Lib) 19 | 20 | ```xml 21 | 22 | com.tictactec 23 | ta-lib 24 | 0.4.0 25 | 26 | 27 | com.tictactec 28 | ta-lib 29 | 0.4.0 30 | javadoc 31 | 32 | 33 | com.tictactec 34 | ta-lib 35 | 0.4.0 36 | sources 37 | 38 | ``` 39 | 40 | You can also have Maven installed, and run `mvn package` in this respository. 41 | 42 | ## Use with Scala sbt 43 | 44 | Add below to your `build.sbt`: 45 | 46 | ```scala 47 | libraryDependencies += "com.tictactec" % "ta-lib" % "0.4.0" 48 | ``` 49 | 50 | ## Contributors 51 | 52 | * Original author: Mario Fortier 53 | * Maven packager: Carbo Kuo 54 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.tictactec 6 | ta-lib 7 | 0.4.0 8 | jar 9 | 10 | TA-Lib 11 | TA-Lib is a Technical Analysis Library. 12 | http://ta-lib.org 13 | 14 | 15 | 16 | TA-Lib BSD License 17 | http://ta-lib.org/hdr_dev.html 18 | repo 19 | 20 | 21 | 22 | 23 | scm:git:git@github.com:BYVoid/TA-Lib.git 24 | scm:git:git@github.com:BYVoid/TA-Lib.git 25 | git@github.com:BYVoid/TA-Lib.git 26 | ta-lib-0.4.0 27 | 28 | 29 | 30 | 31 | sonatype-nexus-snapshots 32 | Sonatype Nexus Snapshots 33 | http://oss.sonatype.org/content/repositories/snapshots 34 | 35 | 36 | sonatype-nexus-staging 37 | Nexus Release Repository 38 | http://oss.sonatype.org/service/local/staging/deploy/maven2/ 39 | 40 | 41 | 42 | 43 | 44 | Mario Fortier 45 | 46 | 47 | Barry Tsung 48 | 49 | 50 | 51 | 52 | 53 | junit 54 | junit 55 | 4.11 56 | test 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | org.apache.maven.plugins 65 | maven-source-plugin 66 | 2.2.1 67 | 68 | 69 | attach-sources 70 | 71 | jar 72 | 73 | 74 | 75 | 76 | 77 | 78 | org.apache.maven.plugins 79 | maven-javadoc-plugin 80 | 2.9.1 81 | 82 | 83 | attach-javadocs 84 | 85 | jar 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | UTF-8 95 | UTF-8 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/CandleSetting.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * MF Mario Fortier 39 | * BT Barry Tsung 40 | * 41 | * Change history: 42 | * 43 | * MMDDYY BY Description 44 | * ------------------------------------------------------------------- 45 | * 121005 MF First Version 46 | * 022206 BT add copy constructor 47 | */ 48 | 49 | package com.tictactec.ta.lib; 50 | 51 | public class CandleSetting { 52 | 53 | /** Creates a new instance of TA_CandleSetting */ 54 | public CandleSetting( CandleSettingType p_settingType, 55 | RangeType p_rangeType, 56 | int p_avgPeriod, 57 | double p_factor ) 58 | { 59 | settingType = p_settingType; 60 | rangeType = p_rangeType; 61 | avgPeriod = p_avgPeriod; 62 | factor = p_factor; 63 | } 64 | 65 | public CandleSetting(CandleSetting that) 66 | { 67 | this.settingType = that.settingType; 68 | this.rangeType = that.rangeType; 69 | this.avgPeriod = that.avgPeriod; 70 | this.factor = that.factor; 71 | } 72 | 73 | public void CopyFrom( CandleSetting src ) 74 | { 75 | this.settingType = src.settingType; 76 | this.rangeType = src.rangeType; 77 | this.avgPeriod = src.avgPeriod; 78 | this.factor = src.factor; 79 | } 80 | 81 | CandleSettingType settingType; 82 | RangeType rangeType; 83 | int avgPeriod; 84 | double factor; 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/CandleSettingType.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * MF Mario Fortier 39 | * 40 | * Change history: 41 | * 42 | * MMDDYY BY Description 43 | * ------------------------------------------------------------------- 44 | * 121005 MF First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib; 48 | 49 | public enum CandleSettingType 50 | { 51 | BodyLong, 52 | BodyVeryLong, 53 | BodyShort, 54 | BodyDoji, 55 | ShadowLong, 56 | ShadowVeryLong, 57 | ShadowShort, 58 | ShadowVeryShort, 59 | Near, 60 | Far, 61 | Equal, 62 | AllCandleSettings 63 | }; 64 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/Compatibility.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * MF Mario Fortier 39 | * 40 | * Change history: 41 | * 42 | * MMDDYY BY Description 43 | * ------------------------------------------------------------------- 44 | * 121005 MF First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib; 48 | 49 | public enum Compatibility 50 | { 51 | Default, 52 | Metastock 53 | }; 54 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/FuncUnstId.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * MF Mario Fortier 39 | * 40 | * Change history: 41 | * 42 | * MMDDYY BY Description 43 | * ------------------------------------------------------------------- 44 | * 121005 MF First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib; 48 | 49 | public enum FuncUnstId { 50 | 51 | /* 000 */ Adx, 52 | /* 001 */ Adxr, 53 | /* 002 */ Atr, 54 | /* 003 */ Cmo, 55 | /* 004 */ Dx, 56 | /* 005 */ Ema, 57 | /* 006 */ HtDcPeriod, 58 | /* 007 */ HtDcPhase, 59 | /* 008 */ HtPhasor, 60 | /* 009 */ HtSine, 61 | /* 010 */ HtTrendline, 62 | /* 011 */ HtTrendMode, 63 | /* 012 */ Kama, 64 | /* 013 */ Mama, 65 | /* 014 */ Mfi, 66 | /* 015 */ MinusDI, 67 | /* 016 */ MinusDM, 68 | /* 017 */ Natr, 69 | /* 018 */ PlusDI, 70 | /* 019 */ PlusDM, 71 | /* 020 */ Rsi, 72 | /* 021 */ StochRsi, 73 | /* 022 */ T3, 74 | All, 75 | None 76 | }; 77 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/MAType.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * MF Mario Fortier 39 | * 40 | * Change history: 41 | * 42 | * MMDDYY BY Description 43 | * ------------------------------------------------------------------- 44 | * 121005 MF First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib; 48 | 49 | public enum MAType 50 | { 51 | Sma, 52 | Ema, 53 | Wma, 54 | Dema, 55 | Tema, 56 | Trima, 57 | Kama, 58 | Mama, 59 | T3 60 | }; 61 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/MInteger.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2006, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * MF Mario Fortier 39 | * 40 | * Change history: 41 | * 42 | * MMDDYY BY Description 43 | * ------------------------------------------------------------------- 44 | * 121005 MF First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib; 48 | 49 | /* 'Boxing' of an int. 50 | * Used instead of auto-boxing because it provides a "mutable" Integer 51 | * object. 52 | */ 53 | public class MInteger 54 | { 55 | public int value; 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/MoneyFlow.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * MF Mario Fortier 39 | * 40 | * Change history: 41 | * 42 | * MMDDYY BY Description 43 | * ------------------------------------------------------------------- 44 | * 121005 MF First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib; 48 | 49 | class MoneyFlow 50 | { 51 | public double positive; 52 | public double negative; 53 | }; 54 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/RangeType.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * MF Mario Fortier 39 | * 40 | * Change history: 41 | * 42 | * MMDDYY BY Description 43 | * ------------------------------------------------------------------- 44 | * 121005 MF First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib; 48 | 49 | 50 | public enum RangeType 51 | { 52 | RealBody, 53 | HighLow, 54 | Shadows 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/RetCode.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * MF Mario Fortier 39 | * 40 | * Change history: 41 | * 42 | * MMDDYY BY Description 43 | * ------------------------------------------------------------------- 44 | * 121005 MF First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib; 48 | 49 | public enum RetCode 50 | { 51 | Success, 52 | BadParam, 53 | OutOfRangeStartIndex, 54 | OutOfRangeEndIndex, 55 | AllocErr, 56 | InternalError 57 | }; 58 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/CoreMetaData.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * RG Richard Gomes 39 | * 40 | * Change history: 41 | * 42 | * YYYYMMDD BY Description 43 | * ------------------------------------------------------------------- 44 | * 20070311 RG First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib.meta; 48 | 49 | import java.lang.annotation.Annotation; 50 | import java.lang.annotation.IncompleteAnnotationException; 51 | import java.lang.reflect.InvocationTargetException; 52 | import java.lang.reflect.Method; 53 | import java.lang.reflect.Type; 54 | import java.util.HashMap; 55 | import java.util.Map; 56 | import java.util.Set; 57 | import java.util.TreeMap; 58 | import java.util.TreeSet; 59 | 60 | import com.tictactec.ta.lib.CoreAnnotated; 61 | import com.tictactec.ta.lib.MAType; 62 | import com.tictactec.ta.lib.MInteger; 63 | import com.tictactec.ta.lib.RetCode; 64 | import com.tictactec.ta.lib.meta.annotation.FuncInfo; 65 | import com.tictactec.ta.lib.meta.annotation.InputParameterInfo; 66 | import com.tictactec.ta.lib.meta.annotation.InputParameterType; 67 | import com.tictactec.ta.lib.meta.annotation.IntegerList; 68 | import com.tictactec.ta.lib.meta.annotation.IntegerRange; 69 | import com.tictactec.ta.lib.meta.annotation.OptInputParameterInfo; 70 | import com.tictactec.ta.lib.meta.annotation.OptInputParameterType; 71 | import com.tictactec.ta.lib.meta.annotation.OutputParameterInfo; 72 | import com.tictactec.ta.lib.meta.annotation.OutputParameterType; 73 | import com.tictactec.ta.lib.meta.annotation.RealList; 74 | import com.tictactec.ta.lib.meta.annotation.RealRange; 75 | 76 | /** 77 | * CoreMetaData provides low level RTTI (Run Time Type Information) for TA functions. It also provides methods 78 | * for those willing to call a certain TA function using late binding techniques. These two functionalities let you 79 | * call TA functions dinamically. Even if more TA functions are added by the time, your application code will be able 80 | * to call all added functions by querying TA-Lib package about: 81 | * 82 | *
  • TA functions available; 83 | *
  • function groups the TA functions belong to; 84 | *
  • input arguments of TA functions and also their run time type information; 85 | *
  • output arguments of TA functions and also their run time type information; 86 | *
  • optional input arguments of TA functions and also their run time type information; 87 | * 88 | * CoreMetaData is mostly intended for API developers and mimic as accurately as possible the functionality exposed by 89 | * ta_abstract.h "C" header file. 90 | 91 | * @see com.tictactec.ta.lib.meta.helpers.SimpleHelper is a simple API level helper class based on CoreMetaData 92 | * @see com.tictactec.ta.lib.meta.CoreMetaDataCompatibility for a "C" style interface, mostly intended for those traslating "C" code to Java. 93 | * 94 | * @author Richard Gomes 95 | */ 96 | public class CoreMetaData implements Comparable { 97 | 98 | private static transient final String CONTACT_DEVELOPERS = "Contact developers"; 99 | private static transient final String INDEX_OUT_OF_BOUNDS = "Index out of bounds"; 100 | private static transient final String ILLEGAL_NUMBER_OF_ARGUMENTS = "Illegal number of arguments"; 101 | 102 | private static transient final String ARRAY_IS_NULL = "Array is null"; 103 | private static transient final String INT_ARRAY_EXPECTED = "int[] expected"; 104 | private static transient final String DOUBLE_ARRAY_EXPECTED = "double[] expected"; 105 | private static transient final String PRICE_EXPECTED = "PriceInputParameter object expected"; 106 | 107 | private static transient final Class coreClass = CoreAnnotated.class; 108 | private static transient final String LOOKBACK_SUFFIX = "Lookback"; 109 | 110 | private static transient CoreAnnotated taCore = null; 111 | 112 | private String name = null; 113 | private Method function = null; 114 | private Method lookback = null; 115 | 116 | private static transient Map taFuncMap = null; 117 | private static transient Map > taGrpMap = null; 118 | 119 | private transient Object callInputParams[] = null; 120 | private transient Object callOutputParams[] = null; 121 | private transient Object callOptInputParams[] = null; 122 | 123 | 124 | protected CoreMetaData() { 125 | synchronized (coreClass) { 126 | if (taCore==null) { 127 | taCore = new CoreAnnotated(); 128 | } 129 | } 130 | } 131 | 132 | public int compareTo(CoreMetaData arg) { 133 | return this.name.compareTo(arg.name); 134 | } 135 | 136 | static private Map getAllFuncs() { 137 | synchronized (coreClass) { 138 | if (taFuncMap == null) { 139 | taFuncMap = getTaFuncMetaInfoMap(); 140 | } 141 | } 142 | return taFuncMap; 143 | } 144 | 145 | static private Map > getAllGrps() { 146 | synchronized (coreClass) { 147 | if (taGrpMap == null) { 148 | taGrpMap = getTaGrpMetaInfoMap(); 149 | } 150 | } 151 | return taGrpMap; 152 | } 153 | 154 | static private Map getLookbackMethodMap() { 155 | Map map = new HashMap(); 156 | Method[] ms = coreClass.getDeclaredMethods(); 157 | for (Method m : ms) { 158 | if (m.getName().endsWith(LOOKBACK_SUFFIX)) { 159 | map.put(m.getName(), m); 160 | // System.out.println("lookback="+m.getName()); 161 | } 162 | } 163 | return map; 164 | } 165 | 166 | static private Map getTaFuncMetaInfoMap() { 167 | Map result = new TreeMap(); 168 | Method[] ms = coreClass.getDeclaredMethods(); 169 | Map lookbackMap = getLookbackMethodMap(); 170 | for (Method funcMethod : ms) { 171 | String fn = funcMethod.getName(); 172 | if (funcMethod.getReturnType().equals(RetCode.class)) 173 | // && !fn.startsWith(INT_PREFIX)) 174 | { 175 | String lookbackName = fn + LOOKBACK_SUFFIX; 176 | Method lookbackMethod = lookbackMap.get(lookbackName); 177 | if (lookbackMethod != null) { 178 | FuncInfo info = getFuncInfo(funcMethod); 179 | String funcName = info.name(); 180 | CoreMetaData mi = new CoreMetaData(); 181 | mi.name = funcName; 182 | mi.function = funcMethod; 183 | mi.lookback = lookbackMethod; 184 | result.put(funcName, mi); 185 | } 186 | } 187 | } 188 | return result; 189 | } 190 | 191 | static private Map > getTaGrpMetaInfoMap() { 192 | if (taFuncMap==null) getAllFuncs(); 193 | Map > result = new TreeMap >(); 194 | for (String func : taFuncMap.keySet()) { 195 | CoreMetaData mi = taFuncMap.get(func); 196 | String group = mi.getFuncInfo().group(); 197 | Set set = result.get(group); 198 | if (set==null) { 199 | set = new TreeSet(); 200 | result.put(group, set); 201 | } 202 | set.add(mi); 203 | } 204 | return result; 205 | } 206 | 207 | static private FuncInfo getFuncInfo(Method method) throws IncompleteAnnotationException { 208 | FuncInfo annotation = method.getAnnotation(FuncInfo.class); 209 | if (annotation != null) return annotation; 210 | throw new IncompleteAnnotationException(FuncInfo.class, "Method " + method.getName()); 211 | } 212 | 213 | static CoreMetaData getFuncHandle(final String name) throws NoSuchMethodException { 214 | CoreMetaData mi = getAllFuncs().get(name.toUpperCase()); 215 | if (mi == null) throw new NoSuchMethodException(name.toUpperCase()); 216 | mi.callInputParams = null; 217 | mi.callOutputParams = null; 218 | mi.callOptInputParams = null; 219 | if (mi != null) return mi; 220 | throw new NoSuchMethodException("Function " + name); 221 | } 222 | 223 | /** 224 | * Returns the instance which describes a TA function. This is a 225 | * convenience method that simply adopts the standard "getInstance" 226 | * convention. This method simply calls getFuncHandle. 227 | * 228 | * @param name 229 | * @return an instance of CoreMetaData 230 | * @throws NoSuchMethodException 231 | */ 232 | static public CoreMetaData getInstance(final String name) throws NoSuchMethodException { 233 | return getFuncHandle(name); 234 | } 235 | 236 | /** 237 | * Returns an annotation which describes this TA function. 238 | * 239 | * @return an @interface FuncInfo 240 | * @throws IncompleteAnnotationException 241 | */ 242 | public FuncInfo getFuncInfo() throws IncompleteAnnotationException { 243 | return getFuncInfo(function); 244 | } 245 | 246 | private Annotation getParameterInfo(final int paramIndex, Class paramAnnotation) { 247 | if (paramIndex < 0) 248 | throw new IllegalArgumentException(INDEX_OUT_OF_BOUNDS); 249 | int i = 0; 250 | for (Annotation[] annArray : function.getParameterAnnotations()) { 251 | for (Annotation ann : annArray) { 252 | if ((ann.annotationType() == paramAnnotation) && (paramIndex == i++)) { 253 | return ann; 254 | } 255 | } 256 | } 257 | return null; 258 | } 259 | 260 | private Annotation getParameterInfo(final int paramIndex, Class paramAnnotation, Class paramExtraAnnotation) { 261 | if (paramIndex < 0) 262 | throw new IllegalArgumentException(INDEX_OUT_OF_BOUNDS); 263 | int i = 0; 264 | for (Annotation[] annArray : function.getParameterAnnotations()) { 265 | for (Annotation ann : annArray) { 266 | if ((ann.annotationType() == paramAnnotation) && (paramIndex == i++)) { 267 | for (Annotation annExt : annArray) { 268 | if (annExt.annotationType() == paramExtraAnnotation) { 269 | return annExt; 270 | } 271 | } 272 | } 273 | } 274 | } 275 | return null; 276 | } 277 | 278 | /** 279 | * Returns an annotation which describes the n-th input parameter requested, if any. 280 | * 281 | * @param paramIndex is the n-th input parameter 282 | * @return an @interface InputParameterInfo 283 | * @throws IllegalArgumentException 284 | */ 285 | public InputParameterInfo getInputParameterInfo(final int paramIndex) throws IllegalArgumentException { 286 | return (InputParameterInfo) getParameterInfo(paramIndex, InputParameterInfo.class); 287 | } 288 | 289 | /** 290 | * Returns an annotation which describes the n-th output parameter requested, if any. 291 | * 292 | * @param paramIndex is the n-th output parameter 293 | * @return an @interface OutputParameterInfo 294 | * @throws IllegalArgumentException 295 | */ 296 | public OutputParameterInfo getOutputParameterInfo(final int paramIndex) throws IllegalArgumentException { 297 | return (OutputParameterInfo) getParameterInfo(paramIndex, OutputParameterInfo.class); 298 | } 299 | 300 | /** 301 | * Returns an annotation which describes the n-th optional input parameter requested, if any. 302 | * 303 | * @param paramIndex is the n-th optional input parameter 304 | * @return an @interface OptInputParameterInfo 305 | * @throws IllegalArgumentException 306 | */ 307 | public OptInputParameterInfo getOptInputParameterInfo(final int paramIndex) throws IllegalArgumentException { 308 | return (OptInputParameterInfo) getParameterInfo(paramIndex, OptInputParameterInfo.class); 309 | } 310 | 311 | /** 312 | * Returns an annotation describing an optional input parameter which type 313 | * is expected to be an IntegerList 314 | * 315 | * @param paramIndex is the n-th optional input parameter 316 | * @return an @interface IntegerList 317 | * @throws IllegalArgumentException 318 | */ 319 | public IntegerList getOptInputIntegerList(final int paramIndex) throws IllegalArgumentException { 320 | return (IntegerList) getParameterInfo(paramIndex, OptInputParameterInfo.class, IntegerList.class); 321 | } 322 | 323 | /** 324 | * Returns an annotation describing an optional input parameter which type 325 | * is expected to be an IntegerRange 326 | * 327 | * @param paramIndex is the n-th optional input parameter 328 | * @return an @interface IntegerRange 329 | * @throws IllegalArgumentException 330 | */ 331 | public IntegerRange getOptInputIntegerRange(final int paramIndex) throws IllegalArgumentException { 332 | return (IntegerRange) getParameterInfo(paramIndex, OptInputParameterInfo.class, IntegerRange.class); 333 | } 334 | 335 | /** 336 | * Returns an annotation describing an optional input parameter which type 337 | * is expected to be an RealList 338 | * 339 | * @param paramIndex is the n-th optional input parameter 340 | * @return an @interface RealList 341 | * @throws IllegalArgumentException 342 | */ 343 | public RealList getOptInputRealList(final int paramIndex) throws IllegalArgumentException { 344 | return (RealList) getParameterInfo(paramIndex, OptInputParameterInfo.class, RealList.class); 345 | } 346 | 347 | /** 348 | * Returns an annotation describing an optional input parameter which type 349 | * is expected to be an RealRange 350 | * 351 | * @param paramIndex is the n-th optional input parameter 352 | * @return an @interface RealRange 353 | * @throws IllegalArgumentException 354 | */ 355 | public RealRange getOptInputRealRange(final int paramIndex) throws IllegalArgumentException { 356 | return (RealRange) getParameterInfo(paramIndex, OptInputParameterInfo.class, RealRange.class); 357 | } 358 | 359 | /** 360 | * Assigns an int value to an optional input parameter 361 | * which is expected to be assignment compatible to int. 362 | * 363 | * @param paramIndex is the n-th optional input parameter 364 | * @param value is the int value 365 | * @throws IllegalArgumentException 366 | */ 367 | public void setOptInputParamInteger(final int paramIndex, final int value) throws IllegalArgumentException { 368 | OptInputParameterInfo param = getOptInputParameterInfo(paramIndex); 369 | if (param==null) throw new InternalError(CONTACT_DEVELOPERS); 370 | if (param.type()==OptInputParameterType.TA_OptInput_IntegerList) { 371 | IntegerList list = getOptInputIntegerList(paramIndex); 372 | for (int entry : list.value()) { 373 | if (value==entry) { 374 | if (callOptInputParams==null) callOptInputParams = new Object[getFuncInfo().nbOptInput()]; 375 | callOptInputParams[paramIndex] = value; 376 | return; 377 | } 378 | } 379 | } else if (param.type()==OptInputParameterType.TA_OptInput_IntegerRange) { 380 | IntegerRange range = getOptInputIntegerRange(paramIndex); 381 | if ((value >= range.min())&&(value <= range.max())) { 382 | if (callOptInputParams==null) callOptInputParams = new Object[getFuncInfo().nbOptInput()]; 383 | callOptInputParams[paramIndex] = value; 384 | return; 385 | } 386 | } 387 | throw new InternalError(CONTACT_DEVELOPERS); 388 | } 389 | 390 | /** 391 | * Assigns an int value obtained from a String to an optional input parameter 392 | * which is expected to be assignment compatible to int. 393 | * 394 | * @param paramIndex is the n-th optional input parameter 395 | * @param string is the String which must hold an int value 396 | * @throws IllegalArgumentException 397 | */ 398 | public void setOptInputParamInteger(final int paramIndex, final String string) throws IllegalArgumentException { 399 | try { 400 | Integer v = new Integer(string); 401 | setOptInputParamInteger(paramIndex, v.intValue()); 402 | } catch (NumberFormatException e) { 403 | OptInputParameterInfo param = getOptInputParameterInfo(paramIndex); 404 | if (param==null) throw new InternalError(CONTACT_DEVELOPERS); 405 | if (param.type()!=OptInputParameterType.TA_OptInput_IntegerList) throw new InternalError(CONTACT_DEVELOPERS); 406 | 407 | // FIXME: The correct implementation should ... 408 | // expose a field in @IntegerList informing 409 | // which Class should be taken for introspection. 410 | // Currently, all IntegerList instances implicitly depend on MAType class 411 | // but it may change some day. 412 | 413 | MAType[] fields = MAType.values(); 414 | for (MAType value : fields) { 415 | if (value.name().toUpperCase().equals(string.toUpperCase())) { 416 | if (callOptInputParams==null) callOptInputParams = new Object[getFuncInfo().nbOptInput()]; 417 | callOptInputParams[paramIndex] = value; 418 | return; 419 | } 420 | } 421 | throw new InternalError(CONTACT_DEVELOPERS); 422 | } 423 | } 424 | 425 | /** 426 | * Assigns an double value to an optional input parameter 427 | * which is expected to be assignment compatible to double. 428 | * 429 | * @param paramIndex is the n-th optional input parameter 430 | * @param value is the double value 431 | * @throws IllegalArgumentException 432 | */ 433 | public void setOptInputParamReal(final int paramIndex, final double value) throws IllegalArgumentException { 434 | OptInputParameterInfo param = getOptInputParameterInfo(paramIndex); 435 | if (param.type()==OptInputParameterType.TA_OptInput_RealList) { 436 | RealList list = getOptInputRealList(paramIndex); 437 | for (double entry : list.value()) { 438 | if (value==entry) { 439 | if (callOptInputParams==null) callOptInputParams = new Object[getFuncInfo().nbOptInput()]; 440 | callOptInputParams[paramIndex] = value; 441 | return; 442 | } 443 | } 444 | } else if (param.type()==OptInputParameterType.TA_OptInput_RealRange) { 445 | RealRange range = getOptInputRealRange(paramIndex); 446 | if ((value >= range.min())&&(value <= range.max())) { 447 | if (callOptInputParams==null) callOptInputParams = new Object[getFuncInfo().nbOptInput()]; 448 | callOptInputParams[paramIndex] = value; 449 | return; 450 | } 451 | } 452 | throw new InternalError(CONTACT_DEVELOPERS); 453 | } 454 | 455 | /** 456 | * Assigns an double value obtained from a String to an optional input parameter 457 | * which is expected to be assignment compatible to double. 458 | * 459 | * @param paramIndex is the n-th optional input parameter 460 | * @param string is the String which must hold an double value 461 | * @throws IllegalArgumentException 462 | */ 463 | public void setOptInputParamReal(final int paramIndex, final String string) throws IllegalArgumentException { 464 | try { 465 | Double v = new Double(string); 466 | setOptInputParamReal(paramIndex, v.doubleValue()); 467 | } catch (NumberFormatException e) { 468 | OptInputParameterInfo param = getOptInputParameterInfo(paramIndex); 469 | if (param==null) throw new InternalError(CONTACT_DEVELOPERS); 470 | if (param.type()==OptInputParameterType.TA_OptInput_RealList) { 471 | RealList list = getOptInputRealList(paramIndex); 472 | for (int i=0; idouble[] to 487 | * an input parameter which is expected to be assignment compatible of double[]. 488 | * 489 | * @param paramIndex is the n-th input parameter 490 | * @param array is an Object expected to be assignment compatible to double[] 491 | * @throws IllegalArgumentException 492 | * @throws NullPointerException 493 | */ 494 | public void setInputParamReal(final int paramIndex, final Object array) throws IllegalArgumentException, NullPointerException { 495 | if (array==null) throw new NullPointerException(ARRAY_IS_NULL); 496 | InputParameterInfo param = getInputParameterInfo(paramIndex); 497 | if ((param==null) || (param.type()!=InputParameterType.TA_Input_Real)) throw new InternalError(CONTACT_DEVELOPERS); 498 | if (! (array instanceof double[]) ) throw new IllegalArgumentException(DOUBLE_ARRAY_EXPECTED); 499 | if (callInputParams==null) callInputParams = new Object[getFuncInfo().nbInput()]; 500 | callInputParams[paramIndex] = array; 501 | } 502 | 503 | /** 504 | * Assigns an Object which is expected to be assignment compatible of int[] to 505 | * an input parameter which is expected to be assignment compatible of int[]. 506 | * 507 | * @param paramIndex is the n-th input parameter 508 | * @param array is an Object expected to be assignment compatible to int[] 509 | * @throws IllegalArgumentException 510 | * @throws NullPointerException 511 | */ 512 | public void setInputParamInteger(final int paramIndex, final Object array) throws IllegalArgumentException, NullPointerException { 513 | if (array==null) throw new NullPointerException(ARRAY_IS_NULL); 514 | InputParameterInfo param = getInputParameterInfo(paramIndex); 515 | if ((param==null) || (param.type()!=InputParameterType.TA_Input_Integer)) throw new InternalError(CONTACT_DEVELOPERS); 516 | if (! (array instanceof int[]) ) throw new IllegalArgumentException(INT_ARRAY_EXPECTED); 517 | if (callInputParams==null) callInputParams = new Object[getFuncInfo().nbInput()]; 518 | callInputParams[paramIndex] = array; 519 | } 520 | 521 | /** 522 | * Assigns Objects which are expected to be assignment compatible of double[] to 523 | * an input parameter which is expected to be assignment compatible of PriceInputParameter. 524 | * 525 | *

    You only need to pass those parameters strictly needed by the n-th input parameter of a certain TA function. 526 | * 527 | * @param paramIndex is the n-th input parameter 528 | * @param open represents the open prices. This Object expected to be assignment compatible to double[] 529 | * @param high represents the high prices. This Object expected to be assignment compatible to double[] 530 | * @param low represents the low prices. This Object expected to be assignment compatible to double[] 531 | * @param close represents the close prices. This Object expected to be assignment compatible to double[] 532 | * @param volume represents the volume. This Object expected to be assignment compatible to double[] 533 | * @param openInterest represents the open interest. This Object expected to be assignment compatible to double[] 534 | * @throws IllegalArgumentException 535 | * @throws NullPointerException 536 | */ 537 | public void setInputParamPrice(final int paramIndex, 538 | final double[] open, final double[] high, final double[] low, final double[] close, 539 | final double[] volume, final double[] openInterest) 540 | throws IllegalArgumentException, NullPointerException { 541 | InputParameterInfo param = getInputParameterInfo(paramIndex); 542 | if ((param==null) || (param.type()!=InputParameterType.TA_Input_Price)) throw new InternalError(CONTACT_DEVELOPERS); 543 | if (callInputParams==null) callInputParams = new Object[getFuncInfo().nbInput()]; 544 | callInputParams[paramIndex] = new PriceInputParameter(param.flags(), open, high, low, close, volume, openInterest); 545 | } 546 | 547 | /** 548 | * Assigns an Object which are expected to be assignment compatible of PriceInputParameter to 549 | * an input parameter which is expected to be assignment compatible of PriceInputParameter. 550 | * 551 | * @param paramIndex is the n-th input parameter 552 | * @param array is an Object expected to be assignment compatible to PriceInputParameter 553 | * @throws IllegalArgumentException 554 | * @throws NullPointerException 555 | */ 556 | public void setInputParamPrice(final int paramIndex, final Object array) throws IllegalArgumentException, NullPointerException { 557 | if (array==null) throw new NullPointerException(ARRAY_IS_NULL); 558 | InputParameterInfo param = getInputParameterInfo(paramIndex); 559 | if ((param==null) || (param.type()!=InputParameterType.TA_Input_Price)) throw new InternalError(CONTACT_DEVELOPERS); 560 | if (! (array instanceof PriceInputParameter) ) throw new IllegalArgumentException(PRICE_EXPECTED); 561 | if (callInputParams==null) callInputParams = new Object[getFuncInfo().nbInput()]; 562 | callInputParams[paramIndex] = array; 563 | } 564 | 565 | /** 566 | * Assigns an Object which are expected to be assignment compatible of double[] to 567 | * an output parameter which is expected to be assignment compatible of double[]. 568 | * 569 | * @param paramIndex is the n-th output parameter 570 | * @param array is an Object expected to be assignment compatible to double[] 571 | * @throws IllegalArgumentException 572 | * @throws NullPointerException 573 | * @throws ClassCastException 574 | */ 575 | public void setOutputParamReal(final int paramIndex, Object array) throws IllegalArgumentException, NullPointerException, ClassCastException { 576 | if (array==null) throw new NullPointerException(ARRAY_IS_NULL); 577 | OutputParameterInfo param = getOutputParameterInfo(paramIndex); 578 | if ((param==null)||(param.type()!=OutputParameterType.TA_Output_Real)) throw new InternalError(CONTACT_DEVELOPERS); 579 | if (! (array instanceof double[]) ) throw new IllegalArgumentException(DOUBLE_ARRAY_EXPECTED); 580 | if (callOutputParams==null) callOutputParams = new Object[getFuncInfo().nbOutput()]; 581 | callOutputParams[paramIndex] = array; 582 | } 583 | 584 | /** 585 | * Assigns an Object which are expected to be assignment compatible of int[] to 586 | * an output parameter which is expected to be assignment compatible of int[]. 587 | * 588 | * @param paramIndex is the n-th output parameter 589 | * @param array is an Object expected to be assignment compatible to int[] 590 | * @throws IllegalArgumentException 591 | * @throws NullPointerException 592 | * @throws ClassCastException 593 | */ 594 | public void setOutputParamInteger(final int paramIndex, Object array) throws IllegalArgumentException, NullPointerException, ClassCastException { 595 | if (array==null) throw new NullPointerException(ARRAY_IS_NULL); 596 | OutputParameterInfo param = getOutputParameterInfo(paramIndex); 597 | if ((param==null)||(param.type()!=OutputParameterType.TA_Output_Integer)) throw new InternalError(CONTACT_DEVELOPERS); 598 | if (! (array instanceof int[]) ) throw new IllegalArgumentException(INT_ARRAY_EXPECTED); 599 | if (callOutputParams==null) callOutputParams = new Object[getFuncInfo().nbOutput()]; 600 | callOutputParams[paramIndex] = array; 601 | } 602 | 603 | /** 604 | * For each defined TA function executes the TaFuncService.execute() interface method of the implementation 605 | * class passed ar argument. 606 | * 607 | * @param service is a TaFuncService implementation class 608 | * @throws Exception 609 | */ 610 | static public void forEachFunc(TaFuncService service) throws Exception { 611 | for (CoreMetaData mi : getAllFuncs().values()) { 612 | service.execute(mi); 613 | } 614 | } 615 | 616 | /** 617 | * For each defined group of TA functions executes the TaFuncService.execute() interface method of the implementation 618 | * class passed ar argument. 619 | * 620 | * @param service 621 | * @throws Exception 622 | */ 623 | static public void forEachGrp(TaGrpService service) throws Exception { 624 | for (String group : getAllGrps().keySet()) { 625 | service.execute(group, taGrpMap.get(group)); 626 | } 627 | } 628 | 629 | private Object[] getOptInputParameters() { 630 | int size = getFuncInfo().nbOptInput(); 631 | if (callOptInputParams==null) callOptInputParams = new Object[size]; 632 | for (int i=0; i Lookback is the number of input data points to be consumed in order to calculate the first output data point. This value 661 | * is affected by the optional input arguments passed to this TA function. 662 | * 663 | * @return the lookback number of input points to be consumed before the first output data point is produced. 664 | * @throws IllegalArgumentException 665 | * @throws IllegalAccessException 666 | * @throws InvocationTargetException 667 | */ 668 | public int getLookback() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { 669 | Object[] params = getOptInputParameters(); 670 | return (Integer) lookback.invoke(taCore, params); 671 | } 672 | 673 | 674 | /** 675 | * Executes the calculations defined by this TA function. 676 | * 677 | *

    You need to provide input arguments where this TA function will obtain data from and output arguments where this 678 | * TA function will write output data to. 679 | * 680 | * @see com.tictactec.ta.lib.meta.helpers.SimpleHelper class for an example of use. 681 | * 682 | * @param startIndex is the initial position of input data to be considered for TA function calculations 683 | * @param endIndex is the final position of input data to be considered for TA function calculations 684 | * @param outBegIdx is returned by this method and represents the initial position of output data returned by this TA function 685 | * @param outNbElement is returned by this method and represents the quantity of output data returned by this TA function 686 | * @throws IllegalArgumentException 687 | * @throws IllegalAccessException 688 | * @throws InvocationTargetException 689 | */ 690 | public void callFunc(final int startIndex, final int endIndex, MInteger outBegIdx, MInteger outNbElement) 691 | throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { 692 | 693 | int count = 0; 694 | for (Object item : callInputParams) { 695 | if (PriceInputParameter.class.isAssignableFrom(item.getClass())) { 696 | count += ((PriceInputParameter)item).getCount(); 697 | } else { 698 | count++; 699 | } 700 | } 701 | count += callOutputParams.length; 702 | count += callOptInputParams.length; 703 | 704 | Object[] params = new Object[count+4]; 705 | count = 0; 706 | params[count++] = startIndex; 707 | params[count++] = endIndex; 708 | 709 | for (Object item : callInputParams) { 710 | if (PriceInputParameter.class.isAssignableFrom(item.getClass())) { 711 | Object objs[] = ((PriceInputParameter)item).toArrays(); 712 | for (int i=0; ita_abstract.h. 60 | * 61 | * In Java, applications and API make a wide use of exceptions whilst in "C" code the common approach is returning status 62 | * codes. This class adds a layer over class CoreMetaData which handles and consumes exceptions and, instead of exceptions, 63 | * returns status codes. 64 | * 65 | *

    IMPORTANT: This class is provided as it is by the author as a starting point for "C" application code translators. 66 | * Use this class on your own risk as this class was not tested by the author. 67 | * 68 | *

    IMPORTANT: Some methods from ta_abstract.h where not implemented. The author do not intend to 69 | * provide these methods as there's low or even no interest on this kind of compatibility mode. As already said, this is 70 | * only a starting point for applications translators which could be interested to further improve this class. 71 | * 72 | * @author Richard Gomes 73 | * 74 | */ 75 | public class CoreMetaDataCompatibility extends CoreMetaData { 76 | 77 | static RetCode taGetFuncHandle(final String name, CoreMetaData retHandle) { 78 | try { 79 | retHandle = getFuncHandle(name); 80 | return RetCode.Success; 81 | } catch (NoSuchMethodException e) { 82 | return RetCode.BadParam; 83 | } 84 | } 85 | 86 | 87 | RetCode taGetFuncInfo(FuncInfo retFuncInfo) { 88 | try { 89 | retFuncInfo = super.getFuncInfo(); 90 | return RetCode.Success; 91 | } catch (IncompleteAnnotationException e) { 92 | return RetCode.InternalError; 93 | } 94 | } 95 | 96 | 97 | RetCode taGetInputParameterInfo(final int paramIndex, InputParameterInfo retInputParameterInfo) { 98 | try { 99 | retInputParameterInfo = super.getInputParameterInfo(paramIndex); 100 | return RetCode.Success; 101 | } catch (IllegalArgumentException e) { 102 | return RetCode.BadParam; 103 | } 104 | } 105 | 106 | 107 | RetCode taGetInputParameterInfo(final int paramIndex, OptInputParameterInfo retOptInputParameterInfo) { 108 | try { 109 | retOptInputParameterInfo = super.getOptInputParameterInfo(paramIndex); 110 | return RetCode.Success; 111 | } catch (IllegalArgumentException e) { 112 | return RetCode.BadParam; 113 | } 114 | } 115 | 116 | 117 | RetCode taGetOutputParameterInfo(final int paramIndex, OutputParameterInfo retOutputParameterInfo) { 118 | try { 119 | retOutputParameterInfo = super.getOutputParameterInfo(paramIndex); 120 | return RetCode.Success; 121 | } catch (IllegalArgumentException e) { 122 | return RetCode.BadParam; 123 | } 124 | } 125 | 126 | 127 | RetCode taSetInputParamIntegerPtr(final int paramIndex, final int[] value ) { 128 | try { 129 | super.setInputParamInteger(paramIndex, value); 130 | return RetCode.Success; 131 | } catch (NullPointerException e) { 132 | return RetCode.BadParam; 133 | } 134 | } 135 | 136 | 137 | RetCode taSetInputParamRealPtr(final int paramIndex, final double[] value ) { 138 | try { 139 | super.setInputParamReal(paramIndex, value); 140 | return RetCode.Success; 141 | } catch (NullPointerException e) { 142 | return RetCode.BadParam; 143 | } 144 | } 145 | 146 | 147 | RetCode taSetInputParamPricePtr(final int paramIndex, 148 | final double[] open, 149 | final double[] high, 150 | final double[] low, 151 | final double[] close, 152 | final double[] volume, 153 | final double[] openInterest) { 154 | try { 155 | super.setInputParamPrice(paramIndex, open, high, low, close, volume, openInterest); 156 | return RetCode.Success; 157 | } catch (NullPointerException e) { 158 | return RetCode.BadParam; 159 | } 160 | } 161 | 162 | 163 | RetCode taSetOptInputParamInteger(final int paramIndex, final int optInValue) { 164 | try { 165 | setOptInputParamInteger(paramIndex, optInValue); 166 | return RetCode.Success; 167 | } catch (IllegalArgumentException e) { 168 | return RetCode.BadParam; 169 | } 170 | } 171 | 172 | 173 | RetCode taSetOptInputParamReal(final int paramIndex, final double optInValue) { 174 | try { 175 | setOptInputParamReal(paramIndex, optInValue); 176 | return RetCode.Success; 177 | } catch (IllegalArgumentException e) { 178 | return RetCode.BadParam; 179 | } 180 | } 181 | 182 | 183 | RetCode taSetOutputParamIntegerPtr(final int paramIndex, int[] outArray) { 184 | if (outArray == null) return RetCode.BadParam; 185 | try { 186 | setOutputParamInteger(paramIndex, outArray); 187 | return RetCode.Success; 188 | } catch (IllegalArgumentException e) { 189 | return RetCode.BadParam; 190 | } 191 | } 192 | 193 | 194 | RetCode taSetOutputParamRealPtr(final int paramIndex, double[] outArray) { 195 | if (outArray == null) return RetCode.BadParam; 196 | try { 197 | setOutputParamReal(paramIndex, outArray); 198 | return RetCode.Success; 199 | } catch (IllegalArgumentException e) { 200 | return RetCode.BadParam; 201 | } 202 | } 203 | 204 | 205 | } 206 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/CoreMetaInfo.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * BT Barry Tsung 39 | * 40 | * Change history: 41 | * 42 | * MMDDYY BY Description 43 | * ------------------------------------------------------------------- 44 | * 022206 BT First Version 45 | * 031107 RG Deprecating this class in favor of CoreMetaData 46 | */ 47 | 48 | package com.tictactec.ta.lib.meta; 49 | 50 | import java.lang.reflect.Method; 51 | import java.util.Collection; 52 | import java.util.HashMap; 53 | import java.util.Map; 54 | import java.util.TreeMap; 55 | 56 | import com.tictactec.ta.lib.Core; 57 | import com.tictactec.ta.lib.RetCode; 58 | 59 | /** 60 | * @deprecated in favor of CoreMetaData class 61 | */ 62 | public class CoreMetaInfo 63 | { 64 | static final Class coreClass = Core.class; 65 | 66 | static final String LOOKBACK_SUFFIX = "_Lookback"; 67 | 68 | static final String INT_PREFIX = "INT_"; 69 | 70 | Map taFuncMap; 71 | 72 | public CoreMetaInfo() 73 | { 74 | this.taFuncMap = getTaFuncMetaInfoMap(); 75 | } 76 | 77 | protected Map getLookbackMethodMap() 78 | { 79 | Map map = new HashMap(); 80 | Method[] ms = coreClass.getDeclaredMethods(); 81 | for (Method m : ms) 82 | { 83 | if (m.getName().endsWith(LOOKBACK_SUFFIX)) 84 | { 85 | map.put(m.getName(), m); 86 | // System.out.println("lookback="+m.getName()); 87 | } 88 | } 89 | return map; 90 | } 91 | 92 | @SuppressWarnings("unchecked") 93 | protected Map getTaFuncMetaInfoMap() 94 | { 95 | Map result = new TreeMap(); 96 | Method[] ms = coreClass.getDeclaredMethods(); 97 | Map lookbackMap = getLookbackMethodMap(); 98 | for (Method taMethod : ms) 99 | { 100 | String fn = taMethod.getName(); 101 | if (taMethod.getReturnType().equals(RetCode.class) 102 | && !fn.startsWith(INT_PREFIX)) 103 | { 104 | String lookbackName = fn + LOOKBACK_SUFFIX; 105 | Method lookbackMethod = lookbackMap.get(lookbackName); 106 | if (lookbackMethod != null) 107 | { 108 | // System.out.println(fn+","+lookbackName); 109 | TaFuncMetaInfo mi = new TaFuncMetaInfo(fn, taMethod, 110 | lookbackMethod); 111 | result.put(mi, mi); 112 | } 113 | } 114 | } 115 | return result; 116 | } 117 | 118 | public Collection getAllFuncs() 119 | { 120 | return taFuncMap.values(); 121 | } 122 | 123 | public TaFuncMetaInfo get(String taName, Class[] inVarTypes) 124 | { 125 | return taFuncMap.get(new TaFuncSignature(taName, inVarTypes)); 126 | } 127 | 128 | public void forEach(TaFuncClosure closure) throws Exception 129 | { 130 | for (TaFuncMetaInfo mi : getAllFuncs()) 131 | { 132 | closure.execute(mi); 133 | } 134 | } 135 | 136 | public static void main(String[] args) 137 | { 138 | CoreMetaInfo mi = new CoreMetaInfo(); 139 | Collection fs = mi.getAllFuncs(); 140 | int i = 0; 141 | for (TaFuncMetaInfo f : fs) 142 | { 143 | System.out.println(" " + (i++) + " " + f); 144 | } 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/PriceHolder.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * RG Richard Gomes 39 | * 40 | * Change history: 41 | * 42 | * YYYYMMDD BY Description 43 | * ------------------------------------------------------------------- 44 | * 20070311 RG First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib.meta; 48 | 49 | 50 | /** 51 | * PriceHolder is responsible for holding prices, which are composed by OHLCVI, i.e: 52 | * open, high, low, close, volume and open interest. 53 | * 54 | *

    Indicators which take prices as input, only take subsets of OHLCVI components and one could think 55 | * that PriceHolder could be used for such purpose. This class is not intended to hold prices passed to indicators. 56 | * 57 | *

    In order to avoid this kind of confusion, PriceHolder cannot be initialized with null arrays. 58 | * PriceHoder also checks if all arrays passed to constructor have the same length. 59 | * 60 | * @author Richard Gomes 61 | */ 62 | public class PriceHolder { 63 | 64 | private double[] o; 65 | private double[] h; 66 | private double[] l; 67 | private double[] c; 68 | private double[] v; 69 | private double[] i; 70 | public final int length; 71 | 72 | /** 73 | * Stores all data point arrays in a PriceHolder instance 74 | * 75 | * @param o represent the open data points and is expected to be double[] assignment compatible. 76 | * @param h represent the high data points and is expected to be double[] assignment compatible. 77 | * @param l represent the low data points and is expected to be double[] assignment compatible. 78 | * @param c represent the close data points and is expected to be double[] assignment compatible. 79 | * @param v represent the volume data points and is expected to be double[] assignment compatible. 80 | * @param i represent the open interest data points and is expected to be double[] assignment compatible. 81 | * 82 | * @throws NullPointerException if any arrays is null 83 | * @throws IllegalArgumentException if sizes of arrays dont match 84 | */ 85 | public PriceHolder(double[] o, double[] h, double[] l, double[] c, double[] v, double[] i) 86 | throws NullPointerException, IllegalArgumentException { 87 | 88 | if (o==null) throw new NullPointerException(); // TODO: message 89 | if (h==null) throw new NullPointerException(); // TODO: message 90 | if (l==null) throw new NullPointerException(); // TODO: message 91 | if (c==null) throw new NullPointerException(); // TODO: message 92 | if (v==null) throw new NullPointerException(); // TODO: message 93 | if (i==null) throw new NullPointerException(); // TODO: message 94 | 95 | length = o.length; 96 | if (h.length != length) throw new IllegalArgumentException(); // TODO: message 97 | if (l.length != length) throw new IllegalArgumentException(); // TODO: message 98 | if (c.length != length) throw new IllegalArgumentException(); // TODO: message 99 | if (v.length != length) throw new IllegalArgumentException(); // TODO: message 100 | if (i.length != length) throw new IllegalArgumentException(); // TODO: message 101 | 102 | this.o = o; 103 | this.h = h; 104 | this.l = l; 105 | this.c = c; 106 | this.v = v; 107 | this.i = i; 108 | } 109 | 110 | /** 111 | * This method is deprecated. Use public field "length" instead. 112 | * @deprecated 113 | * @return length 114 | */ 115 | public int getSize() { 116 | return length; 117 | } 118 | 119 | /** 120 | * @return an Object[] which contais all data point arrays OHLCVI. 121 | * @see PriceInputParameter overrides this method 122 | */ 123 | public Object[] toArrays() { 124 | Object objs[] = new Object[6]; 125 | int n = 0; 126 | objs[n++] = o; 127 | objs[n++] = h; 128 | objs[n++] = l; 129 | objs[n++] = c; 130 | objs[n++] = v; 131 | objs[n++] = i; 132 | return objs; 133 | } 134 | 135 | /** 136 | * 137 | * @return the Open component 138 | */ 139 | public double[] getO() { return o; } 140 | 141 | /** 142 | * 143 | * @return the High component 144 | */ 145 | public double[] getH() { return h; } 146 | 147 | /** 148 | * 149 | * @return the Low component 150 | */ 151 | public double[] getL() { return l; } 152 | 153 | /** 154 | * 155 | * @return the Close component 156 | */ 157 | public double[] getC() { return c; } 158 | 159 | /** 160 | * 161 | * @return the Volume component 162 | */ 163 | public double[] getV() { return v; } 164 | 165 | /** 166 | * 167 | * @return the Open Interest component 168 | */ 169 | public double[] getI() { return i; } 170 | 171 | } 172 | 173 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/PriceInputParameter.java: -------------------------------------------------------------------------------- 1 | package com.tictactec.ta.lib.meta; 2 | 3 | import com.tictactec.ta.lib.meta.annotation.InputFlags; 4 | 5 | /** 6 | * This class is deprecated. Do not use it. 7 | * 8 | * @deprecated 9 | * 10 | * @author Richard Gomes 11 | * 12 | */ 13 | public class PriceInputParameter extends PriceHolder { 14 | 15 | private int flags; 16 | private int count; 17 | 18 | public PriceInputParameter(final int flags, double[] o, double[] h, double[] l, double[] c, double[] v, double[] i) 19 | throws NullPointerException, IllegalArgumentException { 20 | super(o, h, l, c, v, i); 21 | initialize(flags); 22 | } 23 | 24 | public PriceInputParameter(final PriceHolder p) { 25 | super(p.getO(), p.getH(), p.getL(), p.getC(), p.getV(), p.getI()); 26 | initialize(flags); 27 | } 28 | 29 | private void initialize(final int flags) { 30 | this.flags = flags; 31 | count = 0; 32 | count += ((flags&InputFlags.TA_IN_PRICE_OPEN)!=0) ? 1 : 0; 33 | count += ((flags&InputFlags.TA_IN_PRICE_HIGH)!=0) ? 1 : 0; 34 | count += ((flags&InputFlags.TA_IN_PRICE_LOW)!=0) ? 1 : 0; 35 | count += ((flags&InputFlags.TA_IN_PRICE_CLOSE)!=0) ? 1 : 0; 36 | count += ((flags&InputFlags.TA_IN_PRICE_VOLUME)!=0) ? 1 : 0; 37 | count += ((flags&InputFlags.TA_IN_PRICE_OPENINTEREST)!=0) ? 1 : 0; 38 | } 39 | 40 | /** 41 | * @return the InputFlags passed during construction of this class 42 | */ 43 | public int getFlags() { 44 | return flags; 45 | } 46 | 47 | /** 48 | * Returns the number of arrays expected to be returned by toArrays(). 49 | * This number is based on the flags passed during the construction of this object. 50 | * 51 | * @return the number of arrays expected to be returned by toArrays() 52 | */ 53 | public int getCount() { 54 | return count; 55 | } 56 | 57 | /** 58 | * @return the arrays corresponding to the flags passed during construction of this object. 59 | */ 60 | public Object[] toArrays() { 61 | Object objs[] = new Object[count]; 62 | int n = 0; 63 | 64 | if ((flags&InputFlags.TA_IN_PRICE_OPEN)!=0) { 65 | objs[n++] = getO(); 66 | } 67 | if ((flags&InputFlags.TA_IN_PRICE_HIGH)!=0) { 68 | objs[n++] = getH(); 69 | } 70 | if ((flags&InputFlags.TA_IN_PRICE_LOW)!=0) { 71 | objs[n++] = getL(); 72 | } 73 | if ((flags&InputFlags.TA_IN_PRICE_CLOSE)!=0) { 74 | objs[n++] = getC(); 75 | } 76 | if ((flags&InputFlags.TA_IN_PRICE_VOLUME)!=0) { 77 | objs[n++] = getV(); 78 | } 79 | if ((flags&InputFlags.TA_IN_PRICE_OPENINTEREST)!=0) { 80 | objs[n++] = getI(); 81 | } 82 | 83 | return objs; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/TaFuncClosure.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * BT Barry Tsung 39 | * 40 | * Change history: 41 | * 42 | * MMDDYY BY Description 43 | * ------------------------------------------------------------------- 44 | * 022206 BT First Version 45 | * 031107 RG Deprecated 46 | */ 47 | 48 | package com.tictactec.ta.lib.meta; 49 | 50 | /** 51 | * @deprecated in favor of interfaces TaFuncService and taGrpService 52 | */ 53 | public interface TaFuncClosure 54 | { 55 | void execute(TaFuncMetaInfo mi) throws Exception; 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/TaFuncMetaInfo.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * BT Barry Tsung 39 | * 40 | * Change history: 41 | * 42 | * MMDDYY BY Description 43 | * ------------------------------------------------------------------- 44 | * 022206 BT First Version 45 | * 031107 RG Deprecated 46 | */ 47 | 48 | package com.tictactec.ta.lib.meta; 49 | 50 | import java.lang.reflect.InvocationTargetException; 51 | import java.lang.reflect.Method; 52 | 53 | import com.tictactec.ta.lib.Core; 54 | import com.tictactec.ta.lib.MInteger; 55 | import com.tictactec.ta.lib.RetCode; 56 | 57 | /** 58 | * @deprecated in favor of CoreMetaData class 59 | */ 60 | public class TaFuncMetaInfo extends TaFuncSignature 61 | { 62 | Method method; 63 | Method lookbackMethod; 64 | Class[] outVarTypes; 65 | Class[] optionTypes; 66 | Class[] parameterTypes; 67 | 68 | static final int TOTAL_FIX_PARAMETERS = 4; 69 | static final int INPUT_FIX_PARAMETERS = 2; 70 | static final int OUTPUT_FIX_PARAMETERS = 2; 71 | 72 | public TaFuncMetaInfo(String name, Method method, Method lookbackMethod) 73 | { 74 | this.name = name; 75 | this.method = method; 76 | this.lookbackMethod = lookbackMethod; 77 | this.optionTypes = lookbackMethod.getParameterTypes(); 78 | this.parameterTypes = method.getParameterTypes(); 79 | 80 | int ins = getNumberOfInputParameters(); 81 | int outs = getNumberOfOutputParameters(); 82 | 83 | createVarTypes(ins, outs); 84 | } 85 | 86 | int getNumberOfInputParameters() 87 | { 88 | return getFirstMInteger() - optionTypes.length - INPUT_FIX_PARAMETERS; 89 | } 90 | 91 | int getNumberOfOutputParameters() 92 | { 93 | return parameterTypes.length - getFirstMInteger() - OUTPUT_FIX_PARAMETERS; 94 | } 95 | 96 | int getFirstMInteger() 97 | { 98 | for (int i = 0; i < parameterTypes.length; i++) 99 | { 100 | if (parameterTypes[i].equals(MInteger.class)) 101 | { 102 | return i; 103 | } 104 | } 105 | return -1; 106 | } 107 | 108 | void createVarTypes(int ins, int outs) 109 | { 110 | assert ins > 0 && outs > 0; 111 | inVarTypes = new Class[ins]; 112 | outVarTypes = new Class[outs]; 113 | 114 | for (int i = 0; i < ins; i++) 115 | { 116 | inVarTypes[i] = parameterTypes[INPUT_FIX_PARAMETERS + i]; 117 | } 118 | int offset = INPUT_FIX_PARAMETERS + ins + optionTypes.length 119 | + OUTPUT_FIX_PARAMETERS; 120 | for (int i = 0; i < outs; i++) 121 | { 122 | outVarTypes[i] = parameterTypes[offset + i]; 123 | } 124 | } 125 | 126 | public Class[] getInVarTypes() 127 | { 128 | return inVarTypes; 129 | } 130 | 131 | public Method getLookbackMethod() 132 | { 133 | return lookbackMethod; 134 | } 135 | 136 | public Method getMethod() 137 | { 138 | return method; 139 | } 140 | 141 | public String getName() 142 | { 143 | return name; 144 | } 145 | 146 | public Class[] getOptionTypes() 147 | { 148 | return optionTypes; 149 | } 150 | 151 | public Class[] getOutVarTypes() 152 | { 153 | return outVarTypes; 154 | } 155 | 156 | public boolean is11() 157 | { 158 | return inVarTypes.length == 1 && outVarTypes.length == 1; 159 | } 160 | 161 | public boolean is1N() 162 | { 163 | return inVarTypes.length == 1 && outVarTypes.length > 1; 164 | } 165 | 166 | public boolean isN1() 167 | { 168 | return inVarTypes.length > 1 && outVarTypes.length == 1; 169 | } 170 | 171 | public boolean isNN() 172 | { 173 | return inVarTypes.length > 1 && outVarTypes.length > 1; 174 | } 175 | 176 | public RetCode call(Core taCore, Object[] inArs, int startIndex, int endIndex, Object[] outArs, MInteger outBegIdx, MInteger outNbElement, Object ... options) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException{ 177 | Object[] parameters = new Object[inArs.length+outArs.length+options.length+TOTAL_FIX_PARAMETERS]; 178 | parameters[0] = startIndex; 179 | parameters[1] = endIndex; 180 | int i=2; 181 | for(int j=0;j set) throws Exception; 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/annotation/FuncFlags.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * RG Richard Gomes 39 | * 40 | * Change history: 41 | * 42 | * YYYYMMDD BY Description 43 | * ------------------------------------------------------------------- 44 | * 20070311 RG First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib.meta.annotation; 48 | 49 | public class FuncFlags { 50 | static public final int TA_FUNC_FLG_OVERLAP = 0x01000000; /* Output scale same as input data. */ 51 | static public final int TA_FUNC_FLG_VOLUME = 0x04000000; /* Output shall be over the volume data. */ 52 | static public final int TA_FUNC_FLG_UNST_PER = 0x08000000; /* Indicate if this function have an unstable 53 | * initial period. Some additional code exist 54 | * for these functions for allowing to set that 55 | * unstable period. See Documentation. 56 | */ 57 | static public final int TA_FUNC_FLG_CANDLESTICK = 0x10000000; /* Output shall be a candlestick */ 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/annotation/FuncInfo.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * RG Richard Gomes 39 | * 40 | * Change history: 41 | * 42 | * YYYYMMDD BY Description 43 | * ------------------------------------------------------------------- 44 | * 20070311 RG First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib.meta.annotation; 48 | 49 | import java.lang.annotation.ElementType; 50 | import java.lang.annotation.Retention; 51 | import java.lang.annotation.RetentionPolicy; 52 | import java.lang.annotation.Target; 53 | 54 | @Target(ElementType.METHOD) 55 | @Retention(RetentionPolicy.RUNTIME) 56 | public @interface FuncInfo { 57 | String name(); 58 | String group(); 59 | 60 | String hint() default ""; 61 | String helpFile() default ""; 62 | int flags(); 63 | 64 | int nbInput(); 65 | int nbOptInput(); 66 | int nbOutput(); 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/annotation/InputFlags.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * RG Richard Gomes 39 | * 40 | * Change history: 41 | * 42 | * YYYYMMDD BY Description 43 | * ------------------------------------------------------------------- 44 | * 20070311 RG First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib.meta.annotation; 48 | 49 | /* When the input is a TA_Input_Price, the following 50 | * TA_InputFlags indicates the required components. 51 | * These can be combined for functions requiring more 52 | * than one component. 53 | * 54 | * Example: 55 | * (TA_IN_PRICE_OPEN|TA_IN_PRICE_HIGH) 56 | * Indicates that the functions requires two inputs 57 | * that must be specifically the open and the high. 58 | */ 59 | public final class InputFlags { 60 | static public final int TA_IN_PRICE_OPEN = 0x00000001; 61 | static public final int TA_IN_PRICE_HIGH = 0x00000002; 62 | static public final int TA_IN_PRICE_LOW = 0x00000004; 63 | static public final int TA_IN_PRICE_CLOSE = 0x00000008; 64 | static public final int TA_IN_PRICE_VOLUME = 0x00000010; 65 | static public final int TA_IN_PRICE_OPENINTEREST = 0x00000020; 66 | static public final int TA_IN_PRICE_TIMESTAMP = 0x00000040; 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/annotation/InputParameterInfo.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * RG Richard Gomes 39 | * 40 | * Change history: 41 | * 42 | * YYYYMMDD BY Description 43 | * ------------------------------------------------------------------- 44 | * 20070311 RG First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib.meta.annotation; 48 | 49 | import java.lang.annotation.ElementType; 50 | import java.lang.annotation.Retention; 51 | import java.lang.annotation.RetentionPolicy; 52 | import java.lang.annotation.Target; 53 | 54 | @Target(ElementType.PARAMETER) 55 | @Retention(RetentionPolicy.RUNTIME) 56 | public @interface InputParameterInfo { 57 | InputParameterType type(); 58 | String paramName(); 59 | int flags(); // bitwise OR of InputFlags 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/annotation/InputParameterType.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * RG Richard Gomes 39 | * 40 | * Change history: 41 | * 42 | * YYYYMMDD BY Description 43 | * ------------------------------------------------------------------- 44 | * 20070311 RG First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib.meta.annotation; 48 | 49 | public enum InputParameterType { 50 | TA_Input_Price, 51 | TA_Input_Real, 52 | TA_Input_Integer 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/annotation/IntegerList.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * RG Richard Gomes 39 | * 40 | * Change history: 41 | * 42 | * YYYYMMDD BY Description 43 | * ------------------------------------------------------------------- 44 | * 20070311 RG First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib.meta.annotation; 48 | 49 | import java.lang.annotation.ElementType; 50 | import java.lang.annotation.Retention; 51 | import java.lang.annotation.RetentionPolicy; 52 | import java.lang.annotation.Target; 53 | 54 | @Target(ElementType.PARAMETER) 55 | @Retention(RetentionPolicy.RUNTIME) 56 | public @interface IntegerList { 57 | String paramName(); 58 | int defaultValue(); 59 | int[] value(); 60 | String[] string(); 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/annotation/IntegerRange.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * RG Richard Gomes 39 | * 40 | * Change history: 41 | * 42 | * YYYYMMDD BY Description 43 | * ------------------------------------------------------------------- 44 | * 20070311 RG First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib.meta.annotation; 48 | 49 | import java.lang.annotation.ElementType; 50 | import java.lang.annotation.Retention; 51 | import java.lang.annotation.RetentionPolicy; 52 | import java.lang.annotation.Target; 53 | 54 | @Target(ElementType.PARAMETER) 55 | @Retention(RetentionPolicy.RUNTIME) 56 | public @interface IntegerRange { 57 | String paramName(); 58 | int defaultValue(); 59 | int min(); 60 | int max(); 61 | 62 | /* The following suggested value are used by Tech. Analysis software 63 | * doing parameter "optimization". Can be ignored by most user. 64 | */ 65 | int suggested_start(); 66 | int suggested_end(); 67 | int suggested_increment(); 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/annotation/OptInputFlags.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * RG Richard Gomes 39 | * 40 | * Change history: 41 | * 42 | * YYYYMMDD BY Description 43 | * ------------------------------------------------------------------- 44 | * 20070311 RG First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib.meta.annotation; 48 | 49 | /* The following are flags for optional inputs. 50 | * 51 | * TA_OPTIN_IS_PERCENT: Input is a percentage. 52 | * 53 | * TA_OPTIN_IS_DEGREE: Input is a degree (0-360). 54 | * 55 | * TA_OPTIN_IS_CURRENCY: Input is a currency. 56 | * 57 | * TA_OPTIN_ADVANCED: 58 | * Used for parameters who are rarely changed. 59 | * Most application can hide these advanced optional inputs to their 60 | * end-user (or make it harder to change). 61 | */ 62 | public final class OptInputFlags { 63 | static public final int TA_OPTIN_IS_PERCENT = 0x00100000; 64 | static public final int TA_OPTIN_IS_DEGREE = 0x00200000; 65 | static public final int TA_OPTIN_IS_CURRENCY = 0x00400000; 66 | static public final int TA_OPTIN_ADVANCED = 0x01000000; 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/annotation/OptInputParameterInfo.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * RG Richard Gomes 39 | * 40 | * Change history: 41 | * 42 | * YYYYMMDD BY Description 43 | * ------------------------------------------------------------------- 44 | * 20070311 RG First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib.meta.annotation; 48 | 49 | import java.lang.annotation.ElementType; 50 | import java.lang.annotation.Retention; 51 | import java.lang.annotation.RetentionPolicy; 52 | import java.lang.annotation.Target; 53 | 54 | @Target(ElementType.PARAMETER) 55 | @Retention(RetentionPolicy.RUNTIME) 56 | public @interface OptInputParameterInfo { 57 | String paramName(); 58 | String displayName(); 59 | int flags(); // bitwise OR of OptInputFlags 60 | 61 | OptInputParameterType type(); 62 | Class dataSet(); 63 | // String hint(); // TODO: reserved for future 64 | // String helpFile(); // TODO: reserved for future 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/annotation/OptInputParameterType.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * RG Richard Gomes 39 | * 40 | * Change history: 41 | * 42 | * YYYYMMDD BY Description 43 | * ------------------------------------------------------------------- 44 | * 20070311 RG First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib.meta.annotation; 48 | 49 | public enum OptInputParameterType { 50 | TA_OptInput_RealRange, 51 | TA_OptInput_RealList, 52 | TA_OptInput_IntegerRange, 53 | TA_OptInput_IntegerList; 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/annotation/OutputFlags.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * RG Richard Gomes 39 | * 40 | * Change history: 41 | * 42 | * YYYYMMDD BY Description 43 | * ------------------------------------------------------------------- 44 | * 20070311 RG First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib.meta.annotation; 48 | 49 | 50 | public final class OutputFlags { 51 | static public final int TA_OUT_LINE = 0x00000001; /* Suggest to display as a connected line. */ 52 | static public final int TA_OUT_DOT_LINE = 0x00000002; /* Suggest to display as a 'dotted' line. */ 53 | static public final int TA_OUT_DASH_LINE = 0x00000004; /* Suggest to display as a 'dashed' line. */ 54 | static public final int TA_OUT_DOT = 0x00000008; /* Suggest to display with dots only. */ 55 | static public final int TA_OUT_HISTO = 0x00000010; /* Suggest to display as an histogram. */ 56 | static public final int TA_OUT_PATTERN_BOOL = 0x00000020; /* Indicates if pattern exists (!=0) or not (0) */ 57 | static public final int TA_OUT_PATTERN_BULL_BEAR = 0x00000040; /* =0 no pattern, > 0 bullish, < 0 bearish */ 58 | static public final int TA_OUT_PATTERN_STRENGTH = 0x00000080; /* =0 neutral, ]0..100] getting bullish, ]100..200] bullish, [-100..0[ getting bearish, [-200..100[ bearish */ 59 | static public final int TA_OUT_POSITIVE = 0x00000100; /* Output can be positive */ 60 | static public final int TA_OUT_NEGATIVE = 0x00000200; /* Output can be negative */ 61 | static public final int TA_OUT_ZERO = 0x00000400; /* Output can be zero */ 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/annotation/OutputParameterInfo.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * RG Richard Gomes 39 | * 40 | * Change history: 41 | * 42 | * YYYYMMDD BY Description 43 | * ------------------------------------------------------------------- 44 | * 20070311 RG First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib.meta.annotation; 48 | 49 | import java.lang.annotation.ElementType; 50 | import java.lang.annotation.Retention; 51 | import java.lang.annotation.RetentionPolicy; 52 | import java.lang.annotation.Target; 53 | 54 | @Target(ElementType.PARAMETER) 55 | @Retention(RetentionPolicy.RUNTIME) 56 | public @interface OutputParameterInfo { 57 | OutputParameterType type(); 58 | String paramName(); 59 | int flags(); // bitwise OR of OutputFlags 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/annotation/OutputParameterType.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * RG Richard Gomes 39 | * 40 | * Change history: 41 | * 42 | * YYYYMMDD BY Description 43 | * ------------------------------------------------------------------- 44 | * 20070311 RG First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib.meta.annotation; 48 | 49 | public enum OutputParameterType { 50 | TA_Output_Real, 51 | TA_Output_Integer; 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/annotation/RealList.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * RG Richard Gomes 39 | * 40 | * Change history: 41 | * 42 | * YYYYMMDD BY Description 43 | * ------------------------------------------------------------------- 44 | * 20070311 RG First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib.meta.annotation; 48 | 49 | import java.lang.annotation.ElementType; 50 | import java.lang.annotation.Retention; 51 | import java.lang.annotation.RetentionPolicy; 52 | import java.lang.annotation.Target; 53 | 54 | @Target(ElementType.PARAMETER) 55 | @Retention(RetentionPolicy.RUNTIME) 56 | public @interface RealList { 57 | String paramName(); 58 | double defaultValue(); 59 | double[] value(); 60 | String[] string(); 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/annotation/RealRange.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * RG Richard Gomes 39 | * 40 | * Change history: 41 | * 42 | * YYYYMMDD BY Description 43 | * ------------------------------------------------------------------- 44 | * 20070311 RG First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib.meta.annotation; 48 | 49 | import java.lang.annotation.ElementType; 50 | import java.lang.annotation.Retention; 51 | import java.lang.annotation.RetentionPolicy; 52 | import java.lang.annotation.Target; 53 | 54 | @Target(ElementType.PARAMETER) 55 | @Retention(RetentionPolicy.RUNTIME) 56 | public @interface RealRange { 57 | String paramName(); 58 | double defaultValue(); 59 | double min(); 60 | double max(); 61 | int precision(); /* nb of digit after the '.' */ 62 | 63 | /* The following suggested value are used by Tech. Analysis software 64 | * doing parameter "optimization". Can be ignored by most user. 65 | */ 66 | double suggested_start(); 67 | double suggested_end(); 68 | double suggested_increment(); 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/tictactec/ta/lib/meta/helpers/SimpleHelper.java: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * RG Richard Gomes 39 | * 40 | * Change history: 41 | * 42 | * YYYYMMDD BY Description 43 | * ------------------------------------------------------------------- 44 | * 20070311 RG First Version 45 | */ 46 | 47 | package com.tictactec.ta.lib.meta.helpers; 48 | 49 | import java.lang.reflect.InvocationTargetException; 50 | import java.util.List; 51 | 52 | import com.tictactec.ta.lib.MInteger; 53 | import com.tictactec.ta.lib.meta.CoreMetaData; 54 | import com.tictactec.ta.lib.meta.annotation.FuncInfo; 55 | import com.tictactec.ta.lib.meta.annotation.InputParameterInfo; 56 | import com.tictactec.ta.lib.meta.annotation.InputParameterType; 57 | import com.tictactec.ta.lib.meta.annotation.IntegerList; 58 | import com.tictactec.ta.lib.meta.annotation.IntegerRange; 59 | import com.tictactec.ta.lib.meta.annotation.OptInputParameterInfo; 60 | import com.tictactec.ta.lib.meta.annotation.OutputParameterInfo; 61 | import com.tictactec.ta.lib.meta.annotation.OutputParameterType; 62 | import com.tictactec.ta.lib.meta.annotation.RealList; 63 | import com.tictactec.ta.lib.meta.annotation.RealRange; 64 | 65 | 66 | /** 67 | * This is a simple API level helper class based on CoreMetaData. 68 | * 69 | *

    This class provides the very simple functionality of calling dinamically a TA function once you already know beforehand: 70 | * 71 | *

  • the TA function name; 72 | *
  • its input argument types; 73 | *
  • its output argument types; 74 | *
  • its optional input arguments types and domain values; 75 | * 76 | * It means this class is mostly intended for test purposes and provided as example of how to obtain RTTI 77 | * (run time type information) from CoreMetaData. 78 | * 79 | * @see com.tictactec.ta.lib.meta.CoreMetaData 80 | * 81 | * @author Richard Gomes 82 | */ 83 | public class SimpleHelper { 84 | 85 | private String func = null; 86 | private String[] args = null; 87 | private CoreMetaData calc = null; 88 | 89 | /** 90 | * Constructs a SimpleHelper class providing the TA function name and a list of optional parameters. 91 | * 92 | * @see SimpleHelper#calculate(int, int, Object[], Object[], MInteger, MInteger) 93 | * @param func is the TA function name 94 | * @param args is a list of optional input arguments 95 | */ 96 | public SimpleHelper(final String func, final List args) { 97 | if (func==null || func.length()==0) throw new NullPointerException(); //TODO: message 98 | this.func = func; 99 | if (args!=null && args.size()>0) { 100 | this.args = (String[]) args.toArray(new String[0]); 101 | for (int i=0; ifinfo.nbOptInput()) throw new IllegalArgumentException(); //TODO: message 117 | for (int i=0; i Lookback is the number of input data points to be consumed in order to calculate the first output data point. This value 134 | * is affected by the optional input arguments passed to this TA function. 135 | * 136 | * @return the lookback number of input points to be consumed before the first output data point is produced. 137 | * 138 | * @throws NoSuchMethodException 139 | * @throws IllegalAccessException 140 | * @throws InvocationTargetException 141 | */ 142 | public int getLookback() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { 143 | return getMetaData().getLookback(); 144 | } 145 | 146 | /** 147 | * Executes the calculations defined by this TA function. 148 | * 149 | *

    You need to provide input arguments where this TA function will obtain data from and output arguments where this 150 | * TA function will write output data to. Optionally you can change default parameters used by this TA function in order 151 | * to execute the calculations. The typical use case would be: 152 | *

    153 |      *       func = "MAMA";
    154 |      *       params.clear();
    155 |      *       params.add("0.2");
    156 |      *       params.add("0.02");
    157 |      *       calc = new SimpleHelper(func, params);
    158 |      *       calc.calculate(0, 59, new Object[] { close }, new Object[] { output1, output2 }, lOutIdx, lOutSize);
    159 |      *       System.out.println("lookback="+calc.getLookback());
    160 |      *       System.out.println("outBegIdx    = "+lOutIdx.value+ "    outNbElement = "+lOutSize.value);
    161 |      *       for (int i=0; i getAllCombinations(Object[] parms)
    57 |    { 
    58 |       List children=null;
    59 |       if( parms.length > 1 ){
    60 |          Object[] cp = new Object[parms.length-1];
    61 |          for(int i=0;i ret = new ArrayList();
    67 |       if( parms.length == 0 ){
    68 |          ret.add(parms);
    69 |       }else{
    70 |          if( parms[0].getClass().isArray() ){
    71 |             for(Object o : (Object[]) parms[0]){
    72 |                process(ret, children, o);
    73 |             }
    74 |          }else{
    75 |             process(ret, children, parms[0]);
    76 |          }
    77 |       }
    78 |       return ret;
    79 |    }
    80 | 
    81 |    void process(List ret, List children, Object obj)
    82 |    {
    83 |       if( children == null ){
    84 |          Object[] da = new Object[1];
    85 |          da[0] = obj;
    86 |          ret.add(da);
    87 |       }else{
    88 |          for(Object[] cr : children){
    89 |             Object[] rr = new Object[cr.length+1];
    90 |             rr[0] = obj;
    91 |             for(int i=0;i"+mi.toString()+"["+j+"]="+d+":"+curInputData.getName());
    245 |                   //return false;
    246 |                }
    247 |                j++;
    248 |             }
    249 |          }
    250 |          else if( outVarTypes[i].equals(float[].class) )
    251 |          {
    252 |          }
    253 |          else if( outVarTypes[i].equals(int[].class) )
    254 |          {
    255 |          }
    256 |          else
    257 |          {
    258 |             fail("invalid output type : "+outVarTypes[i]);
    259 |          }
    260 |       }
    261 |       return true;
    262 |    }
    263 |    
    264 |    boolean verifyInputData(InputData inputData, InputData originalInputData)
    265 |    {
    266 |       return
    267 |          Arrays.equals(inputData.getDoubleData(),originalInputData.getDoubleData()) &&
    268 |          Arrays.equals(inputData.getFloatData(),originalInputData.getFloatData())  &&
    269 |          Arrays.equals(inputData.getIntData(),originalInputData.getIntData());
    270 |    }
    271 | }
    272 | 
    
    
    --------------------------------------------------------------------------------
    /src/test/java/TestCoreMetaData.java:
    --------------------------------------------------------------------------------
      1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier
      2 |  * All rights reserved.
      3 |  *
      4 |  * Redistribution and use in source and binary forms, with or
      5 |  * without modification, are permitted provided that the following
      6 |  * conditions are met:
      7 |  *
      8 |  * - Redistributions of source code must retain the above copyright
      9 |  *   notice, this list of conditions and the following disclaimer.
     10 |  *
     11 |  * - Redistributions in binary form must reproduce the above copyright
     12 |  *   notice, this list of conditions and the following disclaimer in
     13 |  *   the documentation and/or other materials provided with the
     14 |  *   distribution.
     15 |  *
     16 |  * - Neither name of author nor the names of its contributors
     17 |  *   may be used to endorse or promote products derived from this
     18 |  *   software without specific prior written permission.
     19 |  *
     20 |  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     21 |  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     22 |  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     23 |  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     24 |  * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     25 |  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     26 |  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     27 |  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28 |  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     29 |  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     30 |  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     31 |  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32 |  */
     33 | 
     34 | /* List of contributors:
     35 |  *
     36 |  *  Initial  Name/description
     37 |  *  -------------------------------------------------------------------
     38 |  *  RG       Richard Gomes
     39 |  *
     40 |  * Change history:
     41 |  *
     42 |  *  YYYYMMDD BY     Description
     43 |  *  -------------------------------------------------------------------
     44 |  *  20070311 RG     First Version
     45 |  */
     46 | 
     47 | import java.util.ArrayList;
     48 | import java.util.List;
     49 | import java.util.Set;
     50 | 
     51 | import com.tictactec.ta.lib.MInteger;
     52 | import com.tictactec.ta.lib.meta.CoreMetaData;
     53 | import com.tictactec.ta.lib.meta.PriceHolder;
     54 | import com.tictactec.ta.lib.meta.PriceInputParameter;
     55 | import com.tictactec.ta.lib.meta.TaFuncService;
     56 | import com.tictactec.ta.lib.meta.TaGrpService;
     57 | import com.tictactec.ta.lib.meta.annotation.InputParameterInfo;
     58 | import com.tictactec.ta.lib.meta.annotation.IntegerList;
     59 | import com.tictactec.ta.lib.meta.annotation.IntegerRange;
     60 | import com.tictactec.ta.lib.meta.annotation.OptInputParameterInfo;
     61 | import com.tictactec.ta.lib.meta.annotation.OutputParameterInfo;
     62 | import com.tictactec.ta.lib.meta.annotation.RealList;
     63 | import com.tictactec.ta.lib.meta.annotation.RealRange;
     64 | import com.tictactec.ta.lib.meta.helpers.SimpleHelper;
     65 | 
     66 | public class TestCoreMetaData {
     67 | 
     68 |     public static void main(String[] args) {
     69 |         
     70 |         final class DumpGrp implements TaGrpService {
     71 |             public void execute(String group, Set set) {
     72 |                 System.out.println("GROUP "+group);
     73 |                 for (CoreMetaData mi : set) {
     74 |                     System.out.println("        "+mi.getFuncInfo().name());
     75 |                 }
     76 |                 
     77 |             }
     78 |         }
     79 |         
     80 |         final class DumpFunc implements TaFuncService {
     81 |             public void execute(CoreMetaData mi) {
     82 |                 System.out.println(mi.getFuncInfo().name());
     83 |                 for (int i = 0; i < mi.getFuncInfo().nbInput(); i++) {
     84 |                     InputParameterInfo pinfo = mi.getInputParameterInfo(i);
     85 |                     System.out.println("    " + pinfo.paramName());
     86 |                     System.out.println("        " + pinfo.type());
     87 |                 }
     88 |                 for (int i = 0; i < mi.getFuncInfo().nbOptInput(); i++) {
     89 |                     OptInputParameterInfo pinfo = mi.getOptInputParameterInfo(i);
     90 |                     System.out.println("    " + pinfo.paramName());
     91 |                     System.out.println("        " + pinfo.type());
     92 |                     switch (pinfo.type()) {
     93 |                     case TA_OptInput_RealRange:
     94 |                         RealRange rrange = mi.getOptInputRealRange(i);
     95 |                         System.out.println("            min="+rrange.min());
     96 |                         System.out.println("            max="+rrange.max());
     97 |                         System.out.println("            precision="+rrange.precision());
     98 |                         System.out.println("            default="+rrange.defaultValue());
     99 |                         break;
    100 |                     case TA_OptInput_RealList:
    101 |                         RealList rlist = mi.getOptInputRealList(i);
    102 |                         System.out.print("            value=");
    103 |                         for (double value : rlist.value()) {
    104 |                             System.out.print(value); System.out.print(" ");
    105 |                         }
    106 |                         System.out.println();
    107 |                         System.out.print("            string="+rlist.string());
    108 |                         for (String string : rlist.string()) {
    109 |                             System.out.print(string); System.out.print(" ");
    110 |                         }
    111 |                         System.out.println();
    112 |                         break;
    113 |                     case TA_OptInput_IntegerRange:
    114 |                         IntegerRange irange = mi.getOptInputIntegerRange(i);
    115 |                         System.out.println("            min="+irange.min());
    116 |                         System.out.println("            max="+irange.max());
    117 |                         System.out.println("            default="+irange.defaultValue());
    118 |                         break;
    119 |                     case TA_OptInput_IntegerList:
    120 |                         IntegerList ilist = mi.getOptInputIntegerList(i);
    121 |                         System.out.print("            value=");
    122 |                         for (int value : ilist.value()) {
    123 |                             System.out.print(value); System.out.print(" ");
    124 |                         }
    125 |                         System.out.println();
    126 |                         System.out.print("            string=");
    127 |                         for (String string : ilist.string()) {
    128 |                             System.out.print(string); System.out.print(" ");
    129 |                         }
    130 |                         System.out.println();
    131 |                         break;
    132 |                     }
    133 |                 }
    134 |                 for (int i = 0; i < mi.getFuncInfo().nbOutput(); i++) {
    135 |                     OutputParameterInfo pinfo = mi.getOutputParameterInfo(i);
    136 |                     System.out.println("    " + pinfo.paramName());
    137 |                     System.out.println("        " + pinfo.type());
    138 |                 }
    139 |             }
    140 |         }
    141 | 
    142 |         TaGrpService grpServ = new DumpGrp();
    143 |         try {
    144 |             CoreMetaData.forEachGrp(grpServ);
    145 |         } catch (Exception e) {
    146 |             e.printStackTrace();
    147 |         }
    148 | 
    149 |         System.out.println("=  =  =  =  =  =  =  =  =  =  =  =  =");
    150 |         
    151 |         TaFuncService funcServ = new DumpFunc();
    152 |         try {
    153 |             CoreMetaData.forEachFunc(funcServ);
    154 |         } catch (Exception e) {
    155 |             e.printStackTrace();
    156 |         }
    157 |         System.out.println("=====================================");
    158 | 
    159 |     
    160 |     
    161 |         
    162 |         
    163 |         
    164 |         SimpleHelper calc;
    165 | 
    166 |         // input data
    167 |         double open[] = {
    168 |                 1.4054, 1.4060, 1.4062, 1.4059, 1.4057, 1.4057, 1.4051, 1.4054, 1.4056, 1.4056,
    169 |                 1.4054, 1.4060, 1.4062, 1.4059, 1.4057, 1.4057, 1.4051, 1.4054, 1.4056, 1.4056,
    170 |                 1.4054, 1.4060, 1.4062, 1.4059, 1.4057, 1.4057, 1.4051, 1.4054, 1.4056, 1.4056,
    171 |                 1.4054, 1.4060, 1.4062, 1.4059, 1.4057, 1.4057, 1.4051, 1.4054, 1.4056, 1.4056,
    172 |                 1.4054, 1.4060, 1.4062, 1.4059, 1.4057, 1.4057, 1.4051, 1.4054, 1.4056, 1.4056,
    173 |                 1.4054, 1.4060, 1.4062, 1.4059, 1.4057, 1.4057, 1.4051, 1.4054, 1.4056, 1.4056
    174 |         };
    175 | 
    176 |         double high[] = {
    177 |                 1.4654, 1.4660, 1.4662, 1.4659, 1.4657, 1.4657, 1.4651, 1.4654, 1.4656, 1.4656,
    178 |                 1.4654, 1.4660, 1.4662, 1.4659, 1.4657, 1.4657, 1.4651, 1.4654, 1.4656, 1.4656,
    179 |                 1.4654, 1.4660, 1.4662, 1.4659, 1.4657, 1.4657, 1.4651, 1.4654, 1.4656, 1.4656,
    180 |                 1.4654, 1.4660, 1.4662, 1.4659, 1.4657, 1.4657, 1.4651, 1.4654, 1.4656, 1.4656,
    181 |                 1.4654, 1.4660, 1.4662, 1.4659, 1.4657, 1.4657, 1.4651, 1.4654, 1.4656, 1.4656,
    182 |                 1.4654, 1.4660, 1.4662, 1.4659, 1.4657, 1.4657, 1.4651, 1.4654, 1.4656, 1.4656
    183 |         };
    184 | 
    185 | 
    186 |         double low[] = {
    187 |                 1.3954, 1.3960, 1.3962, 1.3959, 1.3957, 1.3957, 1.3951, 1.3954, 1.3956, 1.3956,
    188 |                 1.3954, 1.3960, 1.3962, 1.3959, 1.3957, 1.3957, 1.3951, 1.3954, 1.3956, 1.3956,
    189 |                 1.3954, 1.3960, 1.3962, 1.3959, 1.3957, 1.3957, 1.3951, 1.3954, 1.3956, 1.3956,
    190 |                 1.3954, 1.3960, 1.3962, 1.3959, 1.3957, 1.3957, 1.3951, 1.3954, 1.3956, 1.3956,
    191 |                 1.3954, 1.3960, 1.3962, 1.3959, 1.3957, 1.3957, 1.3951, 1.3954, 1.3956, 1.3956,
    192 |                 1.3954, 1.3960, 1.3962, 1.3959, 1.3957, 1.3957, 1.3951, 1.3954, 1.3956, 1.3956
    193 |         };
    194 | 
    195 |         
    196 |         double close[] = {
    197 |                 1.4554, 1.4560, 1.4562, 1.4559, 1.4557, 1.4557, 1.4551, 1.4554, 1.4556, 1.4556,
    198 |                 1.4554, 1.4560, 1.4562, 1.4559, 1.4557, 1.4557, 1.4551, 1.4554, 1.4556, 1.4556,
    199 |                 1.4554, 1.4560, 1.4562, 1.4559, 1.4557, 1.4557, 1.4551, 1.4554, 1.4556, 1.4556,
    200 |                 1.4554, 1.4560, 1.4562, 1.4559, 1.4557, 1.4557, 1.4551, 1.4554, 1.4556, 1.4556,
    201 |                 1.4554, 1.4560, 1.4562, 1.4559, 1.4557, 1.4557, 1.4551, 1.4554, 1.4556, 1.4556,
    202 |                 1.4554, 1.4560, 1.4562, 1.4559, 1.4557, 1.4557, 1.4551, 1.4554, 1.4556, 1.4556
    203 |         };
    204 |         // output buffers and return values
    205 |         double output1[] = new double[60];
    206 |         double output2[] = new double[60];
    207 |         double output3[] = new double[60];
    208 |         MInteger lOutIdx  = new MInteger();
    209 |         MInteger lOutSize = new MInteger();
    210 | 
    211 |         // function name and parameter holder
    212 |         String func;
    213 |         List params = new ArrayList();
    214 |         
    215 |         try {
    216 |             /*
    217 |                 MAMA
    218 |                     [TA_Input_Real]    [0] inReal
    219 |                     [TA_OptInput_RealRange]   [0] optInFastLimit : 0.01..0.99 [0.01]
    220 |                     [TA_OptInput_RealRange]   [0] optInSlowLimit : 0.01..0.99 [0.01]
    221 |                     [TA_Output_Real]    [1] outMAMA
    222 |                     [TA_Output_Real]    [4] outFAMA
    223 |             */
    224 |             func = "MAMA";
    225 |             params.clear();
    226 |             params.add("0.2");
    227 |             params.add("0.02");
    228 |             calc = new SimpleHelper(func, params);
    229 |     
    230 |             System.out.println("===============================================");
    231 |             System.out.println(func);
    232 |             calc.calculate(0, 59, new Object[] { close }, new Object[] { output1, output2 }, lOutIdx, lOutSize);
    233 |             
    234 |             System.out.println("lookback="+calc.getLookback());
    235 |             System.out.println("outBegIdx    = "+lOutIdx.value+ "    outNbElement = "+lOutSize.value);
    236 |             for (int i=0; i getAllInputData()
    138 |    {
    139 |       return allInputData;
    140 |    }
    141 | }
    142 | 
    
    
    --------------------------------------------------------------------------------