Exemple #1
0
def get_hist_quotes(stock_id):
	dc['url_params']['stock_id'] = stock_id
	last_quote = ysk.yh_stock_api_get(dh)
	t = {}
	t['aaData'] = last_quote['values']
	t['aoColumns'] = last_quote['header']
	#t['aaData'] = [["q","b","c"]]
	return jsonify(t)
Exemple #2
0
def js_plot_t(stock_id):
	interval = request.args['interval']
	mvs = request.args['mvs']
	from_y = request.args['from_y']
	mvs = mvs.split('-')
	dh['url_params']['stock_id']=stock_id
	dh['url_params']['interval']=interval
	dh['url_params']['from_y']=from_y
	rd = ysk.yh_stock_api_get(dh)
	l = []
	j = {}
	for item in rd['values']:
		tl = []
		item_s = item[0].split('-')
		tm = calendar.timegm((int(item_s[0]),int(item_s[1]),int(item_s[2]),0,0,0,0,0))*1000
		tl.append(tm)
		tl.append(float(item[4]))
		l.append(tl)
		tl = []
	j['stock'] = {'label':stock_id,'data':l}
	del l
	n = 0
	acc = 0
	sort_order = ['stock']
	if int(mvs[0]) != 0:
		for m in mvs:
			m = int(m)
			l = []
			for item in rd['values']:
				tl = []
				n+=1
				if n<=m:
					acc+=float(item[4])
				if n == m:
					item_s = item[0].split('-')
					tm = calendar.timegm((int(item_s[0]),int(item_s[1]),int(item_s[2]),0,0,0,0,0))*1000
					tl.append(tm)
					tl.append(acc/m)
					l.append(tl)
					n=0
					acc=0
			m_nm = 'lm'+str(m)
			sort_order.append(m_nm)
			j['lm'+str(m)] = {'label':m_nm, 'data':l}
	j['sort_order'] = sort_order
	return jsonify(j)