Blog2

Blog2

[ Life is either a daring adventure or nothing! Helen Keller]

Blog2 RSS Feed
 
 
 
 

Stock Historical Data

In my DB project I want to design a site for stock mining. First thing I did is writing a bot for downloading all stock historical data  in Python. I really like Python it makes my life a lot easier and more effective. Unless I don’t feel I’m really live effectively!

Here is code:

import urllib2

f=open(’cusip.txt’, ‘r’)

tickers = []
for line in f:
tickers.append(line.split(’,')[0])
for t in tickers:
# Open the URL
try:
rows=urllib2.urlopen(’http://ichart.finance.yahoo.com/table.csv?’+\
’s=%s&d=09&e=05&f=2008&g=d&a=3&b=12&c=1997′%t +\
‘&ignore=.csv’).read()
t = open(t+’.csv’,'w’)
t.write(rows)
t.close()

except IOError:
errors = [t]
errf = open(’bad_trickers.txt’,'w’)
errf.write(str(errors))
errf.close()
f.close()
print errors

Click here to download!

23 Responses to “Stock Historical Data”

  1. 1
    incikaniideah:

    After rain comes fair weather ;)

  2. 2
    TiPkekquien:

    Last night I was having dinner with Charles Manson, and in the middle of dinner he turned to me and said “Is it hot in here, or am I crazy?” (Gilbert Gottfried) ;)

  3. 3
    alex:

    Add to my Bookmarks ;)

  4. 4
    EmobreObserce:

    blog.digvan.com - great domain name for blog like this)))
    ————————
    ad: http://qugor.ru

  5. 5
    Meewmette:

    blog.digvan.com - cool sitename man)))
    ————————
    internet signature: http://youraudiovox.com/music13/map.html

  6. 6
    Moffhovarve:

    blog.digvan.com - cooooolest domain name)))
    ————————
    internet signature: http://lilid.ru/

  7. 7
    Moffhovarve:

    blog.digvan.com - cool sitename man)))
    ————————
    ads: http://lilid.ru/

  8. 8
    Valaweers:

    Hello, I can’t understand how to add your blog ( blog.digvan.com ) in my rss reader
    ————————
    signature: http://zehon.ru/

  9. 9
    Valaweers:

    blog.digvan.com - great domain name for blog like this)))
    ————————
    sponsored link: http://zehon.ru/

  10. 10
    Irrannoma:

    blog.digvan.com - now in my rss reader)))
    ————————
    sponsor: http://vahar.ru/

  11. 11
    TactAccib:

    Hello, I can’t understand how to add your blog ( blog.digvan.com ) in my rss reader
    ————————
    internet signature: http://cexiq.ru/

  12. 12
    SeeniInvajere:

    blog.digvan.com - cool sitename man)))
    ————————
    my blog: http://hixoh.ru/

  13. 13
    SeeniInvajere:

    blog.digvan.com - great domain name for blog like this)))
    ————————
    ads: http://hixoh.ru/

  14. 14
    Tamiflu:

    Great site, Good info

  15. 15
    viagra:

    Very interesting site, Hope it will always be alive!

  16. 16
    AndrewBoldman:

    I really liked this post. Can I copy it to my site? Thank you in advance.

  17. 17
    Kelly Brown:

    Great post! I’ll subscribe right now wth my feedreader software!

  18. 18
    JaneRadriges:

    Hi, gr8 post thanks for posting. Information is useful!

  19. 19
    KattyBlackyard:

    Hi, very nice post. I have been wonder’n bout this issue,so thanks for posting

  20. 20
    GarykPatton:

    You know so many interesting infomation. You might be very wise. I like such people. Don’t top writing.

  21. 21
    vision:

    I bookmarked this link. Thank you for good job

  22. 22
    nfaze:

    Thanks!!

  23. 23
    south:

    Thank you lol I’ve been searching for this everywhere >_<

Leave a Reply