How To Calculate Bollinger Bands Of A Stock With Python

Sohan Dillikar
CodeX
Published in
4 min readMar 31, 2021

--

Photo by Jamie Street

In this article, I will be showing you how you can calculate the Bollinger bands of any stock with Python.

Step 1. Install the modules

The modules that we will need are listed below and you can simply install them with a pip3 install….

numpy==1.20.0
pandas==1.1.4
pandas-datareader==0.9.0
matplotlib==3.3.3

Step 2. Understanding Bollinger Bands

While I won’t be going too deep into the concept of Bollinger bands, I will try to provide a basic understanding of what they are. Bollinger bands are a type of technical indicator that allows traders to analyze the volatility of a stock and whether the price is high or low on a relative basis. The top band is typically two standard deviations above the SMA and the bottom band is typically two standard deviations below the SMA. This is how the bands look like when they are graphed.

AAPL 07/01/14–07/01/15

Some quick observations you can make from looking at this graph is that the closing prices of the stock mostly stay in between both the Bollinger bands. In addition, you can identify buy signals…

--

--

Sohan Dillikar
CodeX

The Daily Writer ✍️ | Entrepreneurship, Self-Improvement & Content Creation 🧠 | Learn how to build a life doing what you love 🚀✨