【问题标题】:How to convert a list of closing price data to RSI Value using Ta-LIB Python library?如何使用 Ta-LIB Python 库将收盘价数据列表转换为 RSI 值?
【发布时间】:2020-05-05 14:16:36
【问题描述】:

假设我有一个资产的收盘价数据列表:

priceList = [3,1,2,1,2,1,2,1,2,1,2]

如何获取 priceList 的最后收盘价的 RSI 值? 目前,我有这个代码:

import talib
import numpy

priceList = [1,2,1,2,1,2,1,2,1,2]
print(talib.RSI(priceList, timeperiod=10))

但是,它给了我这个错误:

TypeError: Argument 'real' has incorrect type (expected numpy.ndarray, got list)

请帮我解决!谢谢。

【问题讨论】:

    标签: python indicator forex ta-lib


    【解决方案1】:

    我很确定 TA-Lib 需要一个 numpy 数组,而不是一个列表作为输入。 尝试将 priceList 转换为 numpy 数组:

    priceList = np.asarray(priceList, dtype='f8')   
    

    然后将其传递给 TA-Lib。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-09
      • 2023-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多