Ejemplo n.º 1
0
def extrema(df,s):
	y = df.adj_close_price
	x = df.index
	threshold = len(df.log_ret[np.abs(df.log_ret-df.log_ret.mean())>=(s*df.log_ret.std())])

	_max, _min = peakdetect(y, x, threshold)

	xm = pd.DatetimeIndex([p[0] for p in _max])
	ym = [p[1] for p in _max]
	xn = pd.DatetimeIndex([p[0] for p in _min])
	yn = [p[1] for p in _min]

	for i in xm:
		minima[i.date()] +=1

	for j in xn:
		maxima[j.date()] +=1