Hackster is hosting Impact Spotlights: Industrial Automation. Watch the stream live on Thursday!Hackster is hosting Impact Spotlights: Industrial Automation. Stream on Thursday!
Onion
Published © GPL3+

Onion Omega Stock Ticker

In this guide, we will use the Omega to retrieve and display stock prices.

BeginnerProtip15 minutes1,097
Onion Omega Stock Ticker

Things used in this project

Hardware components

Omega2
Onion Corporation Omega2
×1

Story

Read more

Code

Shell Script

SH
Shell Script for Stock Ticker
#!/bin/sh
oled-exp -c
echo $1 > /root/ticker.txt
VAR=$(python ./stock_script.py)
oled-exp -i  oled-exp write $VAR

Python Script

Python
Python Script for Stock Ticker
#!/usr/bin/env python

import urllib
import json

myfile = open('/root/ticker.txt', 'r')

rg=myfile.read()

site="http://www.google.com/finance/info?q="+rg

jfile=urllib.urlopen(site)

jsfile=jfile.read()

jsfile=jsfile.replace("\n","")
jsfile=jsfile.replace("/","")
jsfile=jsfile.replace("]","")
jsfile=jsfile.replace("[","")

a=json.loads(jsfile)

ticker=a['t']
price=a['l_fix']
info=ticker+":"+price

print info

Credits

Onion
8 projects • 19 followers
The Invention Platform for the Internet of Things
Contact

Comments

Please log in or sign up to comment.