HI, I recently looked at sneekula's ticker code, and I was wondering about any good graph extras, to show it in a simpler form, also any tutorials if at all possible, thanks in advance

# find the stock trading value for a given ticker symbol
# tested with Python25

import urllib2

def extract(text, sub1, sub2):
    """
    extract a substring from text between first
    occurances of substrings sub1 and sub2
    """
    return text.split(sub1, 1)[-1].split(sub2, 1)[0]


ticker = 'GE'
url = 'http://finance.yahoo.com/q?s='+ticker
fh = urllib2.urlopen(url)
ticker_html = fh.read()
a=0
#most accurate (I played around with the code)
while a<=100:
    for line in ticker_html.split('><'):
        if 'id="yfs_l10_' in line:
            print(extract(line, '>', '<'))
    a+=1

Oh, and do you know of a quicker way to get the information?

I haven't tested but Matlab is said to be best pythonic graphing of complex plots. Not sure because haven't used it. There are examples in matlab homepage. Test them and see if it suits you!

This article has been dead for over six months. Start a new discussion instead.