Member Avatar for leegeorg07

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

Recommended Answers

All 6 Replies

Help, I can't find my Ticker code!

Member Avatar for leegeorg07
# 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?

You mean you want to graph stock values?

Member Avatar for leegeorg07

yeah, I was looking at matplotlib, do you think it will work?

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!

Member Avatar for leegeorg07

Ok, will do, once my bro stops downloading crap :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.