Manufactura industrial
Internet industrial de las cosas | Materiales industriales | Mantenimiento y reparación de equipos | Programación industrial |
home  MfgRobots >> Manufactura industrial >  >> Manufacturing Technology >> Proceso de manufactura

Ticker Bursátil en Tiempo Real con Arduino y Python – Yahoo Finance API

Componentes y Suministros

Herramientas

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

  1. La Evolución, Materiales y Fabricación de los Inodoros Modernos
  2. Revólver: De sus Orígenes a la Fabricación Moderna
  3. Construye un Spybot controlado por Bluetooth con Arduino
  4. FlickMote: Mando IR por gestos para Smart Home
  5. TV‑B‑Gone DIY con Arduino: Mando universal para apagar cualquier TV
  6. Construye un Reloj Maestro LED Personalizado con Alarma – Visible desde 12 Metros
  7. Find Me: Localizador Inteligente de Objetos con Arduino y Bluetooth
  8. Soluciones de Alimentación Optimizadas para Proyectos Arduino
  9. Tres en raya con Arduino, matriz LED MAX7219 y carcasa de cartón
  10. Construye un Robot Cuadrúpedo Inteligente con Arduino: Guía Paso a Paso
  11. Construye un volante joystick personalizado con Arduino para gaming