Created
June 25, 2014 04:11
-
-
Save ThiagoAnunciacao/cc54b806d4a10bf3408f to your computer and use it in GitHub Desktop.
WebServices Bovespa
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
# Retorna dados sobre o pregão | |
http://www.bmfbovespa.com.br/Pregao-Online/ExecutaAcaoCarregarDados.asp?CodDado=IBOV,ticker&CA=undefined | |
# Retorna ações e seus últimos valores negociados | |
http://www.bmfbovespa.com.br/Pregao-OnLine/ExecutaAcaoCarregarDados.asp?CodDado=Ticker | |
# Retorna o histórico do dia de um papel | |
http://www.bmfbovespa.com.br/Pregao-Online/ExecutaAcaoCarregarDadosPapeis.asp?CodDado=petr4 | |
# Retorna dados de um papel | |
http://www.bmfbovespa.com.br/cotacoes2000/formCotacoesMobile.asp?codsocemi=PETR4 | |
# Retorna array com vários papeis | |
http://www.bmfbovespa.com.br/Pregao-Online/ExecutaAcaoAjax.asp?CodigoPapel=BISA3|PETR4|BBDC4 | |
# Retorna dados do pregão | |
http://www.bmfbovespa.com.br/cotacoes2000/formCotacoesMobile.asp?codsocemi=IBOV |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ola, tudo bem?
Alguem pode me ajudar?
Adaptei esse sketch em um ESP32, tem conecção WI-FI direto com reset pino 4.
Cotação STOCK EUA
CRIPITO
B3
Porem a B3 parou de funcionar.
Com a API do nosso amigo
@felipemarinho97 com o link: https://felipemarinho.vercel.app/api/b3/prices/
Vou colocar o Sketch para analizarem.
Agradeço a atenção.
Fico no aguardo.
//Cotação
// display: 8-pin 128160 SPI TFT (SD card reader not used) controller ST7735S
// Example in the Adafruit ST7735 and ST7789 library
// pin assignment
// NODEMCU ESP32 ============================= 128160 SPI TFT ECRÃ LCD
// 3V --------------------------------------------------- VCC
// GND --------------------------------------------------- GND
// GPIO5 VSPI SS (Slave Select/ Chip Select) ------------ CS
// GPIO4 ------------------------------------------------ RESET
// GPIO2 (labelled as DC in Adafruit code) -------------- A0
// GPIO23 VSPI MOSI (MOSI, Data to Screen) -------------- SDA
// GPIO18 VSPI SCK (SPI Clock) -------------------------- SCK
// 3V --------------------------------------------------- LED
//Programa: WifiManager com e ESP32
//Autor: Arduino e Cia
#include <WiFi.h>
#include <WebServer.h>
#include <DNSServer.h>
#include <WiFiManager.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <SPI.h>
#define TFT_DC 2 // register select (stands for Data Control perhaps!)
#define TFT_RST 15 // Display reset pin, you can also connect this to the ESP32 reset
// in which case, set this #define pin to -1!
#define TFT_CS 5 // Display enable (Chip select), if not enabled will not talk on SPI bus
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
void resettft() {
tft.fillScreen(ST77XX_BLACK);
}
//Define o pino para reset das definicoes de wifi
int pino_reset = 4;
// Array of cryptocurrencies you want to track
const char* cryptoSymbols[] = {
"bitcoin",
"ethereum",
// "cardano",
// "cardano",
};
// Number of cryptocurrencies in the array
const int numCryptoSymbols = sizeof(cryptoSymbols) / sizeof(cryptoSymbols[0]);
void readPriceBR(int x, int y, const String& Acao) {
String httpRequestAddress = "https://felipemarinho.vercel.app/api/b3/prices/" + Acao;
// https://felipemarinho.vercel.app/api/b3/prices/petr3 Site onde encontrei o link: https://gist.github.com/ThiagoAnunciacao/cc54b806d4a10bf3408f?permalink_comment_id=4198272
HTTPClient http;
int httpCode;
http.begin(httpRequestAddress);
httpCode = http.GET();
if (httpCode > 0) {
DynamicJsonDocument doc(1024);
String payload = http.getString();
Serial.println(payload);
deserializeJson(doc, payload);
// float currentsymbol = doc["symbol"];
// float currentname = doc["name"];
// float currentopeningPrice = doc["openingPrice"];
// float currentminPrice = doc["minPrice"];
// float currentmaxPrice = doc["maxPrice"];
// float currentaveragePrice = doc["averagePrice"];
float Price = doc["currentPrice"];
float Variation = doc["priceVariation"];
} else {
}
}
void readPriceUSA(int x, int y, const String& stockName) {
String httpRequestAddress = "https://finnhub.io/api/v1/quote?symbol=" + stockName + "&token=cmgs2lpr01qilgs0uohgcmgs2lpr01qilgs0uoi0";
HTTPClient http;
int httpCode;
http.begin(httpRequestAddress);
httpCode = http.GET();
if (httpCode > 0) {
DynamicJsonDocument doc(1024);
String payload = http.getString();
Serial.println(payload);
deserializeJson(doc, payload);
} else {
}
http.end();
}
void setup() {
// Start Serial for debugging
Serial.begin(115200);
delay(10);
tft.initR(INITR_BLACKTAB); // Init ST7735S chip, black tab
pinMode(pino_reset, INPUT);
WiFiManager wifiManager;
wifiManager.setConfigPortalTimeout(240);
//Cria um AP (Access Point) com: ("nome da rede", "senha da rede")
if (!wifiManager.autoConnect("Cotação", "12345678")) {
Serial.println(F("Falha na conexao. Resetar e tentar novamente..."));
delay(3000);
ESP.restart();
delay(5000);
}
//Mensagem caso conexao Ok
Serial.println(F("Conectado na rede Wifi."));
Serial.print(F("Endereco IP: "));
Serial.println(WiFi.localIP());
tft.setTextWrap(false);
tft.fillScreen(ST77XX_BLACK);
tft.setCursor(0, 0);
tft.setTextColor(ST77XX_YELLOW);
tft.setTextSize(1,2);
tft.println("Conectado WI-FI");
tft.println(WiFi.localIP());
tft.println(WiFi.SSID());
delay (2000);
}
void loop() {
//Verifica se o botao foi pressionado
int valor = digitalRead(pino_reset);
if (valor == 1) {
//Apaga os dados da rede wifi gravados na memoria e reinicia o ESP
WiFiManager wifiManager;
wifiManager.resetSettings();
Serial.println("Configuracoes zeradas!");
ESP.restart();
}
// Loop through all the cryptocurrencies
for (int i = 0; i < numCryptoSymbols; i++) {
}
}
float getCryptoPrice(const char* cryptoSymbol) {
String url = "https://api.coingecko.com/api/v3/simple/price";
url += "?ids=";
url += cryptoSymbol;
url += "&vs_currencies=usd";
HTTPClient http;
http.begin(url);
int httpResponseCode = http.GET();
float price = 0;
if (httpResponseCode == 200) {
String payload = http.getString();
const size_t capacity = JSON_OBJECT_SIZE(1) + JSON_OBJECT_SIZE(1) + 20;
DynamicJsonDocument doc(capacity);
deserializeJson(doc, payload);
price = doc[cryptoSymbol]["usd"].as();
}
readPriceBR(0, 0, "B3SA3");
delay(10000);
readPriceBR(0, 0, "CMIG4");
delay(10000);
readPriceUSA(0, 0, "AGNC");
delay(10000);
readPriceUSA(0, 0, "BXMT");
delay(10000);
return price;
}
Pelo que entendi, teria como colocar um comando para que o site achei que é Android ou windows, pois neste caso acho que funciona , pois ao link abre e diz verificar o sistema operacional.