Ticker Bursátil en Tiempo Real con Arduino y Python – Yahoo Finance API
Componentes y Suministros
- Pantalla LCD 16x2 Blanco sobre Azul (Adafruit) × 1
- Arduino Mega 2560 × 1
- Cables Jumper Macho/Hembra × 12
- Cables Jumper Macho/Macho × 5
Herramientas
- Impresora 3D (opcional, para carcasa LCD – Thingiverse)
Sobre el Proyecto
Muestra precios de apertura y actuales de una lista de acciones en un LCD 16x2, actualizándose cada ~10 segundos. Python (2.7) en PC obtiene datos vía yahoo_finance y los envía por serie al Arduino.
Requisitos Python
pip install yahoo_finance pyserial
Edita el puerto serie en ser = serial.Serial('COM1', 9600).
Código
Lado Python
from yahoo_finance import Share
import time, serial
StockShares = ['DOW','YHOO','BAC','F','JPM','TWTR','CHK','PBR','FIT','COG',
'ABX','FCX','GE','TRGP','CNX','BSX','MRC','NKE','NEM','PBRA',
'HST','BP','MRK','HON','MET','CLR','WPX','EXC','JCP','YELP',
'GNC','TSLA','VRX','P','NFLX','CMG','SM','WYNN','SHAK','ICON']
ser = serial.Serial('COM1', 9600)
def printShare(share, name):
msg = name + ': *' + share.get_open() + ',' + share.get_price()
ser.write(msg.encode())
print(msg)
time.sleep(0.1)
def mainProgram():
for name in StockShares:
s = Share(name)
printShare(s, name)
s.refresh()
time.sleep(9.5)
while True:
mainProgram()
Lado Arduino
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
String symbol; float openPrice, currentPrice;
void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
delay(1000);
}
void loop() {
if (Serial.available() > 0) {
symbol = Serial.readStringUntil('*');
openPrice = Serial.parseFloat();
currentPrice = Serial.parseFloat();
}
lcd.clear(); lcd.setCursor(0,0);
lcd.print(symbol + " open:" + String(openPrice));
lcd.setCursor(0,1);
lcd.print("current:" + String(currentPrice));
delay(2000);
// Scroll
for (int i=0; i<17; i++) { lcd.scrollDisplayLeft(); delay(200); }
delay(500);
lcd.clear(); lcd.setCursor(0,0);
lcd.print("change: " + String(currentPrice - openPrice));
delay(2000);
for (int i=0; i<17; i++) { lcd.scrollDisplayLeft(); delay(200); }
lcd.clear();
}
Esquemático
Conexión estándar LCD 16x2 (RS, E, D4-D7 a pines 12,11,5,4,3,2). Ver imagen en proyecto.
Proceso de manufactura
- La Evolución, Materiales y Fabricación de los Inodoros Modernos
- Revólver: De sus Orígenes a la Fabricación Moderna
- Construye un Spybot controlado por Bluetooth con Arduino
- FlickMote: Mando IR por gestos para Smart Home
- TV‑B‑Gone DIY con Arduino: Mando universal para apagar cualquier TV
- Construye un Reloj Maestro LED Personalizado con Alarma – Visible desde 12 Metros
- Find Me: Localizador Inteligente de Objetos con Arduino y Bluetooth
- Soluciones de Alimentación Optimizadas para Proyectos Arduino
- Tres en raya con Arduino, matriz LED MAX7219 y carcasa de cartón
- Construye un Robot Cuadrúpedo Inteligente con Arduino: Guía Paso a Paso
- Construye un volante joystick personalizado con Arduino para gaming