def download_csv_cn(instrument, frequency=None): match = re.match('6', instrument) if match: url = "http://table.finance.yahoo.com/table.csv?s=%s.ss" % (instrument) else: url = "http://table.finance.yahoo.com/table.csv?s=%s.sz" % (instrument) return csvutils.download_csv(url)
def download_csv(instrument, begin, end): url = "http://www.google.com/finance/historical" params = { "q": instrument, "startdate": begin.strftime("%Y-%m-%d"), "enddate": end.strftime("%Y-%m-%d"), "output": "csv", } return csvutils.download_csv(url, url_params=params, content_type="application/vnd.ms-excel")
def download_csv(sourceCode, tableCode, begin, end, frequency, authToken): url = "http://www.quandl.com/api/v1/datasets/%s/%s.csv" % (sourceCode, tableCode) params = { "trim_start": begin.strftime("%Y-%m-%d"), "trim_end": end.strftime("%Y-%m-%d"), "collapse": frequency } if authToken is not None: params["auth_token"] = authToken return csvutils.download_csv(url, params)
def download_csv(instrument, begin, end, frequency): url = "http://ichart.finance.yahoo.com/table.csv?s=%s&a=%d&b=%d&c=%d&d=%d&e=%d&f=%d&g=%s&ignore=.csv" % (instrument, __adjust_month(begin.month), begin.day, begin.year, __adjust_month(end.month), end.day, end.year, frequency) return csvutils.download_csv(url)