Beispiel #1
0
def getClosePrice(stock_code, stock_date):
	#print stock_code, stock_date
	stock_code = str(stock_code)
	has_dot = stock_code.rfind('.')
	if has_dot != -1:
		stock_code = stock_code[:has_dot]

	p = getGC001Price(stock_code)
	if p != -1:
		#print 'xx'
		return p

	p = QuoteCache.get_xianjin_fund_price(stock_code, stock_date)
	if p != -1:
		return p

	p = QuoteCache.get_new_stock_price(stock_code, stock_date)
	if p != -1:
		return p

	p = QuoteCache.get_missing_stock_price(stock_code, stock_date)
	if p != -1:
		return p

	stock_code1 = stock_code
	if stock_code.startswith('127'):
		stock_code1 = get_sh_sz(stock_code)
	key = stock_code1 + '{:.0f}'.format(int(stock_date))

	row = QuoteCache.get(key)
	if row != None:
		return row[0]

	url = composeUrl(stock_code, stock_date)
	close = 0
	(status_code, status_str, result) = querySina(url)
	if status_code == 0:
		if status_str == u'成功':
			close = float( result[u'result'][u'data'][u'data'][0][u'close'] )
		elif status_str == u'无相关数据':
			close = 0
		else:
			close = -1
	else:
		close = -1

	QuoteCache.insert(key, close)
	return close
Beispiel #2
0
def getNewStockName(stock_code):
	row = QuoteCache.get_new_stock_name(stock_code)
	if row != None:
		return row[0]
	else:
		return ''
Beispiel #3
0
def getNewStockCode(shengou_code):
	row = QuoteCache.get_new_stock_code(shengou_code)
	if row != None:
		return row[0]
	else:
		return ''