MA, SMA, EMA

MA: Moving Average. 移動平均線

SMA: Simple Moving Average 簡單移動平均

EMA: Exponential Moving Average.  指數移動平均

#!/usr/bin/env python
# -*- coding=utf-8 -*-
__author__ = "柯博文老師 Powen Ko, www.powenko.com"
# EMA httpsss://towardsdatascience.com/implementing-moving-averages-in-python-1ad28e636f9d

import pandas as pd
import numpy as np
from datetime import datetime
import matplotlib.pyplot as plt
import pyEX as p
# httpsss://iexcloud.io/  申請免費帳號

TOKEN="xxxxxxx"
c = p.Client(api_token=TOKEN)


ticker = 'AMD'
timeframe = '6m'
df = c.chartDF(ticker, timeframe)
df = df[['close']]
df.reset_index(level=0, inplace=True)
df.columns=['ds','y']
plt.plot(df.ds, df.y, label='AMD')
plt.show()