Member-only story
Candlestick Charts in Python with NSEPython and Plotly
2 min readAug 28, 2023
The candlestick chart is a style of financial chart describing open, high, low, and close for a given x coordinate (most likely time).
- The boxes represent the spread between the open and close values and the lines represent the spread between the low and high values.
- Sample points where the close value is higher (lower) than the open value are called increasing (decreasing).
- By default, increasing candles are drawn in green whereas decreasing are drawn in red.
Simple Candlestick with Pandas
We shall be using equity_history()
function of NSEPython.
NSEPython is a Python wrapper coded by us only to scrap values from the NSE India website. Here is a basic construction of Pandas
Dataframe with 365 days
of data of SBI
Equities –
from nsepython import *
end_date = datetime.datetime.now().strftime("%d-%m-%Y")
end_date = str(end_date)
start_date = (datetime.datetime.now()- datetime.timedelta(days=65)).strftime("%d-%m-%Y")
start_date = str(start_date)
symbol = "SBIN"
series = "EQ"
df = equity_history(symbol,series,start_date,end_date)
Plotting Candle Stick Charts Using Python
Here is the second part of the code that uses Plotly
library to draw a Candlestick Chart from the data We just fetched –
import plotly.graph_objects as go
fig =…