Created
October 23, 2019 23:41
-
-
Save maxcelos/9089bc3463703b80eeab3c17fb132ea4 to your computer and use it in GitHub Desktop.
Consulta a taxa de emonumentos para swing trade pessoa física no Laravel
This file contains hidden or 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
<?php | |
// Consulta a taxa de emonumentos para swing trade pessoa física no Laravel | |
$html = @file_get_contents('http://www.b3.com.br/pt_br/produtos-e-servicos/tarifas/listados-a-vista-e-derivativos/renda-variavel/tarifas-de-acoes-e-fundos-de-investimento/a-vista/'); | |
$html = explode("Taxa de negociação, taxa de liquidação e taxa de registro", $html); | |
$html = explode("Faixas de volume para daytrade", $html[1]); | |
$html = explode("</table>", $html[0]); | |
$html = explode("<tr>", $html[0]); | |
if ( | |
\Illuminate\Support\Str::contains($html[1], "Tipo de Investidor") && | |
\Illuminate\Support\Str::contains($html[1], "Negociação") && | |
\Illuminate\Support\Str::contains($html[1], "Liquidação") && | |
\Illuminate\Support\Str::contains($html[1], "Registro") && | |
\Illuminate\Support\Str::contains($html[1], "Total") && | |
\Illuminate\Support\Str::contains($html[2], "Pessoas físicas e demais investidores") | |
) { | |
$linha = explode("<td align=\"right\">", $html[2])[4]; | |
$linha = explode("%</td>", $linha)[0]; | |
$b3Tax = (float)str_replace(',', '.', $linha); | |
if ($b3Tax >= 0.03 && $b3Tax <= 0.032) { | |
return $b3Tax; | |
} else { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment