text: import numpy as np
  import pandas as pd
  import matplotlib.pyplot as plt
  import warnings
  warnings.filterwarnings("ignore")
  import yfinance as yf
  yf.pdr_override()
  import datetime as dt
  
  # input
  symbol = 'AAPL'
  start = dt.date.today() - dt.timedelta(days = 365*2)
  end = dt.date.today()
  
  # Read data 
  df = yf.download(symbol,start,end)
  
  n = 14
  df['Minimum_Price'] = df['Adj Close'].rolling(14).min()
  df['Moving_Minimum'] = df['Minimum_Price'].rolling(n).min()
  
  plt.figure(figsize=(14,7))
  plt.plot(df['Adj Close'])
  plt.plot(df['Moving_Minimum'], color='red')
  plt.title('Moving Minimum Price Indicator of Stock')
  plt.legend()
  plt.xlabel('Date')
  plt.ylabel('Price')
  plt.show()
  
  # ## Candlestick with Minimum Price
  from matplotlib import dates as mdates
  dfc = df.copy()
  dfc['VolumePositive'] = dfc['Open'] < dfc['Adj Close']
  #dfc = dfc.dropna()
  dfc = dfc.reset_index()
  dfc['Date'] = pd.to_datetime(dfc['Date'])
  dfc['Date'] = dfc['Date'].apply(mdates.date2num)
  from mplfinance.original_flavor import candlestick_ohlc
  fig = plt.figure(figsize=(14,7))
  ax1 = plt.subplot(2, 1, 1)
  candlestick_ohlc(ax1,dfc.values, width=0.5, colorup='g', colordown='r', alpha=1.0)
  ax1.plot(df['Moving_Minimum'], color='orange')
  ax1.xaxis_date()
  ax1.xaxis.set_major_formatter(mdates.DateFormatter('%d-%m-%Y'))
  ax1.grid(True, which='both')
  ax1.minorticks_on()
  ax1v = ax1.twinx()
  colors = dfc.VolumePositive.map({True: 'g', False: 'r'})
  ax1v.bar(dfc.Date, dfc['Volume'], color=colors, alpha=0.4)
  ax1v.axes.yaxis.set_ticklabels([])
  ax1v.set_ylim(0, 3*df.Volume.max())
  ax1.set_title('Stock '+ symbol +' Closing Price')
  ax1.set_ylabel('Price')
  ax1.legend()
  
  ax2 = plt.subplot(2, 1, 2)
  df['VolumePositive'] = df['Open'] < df['Adj Close']
  ax2.bar(df.index, df['Volume'], color=df.VolumePositive.map({True: 'g', False: 'r'}), label='macdhist')
  ax2.grid()
  ax2.set_ylabel('Volume')
  ax2.set_xlabel('Date')
  plt.show()