本文主要是介绍Talib.MAVP中的periods参数意义,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
-
Talib
real = MAVP(close, periods, minperiod=2, maxperiod=30, matype=0)
-
periods的意义
This is what the function does. It gets an input price array, and a periods array that are the same length. The output price array is the moving average at the point using the specified period at the point. So, if you have an array of [1, 5, 3, 8] and you specify periods [2,3,3,2] then the output will be:
[SMA(2)[0], SMA(3)[1], SMA(3)[2], SMA(2)[3]]
With the exception that it puts maxperiods number of nan’s at the front, for some reason so you’d need to call it like:
>>> prices = np.array([1,5,7,8], dtype=float) >>> periods =np.array([2,3,3,2], dtype=float) >>> ta.MAVP(prices, periods, maxperiod=3) array([ nan, nan, 4.33333333, 7.5 ])>>> ta.SMA(prices, 2) array([ nan, 3. , 6. , 7.5])>>> ta.SMA(prices, 3) array([ nan, nan, 4.33333333, 6.66666667])
-
References
- Ta-Lib: What is the Idea of Periods in MAVP - (Moving average with variable period)?
这篇关于Talib.MAVP中的periods参数意义的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!