Python Stock Graphing (No Values)

Posted on at

Well, it took me about five hours to get this operational. But after a great amount of research and testing, I finally did it. In all of it's annoying glory, here it is:#

from turtle import *
import urllib2
import xml.etree.ElementTree as ET
from random import randint
import time
import math
import os

#Written by Eric DiGioachino (cpunation)

def GET_STOCKS(sym, n):
   ida = []
   for i in range(0,n):
   idb = "".join(ida)
   idn = idb      #yes this is needed, it makes sure that the join has been processed
   def BD(data):
      fo = open("stcks.xml", "w+")
      tree = ET.parse("stcks.xml")
      root = tree.getroot()
      item = root.find('Change')
      att = item.text
      return att
   urls = "" + sym + "&callback=" + idn
   resp = urllib2.urlopen(urls, timeout = 1)
   data =
   print BD(data)
   return BD(data)

j = 0
while True:
   time.sleep(30)       #this limits time in between requests, it makes sure that the server doesn't spit you out for quick request times
   inc = float(GET_STOCKS("AAPL", 8))
   goto(j, (inc * 10))
   j += 1


About the author