Esempio n. 1
0
def importing():
	exchange = 'sz'
	f = open('/home/appleface/ashare/%s.txt'%exchange,'r')
	for i in f.readlines():
		print str(i.strip())
		s = ASharesCode.new()
		try:
			s.code = str(i.strip())
			s.exchange = exchange
			s.save()
		except Exception,e: 
			print i
			logging.error('%s\n',str(e),exc_info=True)
Esempio n. 2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import urllib2

sys.path.append(os.path.dirname(os.path.split(os.path.realpath(__file__))[0]))

from model.system import ASharesCode

res = ASharesCode.mgr().get_all_codes()

#http://table.finance.yahoo.com/table.csv?s=000001.sz

for i in res:
    if int(i.code) <= 512120:
        continue
    if i.exchange != 'sh':
        continue
    else:
        i.exchange = 'ss'
    url = "http://table.finance.yahoo.com/table.csv?s=%s.%s" % (str(
        i.code), str(i.exchange))
    try:
        print "downloading... %s" % url
        f = urllib2.urlopen(url, timeout=5)
        data = f.read()
        filename = "/home/appleface/ashare/tools/data/table%s.%s" % (str(
            i.code), str(i.exchange))
        with open(filename, 'wb') as res:
Esempio n. 3
0
import os
import sys 
import urllib2

sys.path.append(os.path.dirname(os.path.split(os.path.realpath(__file__))[0]))

from model.system import ASharesCodeReal,ASharesCode

def download_data(code,exchange):
	url = "http://table.finance.yahoo.com/table.csv?s=%s.%s" % (code,exchange)
	try:
		print "downloading... %s" % url
		f = urllib2.urlopen(url,timeout=15)
		data = f.read()
		filename = "/home/appleface/ashare/tools/otherdata/table%s.%s" % (code,exchange)
		with open(filename,'wb') as res:
			res.write(data)
	except Exception, e:
		print "error",url
		print e

if __name__ == '__main__':
	q = ASharesCode.mgr().get_all_unreal_code()
	for i in q:
		if str(i['exchange']) == 'sh':
			i['exchange'] = 'ss'
		download_data(str(i['code']),str(i['exchange']))


Esempio n. 4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*- 

import os
import sys 

sys.path.append(os.path.dirname(os.path.split(os.path.realpath(__file__))[0]))

from model.system import ASharesCode

res = ASharesCode.mgr().get_all_codes()

#http://table.finance.yahoo.com/table.csv?s=000001.sz

for i in res:
	if i.exchange != 'sh':
		continue
	else:
		i.exchange = 'ss'
	url = "http://table.finance.yahoo.com/table.csv?s=%s.%s" % (str(i.code),str(i.exchange))
	os.system("wget %s"%url)