2165 lines
928 KiB
Plaintext
2165 lines
928 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Projet d'Analyse Boursière\n",
|
||
|
"\n",
|
||
|
"### Remarque: Vous êtes libre de considérer ceci comme un exercice complet ou simplement de voir la vidéo des solutions comme une revue de code pour le projet. Ce projet est conçu pour être assez stimulant car il introduira quelques nouveaux concepts par le biais de quelques astuces !\n",
|
||
|
"\n",
|
||
|
"Bienvenue à votre premier projet! Ce projet est destiné à couronner la première moitié du cours, qui a principalement porté sur l'apprentissage des bibliothèques que nous utilisons dans ce cours, la deuxième moitié du cours traitera beaucoup plus des techniques financières et des plateformes de trading quantitatif.\n",
|
||
|
"\n",
|
||
|
"Nous analyserons les données sur les actions de quelques compagnies automobiles du 1er janvier 2012 au 1er janvier 2017. Gardez à l'esprit que ce projet est principalement fait pour pratiquer vos compétences avec matplotlib, pandas et numpy. Ne déduisez pas des conseils de trading financier de l'analyse que nous faisons ici !\n",
|
||
|
"\n",
|
||
|
"### Partie 0: Importations\n",
|
||
|
"\n",
|
||
|
"**Importez les différentes bibliothèques dont vous aurez besoin - vous pouvez toujours revenir ici ou importer au fur et à mesure :)**"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import numpy as np\n",
|
||
|
"import pandas as pd\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"%matplotlib inline"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"____\n",
|
||
|
"## Partie 1: Obtenir les données\n",
|
||
|
"\n",
|
||
|
"### Action Tesla (Ticker: TSLA sur le NASDAQ)\n",
|
||
|
"\n",
|
||
|
"**Note ! Tout le monde ne travaillera pas sur un ordinateur qui lui donnera un accès complet pour télécharger les informations boursières en utilisant pandas_datareader (pare-feu, permissions d'administration, etc...). Pour cette raison, le fichier csv pour Tesla est fourni dans un dossier data à l'intérieur de ce dossier. Il s'appelle Tesla_Stock.csv. N'hésitez pas à l'utiliser avec read_csv !**\n",
|
||
|
"\n",
|
||
|
"**Utilisez pandas_datareader pour obtenir les informations historiques sur les actions de Tesla du 1er janvier 2012 au 1er janvier 2017.**\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import datetime"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import pandas_datareader.data as web"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"start = datetime.datetime(2012, 1, 1)\n",
|
||
|
"end = datetime.datetime(2017, 1, 1)\n",
|
||
|
"tesla = web.DataReader(\"TSLA\", 'yahoo', start, end)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<style scoped>\n",
|
||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe tbody tr th {\n",
|
||
|
" vertical-align: top;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe thead th {\n",
|
||
|
" text-align: right;\n",
|
||
|
" }\n",
|
||
|
"</style>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>High</th>\n",
|
||
|
" <th>Low</th>\n",
|
||
|
" <th>Open</th>\n",
|
||
|
" <th>Close</th>\n",
|
||
|
" <th>Volume</th>\n",
|
||
|
" <th>Adj Close</th>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>Date</th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-03</th>\n",
|
||
|
" <td>29.500000</td>\n",
|
||
|
" <td>27.650000</td>\n",
|
||
|
" <td>28.940001</td>\n",
|
||
|
" <td>28.080000</td>\n",
|
||
|
" <td>928100</td>\n",
|
||
|
" <td>28.080000</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-04</th>\n",
|
||
|
" <td>28.670000</td>\n",
|
||
|
" <td>27.500000</td>\n",
|
||
|
" <td>28.209999</td>\n",
|
||
|
" <td>27.709999</td>\n",
|
||
|
" <td>630100</td>\n",
|
||
|
" <td>27.709999</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-05</th>\n",
|
||
|
" <td>27.930000</td>\n",
|
||
|
" <td>26.850000</td>\n",
|
||
|
" <td>27.760000</td>\n",
|
||
|
" <td>27.120001</td>\n",
|
||
|
" <td>1005500</td>\n",
|
||
|
" <td>27.120001</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-06</th>\n",
|
||
|
" <td>27.790001</td>\n",
|
||
|
" <td>26.410000</td>\n",
|
||
|
" <td>27.200001</td>\n",
|
||
|
" <td>26.910000</td>\n",
|
||
|
" <td>986300</td>\n",
|
||
|
" <td>26.910000</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-09</th>\n",
|
||
|
" <td>27.490000</td>\n",
|
||
|
" <td>26.120001</td>\n",
|
||
|
" <td>27.000000</td>\n",
|
||
|
" <td>27.250000</td>\n",
|
||
|
" <td>897000</td>\n",
|
||
|
" <td>27.250000</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" High Low Open Close Volume Adj Close\n",
|
||
|
"Date \n",
|
||
|
"2012-01-03 29.500000 27.650000 28.940001 28.080000 928100 28.080000\n",
|
||
|
"2012-01-04 28.670000 27.500000 28.209999 27.709999 630100 27.709999\n",
|
||
|
"2012-01-05 27.930000 26.850000 27.760000 27.120001 1005500 27.120001\n",
|
||
|
"2012-01-06 27.790001 26.410000 27.200001 26.910000 986300 26.910000\n",
|
||
|
"2012-01-09 27.490000 26.120001 27.000000 27.250000 897000 27.250000"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 6,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"tesla.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Autres entreprises automobiles\n",
|
||
|
"\n",
|
||
|
"**Répétez les mêmes étapes pour extraire les données pour Ford et GM (General Motors)**"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"ford = web.DataReader(\"F\", 'yahoo', start, end)\n",
|
||
|
"gm = web.DataReader(\"GM\",'yahoo',start,end)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 8,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<style scoped>\n",
|
||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe tbody tr th {\n",
|
||
|
" vertical-align: top;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe thead th {\n",
|
||
|
" text-align: right;\n",
|
||
|
" }\n",
|
||
|
"</style>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>High</th>\n",
|
||
|
" <th>Low</th>\n",
|
||
|
" <th>Open</th>\n",
|
||
|
" <th>Close</th>\n",
|
||
|
" <th>Volume</th>\n",
|
||
|
" <th>Adj Close</th>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>Date</th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-03</th>\n",
|
||
|
" <td>11.25</td>\n",
|
||
|
" <td>10.99</td>\n",
|
||
|
" <td>11.00</td>\n",
|
||
|
" <td>11.13</td>\n",
|
||
|
" <td>45709900.0</td>\n",
|
||
|
" <td>7.687118</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-04</th>\n",
|
||
|
" <td>11.53</td>\n",
|
||
|
" <td>11.07</td>\n",
|
||
|
" <td>11.15</td>\n",
|
||
|
" <td>11.30</td>\n",
|
||
|
" <td>79725200.0</td>\n",
|
||
|
" <td>7.804530</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-05</th>\n",
|
||
|
" <td>11.63</td>\n",
|
||
|
" <td>11.24</td>\n",
|
||
|
" <td>11.33</td>\n",
|
||
|
" <td>11.59</td>\n",
|
||
|
" <td>67877500.0</td>\n",
|
||
|
" <td>8.004824</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-06</th>\n",
|
||
|
" <td>11.80</td>\n",
|
||
|
" <td>11.52</td>\n",
|
||
|
" <td>11.74</td>\n",
|
||
|
" <td>11.71</td>\n",
|
||
|
" <td>59840700.0</td>\n",
|
||
|
" <td>8.087703</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-09</th>\n",
|
||
|
" <td>11.95</td>\n",
|
||
|
" <td>11.70</td>\n",
|
||
|
" <td>11.83</td>\n",
|
||
|
" <td>11.80</td>\n",
|
||
|
" <td>53981500.0</td>\n",
|
||
|
" <td>8.149862</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" High Low Open Close Volume Adj Close\n",
|
||
|
"Date \n",
|
||
|
"2012-01-03 11.25 10.99 11.00 11.13 45709900.0 7.687118\n",
|
||
|
"2012-01-04 11.53 11.07 11.15 11.30 79725200.0 7.804530\n",
|
||
|
"2012-01-05 11.63 11.24 11.33 11.59 67877500.0 8.004824\n",
|
||
|
"2012-01-06 11.80 11.52 11.74 11.71 59840700.0 8.087703\n",
|
||
|
"2012-01-09 11.95 11.70 11.83 11.80 53981500.0 8.149862"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 8,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"ford.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 9,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"ford.to_csv('Ford_Stock.csv')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 10,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<style scoped>\n",
|
||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe tbody tr th {\n",
|
||
|
" vertical-align: top;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe thead th {\n",
|
||
|
" text-align: right;\n",
|
||
|
" }\n",
|
||
|
"</style>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>High</th>\n",
|
||
|
" <th>Low</th>\n",
|
||
|
" <th>Open</th>\n",
|
||
|
" <th>Close</th>\n",
|
||
|
" <th>Volume</th>\n",
|
||
|
" <th>Adj Close</th>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>Date</th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-03</th>\n",
|
||
|
" <td>21.180000</td>\n",
|
||
|
" <td>20.750000</td>\n",
|
||
|
" <td>20.830000</td>\n",
|
||
|
" <td>21.049999</td>\n",
|
||
|
" <td>9321300.0</td>\n",
|
||
|
" <td>16.103352</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-04</th>\n",
|
||
|
" <td>21.370001</td>\n",
|
||
|
" <td>20.750000</td>\n",
|
||
|
" <td>21.049999</td>\n",
|
||
|
" <td>21.150000</td>\n",
|
||
|
" <td>7856700.0</td>\n",
|
||
|
" <td>16.179853</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-05</th>\n",
|
||
|
" <td>22.290001</td>\n",
|
||
|
" <td>20.959999</td>\n",
|
||
|
" <td>21.100000</td>\n",
|
||
|
" <td>22.170000</td>\n",
|
||
|
" <td>17880600.0</td>\n",
|
||
|
" <td>16.960161</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-06</th>\n",
|
||
|
" <td>23.030001</td>\n",
|
||
|
" <td>22.240000</td>\n",
|
||
|
" <td>22.260000</td>\n",
|
||
|
" <td>22.920000</td>\n",
|
||
|
" <td>18234500.0</td>\n",
|
||
|
" <td>17.533915</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-09</th>\n",
|
||
|
" <td>23.430000</td>\n",
|
||
|
" <td>22.700001</td>\n",
|
||
|
" <td>23.200001</td>\n",
|
||
|
" <td>22.840000</td>\n",
|
||
|
" <td>12084500.0</td>\n",
|
||
|
" <td>17.472712</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" High Low Open Close Volume Adj Close\n",
|
||
|
"Date \n",
|
||
|
"2012-01-03 21.180000 20.750000 20.830000 21.049999 9321300.0 16.103352\n",
|
||
|
"2012-01-04 21.370001 20.750000 21.049999 21.150000 7856700.0 16.179853\n",
|
||
|
"2012-01-05 22.290001 20.959999 21.100000 22.170000 17880600.0 16.960161\n",
|
||
|
"2012-01-06 23.030001 22.240000 22.260000 22.920000 18234500.0 17.533915\n",
|
||
|
"2012-01-09 23.430000 22.700001 23.200001 22.840000 12084500.0 17.472712"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 10,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"gm.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 11,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"gm.to_csv('GM_Stock.csv')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Partie 2: Visualisation des données\n",
|
||
|
"\n",
|
||
|
"**Il est temps de visualiser les données.**\n",
|
||
|
"\n",
|
||
|
"**Suivez et recréez les graphiques ci-dessous en suivant les instructions et les explications.**"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"____\n",
|
||
|
"\n",
|
||
|
"**Recréez ce tracé linéaire de tous les prix à l'ouverture des différentes actions! Astuce: Pour la légende, utilisez le paramètre label et plt.legend()**"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 12,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# Code ici"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 13,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<matplotlib.legend.Legend at 0x116672b90>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 13,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png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IhrFKtSy3R5fKM8rISIiSo5BKRER0ShWXsSglIiIChuDUiIiolHMYhIAGJQSEVHhYlBKREQ0igUjUQBAc5cP/lAELj+DUyIiKiwMSomIiEaxYFgJSrc39+Ajv3gbC+76V55XREREFI9BKRER0SgWUINSVyCMPS2uPK+GiIiGW0tLC66//npMmzYNp556Ks444ww8+eSTeP311yGEwO9//3v9tps3b4YQAv/7v/87rGtkUEpERDSKaZlSI08gnIeVEBHRcJNS4qqrrsK5556LgwcPYuPGjVi5ciWam5sBAAsWLMCjjz6q337lypVYtGjRsK+TQSkREdEoFgxHUV5kRandol82786XcLLHn8dVUSF49L0mvLqrJd/LIKIceu2112Cz2XDTTTfpl02ZMgW33HILAGDy5Mnw+/1oaWmBlBIvvvgiLrvssmFfp2XwmxAREdFIFQxHUWQ1Y3qdE2/v79Av39zUhcsWTMjjyijffvbKPpzo9eNHVy/AJ1dMzvdyiEa/F74DnNye3cccvwC47Mf9Xr1z504sXbp0wIf42Mc+hscffxxLlizB0qVLYbfbs7vGFDBTSkRENIoFwhHYLCYsaqiIu3xviztPK6JC4QtFYBYC33liO97a15bv5RDRMPjqV7+KRYsWYfny5fpl1157LR5//HE88sgjuO666/KyLmZKiYiIRrFgJKoEpZOUoPT2S2dj5XtN2MumR2OeLxTBJ1dMwl/fbcLWo904Z2ZtvpdENLoNkNHMlXnz5mHVqlX69w8++CDa29uxbNky/bL
|
||
|
"text/plain": [
|
||
|
"<Figure size 1152x576 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"tesla['Open'].plot(label='Tesla',figsize=(16,8),title='Open Price')\n",
|
||
|
"gm['Open'].plot(label='GM')\n",
|
||
|
"ford['Open'].plot(label='Ford')\n",
|
||
|
"plt.legend()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"____"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"**Tracez le volume des actions négociées chaque jour.**"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 14,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<matplotlib.legend.Legend at 0x116416050>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 14,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA6IAAAHQCAYAAAC7jddkAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nOzdebwkVX3///fpu8wMzIAG8KsBFVySEB1EHDHb12iij0QeBr4mLpiAa0Jco4lL8iVGcTfGJErUGNTEgR8IfNkEZFMREEFgBhAYYGSAwRkGZt/v2l3n90f3qVvdXdVd1bV0d/Xr6YOHc+/tpbq66lR9zudzzjHWWgEAAAAAUJRKvzcAAAAAADBaCEQBAAAAAIUiEAUAAAAAFIpAFAAAAABQKAJRAAAAAEChCEQBAAAAAIUiEAUAjBxjzNuMMTf3ezvyZox5lTFmfdHPBQCgGwJRAMDQMcZca4z5VMjvTzLGPGmMGe/HdiVhjDndGLOv8d+MMaYW+HlNv7cPAIA8EYgCAIbRdySdaowxLb8/VdK51tpq8ZuUjLX2c9bapdbapZLeJelW97O19gWtjx+G4BoAgLgIRAEAw+gySb8i6X+7XxhjnirptZLObvx8sDHmbGPMVmPMY8aYjxlj2q57xpgjjTE2GOgZY24wxvxl499vM8b81Bjz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x/W8573PK1du1Yf+MAHdO211+rggw9ue+6PfvQjHX/88XrRi16kG2+8UWvWrEm9PWREAQAAACAHvWQu82Kt1Tve8Q59+tOfbvvbPffco6uvvlpnnnmmLr74Yp111ln+36ampvS+971Pd955pw4//HB97GMfS7xUSxgyogAAAABQcq961at04YUXatu2bZLqs+v+8pe/1NatW2Wt1Rve8AZ98pOf1J133tn0vOnpaVUqFR166KHau3evLr744ky2h4woAECSNF+bV9VWtWR8Sb83BQAAZGz58uX6xCc+oVe96lXyPE8TExP6xje+obGxMb3zne+UtVbGGP3zP/9z0/MOOeQQvfWtb9ULX/hCPfvZz9bLXvayTLbHZDHjUS9WrFhhV61a1Zf3BgC0e/3lr9fanWt171vv7femAAAwtB544AEdffTR/d6MwoV9bmPMamvtirDHU5oLAJAkrd25tt+bAAAARgSBKAAAAACgUASiAAAAAIBCEYgCAAAAAApFIAoAAAAAKBSBKAAAAACgUASiAAAAAIBCEYgCAAAAAAo13u8NAAAAAABk59Of/rTOPfdcPfOZz9Shhx6ql7zkJbryyiv14he/WKtXr9bWrVt19tln6/Of/7zuvfdevelNb9JnPvOZQreRQBQAAAAA8nD1P0hP3pvtaz59ufSaL0T+edWqVbr44ot11113qVqt6rjjjtNLXvISSdLk5KRuuukmfeUrX9FJJ52k1atX61d+5Vf03Oc+V3/7t3+rQw45JNtt7YBAFAAAAABK4uabb9ZJJ52kJUuWSJL+5E/+xP/biSeeKElavny5XvCCF+gZz3iGJOk5z3mONmzYQCAKAAAAAEOvQ+YyL9bayL8tWrRIklSpVPx/u5+r1Wru2xbEZEUAAAAAUBK/93u/pyuuuEIzMzPat2+fvv/97/d7k0KREQUAAACAknjpS1+qE088US960Yv07Gc/WytWrNDBBx/c781qYzqlbvO0YsUKu2rVqr68NwCg3fKVyyVJ974140kVAAAYIQ888ICOPvrovm7Dvn37tHTpUk1NTenlL3+5zjrrLB133HG5vmfY5zbGrLbWrgh7PBlRAAAAACiR0047Tffff79mZmb01re+NfcgtBcEogAAAABQIuedd16/N6ErJisCAAAAABSKQBQAAAAAUCgCUQAAAABAoQh
|
||
|
"text/plain": [
|
||
|
"<Figure size 1152x576 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"tesla['Volume'].plot(label='Tesla',figsize=(16,8),title='Volume Traded')\n",
|
||
|
"gm['Volume'].plot(label='gm')\n",
|
||
|
"ford['Volume'].plot(label='ford')\n",
|
||
|
"plt.legend()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"**Intéressant, il semble que Ford ait eu un très gros pic fin 2013. Quelle était la date de ce volume d'échange maximum pour Ford ?**\n",
|
||
|
"\n",
|
||
|
"**Bonus: Que s'est-il passé ce jour-là?**"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 15,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"Timestamp('2013-12-18 00:00:00')"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 15,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"ford['Volume'].idxmax()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# Que s'est-il passé?\n",
|
||
|
"# http://money.cnn.com/2013/12/18/news/companies/ford-profit/\n",
|
||
|
"# https://www.usatoday.com/story/money/cars/2013/12/18/ford-2014-profit-warning/4110015/\n",
|
||
|
"# https://media.ford.com/content/dam/fordmedia/North%20America/US/2014/01/28/4QFinancials.pdf"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"____"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"*La visualisation du prix à l'ouverture des séries temporelles donne l'impression que Tesla a toujours eu beaucoup plus de valeur en tant qu'entreprise que GM et Ford. Mais pour vraiment comprendre cela, il faudrait regarder la capitalisation boursière totale de la société, et pas seulement le cours de l'action. Malheureusement, nos données actuelles n'ont pas cette information du nombre total d'unités d'actions présentes. Mais ce que nous pouvons faire comme simple calcul pour essayer de représenter l'argent total échangé serait de multiplier la colonne 'Volume' par le cours de l'action. Rappelez-vous que ce n'est pas encore la capitalisation boursière réelle, c'est juste une représentation visuelle de la quantité totale d'argent échangé en utilisant la série temporelle. (par exemple 100 unités d'actions à 10 dollars chacune contre 100 000 unités d'actions à 1 dollars chacune)*"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"**Créez une nouvelle colonne pour chaque dataframe appelée \"Total Traded\" qui est le prix d'ouverture multiplié par le volume négocié.**"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 17,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# Code ici"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 18,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"tesla['Total Traded'] = tesla['Open']*tesla['Volume']\n",
|
||
|
"ford['Total Traded'] = ford['Open']*ford['Volume']\n",
|
||
|
"gm['Total Traded'] = gm['Open']*gm['Volume']"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"**Tracez ce total négocié (Total Traded) par rapport à l'index de temps.**"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 19,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# Code ici"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 20,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"Text(0, 0.5, 'Total Traded')"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 20,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA6YAAAHLCAYAAADbd4VGAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nOzdefwkV13v//fp7u8ymUnQLCwSsgBX2UICDCB4BUFAEdyFK164ImKMYETRnxdcLjuCIlcim/mBRhSIIQv+EEjIRkIIIUz2bRKSEJLJJDOTSWb9bt1d5/dH9amtq7uru6u66tv9ej4eyfc73dVVp6v7230+9Tnnc4y1VgAAAAAAlKVWdgMAAAAAALONwBQAAAAAUCoCUwAAAABAqQhMAQAAAAClIjAFAAAAAJSKwBQAAAAAUKrKBabGmH82xuw0xtycYdtjjTEXG2NuNMZ80xhz9CTaCAAAAADIT+UCU0lnSPr5jNt+RNLnrLXPlPReSX9TVKMAAAAAAMWoXGBqrb1c0sPR24wxTzLGnG+MucYY8y1jzFM6dz1N0sWd3y+V9MsTbCoAAAAAIAeVC0x7OF3Sqdba50j6M0mf7Nx+g6Rf7/z+q5IONcYcUUL7AAAAAAAjapTdgEGMMZskvVDSl4wx7uaFzs8/k/RxY8wbJV0u6X5JrUm3EQAAAAAw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ZQmAKAKgs5pgCADAbCEwBAJUTZEy
|
||
|
"text/plain": [
|
||
|
"<Figure size 1152x576 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"tesla['Total Traded'].plot(label='Tesla',figsize=(16,8))\n",
|
||
|
"gm['Total Traded'].plot(label='GM')\n",
|
||
|
"ford['Total Traded'].plot(label='Ford')\n",
|
||
|
"plt.legend()\n",
|
||
|
"plt.ylabel('Total Traded')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"**Intéressant, il semble qu'il y ait eu une énorme quantité d'argent échangé pour Tesla début 2014. Quelle date c'était et que s'est-il passé ?**"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 21,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"Timestamp('2014-02-25 00:00:00')"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 21,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"tesla['Total Traded'].idxmax()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 22,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# http://money.cnn.com/2014/02/25/investing/tesla-record-high/\n",
|
||
|
"# https://blogs.wsj.com/moneybeat/2014/02/25/tesla-shares-surge-on-morgan-stanley-report/\n",
|
||
|
"# https://www.washingtonpost.com/news/wonk/wp/2014/02/25/teslas-stock-is-up-644-why-it-may-not-last/\n",
|
||
|
"# http://www.cnbc.com/2014/02/25/tesla-soars-ford-falls-in-consumer-reports-study.html"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"____"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"**Entraînons-nous à tracer des moyennes glissantes ou mobiles (MA - Moving Averages). Tracez MA50 et MA200 pour GM.**"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 23,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# Code ici"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 24,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<matplotlib.axes._subplots.AxesSubplot at 0x118d65d50>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 24,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA54AAAHACAYAAADKlLdJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nOzdd3xUZfb48c+dnjZpBEISSui9CAgoUlREkGJBF1ex4LqubfG3tnVtqyv6XdeVXde26q7gqoCKHUURaSK9VwklQEJJSG/T7++POzOZkEBmkgwhyXm/Xrwgd+7c+0zITO655zznUVRVRQghhBBCCCGECBddYw9ACCGEEEIIIUTzJoGnEEIIIYQQQoiwksBTCCGEEEIIIURYSeAphBBCCCGEECKsJPAUQgghhBBCCBFWEngKIYQQQgghhAgrw7k8WatWrdSOHTuey1MKIYQQQgghhDhHNm3adEpV1aTT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AO8UE/t118BL1TrBwrslFQ5gjXEIUQQghRg6ioKHbu3ElFhTZVZsmSJaSmplbZp7CwkM2bN1NYWMihQ4f82wcOHMjGjRvZvn07U6dO5ZFHHgEgPz+fZ555hnXr1rF+/XqeeeYZCgoKALj77rt56623yMjIICMjg8WLF9f7NYSS8ZwJ7An4+q/AbFVVuwIFwB31Ho0QQoiw2Xq0kJ5trew5XgLAqG6tg36uxainS+toADLzysIyPiGEEEKc2fjx41m0aBEA8+b
|
||
|
"text/plain": [
|
||
|
"<Figure size 1152x576 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"gm['MA50'] = gm['Open'].rolling(50).mean()\n",
|
||
|
"gm['MA200'] = gm['Open'].rolling(200).mean()\n",
|
||
|
"gm[['Open','MA50','MA200']].plot(label='gm',figsize=(16,8))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"______"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"**Enfin, voyons s'il existe une relation entre ces actions car elles sont tous liées à l'industrie automobile. Nous pouvons le voir facilement à travers un diagramme de dispersion. Importez la matrice de dispersion de pandas.plotting et utilisez-la pour créer un diagramme de dispersion du prix d'ouverture de toutes les actions. Vous devrez peut-être réorganiser les colonnes dans un nouveau dataframe unique. Vous trouverez des conseils et des informations ici: https://pandas.pydata.org/pandas-docs/stable/visualization.html#scatter-matrix-plot**"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 25,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"from pandas.plotting import scatter_matrix"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 26,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"car_comp = pd.concat([tesla['Open'],gm['Open'],ford['Open']],axis=1)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 27,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"car_comp.columns = ['Tesla Open','GM Open','Ford Open']"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 28,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAfEAAAHoCAYAAABZ69YuAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nOy9R6xlWZae9+3jzfXm+fARact0uW52VzebTfZAECVIIkERoCYaUYI0ogBC4kiARhI04EQCBGokUAQHggAJJCGiQUENku3KdLnMqKzM8PH8u+/a483eGuwbLyMyI7MysyOquzLPN3rv2nPvO++svdb+17+EUoqGhoaGhoaGXz6MP+8DaGhoaGhoaPhsNEG8oaGhoaHhl5QmiDc0NDQ0NPyS0gTxhoaGhoaGX1KaIN7Q0NDQ0PBLShPEGxoaGhoafkmx/rwP4NMwGo3U1atX/7wPo+FzxIMHD2jOqYYXSXNONbxovv/970+UUuPn3fdLFcSvXr3K9773vT/vw2j4HPHNb36zOacaXijNOdXwohFCPPyo+36pgnhDQ8MXA6UUj6cpeVWz2/cJnOZS1fD5YxYXnEU5Xd9ms+N9ptdo9sQbGhr+whHlFYu0JCslk1Xx5304DQ0vhZNVRl5KTpc5tfxs7qlNEG9oaPiFUNWSWVxQVPK590/jgrcPF9yfRPi2iW0JAD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DqFgzBgbxDgWQa+bfErl/tkZcX5qkDWkNU1rmXwr26fcnUU8O2b42eO6dMoxQ1D8CuX+1wdhdyfxJyuckopL9wGn3C2ynn7YEFc6g6MX706ICtr/uXbJzgv0Hq1ObsbGhrWbS8
|
||
|
"text/plain": [
|
||
|
"<Figure size 576x576 with 9 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# Vous pouvez utiliser un point-virgule pour supprimer l'impression des axes\n",
|
||
|
"scatter_matrix(car_comp,figsize=(8,8),alpha=0.2,hist_kwds={'bins':50});"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"_____\n",
|
||
|
"### Bonus: Tâche de visualisation ! (C'est difficile !)\n",
|
||
|
"**Créons maintenant un graphique en chandelier! Regardez la vidéo si vous ne parvenez pas à recréer cette visualisation, il y a plusieurs étapes à suivre! Référez-vous à la vidéo pour comprendre comment interpréter et lire ce graphique. Conseils: https://matplotlib.org/examples/pylab_examples/finance_demo.html**\n",
|
||
|
"\n",
|
||
|
"**Créer un graphique de chandeliers pour Ford en janvier 2012 (trop de dates, ce ne sera pas idéal pour un graphique de chandeliers)**"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 29,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# Code ici"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 30,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAADjCAYAAACLvt+vAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHd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4SwBf8ByLoASSHL/gPRNADQOIIegBIHEFftBEcxz6fTsuwLfTl2YBRMe9SguhSguPYWaINGG306AEgcQR90fKOYweAASHoi5Z3HPsgsPAHABH0aWPhDwAi6AEgeQQ9ACSOoEdXmEMEGD0EPbrCHCLA6CHouzS1ZarqKhSP0TlA0gj6Ls3smam6CsVjdA6QNIIeABLHXDc51G+oa8cb++eqmXxoUlJjUq/meWAAYBjRo8+hOeTzlAPAMCHoASBxBD0AJG7eoLe93vZO2880lX3W9lbb79qemOOxM7aftr3F9nRRlQYA5JenRz8laUVL2TOSPiNpU47Hnx0RyyKi4x+EYZDk+HgAUI5RNxGxyfZ4S9lzkmS7nFpVoJTx8VyIBGAIlH2OPiRtsL3Z9pqSjzV8uBAJwBAoexz9GRGxzfbRkjbafj4i2p7uyf4QrJGkpUuXllwtAFg4Su3RR8S27N+dku6UtHyOfddFxERETIyNjZVZLQBYUEoLetuLbB++b1vSOWp8iQsAGKA8wytvlfSIpBNtz9q+3PaFtmclfUzS3bbvz/ZdbPue7KE1SQ/bflLSY5Lujoj7ynkZAIBO8oy6WdXhrjvb7LtN0nnZ9suSTuurdgCAvnFlLAAkjqAHgMQR9ACQOIIeABJH0ANA4gh6AEgcQQ8AiSPoASBxBD0AJI6gB4DEEfQ51BbVuioHgGFS9nz0Sdh+9fb3ttc+uFZrz1pbXWUAoEsLNujrN9S1440
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# from mpl_finance import candlestick_ohlc\n",
|
||
|
"# Maj mpl_finance devient mplfinance - pip install --upgrade mplfinance \n",
|
||
|
"from mplfinance.original_flavor import candlestick_ohlc\n",
|
||
|
"\n",
|
||
|
"from matplotlib.dates import DateFormatter, date2num, WeekdayLocator, DayLocator, MONDAY\n",
|
||
|
"\n",
|
||
|
"# Réinitialiser l'index pour obtenir une colonne des dates de janvier\n",
|
||
|
"ford_reset = ford.loc['2012-01':'2012-01'].reset_index()\n",
|
||
|
"\n",
|
||
|
"# Créer une nouvelle colonne de valeurs numériques de \"date\" à utiliser par matplotlib\n",
|
||
|
"ford_reset['date_ax'] = ford_reset['Date'].apply(lambda date: date2num(date))\n",
|
||
|
"ford_values = [tuple(vals) for vals in ford_reset[['date_ax', 'Open', 'High', 'Low', 'Close']].values]\n",
|
||
|
"\n",
|
||
|
"mondays = WeekdayLocator(MONDAY) # major ticks on the mondays\n",
|
||
|
"alldays = DayLocator() # minor ticks on the days\n",
|
||
|
"weekFormatter = DateFormatter('%b %d') # e.g., Jan 12\n",
|
||
|
"dayFormatter = DateFormatter('%d') # e.g., 12\n",
|
||
|
"\n",
|
||
|
"# Tracé\n",
|
||
|
"fig, ax = plt.subplots()\n",
|
||
|
"fig.subplots_adjust(bottom=0.2)\n",
|
||
|
"ax.xaxis.set_major_locator(mondays)\n",
|
||
|
"ax.xaxis.set_minor_locator(alldays)\n",
|
||
|
"ax.xaxis.set_major_formatter(weekFormatter)\n",
|
||
|
"\n",
|
||
|
"candlestick_ohlc(ax, ford_values, width=0.6, colorup='g',colordown='r');"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"____\n",
|
||
|
"# Partie 3: Analyse financière de base\n",
|
||
|
"\n",
|
||
|
"Il est maintenant temps de se concentrer sur quelques calculs financiers clés. Cela vous servira de transition vers la deuxième moitié du cours. Vous n'avez qu'à suivre les instructions, il s'agira principalement d'un exercice de conversion d'une équation ou d'un concept mathématique en code à l'aide de python et pandas, ce que nous ferons souvent lorsque nous travaillerons avec des données quantitatives! Si vous vous sentez perdu dans cette section, ne vous inquiétez pas! Allez simplement au notebook (ou vidéo) sur les solutions et traitez-la comme une revue de code, utilisez le style d'apprentissage qui vous convient le mieux!\n",
|
||
|
"\n",
|
||
|
"Commençons !\n",
|
||
|
"____"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Rendement quotidien en pourcentage\n",
|
||
|
"Nous commencerons par calculer la rendement quotidienne en pourcentage. Le rendement (en %) est défini par la formule suivante :"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"$ r_t = \\frac{p_t}{p_{t-1}} -1$"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Cela définit r_t (rendement à l'instant t) comme étant égal au prix à l'instant t divisé par le prix à l'instant t-1 (la veille) moins 1. En gros, cela vous informe simplement de votre pourcentage de gain (ou de perte) si vous avez acheté l'action le jour et l'avez ensuite vendue le lendemain. Bien que cela ne soit pas nécessairement utile pour tenter de prédire les valeurs futures du titre, c'est très utile pour analyser la volatilité du titre. Si les rendements quotidiens ont une large distribution, le titre est plus volatil d'un jour à l'autre. Calculons les pourcentages de rendement, puis traçons un histogramme et décidons quel titre est le plus stable!"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"**Créez une nouvelle colonne pour chaque dataframe appelée 'returns'. Cette colonne sera calculée à partir de la colonne de prix à la fermeture'Close'. Il y a deux façons de faire cela, soit un simple calcul en utilisant la méthode .shift() qui suit la formule ci-dessus, ou vous pouvez aussi utiliser la méthode pct_change intégrée à pandas.**"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 31,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# Méthode 1: en utilisant shift\n",
|
||
|
"tesla['returns'] = (tesla['Close'] / tesla['Close'].shift(1) ) - 1"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 32,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<style scoped>\n",
|
||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe tbody tr th {\n",
|
||
|
" vertical-align: top;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe thead th {\n",
|
||
|
" text-align: right;\n",
|
||
|
" }\n",
|
||
|
"</style>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>High</th>\n",
|
||
|
" <th>Low</th>\n",
|
||
|
" <th>Open</th>\n",
|
||
|
" <th>Close</th>\n",
|
||
|
" <th>Volume</th>\n",
|
||
|
" <th>Adj Close</th>\n",
|
||
|
" <th>Total Traded</th>\n",
|
||
|
" <th>returns</th>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>Date</th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-03</th>\n",
|
||
|
" <td>29.500000</td>\n",
|
||
|
" <td>27.650000</td>\n",
|
||
|
" <td>28.940001</td>\n",
|
||
|
" <td>28.080000</td>\n",
|
||
|
" <td>928100</td>\n",
|
||
|
" <td>28.080000</td>\n",
|
||
|
" <td>2.685921e+07</td>\n",
|
||
|
" <td>NaN</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-04</th>\n",
|
||
|
" <td>28.670000</td>\n",
|
||
|
" <td>27.500000</td>\n",
|
||
|
" <td>28.209999</td>\n",
|
||
|
" <td>27.709999</td>\n",
|
||
|
" <td>630100</td>\n",
|
||
|
" <td>27.709999</td>\n",
|
||
|
" <td>1.777512e+07</td>\n",
|
||
|
" <td>-0.013177</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-05</th>\n",
|
||
|
" <td>27.930000</td>\n",
|
||
|
" <td>26.850000</td>\n",
|
||
|
" <td>27.760000</td>\n",
|
||
|
" <td>27.120001</td>\n",
|
||
|
" <td>1005500</td>\n",
|
||
|
" <td>27.120001</td>\n",
|
||
|
" <td>2.791268e+07</td>\n",
|
||
|
" <td>-0.021292</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-06</th>\n",
|
||
|
" <td>27.790001</td>\n",
|
||
|
" <td>26.410000</td>\n",
|
||
|
" <td>27.200001</td>\n",
|
||
|
" <td>26.910000</td>\n",
|
||
|
" <td>986300</td>\n",
|
||
|
" <td>26.910000</td>\n",
|
||
|
" <td>2.682736e+07</td>\n",
|
||
|
" <td>-0.007743</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-09</th>\n",
|
||
|
" <td>27.490000</td>\n",
|
||
|
" <td>26.120001</td>\n",
|
||
|
" <td>27.000000</td>\n",
|
||
|
" <td>27.250000</td>\n",
|
||
|
" <td>897000</td>\n",
|
||
|
" <td>27.250000</td>\n",
|
||
|
" <td>2.421900e+07</td>\n",
|
||
|
" <td>0.012635</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" High Low Open Close Volume Adj Close \\\n",
|
||
|
"Date \n",
|
||
|
"2012-01-03 29.500000 27.650000 28.940001 28.080000 928100 28.080000 \n",
|
||
|
"2012-01-04 28.670000 27.500000 28.209999 27.709999 630100 27.709999 \n",
|
||
|
"2012-01-05 27.930000 26.850000 27.760000 27.120001 1005500 27.120001 \n",
|
||
|
"2012-01-06 27.790001 26.410000 27.200001 26.910000 986300 26.910000 \n",
|
||
|
"2012-01-09 27.490000 26.120001 27.000000 27.250000 897000 27.250000 \n",
|
||
|
"\n",
|
||
|
" Total Traded returns \n",
|
||
|
"Date \n",
|
||
|
"2012-01-03 2.685921e+07 NaN \n",
|
||
|
"2012-01-04 1.777512e+07 -0.013177 \n",
|
||
|
"2012-01-05 2.791268e+07 -0.021292 \n",
|
||
|
"2012-01-06 2.682736e+07 -0.007743 \n",
|
||
|
"2012-01-09 2.421900e+07 0.012635 "
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 32,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"tesla.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 33,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# méthode 2: en utilisant pct_change\n",
|
||
|
"tesla['returns'] = tesla['Close'].pct_change(1)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 34,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<style scoped>\n",
|
||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe tbody tr th {\n",
|
||
|
" vertical-align: top;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe thead th {\n",
|
||
|
" text-align: right;\n",
|
||
|
" }\n",
|
||
|
"</style>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>High</th>\n",
|
||
|
" <th>Low</th>\n",
|
||
|
" <th>Open</th>\n",
|
||
|
" <th>Close</th>\n",
|
||
|
" <th>Volume</th>\n",
|
||
|
" <th>Adj Close</th>\n",
|
||
|
" <th>Total Traded</th>\n",
|
||
|
" <th>returns</th>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>Date</th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-03</th>\n",
|
||
|
" <td>29.500000</td>\n",
|
||
|
" <td>27.650000</td>\n",
|
||
|
" <td>28.940001</td>\n",
|
||
|
" <td>28.080000</td>\n",
|
||
|
" <td>928100</td>\n",
|
||
|
" <td>28.080000</td>\n",
|
||
|
" <td>2.685921e+07</td>\n",
|
||
|
" <td>NaN</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-04</th>\n",
|
||
|
" <td>28.670000</td>\n",
|
||
|
" <td>27.500000</td>\n",
|
||
|
" <td>28.209999</td>\n",
|
||
|
" <td>27.709999</td>\n",
|
||
|
" <td>630100</td>\n",
|
||
|
" <td>27.709999</td>\n",
|
||
|
" <td>1.777512e+07</td>\n",
|
||
|
" <td>-0.013177</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-05</th>\n",
|
||
|
" <td>27.930000</td>\n",
|
||
|
" <td>26.850000</td>\n",
|
||
|
" <td>27.760000</td>\n",
|
||
|
" <td>27.120001</td>\n",
|
||
|
" <td>1005500</td>\n",
|
||
|
" <td>27.120001</td>\n",
|
||
|
" <td>2.791268e+07</td>\n",
|
||
|
" <td>-0.021292</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-06</th>\n",
|
||
|
" <td>27.790001</td>\n",
|
||
|
" <td>26.410000</td>\n",
|
||
|
" <td>27.200001</td>\n",
|
||
|
" <td>26.910000</td>\n",
|
||
|
" <td>986300</td>\n",
|
||
|
" <td>26.910000</td>\n",
|
||
|
" <td>2.682736e+07</td>\n",
|
||
|
" <td>-0.007743</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-09</th>\n",
|
||
|
" <td>27.490000</td>\n",
|
||
|
" <td>26.120001</td>\n",
|
||
|
" <td>27.000000</td>\n",
|
||
|
" <td>27.250000</td>\n",
|
||
|
" <td>897000</td>\n",
|
||
|
" <td>27.250000</td>\n",
|
||
|
" <td>2.421900e+07</td>\n",
|
||
|
" <td>0.012635</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" High Low Open Close Volume Adj Close \\\n",
|
||
|
"Date \n",
|
||
|
"2012-01-03 29.500000 27.650000 28.940001 28.080000 928100 28.080000 \n",
|
||
|
"2012-01-04 28.670000 27.500000 28.209999 27.709999 630100 27.709999 \n",
|
||
|
"2012-01-05 27.930000 26.850000 27.760000 27.120001 1005500 27.120001 \n",
|
||
|
"2012-01-06 27.790001 26.410000 27.200001 26.910000 986300 26.910000 \n",
|
||
|
"2012-01-09 27.490000 26.120001 27.000000 27.250000 897000 27.250000 \n",
|
||
|
"\n",
|
||
|
" Total Traded returns \n",
|
||
|
"Date \n",
|
||
|
"2012-01-03 2.685921e+07 NaN \n",
|
||
|
"2012-01-04 1.777512e+07 -0.013177 \n",
|
||
|
"2012-01-05 2.791268e+07 -0.021292 \n",
|
||
|
"2012-01-06 2.682736e+07 -0.007743 \n",
|
||
|
"2012-01-09 2.421900e+07 0.012635 "
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 34,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"tesla.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 35,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# répéter pour les autres dataframes\n",
|
||
|
"ford['returns'] = ford['Close'].pct_change(1)\n",
|
||
|
"gm['returns'] = gm['Close'].pct_change(1)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 36,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<style scoped>\n",
|
||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe tbody tr th {\n",
|
||
|
" vertical-align: top;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe thead th {\n",
|
||
|
" text-align: right;\n",
|
||
|
" }\n",
|
||
|
"</style>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>High</th>\n",
|
||
|
" <th>Low</th>\n",
|
||
|
" <th>Open</th>\n",
|
||
|
" <th>Close</th>\n",
|
||
|
" <th>Volume</th>\n",
|
||
|
" <th>Adj Close</th>\n",
|
||
|
" <th>Total Traded</th>\n",
|
||
|
" <th>returns</th>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>Date</th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-03</th>\n",
|
||
|
" <td>11.25</td>\n",
|
||
|
" <td>10.99</td>\n",
|
||
|
" <td>11.00</td>\n",
|
||
|
" <td>11.13</td>\n",
|
||
|
" <td>45709900.0</td>\n",
|
||
|
" <td>7.687118</td>\n",
|
||
|
" <td>5.028089e+08</td>\n",
|
||
|
" <td>NaN</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-04</th>\n",
|
||
|
" <td>11.53</td>\n",
|
||
|
" <td>11.07</td>\n",
|
||
|
" <td>11.15</td>\n",
|
||
|
" <td>11.30</td>\n",
|
||
|
" <td>79725200.0</td>\n",
|
||
|
" <td>7.804530</td>\n",
|
||
|
" <td>8.889359e+08</td>\n",
|
||
|
" <td>0.015274</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-05</th>\n",
|
||
|
" <td>11.63</td>\n",
|
||
|
" <td>11.24</td>\n",
|
||
|
" <td>11.33</td>\n",
|
||
|
" <td>11.59</td>\n",
|
||
|
" <td>67877500.0</td>\n",
|
||
|
" <td>8.004824</td>\n",
|
||
|
" <td>7.690521e+08</td>\n",
|
||
|
" <td>0.025664</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-06</th>\n",
|
||
|
" <td>11.80</td>\n",
|
||
|
" <td>11.52</td>\n",
|
||
|
" <td>11.74</td>\n",
|
||
|
" <td>11.71</td>\n",
|
||
|
" <td>59840700.0</td>\n",
|
||
|
" <td>8.087703</td>\n",
|
||
|
" <td>7.025298e+08</td>\n",
|
||
|
" <td>0.010354</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-09</th>\n",
|
||
|
" <td>11.95</td>\n",
|
||
|
" <td>11.70</td>\n",
|
||
|
" <td>11.83</td>\n",
|
||
|
" <td>11.80</td>\n",
|
||
|
" <td>53981500.0</td>\n",
|
||
|
" <td>8.149862</td>\n",
|
||
|
" <td>6.386011e+08</td>\n",
|
||
|
" <td>0.007686</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" High Low Open Close Volume Adj Close Total Traded \\\n",
|
||
|
"Date \n",
|
||
|
"2012-01-03 11.25 10.99 11.00 11.13 45709900.0 7.687118 5.028089e+08 \n",
|
||
|
"2012-01-04 11.53 11.07 11.15 11.30 79725200.0 7.804530 8.889359e+08 \n",
|
||
|
"2012-01-05 11.63 11.24 11.33 11.59 67877500.0 8.004824 7.690521e+08 \n",
|
||
|
"2012-01-06 11.80 11.52 11.74 11.71 59840700.0 8.087703 7.025298e+08 \n",
|
||
|
"2012-01-09 11.95 11.70 11.83 11.80 53981500.0 8.149862 6.386011e+08 \n",
|
||
|
"\n",
|
||
|
" returns \n",
|
||
|
"Date \n",
|
||
|
"2012-01-03 NaN \n",
|
||
|
"2012-01-04 0.015274 \n",
|
||
|
"2012-01-05 0.025664 \n",
|
||
|
"2012-01-06 0.010354 \n",
|
||
|
"2012-01-09 0.007686 "
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 36,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"ford.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 37,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<style scoped>\n",
|
||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe tbody tr th {\n",
|
||
|
" vertical-align: top;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe thead th {\n",
|
||
|
" text-align: right;\n",
|
||
|
" }\n",
|
||
|
"</style>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>High</th>\n",
|
||
|
" <th>Low</th>\n",
|
||
|
" <th>Open</th>\n",
|
||
|
" <th>Close</th>\n",
|
||
|
" <th>Volume</th>\n",
|
||
|
" <th>Adj Close</th>\n",
|
||
|
" <th>Total Traded</th>\n",
|
||
|
" <th>MA50</th>\n",
|
||
|
" <th>MA200</th>\n",
|
||
|
" <th>returns</th>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>Date</th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-03</th>\n",
|
||
|
" <td>21.180000</td>\n",
|
||
|
" <td>20.750000</td>\n",
|
||
|
" <td>20.830000</td>\n",
|
||
|
" <td>21.049999</td>\n",
|
||
|
" <td>9321300.0</td>\n",
|
||
|
" <td>16.103352</td>\n",
|
||
|
" <td>1.941627e+08</td>\n",
|
||
|
" <td>NaN</td>\n",
|
||
|
" <td>NaN</td>\n",
|
||
|
" <td>NaN</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-04</th>\n",
|
||
|
" <td>21.370001</td>\n",
|
||
|
" <td>20.750000</td>\n",
|
||
|
" <td>21.049999</td>\n",
|
||
|
" <td>21.150000</td>\n",
|
||
|
" <td>7856700.0</td>\n",
|
||
|
" <td>16.179853</td>\n",
|
||
|
" <td>1.653835e+08</td>\n",
|
||
|
" <td>NaN</td>\n",
|
||
|
" <td>NaN</td>\n",
|
||
|
" <td>0.004751</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-05</th>\n",
|
||
|
" <td>22.290001</td>\n",
|
||
|
" <td>20.959999</td>\n",
|
||
|
" <td>21.100000</td>\n",
|
||
|
" <td>22.170000</td>\n",
|
||
|
" <td>17880600.0</td>\n",
|
||
|
" <td>16.960161</td>\n",
|
||
|
" <td>3.772807e+08</td>\n",
|
||
|
" <td>NaN</td>\n",
|
||
|
" <td>NaN</td>\n",
|
||
|
" <td>0.048227</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-06</th>\n",
|
||
|
" <td>23.030001</td>\n",
|
||
|
" <td>22.240000</td>\n",
|
||
|
" <td>22.260000</td>\n",
|
||
|
" <td>22.920000</td>\n",
|
||
|
" <td>18234500.0</td>\n",
|
||
|
" <td>17.533915</td>\n",
|
||
|
" <td>4.059000e+08</td>\n",
|
||
|
" <td>NaN</td>\n",
|
||
|
" <td>NaN</td>\n",
|
||
|
" <td>0.033829</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-09</th>\n",
|
||
|
" <td>23.430000</td>\n",
|
||
|
" <td>22.700001</td>\n",
|
||
|
" <td>23.200001</td>\n",
|
||
|
" <td>22.840000</td>\n",
|
||
|
" <td>12084500.0</td>\n",
|
||
|
" <td>17.472712</td>\n",
|
||
|
" <td>2.803604e+08</td>\n",
|
||
|
" <td>NaN</td>\n",
|
||
|
" <td>NaN</td>\n",
|
||
|
" <td>-0.003490</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" High Low Open Close Volume Adj Close \\\n",
|
||
|
"Date \n",
|
||
|
"2012-01-03 21.180000 20.750000 20.830000 21.049999 9321300.0 16.103352 \n",
|
||
|
"2012-01-04 21.370001 20.750000 21.049999 21.150000 7856700.0 16.179853 \n",
|
||
|
"2012-01-05 22.290001 20.959999 21.100000 22.170000 17880600.0 16.960161 \n",
|
||
|
"2012-01-06 23.030001 22.240000 22.260000 22.920000 18234500.0 17.533915 \n",
|
||
|
"2012-01-09 23.430000 22.700001 23.200001 22.840000 12084500.0 17.472712 \n",
|
||
|
"\n",
|
||
|
" Total Traded MA50 MA200 returns \n",
|
||
|
"Date \n",
|
||
|
"2012-01-03 1.941627e+08 NaN NaN NaN \n",
|
||
|
"2012-01-04 1.653835e+08 NaN NaN 0.004751 \n",
|
||
|
"2012-01-05 3.772807e+08 NaN NaN 0.048227 \n",
|
||
|
"2012-01-06 4.059000e+08 NaN NaN 0.033829 \n",
|
||
|
"2012-01-09 2.803604e+08 NaN NaN -0.003490 "
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 37,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"gm.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"**Maintenant, tracez un histogramme des rendements de chaque entreprise. Soit vous les faites séparément, soit vous les empilez les uns sur les autres. Quelle est l'action la plus \"volatile\"? (selon la variance des rendements quotidiens, nous discuterons de la volatilité de façon beaucoup plus détaillée dans les prochaines sections).**"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 38,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<matplotlib.axes._subplots.AxesSubplot at 0x11944bb10>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 38,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAD4CAYAAADmWv3KAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAV6klEQVR4nO3df5Dcd33f8ecbG4ztSyzZwhdFcjhTXDpgkQRdHSht5w6H1OAEewrM2LggUVNNGpJ4giiW687gNDAREIVA05KomFgZKIft0LGxAceovjhkYhLLEM4/YiyMxkhWZIhttWfcgOi7f+xXeHXs6Xb3+13dVx+ej5mb++73+9nv96Xd1Wu/993v7kZmIkkqz7OWO4AkaTQseEkqlAUvSYWy4CWpUBa8JBXqxOUOALBq1aqcmJhoZF1PPfUUp556aiPrapK5BtfWbOYaTFtzQXuz9Ztr165d387M5y06IDOX/Wf9+vXZlDvuuKOxdTXJXINrazZzDaatuTLbm63fXMDdeZRu9RCNJBXKgpekQlnwklQoC16SCmXBS1KhLHhJKpQFL0mFsuAlqVAWvCQVqhUfVSC12cSWW4+4vHndITZuuZU9Wy9cpkRSf9yDl6RCWfCSVCgLXpIKZcFLUqEseEkqlAUvSYWy4CWpUBa8JBXKgpekQlnwklQoC16SCrVkwUfExyLisYi4t8eyd0ZERsSq6nJExIcjYndEfDUiXjaK0JKkpfWzB38dcMHCmRFxFvBq4JGu2a8Bzql+NgEfqR9RkjSMJQs+M+8EHu+x6IPAu4DsmncR8MfZcRewIiJWN5JUkjSQyMylB0VMALdk5rnV5dcB52fmFRGxB5jMzG9HxC3A1sz8YjVuJ3BlZt7dY52b6OzlMz4+vn5mZqaRf9D8/DxjY2ONrKtJ5hpcW7LN7Tt4xOXxk+HA07BuzWnLlKi3ttxeC7U1F7Q3W7+5pqend2Xm5G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MbTnM0hmbge2A0xOTubU1NSwUY4wOztLU+tqkrkGVyfbxhHuwW9ed4htc6P/lI89l00NNL6t92Vbc0F7szWVq85ZND8PfCMzv5WZ3wM+DfwzYEVEHH70rwUerZlRkjSEOgX/CPDyiDglIgI4H7gfuAN4QzVmA3BTvYiSpGEMXfCZ+SXgRjqnQs5V69oOXAm8IyJ2A2cA1zaQU5I0oFoHEjPz3cC7F8x+GDivznolSfX5TlZJKpQFL0mFsuAlqVAWvCQVyoKXpEJZ8JJUKAtekgplwUtSoSx4SSqUBS9JhbLgJalQFrwkFcqCl6RCjf5raaQR8rtXpcW5By9JhbLgJalQFrwkFcqCl6RC1Sr4iFgRETdGxN9GxAMR8YqIOD0ibo+Ih6rfK5sKK0nqX909+A8Bn8/MfwL8NPAAsAXYmZnnADury5KkY2zogo+IHwf+JXAtQGZ+NzOfBC4CdlTDdgAX1w0pSRpcnT34FwDfAv4oIr4cER+NiFOB8czcD1D9PrOBnJKkAUVmDnfFiEngLuCVmfmliPgQ8L+BX8vMFV3jnsjMHzoOHxGbgE0A4+Pj62dmZobKsdD8/DxjY2ONrKtJ5hpcP9nm9h08RmmeMX4yHHh69NtZt+a0gca39b5say5ob7Z+c01PT+/KzMnFltcp+J8A7srMieryv6BzvP2FwFRm7o+I1cBsZr7oaOuanJzMu+++e6gcC83OzjI1NdXIuppkrsH1k2053sm6ed0hts2N/k3ge7ZeOND4tt6Xbc0F7c3Wb66IOGrBD32IJjP/DvhmRBwu7/OB+4GbgQ3VvA3ATcNuQ5I0vLq7Ib8GfCIingM8DLyVzpPG9RFxOfAI8Maa25AkDaFWwWfmV4Befx6cX2e9kqT6/DRJqaUWe31h0GPz+tHlRxVIUqEseEkqlAUvSYWy4CWpUBa8JBXKgpekQln
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"ford['returns'].hist(bins=50)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 39,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<matplotlib.axes._subplots.AxesSubplot at 0x1195afa90>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 39,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD4CAYAAADvsV2wAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAT5ElEQVR4nO3dfZBddX3H8fdXkMetJIiumKCLY2orRFuzotbW2RWtKFaYgjP4GBQn0ylaR2JLqJ1RWx3jA/Wh2nYyosbRsjyoAwWfMGVFnYImgoQQMREyGEhBBbGLVI1++8c9GS/JbnJzzrm7d/N7v2Z29t5zzv3dT/ZuPvu759x7bmQmkqQD3yPmOoAkaXZY+JJUCAtfkgph4UtSISx8SSrEwXMdAOCYY47JkZGRRmM8+OCDHHnkke0EapnZ6jFbPWarZz5m27Bhw08y8zE9D5SZc/61bNmybOraa69tPEa/mK0es9VjtnrmYzZgfe5H1+5zl05EfCIi7o2IW7qWvT8ivh8RN0fEFyJiQde6CyJia0TcFhEv6vkvjySpr3rZh/8p4JTdll0DnJiZTwN+AFwAEBFPBc4CTqhu868RcVBraSVJte2z8DPzOuC+3ZZ9NTN3VlevBxZXl08DJjLzl5l5B7AVOKnFvJKkmiJ7OLVCRIwAV2XmidOs+0/gksz8TER8FLg+Mz9TrbsI+FJmXj7N7VYAKwCGh4eXTUxMNPl3MDU1xdDQUKMx+sVs9Zit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wJakQFr4kFcLCl6RC+IlXBZjuE5t2Wbl0FoMcYGb6uW5bfeosJ5F64wxfkgph4UtSIdylI7XMXT0aVM7wJakQFr4kFcLCl6RC1C78iDguIq6
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"gm['returns'].hist(bins=50)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 40,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<matplotlib.axes._subplots.AxesSubplot at 0x119344ed0>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 40,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAUGElEQVR4nO3dfYxldX3H8fe3+FDqtDyI3m4W2pF0NRXWbt1bamLUO8UHhEa08Ykg7irtaIKJjfuH+JBqNCZbdbU1bdW1ErBVBhQRitQWt45oItVdpSyIyqIr3YXsKuLiyIZ28Ns/5my9zt7ZOXfuvTNzf/f9SiZz7+/85pwv3xw+e+bMuedEZiJJKsuvrXQBkqT+M9wlqUCGuyQVyHCXpAIZ7pJUoEetdAEAp5xySo6Pj9ea+/Of/5zHPe5xgy1oyNiTzuxLZ/blaMPak127dv04M5/QadmqCPfx8XF27txZa+709DStVmuwBQ0Ze9KZfenMvhxtWHsSET9caJmn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m/8hKokFchwl6QCGe6SVCDDXZIKZLhLUoEMd0kqkOEuSQUy3CWpQIa7JBXIcJekAg3ilr/Sko0v4da+ko5muEuLWOgfnL1bz1vmSqT6PC0jSQUy3CWpQIa7JBXIcJekAi35D6oR8RTgqrah04G/Ak4E/gL4UTX+1sy8cckVSpK6tuRwz8zvAhsAIuI4YD9wLXOP1ftgZr6/LxVKkrrWr9MyZwN3Z+YP+7Q+SVIP+hXurwSubHv/hoi4LSIui4iT+rQNSVJNMfc86x5WEPEY4F7gjMw8EBEN4MdAAu8G1mTmazv83CQwCdBoNDZOTU3V2t7MzAx
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"tesla['returns'].hist(bins=50)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 41,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<matplotlib.legend.Legend at 0x11926cdd0>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 41,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlYAAAHSCAYAAAAubIVMAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO3dfbDfVX0n8PfJA0QTeQoSaCIQB6KrZIkh0mhnNDx11d0inRUQVg2VToairEPXsXbXGaidzkLXMdWp2s3UFrpVEwHRtCpODEbXqVhJYHmoEuNTvJUSQOESMCDk7B/5JYbkQu7Duff3+928XjPM/X2fP+Fww/ue77nnlFprAAAYuyndLgAAYLIQrAAAGhGsAAAaEawAABoRrAAAGhGsAAAamdbtApLk6KOPrieeeOKY7/P4449n5syZYy+InqA9JxftObloz8lFe47Mxo0bH6q1vnioYz0RrE488cTcfvvtY77Phg0bsmzZsrEXRE/QnpOL9pxctOfkoj1HppTyk+c65lUgAEAjghUAQCOCFQBAIz0xxgoA6G2/+tWvMjAwkB07dnS7lAkzY8aMzJs3L9OnTx/2NYIVAHBAAwMDedGLXpQTTzwxpZRulzPuaq15+OGHMzAwkPnz5w/7Oq8CAYAD2rFjR2bPnn1QhKokKaVk9uzZI+6hE6wAgGE5WELVbqP58wpWAEDPe/jhh7No0aIsWrQoxx57bObOnbtn+6mnnhr2fd72trfl85///LjVaYwVADBiK9dtbnq/K89Z8LzHZ8+enTvvvDNJcvXVV2fWrFl573vf27SGFvRYAQB97frrr8/pp5+eRYsW5fLLL8/OnTvz9NNP5+1vf3sWLlyYU045JR/96Ef3u+6qq67Kq1/96pxyyim57LLLUmsdcy2CFQDQt+65557cfPPN+ad/+qfceeedefrpp7N69eps3LgxDz30UO6+++7cc889ecc73rHfte95z3vyne98J3fffXceffTR3HLLLWOuR7ACAPrWV7/61XznO9/JkiVLsmjRonz961/PD37wg5x00km577778p73vCdf+cpXcvjhh+937fr163P66afn1FNPzde//vXce++9Y67HGCsAoG/VWvPOd74zf/qnf7rfsbvuuitf/vKX89GPfjQ33XRTVq1atefYE088kXe/+93ZtGlT5s6dmw984ANNJj/VYwUA9K2zzz47n/3sZ/PQQw8l2fXbg1u3bs2DDz6YWmvOP//8/Mmf/Ek2bdr0rOt++ctfZsqUKTn66KPz2GOP5aabbmpSjx4rAKBvLVy4MFdddVXOPvvs7Ny5M9OnT89f/dVfZerUqbn00ktTa00pJddee+2zrps9e3aWL1+eU045JSeccEJ+8zd/s0k9ghUAMGIHmh5hPF199dXP2r744otz8cUX73feHXfcsd++v//7v9/z+Zprrsk111zTtDavAgEAGhGsAAAaEawAABoxxgpoaqhlLro5FgNgIumxAgBoRLACAGhEsALG3cp1m7PtsSezct3mPf8AjNQDDzyQiy++OC996Utz2mmn5TWveU1uvvnmbNiwIaWUfPKTn9xz7h133JFSSj70oQ9NaI3GWAEAI/e1/9n2fmf88fMerrXmvPPOy/Lly/PpT386SfKTn/wka9euzZFHHpmFCxdmzZo1ufTSS5Mkq1evzqmnntq2xmHQYwUA9Lxbb701hxxySC677LI9+0444YRcccUVSZLjjz8+O3bsyAMPPJBaa2655Za88Y1vnPA69VgBAD3v3nvvzeLFi5/3nLe85S254YYb8qpXvSqLFy/OoYceOkHV/ZoeKwCg77zrXe/Kqaeemle/+tV79l1wwQW54YYb8pnPfCYXXXRRV+oSrACAnvfKV74ymzZt2rP9sY99LOvXr8+DDz64Z9+xxx6b6dOnZ926dTnrrLO6UaZgBQD0vjPPPDM7duzIJz7xiT37nnjiif3O++AHP5hrr702U6dOncjy9jDGCgDoeaWUfP7zn8+VV16ZP//zP8+LX/zizJw5M9dee+2zznvta1/bpQp3EawAgJE7wPQI4+G4447L6tWrhzy2bNmy/fZdffXV41vQELwKBABoRLACAGhEsAIAaESwAgBoRLACAGhEsAIAaESwAgD6wtSpU7No0aI9//z4xz8e9b0uueSS3Hjjje2K6zCPFQAwYh+/8+NN73f5ossPeM4LXvCC3HnnnSO+99NPP51p0yYm8ghWAEDf2rFjR/7gD/4gt99+e6ZNm5YPf/jDOeOMM3Ldddfli1/8Ynbs2JHHH38869evzxVXXJFbb7018+fPT611XOoRrACAvvDLX/4yixYtSpLMnz8/N998cz72sY8lSe6+++5873vfy2//9m9n8+bNSZJvfetbueuuu3LUUUflc5/7XO67777cfffdeeCBB/KKV7wi73znO5vXKFgBAH1hqFeB3/zmN3PFFVckSV7+8pfnhBNO2BOszjnnnBx11FFJkm984xu56KKLMnXq1PzGb/xGzjzzzHGp0eB1AKBvPd8rvZkzZz5ru5Qy3uUIVgBA/3rd616XT33qU0mSzZs3Z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gBQDQiGAFANCIYAUA0IhgBQDQiGAFANCIYAUA0IhgBQDQiGAFANDItG4XAPSnles2d7sEgJ6jxwoAoBHBCgCgEcEKAKARwQoAoBHBCgCgEcEKAKARwQoAoBHBCgCgEcEKAKARwQoAoBHBCgCgEcEKAKARwQoAoJFp3S4AYLeV6zbvt+/KcxZ0oRKA0dFjBQDQiGAFANCIYAUA0IgxVkBXDDWeCqDf6bECAGhEsAIAaESwAgBoRLACAGhEsAIAaESwAgBoRLACAGhEsAIAaESwAgBoRLACAGhkTMGqlHJlKeXeUso9pZTPlFJmlFLml1K+XUr5fillTSnlkFbFAgD0slEHq1LK3CT/NcmSWuspSaYmeWuSa5OsrLWenOQ
|
||
|
"text/plain": [
|
||
|
"<Figure size 720x576 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"tesla['returns'].hist(bins=100,label='Tesla',figsize=(10,8),alpha=0.5)\n",
|
||
|
"gm['returns'].hist(bins=100,label='GM',alpha=0.5)\n",
|
||
|
"ford['returns'].hist(bins=100,label='Ford',alpha=0.5)\n",
|
||
|
"plt.legend()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"**Essayez aussi de tracer un KDE au lieu dun 'histogrammes pour avoir un autre point de vue. Quelle action a le tracé le plus large?**"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 42,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<matplotlib.legend.Legend at 0x119b3c790>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 42,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/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bNGgCWLl3KPffcw9e+9jUANm/ezLZt23jVq17FCy+8AMDjjz/Opk2baG5u5oc//CHbt29n8+bN9PT0cNFFF/Hud7+7qv8GUGgWEam5sU5zxB855ng8GKdrpKsGFYmIeGuy8YxHH32UD33oQwCsWLGCxYsXj4fmG264gebm8iZQv/nNb7j55pvx+XwsXLiQ66+/3pUaFZpFRGpsbKb56NUzoLyChjrNIuKl6TrCXppqzCIaPfbvpTHG7XK0eoaISK2NheajV8+AI+MZbs3niYjMZddccw3f+c53AHjhhRfYt28fF1xwwaTX3XXXXRSLRbq7u/n1r3/tSj3qNIuI1Nhkq2dAOTQXSoUJaziLiJwN3v/+9/O+972PVatW4ff7ueOOOwiFQhOue93rXsdDDz3EqlWrOP/883nFK17hSj0KzSIiNTbVeAaUNzhRaBaRM1kymZxwrK6ujjvuuGPC8Xe96128613vGv/dGMM///M/u1hdmcYzRERqLDWawm/8hHzHdlAaQ42AdgUUEZkLFJpFRGosNZoiEohMeJFlrNOsDU5ERGpPoVlEpMZSo6lJxy/GOs0KzSIitafQLCJSYycKzUfPNIuIuOlsXKVntv9mhWYRkRpTaBaRWqqrq2NgYOCsCs7WWgYGBqirq5vxPVo9Q0SkxtKj6QlbaAP4HT/1gXqNZ4iIqzo7O9m/fz99fX21LsVTdXV1dHZ2zvh6hWYRkRpLjiaZH50/6bmGUIM
|
||
|
"text/plain": [
|
||
|
"<Figure size 864x432 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"tesla['returns'].plot(kind='kde',label='Tesla',figsize=(12,6))\n",
|
||
|
"gm['returns'].plot(kind='kde',label='GM')\n",
|
||
|
"ford['returns'].plot(kind='kde',label='Ford')\n",
|
||
|
"plt.legend()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"**Essayez aussi de créer des diagrammes en boîtes comparant les rendements.**"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 43,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<matplotlib.axes._subplots.AxesSubplot at 0x1a1bab9050>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 43,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAewAAAJ1CAYAAAAbq8N2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO3df3xc9X3n+/dnRrIGy+AfQSkg25jeBTJoSNOgZrdBIRFNNnF3H+CwUDJm98LVxIQH11Nu2TXmMrlN3HactdnQ64doUAxSGyiaGNrUdQImSeMpXYVlG/uSJsLTbCDmh7AJGNvEkhlpLH3vHxpPJSP/0sxw5iu9no+HHtKcOXPOx+hw3vp+z/d8jznnBAAAalso6AIAAMCpEdgAAHiAwAYAwAMENgAAHiCwAQDwAIENAIAH6oIu4ETOPfdct2zZsqDLAADgPbNr1679zrmmqd6r2cBetmyZdu7cGXQZAAC8Z8zs5RO9R5c4AAAeILABAPAAgQ0AgAcIbAAAPEBgAwDgAQIbAAAPENgAAHiAwAYAwAMENgAAHiCwAQDwAIENAIAHCGwAADxAYAMA4AECGwAADxDYAAB4gMAGAMADBDYAAB4gsAEA8ACBDQCABwhsAAA8QGADAOABAhsAAA8Q2B7LZDKKxWIKh8OKxWLKZDJBlwQAqJK6oAvA9GQyGaVSKXV3d6utrU19fX1KJBKSpHg8HnB1AIBKM+dc0DVMqbW11e3cuTPoMmp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ZLRlyxadf/75CoVCOv/887VlyxZlMpm
|
||
|
"text/plain": [
|
||
|
"<Figure size 576x792 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"box_df = pd.concat([tesla['returns'],gm['returns'],ford['returns']],axis=1)\n",
|
||
|
"box_df.columns = ['Tesla Returns',' GM Returns','Ford Returns']\n",
|
||
|
"box_df.plot(kind='box',figsize=(8,11),colormap='jet')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Comparaison des rendements quotidiens entre les actions\n",
|
||
|
"\n",
|
||
|
"**Créez un graphique matriciel de dispersion pour voir la corrélation entre les rendements quotidiens de chaque titre. Cela permet de répondre à la question de savoir dans quelle mesure les sociétés automobiles sont liées entre elles. Le marché considère-t-il Tesla comme une entreprise de technologie plutôt que comme une entreprise automobile ?**"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 44,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkEAAAHuCAYAAACYptgLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nOy9eYxk2XWf+Z23xx65197V1QubTYqUqRKHMkharcWCh4JH9tgSrJEBb6BgLWPD8ojEEOOFtkaCIIxga8Zjk5ZHsK0FEjwyZFPbkKJkioukbpHdbHazu7q79qxcI2N9+7t3/ngvszKrs7Kytq4l7wcUKvJGxIsTkTfynXfO75wjWmsMBoPBYDAYDhrWvTbAYDAYDA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WZxEFMUmsPd4J4NsjQYtqOU5nI/AuBwJ7it0njD3tzwk9Va/y/AtwHfpLXOgAj4y3fbMIPBYLjbDKKM3jhlEGWsjc21neH+YCNM6YcZ/TCjd5eaeRpK9lsddhL4VhHZ/vhfuvPmGAwGw1tH4NpbPU/iTPHS4pBW4DzwDeAMDzbb92Xg2aS54tz6BIAT03dv3t1BZD/VYb8A/J/AdwAfqP69f78vICI/KyKfE5F/cc36O0XkD0Xk8yLyrmrtO0XkSyLyWRF5qlr7xuoxnxORD1RrJ0Tk90Tkv4nI91ZrHRH5ryLy+yLy96s1R0R+pTreT2977Z+rHvfvRMSu1j5a2fOfRKRRrf11EfmiiPy2iBy6T238eyLyR5Wd37Lf34vBYChPNk8utHhioUlWKAql6YcZ2Q3GAYzijFeWRlzshXdt9pjh4NLwHZ5caPHkoSbtwGUQZSSZIskUw2h/YzK2c7kf8crSiEF4889
|
||
|
"text/plain": [
|
||
|
"<Figure size 576x576 with 9 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"scatter_matrix(box_df,figsize=(8,8),alpha=0.2,hist_kwds={'bins':50});"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"**Il semble que Ford et GM aient une sorte de relation, traçons juste ces deux-là dans un diagramme de dispersion pour voir cela de plus près !**"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 45,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<matplotlib.axes._subplots.AxesSubplot at 0x1a1bd9a090>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 45,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
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aqsbcX3QgixtUiwE0JsqJhtcvLYbnKOz+hcnpzjc/LY7oauUC1VWfOCkJzj39LzbsX3QgixtciviUKIDdffneK3Hj5IzvFJRq2GDzK1lbVExFrXytpWey+EEFuLVOyEELdFzDbpSkW3RJDZ6MraVnovhFiKtOxpXFKxE0KIJUhlTYilScuexiYVOyGEWIZU1oRYSFr2ND4JdkIIIYSoy0YtLBLrR4KdEEIIIeoiLXsanwQ7IYQQQtRFWvY0PonYQgghhKibLCxqbBLshBBCCLEqMduUQNegZChWCCHEqkgPMyEal1TshBBC1G079zAreoEMP4qGJ8FOCCFEXWp7mFW2Wnv2zCi/9fDBpg862znQiq1FhmKFENuKDCOu3XbtYSZNecVWIhU7IcS2sd5Vl604NHcr51zbw6xSsdsOPcyWCrRzeZec42+Z77vYPpr7p1EIIcrWexhxKw7N3eo5V3qYPXtmlLm8W32OZg832zXQiq1JhmKFENvCeg4jNvrQ3FLDzet1zpUeZr/xoQP81sMHGz7Mrgdpyiu2Evl1QwixLaxn1aWRh+aWq8qt5zlvxx5m0pRXbBVSsRNCbAvrWXVp1P0yb1aVq+ecZWHJzcVsk65UVEKdaGhSsRNCbBvrVXVp1LlmN6vKdaWiNz3nrThnUAhxIwl2QohtZb2GERtxaG6l4eblznk796cTotnIUKwQQqzRzYbmNmNYs57h5qXOebv2pxOiGUnFTggh1tlmDmuupZK4Xdp5bMW+g0KsVnP91AohxAaqJxg0wrDmaoebG3XO4HqSOYRiu5BgJ4QQdag3GKy1rUi9oXG9Kk6Ln6sR5wy
|
||
|
"text/plain": [
|
||
|
"<Figure size 720x576 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"box_df.plot(kind='scatter',x=' GM Returns',y='Ford Returns',alpha=0.4,figsize=(10,8))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"____\n",
|
||
|
"## Rendements quotidiens cumulatifs\n",
|
||
|
"\n",
|
||
|
"Super ! Nous pouvons maintenant voir quel titre a eu le plus grand écart de rendement quotidien (vous auriez dû vous rendre compte que c'était Tesla, notre graphique original du cours de l'action aurait dû aussi le montrer).\n",
|
||
|
"\n",
|
||
|
"Avec les rendements cumulatifs quotidiens, la question à laquelle nous essayons de répondre est la suivante: si j'avais investi 1$ dans l'entreprise au début de la série temporelle, combien vaudrait-elle aujourd'hui? Cette question est différente de celle du prix de l'action à la journée courante, car elle tiendra compte des rendements quotidiens. N'oubliez pas que notre simple calcul ici ne tiendra pas compte des actions qui redonnent un dividende. Examinons quelques exemples simples:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Disons qu'il y a une action \"ABC\" qui est activement négociée en bourse. ABC a les prix suivants correspondant aux dates indiquées:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
" Date Prix\n",
|
||
|
" 01/01/2018 10\n",
|
||
|
" 01/02/2018 15\n",
|
||
|
" 01/03/2018 20\n",
|
||
|
" 01/04/2018 25"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"**Rendement quotidien**: Le rendement quotidien est le profit ou perte réalisé par l'action par rapport à la veille. (C'est ce qu'on vient de calculer ci-dessus). Une valeur supérieure à 1 indique un profit, de même qu'une valeur inférieure à 1 indique une perte. Il est également exprimé en pourcentage pour mieux transmettre l'information. (Exprimé en pourcentage, si la valeur est supérieure à 0, le titre vous a donné un profit, sinon une perte). Ainsi, pour l'exemple ci-dessus, les rendements quotidiens seraient"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
" Date Rendement quotidien %Rendement quotidien\n",
|
||
|
" 01/01/2018 10/10 = 1 - \n",
|
||
|
" 01/02/2018 15/10 = 3/2 50%\n",
|
||
|
" 01/03/2018 20/15 = 4/3 33%\n",
|
||
|
" 01/04/2018 25/20 = 5/4 20%"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"**Rendement Cumulé**: Bien que les rendements quotidiens soient utiles, ils ne donnent pas à l'investisseur un aperçu immédiat des gains qu'il a réalisés jusqu'à présent, surtout si le titre est très volatil. Le rendement cumulatif est calculé par rapport au jour où l'investissement est effectué. Si le rendement cumulatif est supérieur à 1, vous faites des profits, sinon vous êtes en perte. Donc, pour l'exemple ci-dessus, les gains cumulatifs sont les suivants:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
" Date Rendement cumulé %rendement cumulé\n",
|
||
|
" 01/01/2018 10/10 = 1 100 % \n",
|
||
|
" 01/02/2018 15/10 = 3/2 150 %\n",
|
||
|
" 01/03/2018 20/10 = 2 200 %\n",
|
||
|
" 01/04/2018 25/10 = 5/2 250 %"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"La formule pour un rendement quotidien cumulatif est la suivante :\n",
|
||
|
"\n",
|
||
|
"$ i_i = (1+r_t) * i_{t-1} $\n",
|
||
|
"\n",
|
||
|
"Ici, nous pouvons voir que nous ne faisons que multiplier notre investissement précédent à i à t-1 par 1+notre pourcentage de rendement. Pandas rend cela très simple à calculer avec sa méthode cumprod(). En utilisant quelque chose de la manière suivante :\n",
|
||
|
"\n",
|
||
|
" df[daily_cumulative_return] = (1 + df[pct_daily_return]).cumprod()\n",
|
||
|
" "
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"**Créez une colonne de rendement quotidien cumulatif (cumulative daily return) pour le dataframe de chaque société automobile.**"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 46,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"tesla['Cumulative Return'] = (1 + tesla['returns']).cumprod()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 47,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<style scoped>\n",
|
||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe tbody tr th {\n",
|
||
|
" vertical-align: top;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe thead th {\n",
|
||
|
" text-align: right;\n",
|
||
|
" }\n",
|
||
|
"</style>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>High</th>\n",
|
||
|
" <th>Low</th>\n",
|
||
|
" <th>Open</th>\n",
|
||
|
" <th>Close</th>\n",
|
||
|
" <th>Volume</th>\n",
|
||
|
" <th>Adj Close</th>\n",
|
||
|
" <th>Total Traded</th>\n",
|
||
|
" <th>returns</th>\n",
|
||
|
" <th>Cumulative Return</th>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>Date</th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-03</th>\n",
|
||
|
" <td>29.500000</td>\n",
|
||
|
" <td>27.650000</td>\n",
|
||
|
" <td>28.940001</td>\n",
|
||
|
" <td>28.080000</td>\n",
|
||
|
" <td>928100</td>\n",
|
||
|
" <td>28.080000</td>\n",
|
||
|
" <td>2.685921e+07</td>\n",
|
||
|
" <td>NaN</td>\n",
|
||
|
" <td>NaN</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-04</th>\n",
|
||
|
" <td>28.670000</td>\n",
|
||
|
" <td>27.500000</td>\n",
|
||
|
" <td>28.209999</td>\n",
|
||
|
" <td>27.709999</td>\n",
|
||
|
" <td>630100</td>\n",
|
||
|
" <td>27.709999</td>\n",
|
||
|
" <td>1.777512e+07</td>\n",
|
||
|
" <td>-0.013177</td>\n",
|
||
|
" <td>0.986823</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-05</th>\n",
|
||
|
" <td>27.930000</td>\n",
|
||
|
" <td>26.850000</td>\n",
|
||
|
" <td>27.760000</td>\n",
|
||
|
" <td>27.120001</td>\n",
|
||
|
" <td>1005500</td>\n",
|
||
|
" <td>27.120001</td>\n",
|
||
|
" <td>2.791268e+07</td>\n",
|
||
|
" <td>-0.021292</td>\n",
|
||
|
" <td>0.965812</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-06</th>\n",
|
||
|
" <td>27.790001</td>\n",
|
||
|
" <td>26.410000</td>\n",
|
||
|
" <td>27.200001</td>\n",
|
||
|
" <td>26.910000</td>\n",
|
||
|
" <td>986300</td>\n",
|
||
|
" <td>26.910000</td>\n",
|
||
|
" <td>2.682736e+07</td>\n",
|
||
|
" <td>-0.007743</td>\n",
|
||
|
" <td>0.958333</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2012-01-09</th>\n",
|
||
|
" <td>27.490000</td>\n",
|
||
|
" <td>26.120001</td>\n",
|
||
|
" <td>27.000000</td>\n",
|
||
|
" <td>27.250000</td>\n",
|
||
|
" <td>897000</td>\n",
|
||
|
" <td>27.250000</td>\n",
|
||
|
" <td>2.421900e+07</td>\n",
|
||
|
" <td>0.012635</td>\n",
|
||
|
" <td>0.970442</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" High Low Open Close Volume Adj Close \\\n",
|
||
|
"Date \n",
|
||
|
"2012-01-03 29.500000 27.650000 28.940001 28.080000 928100 28.080000 \n",
|
||
|
"2012-01-04 28.670000 27.500000 28.209999 27.709999 630100 27.709999 \n",
|
||
|
"2012-01-05 27.930000 26.850000 27.760000 27.120001 1005500 27.120001 \n",
|
||
|
"2012-01-06 27.790001 26.410000 27.200001 26.910000 986300 26.910000 \n",
|
||
|
"2012-01-09 27.490000 26.120001 27.000000 27.250000 897000 27.250000 \n",
|
||
|
"\n",
|
||
|
" Total Traded returns Cumulative Return \n",
|
||
|
"Date \n",
|
||
|
"2012-01-03 2.685921e+07 NaN NaN \n",
|
||
|
"2012-01-04 1.777512e+07 -0.013177 0.986823 \n",
|
||
|
"2012-01-05 2.791268e+07 -0.021292 0.965812 \n",
|
||
|
"2012-01-06 2.682736e+07 -0.007743 0.958333 \n",
|
||
|
"2012-01-09 2.421900e+07 0.012635 0.970442 "
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 47,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"tesla.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 48,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"ford['Cumulative Return'] = (1 + ford['returns']).cumprod()\n",
|
||
|
"gm['Cumulative Return'] = (1 + gm['returns']).cumprod()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"**Tracez maintenant les colonnes de rendement cumulatif en fonction de l'index de la série temporelle. Quel titre a affiché le rendement le plus élevé pour un dollar investi? Lequel a affiché le rendement le plus faible?**"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 49,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<matplotlib.legend.Legend at 0x1a1c024510>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 49,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA54AAAHQCAYAAADJQrXSAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nOzdd3hc1bU28HdPL+rFki13425jG0wNvYWSBBIghYRAICEECMmXS3JzbwoQ0ki7NyTc9AAhEEJPQo1ppoOxsY1t3C3bsq1ep5ezvz9O0RlpRpoZTZP8/p6HB2k0c2ZLGo3POmvttYSUEkRERERERET5Yin2AoiIiIiIiGhiY+BJREREREREecXAk4iIiIiIiPKKgScRERERERHlFQNPIiIiIiIiyisGnkRERERERJRXDDyJiIg0QohbhBB/HcPjNwshTsvhkoiIiCYEBp5ERFR0QojLhBDvCCF8QohDQoinhRAnFXtdIxFC3C2E+L75NinlYinlSzl+nplCCKn9bHxCiGYhxDczePyYgmkiIqJcYOBJRERFJYT4GoD/BfBDAA0ApgP4PwAXFnNdJahKSlkG4BI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iIiLKgWwyk/kipcRVV12F2267bdjXNm7ciKeffhp33HEHHnnkEfz+9783vhYIBHDDDTdg3bp1aGpqwre//e2MxqakwownERERERHRBHPWWWfhwQcfRGdnJwC1++2+ffvQ0dEBKSUuvfRS3HrrrVi3bl3C44LBICwWC+rq6jAwMIBHHnkkJ+thxpOIiGgCiCsS/kgMFS57sZdCREQlYOnSpbj55ptx1llnQVEU2O12/Pa3v4XVasXVV18NKSWEELj99tsTHldbW4srrrgCS5YswYwZM3DcccflZD0iFx2K0rVy5Ur5zjvvFOz5iIiIDhe3/msz7nqtGVtvOxcuu7XYyyEiOmy8//77WLhwYbGXURTJvnchxFop5cqh92WpLRER0QTwt7f3AQACkXiRV0JERDQcA08iIqJxri8YRSiqAABCUQaeRERUehh4EhERjXM/eHKL8TEDTyIiKkWjBp5CiD8LIdqFEJtMt9UIIVYJIXZo/6/O7zKJiIgolZ5A1Pg4yMCTiIhKUDoZz7sBnDvktm8CeF5KORfA89rnREREVAQO6+A/53e+uBO3P7O1iKuh8eSt3V1Yduu/0We6eEFElA+jBp5SypcBdA+5+UIA92gf3wPgohyvi4iIiNIkMdih/qn3WvGbl3ZhY0tvEVdE48U7e3vQF4yiwxcu9lKIaILLdo9ng5TyEABo/5+UuyURERFRJjp9kWG3feTXryGuFG5kGpWukUbn7e8OAACicaVQyyGiPLBarVi+fLnxX3Nzc9bHuvLKK/Hwww/nbnEaW86POIQQ4hoA1wDA9OnT8/10REREh51OXxjzG8qxrW0g4fZ3mrtx3OzaIq2KSsHruzrxubvWYE59GS4+eiquPmlWwtf396iBZyzOixRE45nb7cb69eszflwsFoPNlveQEED2Gc82IcRkAND+357qjlLK30spV0opV9bX12f5dERERJRKx0AY02rcw25/aXtHEVZDpWRPpx/hmIIufxh3vrhz2Nf3dwcBABFmPIkmnFAohM997nNYunQpVqxYgRdffBEAcPfdd+PSSy/Fhz/8YZxzzjmQUuKGG27AokWLcMEFF6C9PWVoNybZhrf/BHAFgB9r//9HzlZEREREaQtF4xgIxTC12jPsa239oSKsiEpJWJvv+oE5dVi1pS3ha7G4goO9QeNjIsqBp78JtL6X22M2LgXO+/GIdwkGg1i+fDkAYNasWXjsscdw5513AgDee+89bN26Feeccw62b98OAHjjjTewceNG1NT
|
||
|
"text/plain": [
|
||
|
"<Figure size 1152x576 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"tesla['Cumulative Return'].plot(label='Tesla',figsize=(16,8),title='Cumulative Return')\n",
|
||
|
"ford['Cumulative Return'].plot(label='Ford')\n",
|
||
|
"gm['Cumulative Return'].plot(label='GM')\n",
|
||
|
"plt.legend()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Bon travail!\n",
|
||
|
"\n",
|
||
|
"Voilà pour l'analyse de base, qui conclut cette moitié du cours, beaucoup plus axée sur l'apprentissage des outils du métier. La deuxième moitié du cours est celle où nous nous plongerons vraiment dans les fonctionnalités conçues pour les séries temporelles, l'analyse quantitative, le trading algorithmique, et bien plus encore!"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"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.8.5-final"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 1
|
||
|
}
|