17 lines
591 B
Python
17 lines
591 B
Python
import yfinance as yf
|
|
import pandas as pd
|
|
import matplotlib.pyplot as plt
|
|
|
|
def macd_data(data):
|
|
tick_history = data
|
|
tick_macd = pd.DataFrame()
|
|
tick_macd['Close'] = tick_history['Close']
|
|
tick_macd['EMA-12'] = tick_macd['Close'].ewm(span=12, adjust=False).mean()
|
|
tick_macd['EMA-26'] = tick_macd['Close'].ewm(span=26, adjust=False).mean()
|
|
tick_macd['MACD'] = tick_macd['EMA-12'] - tick_macd['EMA-26']
|
|
tick_macd['Signal'] = tick_macd['MACD'].ewm(span=9, adjust=False).mean()
|
|
tick_macd['Gap'] = tick_macd['MACD'] - tick_macd['Signal']
|
|
print(tick_macd.index)
|
|
|
|
return tick_macd
|