Questions tagged «technical-indicator»

2
熊猫:基于局部极小值最大值的数据之字形分割
我有一个时间序列数据。产生资料 date_rng = pd.date_range('2019-01-01', freq='s', periods=400) df = pd.DataFrame(np.random.lognormal(.005, .5,size=(len(date_rng), 3)), columns=['data1', 'data2', 'data3'], index= date_rng) s = df['data1'] 我想创建一条连接局部最大值和局部最小值之间的曲折线,它满足以下条件:|highest - lowest value|每条曲折线在y轴上必须超过上一条距离的百分比(例如20%)之字形线,以及预先设定的值k(例如1.2) 我可以使用以下代码找到本地极值: # Find peaks(max). peak_indexes = signal.argrelextrema(s.values, np.greater) peak_indexes = peak_indexes[0] # Find valleys(min). valley_indexes = signal.argrelextrema(s.values, np.less) valley_indexes = valley_indexes[0] # Merge peaks and valleys data …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.