User Avatar

Leo E.

4y ago

Math enthusiast

Review of Volume, Moving Averages, Candlestick with 5 Lines of Python

Today, I will review some of the key ideas from the previous week and show how Python can help represent all that information with only five lines of code.

  • Volume - a number of shares traded during some time period, usually a day.

    • Volume / price combination can help us determine whether the stock is bearish or bullish.

  • Moving averages - one of the fundamental techniques for technical analysis of stocks.

    • I've shown how simple moving averages can help you remove the noise from the data and then apply volume / price combination.

    • Candlestick chart - simple but effective way to summarize 5 features of the daily stock data.

You can depict all those ideas with 5 lines of Python code!

import mplfinance as mpf
import yfinance as stock_data
cur = stock_data.Ticker('ON')
ohlc_cur = cur.history(period="21d")
mpf.plot(ohlc_cur, type="candle", mav=4, volume=True)

(I'll post the image as a separate tweet.)