TA-lib python,如何使用 MAVP - 可变周期移动平均线

TA-lib python, How use MAVP - Moving average with variable period

real = MAVP(close, periods, minperiod=2, maxperiod=30, matype=0)

我正在尝试使用此方法,但它会引发错误,因为周期参数, 如何像这样将此方法用于 Dataframe

此期间参数必须作为您要获取的期间数组传递。我从雅虎财经得到了苹果股价,得到了整个期间的移动平均线。

import yfinance as yf
data = yf.download("AAPL", start="2020-01-01", end="2021-01-01")

data.head()
    Open    High    Low     Close   Adj Close   Volume
Date                        
2020-01-02  74.059998   75.150002   73.797501   75.087502   74.333511   135480400
2020-01-03  74.287498   75.144997   74.125000   74.357498   73.610840   146322800
2020-01-06  73.447502   74.989998   73.187500   74.949997   74.197395   118387200
2020-01-07  74.959999   75.224998   74.370003   74.597504   73.848442   108872000
2020-01-08  74.290001   76.110001   74.290001   75.797501   75.036385   132079200

import talib as ta
import numpy as np

data.reset_index(drop=False,inplace=True)
periods = data.Date
real = ta.MAVP(data.Close, periods, minperiod=2, maxperiod=30, matype=0)

real
0             NaN
1             NaN
2             NaN
3             NaN
4             NaN
          ...    
248    131.465004
249    134.330002
250    135.779999
251    134.294998
252    133.205002
Length: 253, dtype: float64