Skip to content

Instantly share code, notes, and snippets.

@maxcelos
Created October 23, 2019 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxcelos/9089bc3463703b80eeab3c17fb132ea4 to your computer and use it in GitHub Desktop.
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
<?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