我刚刚了解了使用 yfinance 导入市场数据进行技术分析。yfinance 和 ta-lib 都已正确安装。我使用了 yf.download 方法并检查了数据是否为数据帧格式。这是在 Jupyter 笔记本上运行的。
import talib
import yfinance as yf
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
data = yf.download("MSFT","2015-01-01")
type(data)
data.head()
# Everything up to this point seems fine. I then tried to use the data as the input parameters for ta-lib (ADX as one example).
AvgDaily = talib.ADX('High','Low','Close', timeperiod = 10)
错误是:
TypeError Traceback (most recent call last)
<ipython-input-5-886a1aac12f8> in <module>
----> 1 real = talib.ADX('High','Low','Close', timeperiod = 10)
~\anaconda3\lib\site-packages\talib\__init__.py in wrapper(*args, **kwargs)
25
26 if index is None:
---> 27 return func(*args, **kwargs)
28
29 # Use Series' float64 values if pandas, else use values as passed
TypeError: Argument 'high' has incorrect type (expected numpy.ndarray, got str)
如果我只是尝试调用数据框中的值,它似乎很好:
data.High