Print

Print


here is the code if you don't want to download.
Again, how can we dump the data of interest to a text doc?




var = 1
while var == 1 :
 #FileNameOut = 'stock.txt'
 #OutputFile = open(FileNameOut, 'w')

 import json
 import requests
 import time

 tick = ['GOOG','AAPL','MSFT']
 goog = tick[0]
 aapl = tick[1]
 msft = tick[2]

###################Google
 google = requests.get('
https://finance.google.com/finance?output=json&q='+tick[0])
 tick[0] = google.text.lstrip()[2:]

 quote = json.loads(tick[0])

 ##doc = json.dumps(tick[0])
##OutputFile = open(stock.txt, 'w')
 if google.status_code in (200,):
     google_data = json.loads(google.content[6:-2].decode('unicode_escape'))

    # print out some quote data
 print (goog)
 print('Opening Price: {}'.format(google_data['op']))
#print('Price/Earnings Ratio: {}'.format(google_data['pe']))
#print('52-week high: {}'.format(google_data['hi52']))
#print('52-week low: {}'.format(google_data['lo52']))
 time.sleep(.2)
##################Apple
 apple = requests.get('
https://finance.google.com/finance?output=json&q='+tick[1])
 tick[1] = apple.text.lstrip()[2:]
 quote = json.loads(tick[1])

 if apple.status_code in (200,):
     apple_data = json.loads(apple.content[6:-2].decode('unicode_escape'))

    # print out some quote data
 print(aapl)
 print('Opening Price: {}'.format(apple_data['op']))
#print('Price/Earnings Ratio: {}'.format(apple_data['pe']))
#print('52-week high: {}'.format(apple_data['hi52']))
#print('52-week low: {}'.format(apple_data['lo52']))
 time.sleep(.2)

###################Microsoft
 micro = requests.get('
https://finance.google.com/finance?output=json&q='+tick[2])
 tick[2] = micro.text.lstrip()[2:]
 quote = json.loads(tick[2])

 if micro.status_code in (200,):
     micro_data = json.loads(micro.content[6:-2].decode('unicode_escape'))

    # print out some quote data
 print(msft)
 print('Opening Price: {}'.format(micro_data['op']))
#print('Price/Earnings Ratio: {}'.format(apple_data['pe']))
#print('52-week high: {}'.format(apple_data['hi52']))
#print('52-week low: {}'.format(apple_data['lo52']))
 time.sleep(.2)



On Wed, Dec 20, 2017 at 11:00 AM Michael Norkun <[log in to unmask]>
wrote:

> I discovered that there is a command that "wakes" the sign. In Win95 when
> the GUI program starts it runs that command. I had to send it with stty to
> trigger the sign to WAKE UP and LISTEN! Kind of what we need to do with
> students : )
>
> We can now talk to the sign through linux, next step is fixing my python
> stock ticker code to dump the info into a text document in the format that
> the sign likes.
>
> So part II of my question here is my python script to grab a few stock
> quotes.
> It's a clunky script that needs some cleaning, and some way to dump the
> data to a text file...that's where I'm stuck now.
> The attached script has been modified by many students, again, it needs
> some consolidation, but it works as is.
> Anyone know how to use json.dumps to push the data of interest to a text
> doc, and append the appropriate text/code the sign likes?
>
> We can push a .txt to the sign if the format holds the code to "do
> something."
>
> So, now python help!
>
>
>
> On Wed, Dec 20, 2017 at 10:46 AM Steve Ligett <[log in to unmask]>
> wrote:
>
>> More random thoughts - If you can run it from a Win95 machine (i.e. if
>> you have *something* that will run it well), well, we used to use breakout
>> boxes and feed both sides to another computer to have a complete log to
>> find undocumented info on how things *really* worked.
>>
>> good luck.
>>
>>
>> On Mon, Dec 18, 2017 at 1:36 PM, Steve Ligett <[log in to unmask]>
>> wrote:
>>
>>> Michael - It's been a loong time since I've done anything with serial
>>> ports. (Ah, the days of programming software uarts.) Can you set the speed
>>> the display takes? Maybe handshake is failing, and going slower could help?
>>>
>>> good luck,
>>> steve
>>>
>>> On Wed, Dec 13, 2017 at 5:11 PM, Michael Norkun <
>>> [log in to unmask]> wrote:
>>>
>>>> Hey all, I need some help / ideas.
>>>>
>>>> We have a really old pro-lite led sign that has been great at
>>>> collecting dust on the wall. A math teacher wants to turn it into a stock
>>>> ticker. I was like yeah yeah, let's rig it to a raspberry pi. Here lies the
>>>> problem. There is a serial port built into the sign to allow communication
>>>> through a PC running win95.   : )
>>>> I had a serial to USB adapter that allowed me to connect to Linux. Here
>>>> is where it gets tricky, I can connect and sometimes send text for it to
>>>> scroll using dosbox.  However, it's super clunky win95 software and only
>>>> works sometimes.
>>>> We want to directly communicate from Linux to the pro-lite.  We want
>>>> the pi to pull stocks in real time, which is easy, but sending that data to
>>>> the sign isn't so easy.
>>>> The plan is to use mop to get the ticker fees, push it to a .txt with
>>>> the right codes that the pro-lite likes in front of text...<ID01><PA> stock
>>>> ticker text....<E><EOT>, again which a simple bash script will do. But
>>>> sending that file is the issue. The machines aren't talking very well.
>>>>
>>>> So, long way around, does anyone have any ideas how to make this thing
>>>> work? Anyone have any experience with sending info through serial ports via
>>>> Linux? Anyone know how I can simply bypass the pro-lite motherboard and
>>>> just hack the led display ?
>>>>
>>>> In Linux the serial port is talking through /dev/ttyUSB0. I've used
>>>> this site for help but it has been no help...
>>>> http://www.instructables.com/id/Communicating-with-a-Pro-Lite-LED-Display-Cable-C/
>>>>
>>>> Thanks in advance, I'm all ears.
>>>>
>>>> --
>>>> Mike Norkun
>>>> Science Teacher / Science Coordinator
>>>> Bellows Falls Union High School
>>>>
>>>> *"Nature does not hurry, yet everything is accomplished."*
>>>>
>>>> -----------------------------------------------------------------------
>>>>
>>>> Search <http://list.uvm.edu/archives/school-it.html> the SCHOOL-IT
>>>> Archive
>>>>
>>>> Manage <http://list.uvm.edu/cgi-bin/wa?SUBED1=SCHOOL-IT&A=1> your
>>>> Subscription to SCHOOL-IT
>>>>
>>>
>>>
>> -----------------------------------------------------------------------
>>
>> Search <http://list.uvm.edu/archives/school-it.html> the SCHOOL-IT
>> Archive
>>
>> Manage <http://list.uvm.edu/cgi-bin/wa?SUBED1=SCHOOL-IT&A=1> your
>> Subscription to SCHOOL-IT
>>
> --
> Mike Norkun
> Science Teacher / Science Coordinator
> Bellows Falls Union High School
>
> *"Nature does not hurry, yet everything is accomplished."*
>
-- 
Mike Norkun
Science Teacher / Science Coordinator
Bellows Falls Union High School

*"Nature does not hurry, yet everything is accomplished."*