Skip to content

Instantly share code, notes, and snippets.

@windbg
Created February 11, 2012 01:53
Show Gist options
  • Save windbg/1795198 to your computer and use it in GitHub Desktop.
Save windbg/1795198 to your computer and use it in GitHub Desktop.
example of providers/yahoo
#!/usr/bin/env python
#coding=utf-8
import datetime
import os
import sys
from tornado.curl_httpclient import CurlAsyncHTTPClient as AsyncHTTPClient
from tornado import ioloop
ROOT_PATH = os.path.join(os.path.realpath(os.path.dirname(__file__)), '..')
sys.path[0:0] = [ROOT_PATH]
from datafeed.exchange import *
from datafeed.providers.yahoo import *
def main():
f = YahooDayFetcher()
s1 = YahooSecurity(SZ(), '000001')
s2 = YahooSecurity(SZ(), '000725')
def call_back(security, body):
iters = YahooDay.parse(security, body)
for ohlc in iters:
print ohlc.open
start_date = datetime.datetime.strptime('2011-01-03', '%Y-%m-%d').date()
end_date = datetime.datetime.strptime('2011-02-10', '%Y-%m-%d').date()
print dir(f)
f.fetch(s1,callback=call_back,start_date=start_date,end_date=end_date)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment