使用TA-lib遇到ImportError:无法导入名称'__TA_FUNCTION_NAMES__'

时间:2019-08-26 10:25:56

标签: python ta-lib

有人遇到过Ta-lib问题吗?我无法导入任何功能,该库似乎已正确安装(从.whl文件安装,使用pip列表进行了检查):

import talib

feature_names = ['5d_close_pct']

# Create moving averages and rsi for timeperiods of 14, 30, 50, 200

list_of_timeperiods = [14, 30, 50, 200]
for n in list_of_timeperiods:

    # Create the moving average indicator and divide by Adj_Close
    returns_data['ma' + str(n)] = talib.SMA(returns_data['Adj_Close'].values, timeperiod=n)/returns_data['Adj_Close']

    # Create the RSI indicator
    returns_data['rsi' + str(n)] = talib.RSI(returns_data['Adj_Close'].values, timeperiod=n)

    # Add RSI and MA to the feature name list
    feature_names = feature_names + ['ma' + str(n), 'rsi' + str(n)]

print (feature_names)

ImportError                               Traceback (most recent call last)
<ipython-input-27-5350715961d9> in <module>
     14 # Another common technical indicator is the relative strength index (RSI)
     15 
---> 16 import talib
     17 
     18 feature_names = ['5d_close_pct']

~\AppData\Local\Programs\Python\Python36\lib\site-packages\talib\__init__.py in <module>
     41         return wrapper
     42 
---> 43 from ._ta_lib import (
     44     _ta_initialize, _ta_shutdown, MA_Type, __ta_version__,
     45     _ta_set_unstable_period as set_unstable_period,

ImportError: cannot import name '__TA_FUNCTION_NAME

0 个答案:

没有答案