当前位置: 首页>>代码示例>>Python>>正文


Python Histogram.report方法代码示例

本文整理汇总了Python中histogram.Histogram.report方法的典型用法代码示例。如果您正苦于以下问题:Python Histogram.report方法的具体用法?Python Histogram.report怎么用?Python Histogram.report使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在histogram.Histogram的用法示例。


在下文中一共展示了Histogram.report方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from histogram import Histogram [as 别名]
# 或者: from histogram.Histogram import report [as 别名]
	def __init__(self, dates, open, high, low, close, vol, start, end):
		
		if start > end:
			(start, end) = (end, start)
		
		self.report_log = []    
		
		max = None
		max_date = None
		min = None
		min_date = None
		
		seq_start = dates[0]
		seq_end = dates[0]
		
		series = []
		
		n = 0
	 
		for i in range(len(dates)):    
		 
			d = dates[i]
			if (d > start) and (d < end):      
				
				series.append(close[i])
				
				if (d < seq_start):
					seq_start = d
				if (d > seq_end):
					seq_end = d

				n = n + 1 
				
				h = high[i]
				if max == None:
					max = h
					max_date = d
				else:
					if h > max:
						max = h
						max_date = d
						
				l = low[i]
				if min == None:
					min = l
					min_date = d
				else:
					if l < min:
						min = l
						min_date = d
		
		self.report_log.append('%s - %s' % (seq_start, seq_end))
		self.report_log.append('%d trading days' % n)
		self.report_log.append('Max = %s - %s' % (str(max), max_date))
		self.report_log.append('Min = %s - %s' % (str(min), min_date))
		
		h = Histogram(series)
		for l in h.report():
			self.report_log.append(l)
开发者ID:davidbarkhuizen,项目名称:dart,代码行数:61,代码来源:OHLCVAnalysis.py

示例2: gen_intraday_volatility_plots

# 需要导入模块: from histogram import Histogram [as 别名]
# 或者: from histogram.Histogram import report [as 别名]
def gen_intraday_volatility_plots(symbol, dates, high, low, close, start_date, end_date, gen_title) :

	(start_idx, end_idx) = get_start_end_idxs(dates, start_date, end_date)
		
	# cut slice
	date_slice = dates[start_idx : end_idx]
	slice_start_date = dates[start_idx]
	slice_end_date = dates[end_idx]
	low_slice = low[start_idx : end_idx]
	high_slice = high[start_idx : end_idx]
	close_slice = close[start_idx : end_idx]
	
	delta = []
	for i in range(len(high_slice)):
		delta.append(float(100 * (high_slice[i] - low_slice[i]) / close_slice[i]) )
	
	# generate matplotlib plot
	x = np.array(date_slice)
	y = np.array(delta)
	fever_fig = plt.figure()
	ax = fever_fig.add_subplot(111)
	ax.plot(x,y)
	# leg = ax.legend(('Model length'), 'upper center', shadow=True)
	
	ax.grid(False)  
	ax.set_ylabel('100 * (High - Low) / Close')

	title = gen_title(symbol, 'Intra-Day Range as a Percentage of Closing Price', slice_start_date, slice_end_date)
	ax.set_title(title)

	# date intervals & markers
	(formatter, locator) = tick_info(slice_start_date, slice_end_date)
	ax.xaxis.set_major_formatter(formatter) 
	ax.xaxis.set_major_locator(locator)
	fever_fig.autofmt_xdate(rotation=90)
	ax.set_xlim([slice_start_date, slice_end_date])
	ax.set_xlabel('Date')
	
	# ------------
	
	h = Histogram(delta)
	left_edge = []
	height = []
	for bin in h.bins:
		left_edge.append(float(bin.floor))
		height.append(h.bin_contrib_perc(bin))
	
	x = np.array(left_edge)
	y = np.array(height)
	
	dist_fig = plt.figure()
	ax = dist_fig.add_subplot(111)
	ax.bar(x, y, width=h.bins[0].range)
	
	ax.set_xlim(h.min, h.max)
	ax.set_ylabel('% of Population')
	ax.set_xlabel('Intra-Day Range i.t.o Close : 100 * (High - Low) / Close')

	title = gen_title(symbol, 'Distribution of Intra-Day Range', slice_start_date, slice_end_date)
	ax.set_title(title)

	reports = []
	reports.append(AnalysisReport(symbol, slice_start_date, slice_end_date, 'Intra-Day Range Fever', '', fever_fig))
	reports.append(AnalysisReport(symbol, slice_start_date, slice_end_date, 'Distribution of Intra-day Range', h.report(date_slice, delta), dist_fig))
	return reports
开发者ID:davidbarkhuizen,项目名称:dart,代码行数:67,代码来源:analyser.py


注:本文中的histogram.Histogram.report方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。