Stock Market Data Visualization Using Mplfinance

How to obtain stock market data and create visualizations(candlestick, OHLC, PnF etc.) in Python using mplfinance library

Abhijith Chandradas
8 min readMar 4, 2021

Mplfinance is a dedicated data visulization package from matlplotlib for visualizing financial data.
Mplfinance enable visualization of financial data in the form of different types of charts- Candlestick chart, Renko Chart, OHLC chart, Point and Figure chart etc. with very few lines of code.
Mplfinance also facilitates superimposing moving averages on top of charts for decision making by technical analysts.

Getting the data

Typical market data includes OHLCV(Open High Low Close Volume) data. The data can be obtained by using the sites of stock exchanges, financial publications, APIs, web-scrapping etc.

Mplfinace package can be used to plot any dataframe provided the following conditions are satisfied:
i. Date is the index of the dataframe
ii. Date is in pd.datetime format (‘YYYY-MM-DD’)
iii. Columns are named as below:
Open’ : Opening price
High’ : Highest price for the period
Low’ : Lowest price for the period
Close’ : Closing price
Volume’ : Volume traded during the period

--

--

Abhijith Chandradas

Data Analyst | Hacker | Financial Analyst | Freelancer | IIM MBA | Opensource | Democratize Knowledge | https://www.youtube.com/channel/UCLpBd4gzfIBXm2BPpdHOWdQ