波動指標:布林通道

Financial Trading in Python

Chelsea Yang

Data Science Instructor

什麼是布林通道?

  • 由 John Bollinger 提出

    • 「Bollinger on Bollinger Bands」

     

    布林通道示意

  • 衡量價格波動性
  • 由三條線組成:
    • 中軌:n 期簡單移動平均
    • 上軌:高於中軌 k 個標準差
    • 下軌:低於中軌 k 個標準差
Financial Trading in Python

布林通道的意涵

  • 通道越寬,資產價格越波動。

 

  • 衡量價格在相對意義上是否偏高或偏低:
    • 偏高:價格接近上軌
    • 偏低:價格接近下軌
Financial Trading in Python

在 Python 中實作布林通道

# Define the Bollinger Bands
upper, mid, lower = talib.BBANDS(stock_data['Close'],
                                 nbdevup=2,
                                 nbdevdn=2,
                                 timeperiod=20)
Financial Trading in Python

繪製布林通道

import matplotlib.pyplot as plt

# Plot the Bollinger Bands 
plt.plot(stock_data['Close'], label='Price')
plt.plot(upper, label="Upper band")
plt.plot(mid, label='Middle band')
plt.plot(lower, label='Lower band')


# Customize and show the plot plt.title('Bollinger Bands') plt.legend() plt.show()

布林通道圖

Financial Trading in Python

一起來練習吧!

Financial Trading in Python

Preparing Video For Download...