python-pour-finance/08-Analyse-Time-Series/.ipynb_checkpoints/2-EWMA-Moyennes-mobiles-pon...

446 lines
85 KiB
Plaintext
Raw Permalink Normal View History

2023-08-21 15:12:19 +00:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"___\n",
"\n",
"<a href='http://www.pieriandata.com'> <img src='../Pierian_Data_Logo.png' /></a>\n",
"___\n",
"<center>*Copyright Pierian Data 2017*</center>\n",
"<center>*For more information, visit us at www.pieriandata.com*</center>"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"airline = pd.read_csv('airline_passengers.csv',index_col=\"Month\")"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"airline.dropna(inplace=True)\n",
"airline.index = pd.to_datetime(airline.index)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Thousands of Passengers</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Month</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1949-01-01</th>\n",
" <td>112.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1949-02-01</th>\n",
" <td>118.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1949-03-01</th>\n",
" <td>132.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1949-04-01</th>\n",
" <td>129.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1949-05-01</th>\n",
" <td>121.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Thousands of Passengers\n",
"Month \n",
"1949-01-01 112.0\n",
"1949-02-01 118.0\n",
"1949-03-01 132.0\n",
"1949-04-01 129.0\n",
"1949-05-01 121.0"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"airline.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# SMA\n",
"## Simple Moving Average\n",
"\n",
"We've already shown how to create a simple moving average, for a quick review:"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"airline['6-month-SMA']=airline['Thousands of Passengers'].rolling(window=6).mean()\n",
"airline['12-month-SMA']=airline['Thousands of Passengers'].rolling(window=12).mean()"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Thousands of Passengers</th>\n",
" <th>6-month-SMA</th>\n",
" <th>12-month-SMA</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Month</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1949-01-01</th>\n",
" <td>112.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1949-02-01</th>\n",
" <td>118.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1949-03-01</th>\n",
" <td>132.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1949-04-01</th>\n",
" <td>129.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1949-05-01</th>\n",
" <td>121.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Thousands of Passengers 6-month-SMA 12-month-SMA\n",
"Month \n",
"1949-01-01 112.0 NaN NaN\n",
"1949-02-01 118.0 NaN NaN\n",
"1949-03-01 132.0 NaN NaN\n",
"1949-04-01 129.0 NaN NaN\n",
"1949-05-01 121.0 NaN NaN"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"airline.head()"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x11760a978>"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAEKCAYAAAAcgp5RAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsnXd8VFX6/993MpOZ9N4ggYQOIRA6CgiKUiwUESwgInZX\nRf1Z17qrKK6ua1nXjrCugiBfmigIKFKkSAkdpCQhgUB6nSTTzu+POzOZySSkMBGQ8369fM3Mveee\nc+YGn/vMc57ncxQhBBKJRCL586I53xOQSCQSScsiDb1EIpH8yZGGXiKRSP7kSEMvkUgkf3KkoZdI\nJJI/OdLQSyQSyZ8caeglEonkT4409BKJRPInRxp6iUQi+ZOjPd8TAIiMjBSJiYnnexoSiURyUbFj\nx458IURUQ+0uCEOfmJj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GUOCFEjqIocUCu/fxJIMHl\n+nj7MTeEEJ+g/lKgb9++3q/5lVwSvPXWW+d7ChLJOVNusmATEOqvymEH+2kprfJeQV+DHr0Q4jSQ\npSiKIxViOGoYZxlwh/3YHcBS+/tlwC2KougVRUkCOgLbvDZjiUQi+ZNRYi+WCvGzG/rz4NEDPAx8\npSiKL3AcuBP1IbFAUZS7gExgEoAQYr+iKAtQHwYW4C9CCFmFIpFIJPXgqIoN9XcJ3VT9wYZeCJEG\n1BXwH15P+5nAzHOYl0QikVwyFFeqOjduoZvKPzB0I5FIJJKWxenR20M3IX46Ks1WTBabV/qXhr4B\niouLuemmm+jSpQtdu3Z
"text/plain": [
"<matplotlib.figure.Figure at 0x11773cef0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"airline.plot()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# EWMA\n",
"## Exponentially-weighted moving average \n",
"\n",
"We just showed how to calculate the SMA based on some window.However, basic SMA has some \"weaknesses\".\n",
"* Smaller windows will lead to more noise, rather than signal\n",
"* It will always lag by the size of the window\n",
"* It will never reach to full peak or valley of the data due to the averaging.\n",
"* Does not really inform you about possible future behaviour, all it really does is describe trends in your data.\n",
"* Extreme historical values can skew your SMA significantly\n",
"\n",
"To help fix some of these issues, we can use an EWMA (Exponentially-weighted moving average)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"EWMA will allow us to reduce the lag effect from SMA and it will put more weight on values that occured more recently (by applying more weight to the more recent values, thus the name). The amount of weight applied to the most recent values will depend on the actual parameters used in the EWMA and the number of periods given a window size.\n",
"[Full details on Mathematics behind this can be found here](http://pandas.pydata.org/pandas-docs/stable/computation.html#exponentially-weighted-windows)\n",
"Here is the shorter version of the explanation behind EWMA.\n",
"\n",
"The formula for EWMA is:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$ y_t = \\frac{\\sum\\limits_{i=0}^t w_i x_{t-i}}{\\sum\\limits_{i=0}^t w_i} $"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Where x_t is the input value, w_i is the applied weight (Note how it can change from i=0 to t), and y_t is the output.\n",
"\n",
"Now the question is, how to we define the weight term w_i ?\n",
"\n",
"This depends on the adjust parameter you provide to the .ewm() method.\n",
"\n",
"When adjust is True (default), weighted averages are calculated using weights:\n",
"\n",
"### $y_t = \\frac{x_t + (1 - \\alpha)x_{t-1} + (1 - \\alpha)^2 x_{t-2} + ...\n",
"+ (1 - \\alpha)^t x_{0}}{1 + (1 - \\alpha) + (1 - \\alpha)^2 + ...\n",
"+ (1 - \\alpha)^t}$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"When adjust=False is specified, moving averages are calculated as:\n",
"\n",
"### $\\begin{split}y_0 &= x_0 \\\\\n",
"y_t &= (1 - \\alpha) y_{t-1} + \\alpha x_t,\\end{split}$\n",
"\n",
"which is equivalent to using weights:\n",
"\n",
" \\begin{split}w_i = \\begin{cases}\n",
" \\alpha (1 - \\alpha)^i & \\text{if } i < t \\\\\n",
" (1 - \\alpha)^i & \\text{if } i = t.\n",
"\\end{cases}\\end{split}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"When adjust=True we have y0=x0 and from the last representation above we have yt=αxt+(1α)yt1, therefore there is an assumption that x0 is not an ordinary value but rather an exponentially weighted moment of the infinite series up to that point.\n",
"\n",
"One must have 0<α≤1, and while since version 0.18.0 it has been possible to pass α directly, its often easier to think about either the span, center of mass (com) or half-life of an EW moment:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\\begin{split}\\alpha =\n",
" \\begin{cases}\n",
" \\frac{2}{s + 1}, & \\text{for span}\\ s \\geq 1\\\\\n",
" \\frac{1}{1 + c}, & \\text{for center of mass}\\ c \\geq 0\\\\\n",
" 1 - \\exp^{\\frac{\\log 0.5}{h}}, & \\text{for half-life}\\ h > 0\n",
" \\end{cases}\\end{split}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* Span corresponds to what is commonly called an “N-day EW moving average”.\n",
"* Center of mass has a more physical interpretation and can be thought of in terms of span: c=(s1)/2\n",
"* Half-life is the period of time for the exponential weight to reduce to one half.\n",
"* Alpha specifies the smoothing factor directly."
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"airline['EWMA12'] = airline['Thousands of Passengers'].ewm(span=12).mean()"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x10b146b00>"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAEKCAYAAAAcgp5RAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsnXd8m9X1/99Xlmx5b8dO7MRO4uzhhEzCCiuBUlbYIwRa\noMxQymyB0hYK/PiWMkqh7JQdZgizrJAN2TvBiUdsx45teUqyLUu6vz8eSZZsech5nITkvl+vvCw9\nep57r2TnPEfnnvM5QkqJQqFQKI5cDId6AQqFQqHoW5ShVygUiiMcZegVCoXiCEcZeoVCoTjCUYZe\noVAojnCUoVcoFIojHGXoFQqF4ghHGXqFQqE4wlGGXqFQKI5wjId6AQApKSkyOzv7UC9DoVAoflGs\nW7euWkqZ2t15h4Whz87OZu3atYd6GQqFQvGLQghR3JPzVOhGoVAojnCUoVcoFIojHGXoFQqF4gjn\nsIjRB6O1tZXS0lKam5sP9VIURzFms5nMzExMJtOhXopC0WsOW0NfWlpKbGws2dnZCCEO9XIURyFS\nSiwWC6WlpeTk5Bzq5SgUveawDd00NzeTnJysjLzikCGEIDk5WX2rVPziOWwNPaCMvOKQo/4GFUcC\nh7WhVygUiqMFu8PJwjUluNz6t3dVhr4TLBYLeXl55OXlkZ6ezoABA8jLyyMhIYFRo0Yd6uV1SUxM\nzAGPsWzZMkaPHk1eXh5NTU0Br4WFhZG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vPo/eEbuIjTTS1unA
"text/plain": [
"<matplotlib.figure.Figure at 0x10b11a6d8>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"airline[['Thousands of Passengers','EWMA12']].plot()"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"Great! That is all for now, let's move on to ARIMA modeling!"
]
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}