-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
345 changed files
with
90,232 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
Copyright (c) 2012-2018, Anatol Belski <ab@php.net> | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
|
||
- Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
- Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
/* $Id$ */ | ||
|
||
#include "php.h" | ||
#include "php_trader.h" | ||
|
||
#include <ta_func.h> | ||
#include <ta_common.h> | ||
|
||
ZEND_EXTERN_MODULE_GLOBALS(trader) | ||
|
||
/* {{{ proto array MY_FUNC_NAME_LOWER(MY_FUNC_DOC_PARAMS) | ||
MY_FUNC_DESC */ | ||
PHP_FUNCTION(MY_FUNC_NAME_LOWER) | ||
{ | ||
int optimalOutAlloc, lookback; | ||
MY_IN_PHP_ARRAY_DEFS | ||
MY_FUNC_ARRAY_PARA_DEFS | ||
MY_FUNC_INT_PARA_DEFS | ||
MY_IN_PHP_LONG_DEFS | ||
MY_IN_PHP_DOUBLE_DEFS | ||
#if PHP_MAJOR_VERSION >= 7 | ||
MY_ZEND_FAST_ZPP | ||
#else | ||
if (zend_parse_parameters(ZEND_NUM_ARGS(), MY_ZEND_PARAMS_STR, MY_ZEND_PARAM_LIST) == FAILURE) { | ||
RETURN_FALSE; | ||
} | ||
#endif | ||
|
||
MY_FUNC_CHECK_MA_TYPES | ||
MY_FUNC_SET_BOUNDABLE | ||
|
||
MY_FUNC_SET_MIN_END_IDX | ||
MY_FUNC_SET_START_IDX | ||
|
||
MY_FUNC_OPTIMAL_OUT_ALLOC | ||
if (optimalOutAlloc > 0) { | ||
MY_FUNC_ARRAY_PARA_ALLOCS | ||
TRADER_G(last_error) = MY_FUNC_NAME(MY_FUNC_PARAMS); | ||
if (TRADER_G(last_error) != TA_SUCCESS) { | ||
MY_FUNC_ARRAY_PARA_DEALLOCS2 | ||
RETURN_FALSE; | ||
} | ||
|
||
MY_PHP_MAKE_RETURN | ||
|
||
MY_FUNC_ARRAY_PARA_DEALLOCS1 | ||
} else { | ||
/* The current input args combination would cause TA-Lib to produce | ||
zero output, don't bother making any allocs or calls. */ | ||
TRADER_G(last_error) = TA_BAD_PARAM; | ||
RETURN_FALSE; | ||
} | ||
} | ||
/* }}} */ | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
Copyright (c) 2012-2018, Anatol Belski <[email protected]> | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
- Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
- Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
/* $Id$ */ | ||
|
||
#include "php.h" | ||
#include "php_trader.h" | ||
|
||
#include <ta_func.h> | ||
#include <ta_common.h> | ||
|
||
ZEND_EXTERN_MODULE_GLOBALS(trader) | ||
|
||
/* {{{ proto array trader_accbands(array high, array low, array close [, int timePeriod]) | ||
Acceleration Bands */ | ||
PHP_FUNCTION(trader_accbands) | ||
{ | ||
int optimalOutAlloc, lookback; | ||
zval *zinHigh, *zinLow, *zinClose; | ||
double *inHigh, *inLow, *inClose, *outRealUpperBand, *outRealMiddleBand, *outRealLowerBand; | ||
int startIdx = 0, endIdx = 0, outBegIdx = 0, outNBElement = 0; | ||
zend_long optInTimePeriod = 2; | ||
|
||
|
||
#if PHP_MAJOR_VERSION >= 7 | ||
ZEND_PARSE_PARAMETERS_START(3, 4) | ||
Z_PARAM_ARRAY(zinHigh) | ||
Z_PARAM_ARRAY(zinLow) | ||
Z_PARAM_ARRAY(zinClose) | ||
Z_PARAM_OPTIONAL | ||
Z_PARAM_LONG(optInTimePeriod) | ||
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE); | ||
#else | ||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "aaa|l", &zinHigh, &zinLow, &zinClose, &optInTimePeriod) == FAILURE) { | ||
RETURN_FALSE; | ||
} | ||
#endif | ||
|
||
|
||
TRADER_LONG_SET_BOUNDABLE(2, 100000, optInTimePeriod); | ||
|
||
TRADER_SET_MIN_INT3(endIdx, zend_hash_num_elements(Z_ARRVAL_P(zinHigh)), | ||
zend_hash_num_elements(Z_ARRVAL_P(zinLow)), | ||
zend_hash_num_elements(Z_ARRVAL_P(zinClose))) | ||
endIdx--; /* it's <= in the ta-lib */ | ||
|
||
|
||
lookback = TA_ACCBANDS_Lookback((int)optInTimePeriod); | ||
optimalOutAlloc = (lookback > endIdx) ? 0 : (endIdx - lookback + 1); | ||
if (optimalOutAlloc > 0) { | ||
outRealUpperBand = emalloc(sizeof(double)*optimalOutAlloc); | ||
outRealMiddleBand = emalloc(sizeof(double)*optimalOutAlloc); | ||
outRealLowerBand = emalloc(sizeof(double)*optimalOutAlloc); | ||
TRADER_DBL_ZARR_TO_ARR(zinHigh, inHigh) | ||
TRADER_DBL_ZARR_TO_ARR(zinLow, inLow) | ||
TRADER_DBL_ZARR_TO_ARR(zinClose, inClose) | ||
|
||
TRADER_G(last_error) = TA_ACCBANDS(startIdx, endIdx, inHigh, inLow, inClose, (int)optInTimePeriod, &outBegIdx, &outNBElement, outRealUpperBand, outRealMiddleBand, outRealLowerBand); | ||
if (TRADER_G(last_error) != TA_SUCCESS) { | ||
efree(inHigh); | ||
efree(inLow); | ||
efree(inClose); | ||
efree(outRealUpperBand); | ||
efree(outRealMiddleBand); | ||
efree(outRealLowerBand); | ||
|
||
RETURN_FALSE; | ||
} | ||
|
||
TRADER_DBL_ARR_TO_ZRET3(outRealUpperBand, outRealMiddleBand, outRealLowerBand, return_value, endIdx, outBegIdx, outNBElement) | ||
|
||
efree(inHigh); | ||
efree(inLow); | ||
efree(inClose); | ||
efree(outRealUpperBand); | ||
efree(outRealMiddleBand); | ||
efree(outRealLowerBand); | ||
} else { | ||
/* The current input args combination would cause TA-Lib to produce | ||
zero output, don't bother making any allocs or calls. */ | ||
TRADER_G(last_error) = TA_BAD_PARAM; | ||
RETURN_FALSE; | ||
} | ||
} | ||
/* }}} */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
Copyright (c) 2012-2018, Anatol Belski <[email protected]> | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
- Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
- Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
/* $Id$ */ | ||
|
||
#include "php.h" | ||
#include "php_trader.h" | ||
|
||
#include <ta_func.h> | ||
#include <ta_common.h> | ||
|
||
ZEND_EXTERN_MODULE_GLOBALS(trader) | ||
|
||
/* {{{ proto array trader_acos(array real) | ||
Vector Trigonometric ACos */ | ||
PHP_FUNCTION(trader_acos) | ||
{ | ||
int optimalOutAlloc, lookback; | ||
zval *zinReal; | ||
double *inReal, *outReal; | ||
int startIdx = 0, endIdx = 0, outBegIdx = 0, outNBElement = 0; | ||
|
||
|
||
|
||
#if PHP_MAJOR_VERSION >= 7 | ||
ZEND_PARSE_PARAMETERS_START(1, 1) | ||
Z_PARAM_ARRAY(zinReal) | ||
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE); | ||
#else | ||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "a", &zinReal) == FAILURE) { | ||
RETURN_FALSE; | ||
} | ||
#endif | ||
|
||
|
||
|
||
|
||
TRADER_SET_MIN_INT1(endIdx, zend_hash_num_elements(Z_ARRVAL_P(zinReal))) | ||
endIdx--; /* it's <= in the ta-lib */ | ||
|
||
|
||
lookback = TA_ACOS_Lookback(); | ||
optimalOutAlloc = (lookback > endIdx) ? 0 : (endIdx - lookback + 1); | ||
if (optimalOutAlloc > 0) { | ||
outReal = emalloc(sizeof(double)*optimalOutAlloc); | ||
TRADER_DBL_ZARR_TO_ARR(zinReal, inReal) | ||
|
||
TRADER_G(last_error) = TA_ACOS(startIdx, endIdx, inReal, &outBegIdx, &outNBElement, outReal); | ||
if (TRADER_G(last_error) != TA_SUCCESS) { | ||
efree(inReal); | ||
efree(outReal); | ||
|
||
RETURN_FALSE; | ||
} | ||
|
||
TRADER_DBL_ARR_TO_ZRET1(outReal, return_value, endIdx, outBegIdx, outNBElement) | ||
|
||
efree(inReal); | ||
efree(outReal); | ||
} else { | ||
/* The current input args combination would cause TA-Lib to produce | ||
zero output, don't bother making any allocs or calls. */ | ||
TRADER_G(last_error) = TA_BAD_PARAM; | ||
RETURN_FALSE; | ||
} | ||
} | ||
/* }}} */ | ||
|
Oops, something went wrong.