Esta é uma porta PHP da extensão do trader para PHP, que é uma porta do código TA-LIB C/Java.
Esta porta está escrita no PHP e sem outros requisitos.
O objetivo é que essa biblioteca possa ser usada por aqueles que não podem instalar a extensão do trader PHP.
Essa é a única coisa que você precisa! Como afirmado, você não precisa instalar nenhuma extensão para esta biblioteca.
Esta biblioteca deve ser instalada com compositor.
composer require lupecode/php-trader-native
Esta biblioteca deve ser uma substituição para a extensão do trader, ela vem com um poli-preenchimento para a extensão do trader.
Outra opção que este pacote oferece é usar funções que tenham um nome mais fácil de entender.
Se você não deseja usar adosc porque não é descritivo o suficiente, você pode usar chaikinAccumulationDistributionOscillator como o seguinte: TraderFriendly::chaikinAccumulationDistributionOscillator($high, $low, $close, $volume, $fastPeriod, $slowPeriod)
A versão PECL do TA-Lib, "Trader", não possui os valores padrão corretos para as funções. Uma aparência rápida mostra que muitas das funções usam o valor mínimo para os parâmetros opcionais, em vez dos padrões usados na versão C/Java do TA-Lib. Alguns dos testes, como testAdOscDefaultsDifferent Pass, desde que a Biblioteca PECL Trader use padrões diferentes do que os do código C/Java.
Para os curiosos, a fonte TA-Lib para Adosc pode ser vista aqui com padrões de 3 e 10, enquanto a fonte do trader PECL pode ser vista aqui com inadimplência de 2 e 2.
Este pacote usa os padrões C/Java e não os padrões do PECL.
Dado que esta biblioteca está escrita em PHP puro, o IS é mais lento que a extensão PECL, que é escrita em C. Meus benchmarks dão 5x a 30x mais lento, dependendo da função.
Congratulo -me com qualquer ajuda com otimizações! Não trabalhei para otimizar esta biblioteca; É uma conversão simples de C para PHP.
Confira o repositório e instale com o Composer.
git checkout [email protected]:LupeCode/phpTraderNative.git
cd phpTraderNative
composer install --dev
source - o código -fonte da biblioteca.tests - Os testes de phpunit para a biblioteca.pecl - O Código Fonte de Extensão do Trader do PECL.talib - O código -fonte TA -LIB que a extensão do trader PECL usa.Dois arquivos xml phpunit estão incluídos, um para testes e outro para cobertura. Isso se deve ao fato de que, quando alguns testes são executados com cobertura, o PHP está pendurado e nunca termina.
Execute os testes usando
php -dxdebug.coverage_enable=0 ./vendor/phpunit/phpunit/phpunit --configuration ./phpunit.xml ./tests
Execute a cobertura usando
php -dxdebug.coverage_enable=1 ./vendor/phpunit/phpunit/phpunit --configuration ./phpunit_coverage.xml ./tests
Abaixo está as informações de direitos autorais para o TA-LIB encontradas no código-fonte.
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.
Abaixo está a licença para a minha porte do código para 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.