Python — Live Stock Market Visualization

Visualize Stock Market Data With Python Plotly

Techletters
Python Point

--

Image by Lorenzo Cafaro from Pixabay.

In today’s story, we will use the yfinance API for Python to get live stock market data that we will visualize on an interactive chart. Welcome to Python Data Science December #5.

There are many expensive APIs for retrieving live stock data on the market, e.g. Bloomberg, to name just one. On the other hand, there are also some free APIs like Alpha Vantage, but with certain limitations in the free version.

I have chosen yfinance, as it offers a threaded and pythonic way to download live market data from Yahoo! finance. I do not recommend it for productive usage, as it is not an official Yahoo API, but for us, it will fulfill its purpose. At the end of today's story, we’ll end up with a nice Candlestick chart like this.

A candlestick chart of the Tesla stock — generated with Python Plotly
A candlestick chart of the Tesla stock — generated with Python Plotly. Image by the author.

🔍 Exploring The API

Let’s start exploring the API and its possibilities first. There are two main modules, the Ticker()and the Download()module.

The Ticker() lets us interact with any stock symbol to get some information on the fly.

--

--