【问题标题】:How to plot Technical Analysis indicators in VectorBT如何在 VectorBT 中绘制技术分析指标
【发布时间】:2022-06-19 07:34:23
【问题描述】:

我正在使用 vectorbt 库来运行测试和可视化结果。

我想使用 KeltnerChannel 指标。 KeltnerChannel 仅在技术分析库 (TA) 中可用。

当我打电话时,我得到了一个视觉图

vbt.BBANDS.run(close_price).plot().show()

但是当我调用以下命令时

vbt.ta('KeltnerChannel').run(high=high_price, low=low_price, close=close_price).plot()

抛出错误:AttributeError: 'KeltnerChannel' object has no attribute 'plot'

作为测试,我尝试从 TA-Lib 绘制一个指标。我犯了同样的错误。但是,此示例来自文档。

vbt.talib('MACD').run(btc.get('Close')).plot()

'MACD' 对象没有属性 'plot'

'ta' 和 'talib' 指示符会运行,只是不会绘图。

我可以绘制基本的 vbt 指标,如何绘制 ta 和 talib 指标?

我使用的是社区版,而不是 VectorBT 的专业版。

非常感谢您的帮助,谢谢。

【问题讨论】:

    标签: python algorithmic-trading trading ta-lib back-testing


    【解决方案1】:

    试试这个。

    1. 创建指标对象:
    keltnerIndicator = vbt.IndicatorFactory.from_ta('KeltnerChannel')
    
    1. 计算指标:
    keltner = keltnerIndicator.run(high=prices.High, low=prices.Low, close=prices.Low)
    
    1. 绘图图表:
    prices.Close.plot(figsize = (18, 9), title = 'Price Close and Channel Keltner')
    keltner.keltner_channel_hband.plot()
    keltner.keltner_channel_lband.plot()
    keltner.keltner_channel_mband.plot();
    

    在创建的对象keltner 中,我们还有其他方法。信号交易等。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-07-07
      • 1970-01-01
      • 2021-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多