波动率指标:布林带

Python 中的金融交易

Chelsea Yang

Data Science Instructor

什么是布林带?

  • 由 John Bollinger 提出

    • 《Bollinger on Bollinger Bands》

     

    布林带示意

  • 衡量价格波动性
  • 由三条线构成:
    • 中轨:n 期简单移动平均
    • 上轨:高于中轨 k 个标准差
    • 下轨:低于中轨 k 个标准差
Python 中的金融交易

布林带的含义

  • 布林带越宽,资产价格越波动。

 

  • 判断价格在相对意义上偏高或偏低:
    • 相对偏高:价格接近上轨
    • 相对偏低:价格接近下轨
Python 中的金融交易

在 Python 中实现布林带

# Define the Bollinger Bands
upper, mid, lower = talib.BBANDS(stock_data['Close'],
                                 nbdevup=2,
                                 nbdevdn=2,
                                 timeperiod=20)
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()

布林带图

Python 中的金融交易

开始练习!

Python 中的金融交易

Preparing Video For Download...