Este es un puerto de PHP de la extensión del comerciante para PHP, que es un puerto del código TA-lib C/Java.
Este puerto está escrito en PHP y sin ningún otro requisito.
El objetivo es que esta biblioteca pueda ser utilizada por aquellos que no pueden instalar la extensión PHP Trader.
¡Eso es lo único que necesitas! Como se indicó, no necesita instalar ninguna extensión para esta biblioteca.
Esta biblioteca está destinada a instalarse con el compositor.
composer require lupecode/php-trader-native
Esta biblioteca está destinada a ser un reemplazo de la extensión del comerciante, viene con un polyfill para la extensión del comerciante.
Otra opción que proporciona este paquete es usar funciones que tengan un nombre más fácil de entender.
Si no desea usar adosc porque no es lo suficientemente descriptivo, puede usar chaikinAccumulationDistributionOscillator de la misma manera: TraderFriendly::chaikinAccumulationDistributionOscillator($high, $low, $close, $volume, $fastPeriod, $slowPeriod)
La versión PECL de la TA-lib, "comerciante", no tiene los valores predeterminados correctos para las funciones. Una mirada rápida muestra que muchas de las funciones usan el valor mínimo para los parámetros opcionales en lugar de los valores predeterminados utilizados en la versión C/Java de TA-LIB. Algunas de las pruebas, como testAdOscDefaultsDifferent pasan, siempre que la biblioteca PECL Trader use valores predeterminados diferentes que los del código C/Java.
Para los curiosos, la fuente TA-liber para ADOSC se puede ver aquí con valores predeterminados de 3 y 10, mientras que la fuente PECL Trader se puede ver aquí con valores predeterminados de 2 y 2.
Este paquete utiliza los valores predeterminados C/Java y no los valores predeterminados PECL.
Dado que esta biblioteca está escrita en PHP puro, se ejecuta más lento que la extensión PECL que está escrita en C. Mis puntos de referencia dan 5x a 30x más lento dependiendo de la función.
¡Agradezco cualquier ayuda con las optimizaciones! No he trabajado para optimizar esta biblioteca; Es una simple conversión de C a PHP.
Consulte el repositorio y luego instale con el compositor.
git checkout [email protected]:LupeCode/phpTraderNative.git
cd phpTraderNative
composer install --dev
source : el código fuente para la biblioteca.tests : las pruebas de PhPunit para la biblioteca.pecl : el código fuente de extensión PECL Trader.talib : el código fuente de TA -LIB que utiliza la extensión PECL Trader.Se incluyen dos archivos XML Phpunit, uno para la prueba y el otro para cobertura. Esto se debe al hecho de que cuando algunas pruebas se ejecutan con cobertura, PHP cuelga y nunca termina.
Ejecute las pruebas usando
php -dxdebug.coverage_enable=0 ./vendor/phpunit/phpunit/phpunit --configuration ./phpunit.xml ./tests
Ejecute la cobertura usando
php -dxdebug.coverage_enable=1 ./vendor/phpunit/phpunit/phpunit --configuration ./phpunit_coverage.xml ./tests
A continuación se muestra la información de derechos de autor para TA-LIB que se encuentra en el código fuente.
TA-LIB Copyright (c) 1999-2007, Mario Fortier
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.
- Neither name of author nor the names of its contributors may be used
to endorse or promote products derived from this software without
specific prior written permission.
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 REGENTS 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.
A continuación se muestra la licencia para mi portada del código a PHP.
MIT License
Copyright (C) Lupe Code, LLC.; Joshua Lopez
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.