code: def macd(
      df,
      fast_period=12,
      slow_period=26,
      signal_period=9,
      column=None,
      include=True,
      str=None,
      detail=False,
      **macd_kwargs,
  ):
      periods = "({0},{1},{2})".format(
          fast_period, slow_period, signal_period
      )
  
      def _macd(df, column, include):
          study = "MACD"
          df, _df, column = validate(df, column)
  
          ## === talib ====
          # macd,signal,hist=talib.MACD(df[column].values,fast_period,slow_period,signal_period)
          # _df=pd.DataFrame({'MACD':macd,'SIGNAL':signal},index=df.index)
          ## === /talib ===
  
          ## === pure python ===
          def __macd(s, periods):
              macd_f = []
              factor = 2.0 / (periods + 1)
              macd_f.append(s[0])
              for i in range(1, len(s)):
                  macd_f.append(
                      s[i] * factor + macd_f[i - 1] * (1 - factor)
                  )
              return pd.Series(macd_f, index=s.index)
  
          _df["FAST"] = __macd(df[column], fast_period)
          _df["SLOW"] = __macd(df[column], slow_period)
          _df["MACD"] = _df["FAST"] - _df["SLOW"]
          _df["SIGNAL"] = __macd(_df["MACD"], signal_period)
          ## === /pure python ===
  
          period_dict = {
              "FAST": fast_period,
              "SLOW": slow_period,
              "MACD": "[{0},{1}]".format(fast_period, slow_period),
              "SIGNAL": signal_period,
          }
          return rename(
              df,
              _df,
              study,
              periods,
              column,
              include,
              str,
              detail,
              output=output,
              period_dict=period_dict,
          )
  
      if slow_period < fast_period:
          raise StudyError(
              "slow_period cannot be less than fast_period"
          )
      column = make_list(column)
      str = str if str else "{name}({column},{period})"
      output = ["MACD", "SIGNAL"]
      __df = pd.concat(
          [_macd(df, column=x, include=False) for x in column], axis=1
      )
  
      if include:
          return pd.concat([df, __df], axis=1)
      else:
          return __df
  
imports: import pandas
  import numpy
  from plotly.graph_objs import Figure
  from .utils import make_list
label_desc: Use image node_id 15 for calling a global function with example usage: macd(df, fast_period, slow_period, signal_period, column, include, str, detail) and returns: rename, pd, __df, pd