Wednesday, April 29, 2015
Getting stock price and exchange rate from Yahoo by Python
#download.py gets stock and exchange rates from Yahoo and then saves the data as a csv file in local drive.
#You may change the url and the filepath if necessary.
#Author: David Tsang 28 APR 2015
import urllib
#historical data
def downloadFile(symbol, filename):
url = "http://real-chart.finance.yahoo.com/table.csv?s=" + symbol
directory = "C:\\Python27\\Lib\\site-packages\\QSTK\\QSData\\Yahoo\\"
print "Downloading " + symbol
filepath = directory + filename + ".csv"
urllib.urlretrieve (url, filepath)
print "- Completed"
#latest quote
def quote(symbol, filepath):
url = "http://download.finance.yahoo.com/d/quotes.csv?s=" + symbol + "&f=sl1d1t1c1ohgv&e=.csv"
#print "Downloading " + symbol
urllib.urlretrieve (url, filepath)
#exchange rate
def exchrate(symbol, filepath):
url = "http://download.finance.yahoo.com/d/quotes.csv?s=" + symbol +"=X&f=sl1d1t1c1ohgv&e=.csv"
print "Downloading " + symbol
urllib.urlretrieve (url, filepath)
Subscribe to:
Post Comments (Atom)
Applying SMA10/20, SMA20/50 as trading signals
This is the comparison for results before and after applying SMA10/20 and SMA20/50 in the stock trader. Background Trading 3 stock ma...
-
Snes9X is one of the best Android SNES emulators ever made. It is free, no ads, highly customisable. It helps bringing back tons of go...
-
I struggled with the error "The mobile device interface cannot be opened because either the display settings are not configured or the...
-
Background As a seasonal stock trader, it has been a dream for me to have a stock info system suggesting order price. Traditional tec...
No comments:
Post a Comment