{ "cells": [ { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "import plotly.express as px\n", "from sklearn.metrics import mean_absolute_error\n", "from sklearn.metrics import mean_squared_error\n", "from statsmodels.stats.stattools import durbin_watson\n", "from statsmodels.tsa.api import VAR\n", "from statsmodels.tsa.stattools import adfuller\n", "from statsmodels.tsa.stattools import grangercausalitytests\n", "from statsmodels.tsa.stattools import kpss" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [], "source": [ "df_apple = pd.read_csv('../coal-price-data/investing/AAPL Historical Data.csv')\n", "df_walmart = pd.read_csv('../coal-price-data/investing/WMT Historical Data.csv')\n", "df_tesla = pd.read_csv('../coal-price-data/investing/TSLA Historical Data.csv')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# df_apple.rename(columns = {'Price':'apple'}, inplace = True)\n", "# df_walmart.rename(columns = {'Price':'walmart'}, inplace = True)\n", "# df_tesla.rename(columns = {'Price':'tesla'}, inplace = True)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
DatePriceOpenHighLowVol.Change %
002/01/2024182.52183.97191.00179.2645.12M-1.02%
101/01/2024184.40187.15196.38180.171.19B-4.22%
212/01/2023192.53190.33199.62187.451.06B1.36%
311/01/2023189.95171.00192.93170.121.10B11.23%
410/01/2023170.77171.22182.34165.671.17B-0.26%
........................
51305/01/19810.150.130.150.12590.42M15.38%
51404/01/19810.130.110.130.11536.93M18.18%
51503/01/19810.110.120.120.10700.72M-8.33%
51602/01/19810.120.120.130.11321.62M-7.69%
51701/01/19810.130.150.160.13608.99M-13.33%
\n", "

518 rows × 7 columns

\n", "
" ], "text/plain": [ " Date Price Open High Low Vol. Change %\n", "0 02/01/2024 182.52 183.97 191.00 179.26 45.12M -1.02%\n", "1 01/01/2024 184.40 187.15 196.38 180.17 1.19B -4.22%\n", "2 12/01/2023 192.53 190.33 199.62 187.45 1.06B 1.36%\n", "3 11/01/2023 189.95 171.00 192.93 170.12 1.10B 11.23%\n", "4 10/01/2023 170.77 171.22 182.34 165.67 1.17B -0.26%\n", ".. ... ... ... ... ... ... ...\n", "513 05/01/1981 0.15 0.13 0.15 0.12 590.42M 15.38%\n", "514 04/01/1981 0.13 0.11 0.13 0.11 536.93M 18.18%\n", "515 03/01/1981 0.11 0.12 0.12 0.10 700.72M -8.33%\n", "516 02/01/1981 0.12 0.12 0.13 0.11 321.62M -7.69%\n", "517 01/01/1981 0.13 0.15 0.16 0.13 608.99M -13.33%\n", "\n", "[518 rows x 7 columns]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_apple" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "df = pd.merge(df_apple[['Date', 'Price']], df_walmart[['Date', 'Price']], on='Date', how='right').rename(columns = {'Price_x':'apple', 'Price_y':'walmart'})\n", "df = df.merge(df_tesla[['Date', 'Price']], on='Date', how='right').rename(columns={'Price':'tesla'})" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Dateapplewalmarttesla
002/01/2024182.52175.56191.97
101/01/2024184.40165.25187.29
212/01/2023192.53157.65248.48
311/01/2023189.95155.69240.08
410/01/2023170.77163.41200.84
...............
15911/01/201011.1154.092.36
16010/01/201010.7554.171.46
16109/01/201010.1353.521.36
16208/01/20108.6850.141.30
16307/01/20109.1951.191.33
\n", "

164 rows × 4 columns

\n", "
" ], "text/plain": [ " Date apple walmart tesla\n", "0 02/01/2024 182.52 175.56 191.97\n", "1 01/01/2024 184.40 165.25 187.29\n", "2 12/01/2023 192.53 157.65 248.48\n", "3 11/01/2023 189.95 155.69 240.08\n", "4 10/01/2023 170.77 163.41 200.84\n", ".. ... ... ... ...\n", "159 11/01/2010 11.11 54.09 2.36\n", "160 10/01/2010 10.75 54.17 1.46\n", "161 09/01/2010 10.13 53.52 1.36\n", "162 08/01/2010 8.68 50.14 1.30\n", "163 07/01/2010 9.19 51.19 1.33\n", "\n", "[164 rows x 4 columns]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "df['Date'] = pd.to_datetime(df['Date'])" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Dateapplewalmarttesla
02024-02-01182.52175.56191.97
12024-01-01184.40165.25187.29
22023-12-01192.53157.65248.48
32023-11-01189.95155.69240.08
42023-10-01170.77163.41200.84
...............
1592010-11-0111.1154.092.36
1602010-10-0110.7554.171.46
1612010-09-0110.1353.521.36
1622010-08-018.6850.141.30
1632010-07-019.1951.191.33
\n", "

164 rows × 4 columns

\n", "
" ], "text/plain": [ " Date apple walmart tesla\n", "0 2024-02-01 182.52 175.56 191.97\n", "1 2024-01-01 184.40 165.25 187.29\n", "2 2023-12-01 192.53 157.65 248.48\n", "3 2023-11-01 189.95 155.69 240.08\n", "4 2023-10-01 170.77 163.41 200.84\n", ".. ... ... ... ...\n", "159 2010-11-01 11.11 54.09 2.36\n", "160 2010-10-01 10.75 54.17 1.46\n", "161 2010-09-01 10.13 53.52 1.36\n", "162 2010-08-01 8.68 50.14 1.30\n", "163 2010-07-01 9.19 51.19 1.33\n", "\n", "[164 rows x 4 columns]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "df = df.set_index('Date').rename_axis('company', axis=1)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
companyapplewalmarttesla
Date
2024-02-01182.52175.56191.97
2024-01-01184.40165.25187.29
2023-12-01192.53157.65248.48
2023-11-01189.95155.69240.08
2023-10-01170.77163.41200.84
............
2010-11-0111.1154.092.36
2010-10-0110.7554.171.46
2010-09-0110.1353.521.36
2010-08-018.6850.141.30
2010-07-019.1951.191.33
\n", "

164 rows × 3 columns

\n", "
" ], "text/plain": [ "company apple walmart tesla\n", "Date \n", "2024-02-01 182.52 175.56 191.97\n", "2024-01-01 184.40 165.25 187.29\n", "2023-12-01 192.53 157.65 248.48\n", "2023-11-01 189.95 155.69 240.08\n", "2023-10-01 170.77 163.41 200.84\n", "... ... ... ...\n", "2010-11-01 11.11 54.09 2.36\n", "2010-10-01 10.75 54.17 1.46\n", "2010-09-01 10.13 53.52 1.36\n", "2010-08-01 8.68 50.14 1.30\n", "2010-07-01 9.19 51.19 1.33\n", "\n", "[164 rows x 3 columns]" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "company=apple
Date=%{x}
value=%{y}", "legendgroup": "apple", "line": { "color": "#636efa", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "apple", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "2024-02-01T00:00:00", "2024-01-01T00:00:00", "2023-12-01T00:00:00", "2023-11-01T00:00:00", "2023-10-01T00:00:00", "2023-09-01T00:00:00", "2023-08-01T00:00:00", "2023-07-01T00:00:00", "2023-06-01T00:00:00", "2023-05-01T00:00:00", "2023-04-01T00:00:00", "2023-03-01T00:00:00", "2023-02-01T00:00:00", "2023-01-01T00:00:00", "2022-12-01T00:00:00", "2022-11-01T00:00:00", "2022-10-01T00:00:00", "2022-09-01T00:00:00", "2022-08-01T00:00:00", "2022-07-01T00:00:00", "2022-06-01T00:00:00", "2022-05-01T00:00:00", "2022-04-01T00:00:00", "2022-03-01T00:00:00", "2022-02-01T00:00:00", "2022-01-01T00:00:00", "2021-12-01T00:00:00", "2021-11-01T00:00:00", "2021-10-01T00:00:00", "2021-09-01T00:00:00", "2021-08-01T00:00:00", "2021-07-01T00:00:00", "2021-06-01T00:00:00", "2021-05-01T00:00:00", "2021-04-01T00:00:00", "2021-03-01T00:00:00", "2021-02-01T00:00:00", "2021-01-01T00:00:00", "2020-12-01T00:00:00", "2020-11-01T00:00:00", "2020-10-01T00:00:00", "2020-09-01T00:00:00", "2020-08-01T00:00:00", "2020-07-01T00:00:00", "2020-06-01T00:00:00", "2020-05-01T00:00:00", "2020-04-01T00:00:00", "2020-03-01T00:00:00", "2020-02-01T00:00:00", "2020-01-01T00:00:00", "2019-12-01T00:00:00", "2019-11-01T00:00:00", "2019-10-01T00:00:00", "2019-09-01T00:00:00", "2019-08-01T00:00:00", "2019-07-01T00:00:00", "2019-06-01T00:00:00", "2019-05-01T00:00:00", "2019-04-01T00:00:00", "2019-03-01T00:00:00", "2019-02-01T00:00:00", "2019-01-01T00:00:00", "2018-12-01T00:00:00", "2018-11-01T00:00:00", "2018-10-01T00:00:00", "2018-09-01T00:00:00", "2018-08-01T00:00:00", "2018-07-01T00:00:00", "2018-06-01T00:00:00", "2018-05-01T00:00:00", "2018-04-01T00:00:00", "2018-03-01T00:00:00", "2018-02-01T00:00:00", "2018-01-01T00:00:00", "2017-12-01T00:00:00", "2017-11-01T00:00:00", "2017-10-01T00:00:00", "2017-09-01T00:00:00", "2017-08-01T00:00:00", "2017-07-01T00:00:00", "2017-06-01T00:00:00", "2017-05-01T00:00:00", "2017-04-01T00:00:00", "2017-03-01T00:00:00", "2017-02-01T00:00:00", "2017-01-01T00:00:00", "2016-12-01T00:00:00", "2016-11-01T00:00:00", "2016-10-01T00:00:00", "2016-09-01T00:00:00", "2016-08-01T00:00:00", "2016-07-01T00:00:00", "2016-06-01T00:00:00", "2016-05-01T00:00:00", "2016-04-01T00:00:00", "2016-03-01T00:00:00", "2016-02-01T00:00:00", "2016-01-01T00:00:00", "2015-12-01T00:00:00", "2015-11-01T00:00:00", "2015-10-01T00:00:00", "2015-09-01T00:00:00", "2015-08-01T00:00:00", "2015-07-01T00:00:00", "2015-06-01T00:00:00", "2015-05-01T00:00:00", "2015-04-01T00:00:00", "2015-03-01T00:00:00", "2015-02-01T00:00:00", "2015-01-01T00:00:00", "2014-12-01T00:00:00", "2014-11-01T00:00:00", "2014-10-01T00:00:00", "2014-09-01T00:00:00", "2014-08-01T00:00:00", "2014-07-01T00:00:00", "2014-06-01T00:00:00", "2014-05-01T00:00:00", "2014-04-01T00:00:00", "2014-03-01T00:00:00", "2014-02-01T00:00:00", "2014-01-01T00:00:00", "2013-12-01T00:00:00", "2013-11-01T00:00:00", "2013-10-01T00:00:00", "2013-09-01T00:00:00", "2013-08-01T00:00:00", "2013-07-01T00:00:00", "2013-06-01T00:00:00", "2013-05-01T00:00:00", "2013-04-01T00:00:00", "2013-03-01T00:00:00", "2013-02-01T00:00:00", "2013-01-01T00:00:00", "2012-12-01T00:00:00", "2012-11-01T00:00:00", "2012-10-01T00:00:00", "2012-09-01T00:00:00", "2012-08-01T00:00:00", "2012-07-01T00:00:00", "2012-06-01T00:00:00", "2012-05-01T00:00:00", "2012-04-01T00:00:00", "2012-03-01T00:00:00", "2012-02-01T00:00:00", "2012-01-01T00:00:00", "2011-12-01T00:00:00", "2011-11-01T00:00:00", "2011-10-01T00:00:00", "2011-09-01T00:00:00", "2011-08-01T00:00:00", "2011-07-01T00:00:00", "2011-06-01T00:00:00", "2011-05-01T00:00:00", "2011-04-01T00:00:00", "2011-03-01T00:00:00", "2011-02-01T00:00:00", "2011-01-01T00:00:00", "2010-12-01T00:00:00", "2010-11-01T00:00:00", "2010-10-01T00:00:00", "2010-09-01T00:00:00", "2010-08-01T00:00:00", "2010-07-01T00:00:00" ], "xaxis": "x3", "y": [ 182.52, 184.4, 192.53, 189.95, 170.77, 171.21, 187.87, 196.45, 193.97, 177.25, 169.68, 164.9, 147.41, 144.29, 129.93, 148.03, 153.34, 138.2, 157.22, 162.51, 136.72, 148.84, 157.65, 174.61, 165.12, 174.78, 177.57, 165.3, 149.8, 141.5, 151.83, 145.86, 136.96, 124.61, 131.46, 122.15, 121.26, 131.96, 132.69, 119.05, 108.86, 115.81, 129.04, 106.26, 91.2, 79.49, 73.45, 63.57, 68.34, 77.38, 73.41, 66.81, 62.19, 55.99, 52.19, 53.26, 49.48, 43.77, 50.17, 47.49, 43.29, 41.61, 39.44, 44.65, 54.72, 56.44, 56.91, 47.57, 46.28, 46.72, 41.31, 41.94, 44.53, 41.86, 42.31, 42.96, 42.26, 38.53, 41, 37.18, 36.01, 38.19, 35.91, 35.92, 34.25, 30.34, 28.95, 27.63, 28.39, 28.26, 26.52, 26.05, 23.9, 24.97, 23.43, 27.25, 24.17, 24.33, 26.32, 29.58, 29.88, 27.58, 28.19, 30.33, 31.36, 32.57, 31.29, 31.11, 32.12, 29.29, 27.59, 29.73, 27, 25.19, 25.63, 23.9, 23.23, 22.61, 21.07, 19.17, 18.79, 17.88, 20.04, 19.86, 18.67, 17.03, 17.4, 16.16, 14.16, 16.06, 15.81, 15.81, 15.76, 16.27, 19.01, 20.9, 21.26, 23.83, 23.76, 21.81, 20.86, 20.63, 20.86, 21.41, 19.37, 16.3, 14.46, 13.65, 14.46, 13.62, 13.74, 13.95, 11.99, 12.42, 12.5, 12.45, 12.61, 12.12, 11.52, 11.11, 10.75, 10.13, 8.68, 9.19 ], "yaxis": "y3" }, { "hovertemplate": "company=walmart
Date=%{x}
value=%{y}", "legendgroup": "walmart", "line": { "color": "#EF553B", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "walmart", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "2024-02-01T00:00:00", "2024-01-01T00:00:00", "2023-12-01T00:00:00", "2023-11-01T00:00:00", "2023-10-01T00:00:00", "2023-09-01T00:00:00", "2023-08-01T00:00:00", "2023-07-01T00:00:00", "2023-06-01T00:00:00", "2023-05-01T00:00:00", "2023-04-01T00:00:00", "2023-03-01T00:00:00", "2023-02-01T00:00:00", "2023-01-01T00:00:00", "2022-12-01T00:00:00", "2022-11-01T00:00:00", "2022-10-01T00:00:00", "2022-09-01T00:00:00", "2022-08-01T00:00:00", "2022-07-01T00:00:00", "2022-06-01T00:00:00", "2022-05-01T00:00:00", "2022-04-01T00:00:00", "2022-03-01T00:00:00", "2022-02-01T00:00:00", "2022-01-01T00:00:00", "2021-12-01T00:00:00", "2021-11-01T00:00:00", "2021-10-01T00:00:00", "2021-09-01T00:00:00", "2021-08-01T00:00:00", "2021-07-01T00:00:00", "2021-06-01T00:00:00", "2021-05-01T00:00:00", "2021-04-01T00:00:00", "2021-03-01T00:00:00", "2021-02-01T00:00:00", "2021-01-01T00:00:00", "2020-12-01T00:00:00", "2020-11-01T00:00:00", "2020-10-01T00:00:00", "2020-09-01T00:00:00", "2020-08-01T00:00:00", "2020-07-01T00:00:00", "2020-06-01T00:00:00", "2020-05-01T00:00:00", "2020-04-01T00:00:00", "2020-03-01T00:00:00", "2020-02-01T00:00:00", "2020-01-01T00:00:00", "2019-12-01T00:00:00", "2019-11-01T00:00:00", "2019-10-01T00:00:00", "2019-09-01T00:00:00", "2019-08-01T00:00:00", "2019-07-01T00:00:00", "2019-06-01T00:00:00", "2019-05-01T00:00:00", "2019-04-01T00:00:00", "2019-03-01T00:00:00", "2019-02-01T00:00:00", "2019-01-01T00:00:00", "2018-12-01T00:00:00", "2018-11-01T00:00:00", "2018-10-01T00:00:00", "2018-09-01T00:00:00", "2018-08-01T00:00:00", "2018-07-01T00:00:00", "2018-06-01T00:00:00", "2018-05-01T00:00:00", "2018-04-01T00:00:00", "2018-03-01T00:00:00", "2018-02-01T00:00:00", "2018-01-01T00:00:00", "2017-12-01T00:00:00", "2017-11-01T00:00:00", "2017-10-01T00:00:00", "2017-09-01T00:00:00", "2017-08-01T00:00:00", "2017-07-01T00:00:00", "2017-06-01T00:00:00", "2017-05-01T00:00:00", "2017-04-01T00:00:00", "2017-03-01T00:00:00", "2017-02-01T00:00:00", "2017-01-01T00:00:00", "2016-12-01T00:00:00", "2016-11-01T00:00:00", "2016-10-01T00:00:00", "2016-09-01T00:00:00", "2016-08-01T00:00:00", "2016-07-01T00:00:00", "2016-06-01T00:00:00", "2016-05-01T00:00:00", "2016-04-01T00:00:00", "2016-03-01T00:00:00", "2016-02-01T00:00:00", "2016-01-01T00:00:00", "2015-12-01T00:00:00", "2015-11-01T00:00:00", "2015-10-01T00:00:00", "2015-09-01T00:00:00", "2015-08-01T00:00:00", "2015-07-01T00:00:00", "2015-06-01T00:00:00", "2015-05-01T00:00:00", "2015-04-01T00:00:00", "2015-03-01T00:00:00", "2015-02-01T00:00:00", "2015-01-01T00:00:00", "2014-12-01T00:00:00", "2014-11-01T00:00:00", "2014-10-01T00:00:00", "2014-09-01T00:00:00", "2014-08-01T00:00:00", "2014-07-01T00:00:00", "2014-06-01T00:00:00", "2014-05-01T00:00:00", "2014-04-01T00:00:00", "2014-03-01T00:00:00", "2014-02-01T00:00:00", "2014-01-01T00:00:00", "2013-12-01T00:00:00", "2013-11-01T00:00:00", "2013-10-01T00:00:00", "2013-09-01T00:00:00", "2013-08-01T00:00:00", "2013-07-01T00:00:00", "2013-06-01T00:00:00", "2013-05-01T00:00:00", "2013-04-01T00:00:00", "2013-03-01T00:00:00", "2013-02-01T00:00:00", "2013-01-01T00:00:00", "2012-12-01T00:00:00", "2012-11-01T00:00:00", "2012-10-01T00:00:00", "2012-09-01T00:00:00", "2012-08-01T00:00:00", "2012-07-01T00:00:00", "2012-06-01T00:00:00", "2012-05-01T00:00:00", "2012-04-01T00:00:00", "2012-03-01T00:00:00", "2012-02-01T00:00:00", "2012-01-01T00:00:00", "2011-12-01T00:00:00", "2011-11-01T00:00:00", "2011-10-01T00:00:00", "2011-09-01T00:00:00", "2011-08-01T00:00:00", "2011-07-01T00:00:00", "2011-06-01T00:00:00", "2011-05-01T00:00:00", "2011-04-01T00:00:00", "2011-03-01T00:00:00", "2011-02-01T00:00:00", "2011-01-01T00:00:00", "2010-12-01T00:00:00", "2010-11-01T00:00:00", "2010-10-01T00:00:00", "2010-09-01T00:00:00", "2010-08-01T00:00:00", "2010-07-01T00:00:00" ], "xaxis": "x2", "y": [ 175.56, 165.25, 157.65, 155.69, 163.41, 159.93, 162.61, 159.86, 157.18, 146.87, 150.97, 147.45, 142.13, 143.87, 141.79, 152.42, 142.33, 129.7, 132.55, 132.05, 121.58, 128.63, 152.99, 148.92, 135.16, 139.81, 144.69, 140.63, 149.42, 139.38, 148.1, 142.55, 141.02, 142.03, 139.91, 135.83, 129.92, 140.49, 144.15, 152.79, 138.75, 139.91, 138.85, 129.4, 119.78, 124.06, 121.55, 113.62, 107.68, 114.49, 118.84, 119.09, 117.26, 118.68, 114.26, 110.38, 110.49, 101.44, 102.84, 97.53, 98.99, 95.83, 93.15, 97.65, 100.28, 93.91, 95.86, 89.23, 85.65, 82.54, 88.46, 88.97, 90.01, 106.6, 98.75, 97.23, 87.31, 78.14, 78.07, 79.99, 75.68, 78.6, 75.18, 72.08, 70.93, 66.74, 69.12, 70.43, 70.02, 72.12, 71.44, 72.97, 73.02, 70.78, 66.87, 68.49, 66.34, 66.36, 61.3, 58.84, 57.24, 64.84, 64.73, 71.98, 70.93, 74.27, 78.05, 82.25, 83.93, 84.98, 85.88, 87.54, 76.27, 76.47, 75.5, 73.58, 75.07, 76.77, 79.71, 76.43, 74.7, 74.68, 78.69, 81.01, 76.75, 73.96, 72.98, 77.94, 74.49, 74.84, 77.72, 74.83, 70.78, 69.95, 68.23, 72.02, 75.02, 73.8, 72.6, 74.43, 69.72, 65.82, 58.91, 61.2, 59.08, 61.36, 59.76, 58.9, 56.72, 51.9, 53.19, 52.71, 53.14, 55.22, 54.98, 52.05, 51.98, 56.07, 53.93, 54.09, 54.17, 53.52, 50.14, 51.19 ], "yaxis": "y2" }, { "hovertemplate": "company=tesla
Date=%{x}
value=%{y}", "legendgroup": "tesla", "line": { "color": "#00cc96", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "tesla", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "2024-02-01T00:00:00", "2024-01-01T00:00:00", "2023-12-01T00:00:00", "2023-11-01T00:00:00", "2023-10-01T00:00:00", "2023-09-01T00:00:00", "2023-08-01T00:00:00", "2023-07-01T00:00:00", "2023-06-01T00:00:00", "2023-05-01T00:00:00", "2023-04-01T00:00:00", "2023-03-01T00:00:00", "2023-02-01T00:00:00", "2023-01-01T00:00:00", "2022-12-01T00:00:00", "2022-11-01T00:00:00", "2022-10-01T00:00:00", "2022-09-01T00:00:00", "2022-08-01T00:00:00", "2022-07-01T00:00:00", "2022-06-01T00:00:00", "2022-05-01T00:00:00", "2022-04-01T00:00:00", "2022-03-01T00:00:00", "2022-02-01T00:00:00", "2022-01-01T00:00:00", "2021-12-01T00:00:00", "2021-11-01T00:00:00", "2021-10-01T00:00:00", "2021-09-01T00:00:00", "2021-08-01T00:00:00", "2021-07-01T00:00:00", "2021-06-01T00:00:00", "2021-05-01T00:00:00", "2021-04-01T00:00:00", "2021-03-01T00:00:00", "2021-02-01T00:00:00", "2021-01-01T00:00:00", "2020-12-01T00:00:00", "2020-11-01T00:00:00", "2020-10-01T00:00:00", "2020-09-01T00:00:00", "2020-08-01T00:00:00", "2020-07-01T00:00:00", "2020-06-01T00:00:00", "2020-05-01T00:00:00", "2020-04-01T00:00:00", "2020-03-01T00:00:00", "2020-02-01T00:00:00", "2020-01-01T00:00:00", "2019-12-01T00:00:00", "2019-11-01T00:00:00", "2019-10-01T00:00:00", "2019-09-01T00:00:00", "2019-08-01T00:00:00", "2019-07-01T00:00:00", "2019-06-01T00:00:00", "2019-05-01T00:00:00", "2019-04-01T00:00:00", "2019-03-01T00:00:00", "2019-02-01T00:00:00", "2019-01-01T00:00:00", "2018-12-01T00:00:00", "2018-11-01T00:00:00", "2018-10-01T00:00:00", "2018-09-01T00:00:00", "2018-08-01T00:00:00", "2018-07-01T00:00:00", "2018-06-01T00:00:00", "2018-05-01T00:00:00", "2018-04-01T00:00:00", "2018-03-01T00:00:00", "2018-02-01T00:00:00", "2018-01-01T00:00:00", "2017-12-01T00:00:00", "2017-11-01T00:00:00", "2017-10-01T00:00:00", "2017-09-01T00:00:00", "2017-08-01T00:00:00", "2017-07-01T00:00:00", "2017-06-01T00:00:00", "2017-05-01T00:00:00", "2017-04-01T00:00:00", "2017-03-01T00:00:00", "2017-02-01T00:00:00", "2017-01-01T00:00:00", "2016-12-01T00:00:00", "2016-11-01T00:00:00", "2016-10-01T00:00:00", "2016-09-01T00:00:00", "2016-08-01T00:00:00", "2016-07-01T00:00:00", "2016-06-01T00:00:00", "2016-05-01T00:00:00", "2016-04-01T00:00:00", "2016-03-01T00:00:00", "2016-02-01T00:00:00", "2016-01-01T00:00:00", "2015-12-01T00:00:00", "2015-11-01T00:00:00", "2015-10-01T00:00:00", "2015-09-01T00:00:00", "2015-08-01T00:00:00", "2015-07-01T00:00:00", "2015-06-01T00:00:00", "2015-05-01T00:00:00", "2015-04-01T00:00:00", "2015-03-01T00:00:00", "2015-02-01T00:00:00", "2015-01-01T00:00:00", "2014-12-01T00:00:00", "2014-11-01T00:00:00", "2014-10-01T00:00:00", "2014-09-01T00:00:00", "2014-08-01T00:00:00", "2014-07-01T00:00:00", "2014-06-01T00:00:00", "2014-05-01T00:00:00", "2014-04-01T00:00:00", "2014-03-01T00:00:00", "2014-02-01T00:00:00", "2014-01-01T00:00:00", "2013-12-01T00:00:00", "2013-11-01T00:00:00", "2013-10-01T00:00:00", "2013-09-01T00:00:00", "2013-08-01T00:00:00", "2013-07-01T00:00:00", "2013-06-01T00:00:00", "2013-05-01T00:00:00", "2013-04-01T00:00:00", "2013-03-01T00:00:00", "2013-02-01T00:00:00", "2013-01-01T00:00:00", "2012-12-01T00:00:00", "2012-11-01T00:00:00", "2012-10-01T00:00:00", "2012-09-01T00:00:00", "2012-08-01T00:00:00", "2012-07-01T00:00:00", "2012-06-01T00:00:00", "2012-05-01T00:00:00", "2012-04-01T00:00:00", "2012-03-01T00:00:00", "2012-02-01T00:00:00", "2012-01-01T00:00:00", "2011-12-01T00:00:00", "2011-11-01T00:00:00", "2011-10-01T00:00:00", "2011-09-01T00:00:00", "2011-08-01T00:00:00", "2011-07-01T00:00:00", "2011-06-01T00:00:00", "2011-05-01T00:00:00", "2011-04-01T00:00:00", "2011-03-01T00:00:00", "2011-02-01T00:00:00", "2011-01-01T00:00:00", "2010-12-01T00:00:00", "2010-11-01T00:00:00", "2010-10-01T00:00:00", "2010-09-01T00:00:00", "2010-08-01T00:00:00", "2010-07-01T00:00:00" ], "xaxis": "x", "y": [ 191.97, 187.29, 248.48, 240.08, 200.84, 250.22, 258.08, 267.43, 261.77, 203.93, 164.31, 207.46, 205.71, 173.22, 123.18, 194.7, 227.54, 265.25, 275.61, 297.15, 224.47, 252.75, 290.25, 359.2, 290.14, 312.24, 352.26, 381.59, 371.33, 258.49, 245.24, 229.07, 226.57, 208.41, 236.48, 222.64, 225.17, 264.51, 235.22, 189.2, 129.35, 143, 166.11, 95.38, 71.99, 55.67, 52.13, 34.93, 44.53, 43.37, 27.89, 22, 20.99, 16.06, 15.04, 16.11, 14.9, 12.34, 15.91, 18.66, 21.33, 20.47, 22.19, 23.37, 22.49, 17.65, 20.11, 19.88, 22.86, 18.98, 19.59, 17.74, 22.87, 23.62, 20.76, 20.59, 22.1, 22.74, 23.73, 21.56, 24.11, 22.73, 20.94, 18.55, 16.67, 16.8, 14.25, 12.63, 13.18, 13.6, 14.13, 15.65, 14.15, 14.88, 16.05, 15.32, 12.8, 12.75, 16, 15.35, 13.8, 16.56, 16.6, 17.74, 17.88, 16.72, 15.07, 12.58, 13.56, 13.57, 14.83, 16.3, 16.11, 16.18, 17.98, 14.89, 16, 13.85, 13.86, 13.9, 16.32, 12.09, 10.03, 8.49, 10.66, 12.89, 11.27, 8.95, 7.16, 6.52, 3.6, 2.53, 2.32, 2.5, 2.26, 2.25, 1.88, 1.95, 1.9, 1.83, 2.09, 1.97, 2.21, 2.48, 2.23, 1.94, 1.9, 2.18, 1.96, 1.63, 1.65, 1.88, 1.94, 2.01, 1.84, 1.85, 1.59, 1.61, 1.78, 2.36, 1.46, 1.36, 1.3, 1.33 ], "yaxis": "y" } ], "layout": { "annotations": [ { "font": {}, "showarrow": false, "text": "company=tesla", "x": 0.5, "xanchor": "center", "xref": "paper", "y": 0.2866666666666666, "yanchor": "bottom", "yref": "paper" }, { "font": {}, "showarrow": false, "text": "company=walmart", "x": 0.5, "xanchor": "center", "xref": "paper", "y": 0.6433333333333333, "yanchor": "bottom", "yref": "paper" }, { "font": {}, "showarrow": false, "text": "company=apple", "x": 0.5, "xanchor": "center", "xref": "paper", "y": 0.9999999999999999, "yanchor": "bottom", "yref": "paper" } ], "legend": { "title": { "text": "company" }, "tracegroupgap": 0 }, "margin": { "t": 60 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "title": { "text": "Date" } }, "xaxis2": { "anchor": "y2", "domain": [ 0, 1 ], "matches": "x", "showticklabels": false }, "xaxis3": { "anchor": "y3", "domain": [ 0, 1 ], "matches": "x", "showticklabels": false }, "yaxis": { "anchor": "x", "domain": [ 0, 0.2866666666666666 ], "title": { "text": "value" } }, "yaxis2": { "anchor": "x2", "domain": [ 0.35666666666666663, 0.6433333333333333 ], "title": { "text": "value" } }, "yaxis3": { "anchor": "x3", "domain": [ 0.7133333333333333, 0.9999999999999999 ], "title": { "text": "value" } } } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = px.line(df, facet_col=\"company\", facet_col_wrap=1)\n", "fig.update_yaxes(matches=None)\n", "fig.show()" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "fillpattern": { "shape": "" }, "hovertemplate": "company=apple
Date=%{x}
value=%{y}", "legendgroup": "apple", "line": { "color": "#636efa" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "apple", "orientation": "v", "showlegend": true, "stackgroup": "1", "type": "scatter", "x": [ "2024-02-01T00:00:00", "2024-01-01T00:00:00", "2023-12-01T00:00:00", "2023-11-01T00:00:00", "2023-10-01T00:00:00", "2023-09-01T00:00:00", "2023-08-01T00:00:00", "2023-07-01T00:00:00", "2023-06-01T00:00:00", "2023-05-01T00:00:00", "2023-04-01T00:00:00", "2023-03-01T00:00:00", "2023-02-01T00:00:00", "2023-01-01T00:00:00", "2022-12-01T00:00:00", "2022-11-01T00:00:00", "2022-10-01T00:00:00", "2022-09-01T00:00:00", "2022-08-01T00:00:00", "2022-07-01T00:00:00", "2022-06-01T00:00:00", "2022-05-01T00:00:00", "2022-04-01T00:00:00", "2022-03-01T00:00:00", "2022-02-01T00:00:00", "2022-01-01T00:00:00", "2021-12-01T00:00:00", "2021-11-01T00:00:00", "2021-10-01T00:00:00", "2021-09-01T00:00:00", "2021-08-01T00:00:00", "2021-07-01T00:00:00", "2021-06-01T00:00:00", "2021-05-01T00:00:00", "2021-04-01T00:00:00", "2021-03-01T00:00:00", "2021-02-01T00:00:00", "2021-01-01T00:00:00", "2020-12-01T00:00:00", "2020-11-01T00:00:00", "2020-10-01T00:00:00", "2020-09-01T00:00:00", "2020-08-01T00:00:00", "2020-07-01T00:00:00", "2020-06-01T00:00:00", "2020-05-01T00:00:00", "2020-04-01T00:00:00", "2020-03-01T00:00:00", "2020-02-01T00:00:00", "2020-01-01T00:00:00", "2019-12-01T00:00:00", "2019-11-01T00:00:00", "2019-10-01T00:00:00", "2019-09-01T00:00:00", "2019-08-01T00:00:00", "2019-07-01T00:00:00", "2019-06-01T00:00:00", "2019-05-01T00:00:00", "2019-04-01T00:00:00", "2019-03-01T00:00:00", "2019-02-01T00:00:00", "2019-01-01T00:00:00", "2018-12-01T00:00:00", "2018-11-01T00:00:00", "2018-10-01T00:00:00", "2018-09-01T00:00:00", "2018-08-01T00:00:00", "2018-07-01T00:00:00", "2018-06-01T00:00:00", "2018-05-01T00:00:00", "2018-04-01T00:00:00", "2018-03-01T00:00:00", "2018-02-01T00:00:00", "2018-01-01T00:00:00", "2017-12-01T00:00:00", "2017-11-01T00:00:00", "2017-10-01T00:00:00", "2017-09-01T00:00:00", "2017-08-01T00:00:00", "2017-07-01T00:00:00", "2017-06-01T00:00:00", "2017-05-01T00:00:00", "2017-04-01T00:00:00", "2017-03-01T00:00:00", "2017-02-01T00:00:00", "2017-01-01T00:00:00", "2016-12-01T00:00:00", "2016-11-01T00:00:00", "2016-10-01T00:00:00", "2016-09-01T00:00:00", "2016-08-01T00:00:00", "2016-07-01T00:00:00", "2016-06-01T00:00:00", "2016-05-01T00:00:00", "2016-04-01T00:00:00", "2016-03-01T00:00:00", "2016-02-01T00:00:00", "2016-01-01T00:00:00", "2015-12-01T00:00:00", "2015-11-01T00:00:00", "2015-10-01T00:00:00", "2015-09-01T00:00:00", "2015-08-01T00:00:00", "2015-07-01T00:00:00", "2015-06-01T00:00:00", "2015-05-01T00:00:00", "2015-04-01T00:00:00", "2015-03-01T00:00:00", "2015-02-01T00:00:00", "2015-01-01T00:00:00", "2014-12-01T00:00:00", "2014-11-01T00:00:00", "2014-10-01T00:00:00", "2014-09-01T00:00:00", "2014-08-01T00:00:00", "2014-07-01T00:00:00", "2014-06-01T00:00:00", "2014-05-01T00:00:00", "2014-04-01T00:00:00", "2014-03-01T00:00:00", "2014-02-01T00:00:00", "2014-01-01T00:00:00", "2013-12-01T00:00:00", "2013-11-01T00:00:00", "2013-10-01T00:00:00", "2013-09-01T00:00:00", "2013-08-01T00:00:00", "2013-07-01T00:00:00", "2013-06-01T00:00:00", "2013-05-01T00:00:00", "2013-04-01T00:00:00", "2013-03-01T00:00:00", "2013-02-01T00:00:00", "2013-01-01T00:00:00", "2012-12-01T00:00:00", "2012-11-01T00:00:00", "2012-10-01T00:00:00", "2012-09-01T00:00:00", "2012-08-01T00:00:00", "2012-07-01T00:00:00", "2012-06-01T00:00:00", "2012-05-01T00:00:00", "2012-04-01T00:00:00", "2012-03-01T00:00:00", "2012-02-01T00:00:00", "2012-01-01T00:00:00", "2011-12-01T00:00:00", "2011-11-01T00:00:00", "2011-10-01T00:00:00", "2011-09-01T00:00:00", "2011-08-01T00:00:00", "2011-07-01T00:00:00", "2011-06-01T00:00:00", "2011-05-01T00:00:00", "2011-04-01T00:00:00", "2011-03-01T00:00:00", "2011-02-01T00:00:00", "2011-01-01T00:00:00", "2010-12-01T00:00:00", "2010-11-01T00:00:00", "2010-10-01T00:00:00", "2010-09-01T00:00:00", "2010-08-01T00:00:00", "2010-07-01T00:00:00" ], "xaxis": "x3", "y": [ 182.52, 184.4, 192.53, 189.95, 170.77, 171.21, 187.87, 196.45, 193.97, 177.25, 169.68, 164.9, 147.41, 144.29, 129.93, 148.03, 153.34, 138.2, 157.22, 162.51, 136.72, 148.84, 157.65, 174.61, 165.12, 174.78, 177.57, 165.3, 149.8, 141.5, 151.83, 145.86, 136.96, 124.61, 131.46, 122.15, 121.26, 131.96, 132.69, 119.05, 108.86, 115.81, 129.04, 106.26, 91.2, 79.49, 73.45, 63.57, 68.34, 77.38, 73.41, 66.81, 62.19, 55.99, 52.19, 53.26, 49.48, 43.77, 50.17, 47.49, 43.29, 41.61, 39.44, 44.65, 54.72, 56.44, 56.91, 47.57, 46.28, 46.72, 41.31, 41.94, 44.53, 41.86, 42.31, 42.96, 42.26, 38.53, 41, 37.18, 36.01, 38.19, 35.91, 35.92, 34.25, 30.34, 28.95, 27.63, 28.39, 28.26, 26.52, 26.05, 23.9, 24.97, 23.43, 27.25, 24.17, 24.33, 26.32, 29.58, 29.88, 27.58, 28.19, 30.33, 31.36, 32.57, 31.29, 31.11, 32.12, 29.29, 27.59, 29.73, 27, 25.19, 25.63, 23.9, 23.23, 22.61, 21.07, 19.17, 18.79, 17.88, 20.04, 19.86, 18.67, 17.03, 17.4, 16.16, 14.16, 16.06, 15.81, 15.81, 15.76, 16.27, 19.01, 20.9, 21.26, 23.83, 23.76, 21.81, 20.86, 20.63, 20.86, 21.41, 19.37, 16.3, 14.46, 13.65, 14.46, 13.62, 13.74, 13.95, 11.99, 12.42, 12.5, 12.45, 12.61, 12.12, 11.52, 11.11, 10.75, 10.13, 8.68, 9.19 ], "yaxis": "y3" }, { "fillpattern": { "shape": "" }, "hovertemplate": "company=walmart
Date=%{x}
value=%{y}", "legendgroup": "walmart", "line": { "color": "#EF553B" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "walmart", "orientation": "v", "showlegend": true, "stackgroup": "1", "type": "scatter", "x": [ "2024-02-01T00:00:00", "2024-01-01T00:00:00", "2023-12-01T00:00:00", "2023-11-01T00:00:00", "2023-10-01T00:00:00", "2023-09-01T00:00:00", "2023-08-01T00:00:00", "2023-07-01T00:00:00", "2023-06-01T00:00:00", "2023-05-01T00:00:00", "2023-04-01T00:00:00", "2023-03-01T00:00:00", "2023-02-01T00:00:00", "2023-01-01T00:00:00", "2022-12-01T00:00:00", "2022-11-01T00:00:00", "2022-10-01T00:00:00", "2022-09-01T00:00:00", "2022-08-01T00:00:00", "2022-07-01T00:00:00", "2022-06-01T00:00:00", "2022-05-01T00:00:00", "2022-04-01T00:00:00", "2022-03-01T00:00:00", "2022-02-01T00:00:00", "2022-01-01T00:00:00", "2021-12-01T00:00:00", "2021-11-01T00:00:00", "2021-10-01T00:00:00", "2021-09-01T00:00:00", "2021-08-01T00:00:00", "2021-07-01T00:00:00", "2021-06-01T00:00:00", "2021-05-01T00:00:00", "2021-04-01T00:00:00", "2021-03-01T00:00:00", "2021-02-01T00:00:00", "2021-01-01T00:00:00", "2020-12-01T00:00:00", "2020-11-01T00:00:00", "2020-10-01T00:00:00", "2020-09-01T00:00:00", "2020-08-01T00:00:00", "2020-07-01T00:00:00", "2020-06-01T00:00:00", "2020-05-01T00:00:00", "2020-04-01T00:00:00", "2020-03-01T00:00:00", "2020-02-01T00:00:00", "2020-01-01T00:00:00", "2019-12-01T00:00:00", "2019-11-01T00:00:00", "2019-10-01T00:00:00", "2019-09-01T00:00:00", "2019-08-01T00:00:00", "2019-07-01T00:00:00", "2019-06-01T00:00:00", "2019-05-01T00:00:00", "2019-04-01T00:00:00", "2019-03-01T00:00:00", "2019-02-01T00:00:00", "2019-01-01T00:00:00", "2018-12-01T00:00:00", "2018-11-01T00:00:00", "2018-10-01T00:00:00", "2018-09-01T00:00:00", "2018-08-01T00:00:00", "2018-07-01T00:00:00", "2018-06-01T00:00:00", "2018-05-01T00:00:00", "2018-04-01T00:00:00", "2018-03-01T00:00:00", "2018-02-01T00:00:00", "2018-01-01T00:00:00", "2017-12-01T00:00:00", "2017-11-01T00:00:00", "2017-10-01T00:00:00", "2017-09-01T00:00:00", "2017-08-01T00:00:00", "2017-07-01T00:00:00", "2017-06-01T00:00:00", "2017-05-01T00:00:00", "2017-04-01T00:00:00", "2017-03-01T00:00:00", "2017-02-01T00:00:00", "2017-01-01T00:00:00", "2016-12-01T00:00:00", "2016-11-01T00:00:00", "2016-10-01T00:00:00", "2016-09-01T00:00:00", "2016-08-01T00:00:00", "2016-07-01T00:00:00", "2016-06-01T00:00:00", "2016-05-01T00:00:00", "2016-04-01T00:00:00", "2016-03-01T00:00:00", "2016-02-01T00:00:00", "2016-01-01T00:00:00", "2015-12-01T00:00:00", "2015-11-01T00:00:00", "2015-10-01T00:00:00", "2015-09-01T00:00:00", "2015-08-01T00:00:00", "2015-07-01T00:00:00", "2015-06-01T00:00:00", "2015-05-01T00:00:00", "2015-04-01T00:00:00", "2015-03-01T00:00:00", "2015-02-01T00:00:00", "2015-01-01T00:00:00", "2014-12-01T00:00:00", "2014-11-01T00:00:00", "2014-10-01T00:00:00", "2014-09-01T00:00:00", "2014-08-01T00:00:00", "2014-07-01T00:00:00", "2014-06-01T00:00:00", "2014-05-01T00:00:00", "2014-04-01T00:00:00", "2014-03-01T00:00:00", "2014-02-01T00:00:00", "2014-01-01T00:00:00", "2013-12-01T00:00:00", "2013-11-01T00:00:00", "2013-10-01T00:00:00", "2013-09-01T00:00:00", "2013-08-01T00:00:00", "2013-07-01T00:00:00", "2013-06-01T00:00:00", "2013-05-01T00:00:00", "2013-04-01T00:00:00", "2013-03-01T00:00:00", "2013-02-01T00:00:00", "2013-01-01T00:00:00", "2012-12-01T00:00:00", "2012-11-01T00:00:00", "2012-10-01T00:00:00", "2012-09-01T00:00:00", "2012-08-01T00:00:00", "2012-07-01T00:00:00", "2012-06-01T00:00:00", "2012-05-01T00:00:00", "2012-04-01T00:00:00", "2012-03-01T00:00:00", "2012-02-01T00:00:00", "2012-01-01T00:00:00", "2011-12-01T00:00:00", "2011-11-01T00:00:00", "2011-10-01T00:00:00", "2011-09-01T00:00:00", "2011-08-01T00:00:00", "2011-07-01T00:00:00", "2011-06-01T00:00:00", "2011-05-01T00:00:00", "2011-04-01T00:00:00", "2011-03-01T00:00:00", "2011-02-01T00:00:00", "2011-01-01T00:00:00", "2010-12-01T00:00:00", "2010-11-01T00:00:00", "2010-10-01T00:00:00", "2010-09-01T00:00:00", "2010-08-01T00:00:00", "2010-07-01T00:00:00" ], "xaxis": "x2", "y": [ 175.56, 165.25, 157.65, 155.69, 163.41, 159.93, 162.61, 159.86, 157.18, 146.87, 150.97, 147.45, 142.13, 143.87, 141.79, 152.42, 142.33, 129.7, 132.55, 132.05, 121.58, 128.63, 152.99, 148.92, 135.16, 139.81, 144.69, 140.63, 149.42, 139.38, 148.1, 142.55, 141.02, 142.03, 139.91, 135.83, 129.92, 140.49, 144.15, 152.79, 138.75, 139.91, 138.85, 129.4, 119.78, 124.06, 121.55, 113.62, 107.68, 114.49, 118.84, 119.09, 117.26, 118.68, 114.26, 110.38, 110.49, 101.44, 102.84, 97.53, 98.99, 95.83, 93.15, 97.65, 100.28, 93.91, 95.86, 89.23, 85.65, 82.54, 88.46, 88.97, 90.01, 106.6, 98.75, 97.23, 87.31, 78.14, 78.07, 79.99, 75.68, 78.6, 75.18, 72.08, 70.93, 66.74, 69.12, 70.43, 70.02, 72.12, 71.44, 72.97, 73.02, 70.78, 66.87, 68.49, 66.34, 66.36, 61.3, 58.84, 57.24, 64.84, 64.73, 71.98, 70.93, 74.27, 78.05, 82.25, 83.93, 84.98, 85.88, 87.54, 76.27, 76.47, 75.5, 73.58, 75.07, 76.77, 79.71, 76.43, 74.7, 74.68, 78.69, 81.01, 76.75, 73.96, 72.98, 77.94, 74.49, 74.84, 77.72, 74.83, 70.78, 69.95, 68.23, 72.02, 75.02, 73.8, 72.6, 74.43, 69.72, 65.82, 58.91, 61.2, 59.08, 61.36, 59.76, 58.9, 56.72, 51.9, 53.19, 52.71, 53.14, 55.22, 54.98, 52.05, 51.98, 56.07, 53.93, 54.09, 54.17, 53.52, 50.14, 51.19 ], "yaxis": "y2" }, { "fillpattern": { "shape": "" }, "hovertemplate": "company=tesla
Date=%{x}
value=%{y}", "legendgroup": "tesla", "line": { "color": "#00cc96" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "tesla", "orientation": "v", "showlegend": true, "stackgroup": "1", "type": "scatter", "x": [ "2024-02-01T00:00:00", "2024-01-01T00:00:00", "2023-12-01T00:00:00", "2023-11-01T00:00:00", "2023-10-01T00:00:00", "2023-09-01T00:00:00", "2023-08-01T00:00:00", "2023-07-01T00:00:00", "2023-06-01T00:00:00", "2023-05-01T00:00:00", "2023-04-01T00:00:00", "2023-03-01T00:00:00", "2023-02-01T00:00:00", "2023-01-01T00:00:00", "2022-12-01T00:00:00", "2022-11-01T00:00:00", "2022-10-01T00:00:00", "2022-09-01T00:00:00", "2022-08-01T00:00:00", "2022-07-01T00:00:00", "2022-06-01T00:00:00", "2022-05-01T00:00:00", "2022-04-01T00:00:00", "2022-03-01T00:00:00", "2022-02-01T00:00:00", "2022-01-01T00:00:00", "2021-12-01T00:00:00", "2021-11-01T00:00:00", "2021-10-01T00:00:00", "2021-09-01T00:00:00", "2021-08-01T00:00:00", "2021-07-01T00:00:00", "2021-06-01T00:00:00", "2021-05-01T00:00:00", "2021-04-01T00:00:00", "2021-03-01T00:00:00", "2021-02-01T00:00:00", "2021-01-01T00:00:00", "2020-12-01T00:00:00", "2020-11-01T00:00:00", "2020-10-01T00:00:00", "2020-09-01T00:00:00", "2020-08-01T00:00:00", "2020-07-01T00:00:00", "2020-06-01T00:00:00", "2020-05-01T00:00:00", "2020-04-01T00:00:00", "2020-03-01T00:00:00", "2020-02-01T00:00:00", "2020-01-01T00:00:00", "2019-12-01T00:00:00", "2019-11-01T00:00:00", "2019-10-01T00:00:00", "2019-09-01T00:00:00", "2019-08-01T00:00:00", "2019-07-01T00:00:00", "2019-06-01T00:00:00", "2019-05-01T00:00:00", "2019-04-01T00:00:00", "2019-03-01T00:00:00", "2019-02-01T00:00:00", "2019-01-01T00:00:00", "2018-12-01T00:00:00", "2018-11-01T00:00:00", "2018-10-01T00:00:00", "2018-09-01T00:00:00", "2018-08-01T00:00:00", "2018-07-01T00:00:00", "2018-06-01T00:00:00", "2018-05-01T00:00:00", "2018-04-01T00:00:00", "2018-03-01T00:00:00", "2018-02-01T00:00:00", "2018-01-01T00:00:00", "2017-12-01T00:00:00", "2017-11-01T00:00:00", "2017-10-01T00:00:00", "2017-09-01T00:00:00", "2017-08-01T00:00:00", "2017-07-01T00:00:00", "2017-06-01T00:00:00", "2017-05-01T00:00:00", "2017-04-01T00:00:00", "2017-03-01T00:00:00", "2017-02-01T00:00:00", "2017-01-01T00:00:00", "2016-12-01T00:00:00", "2016-11-01T00:00:00", "2016-10-01T00:00:00", "2016-09-01T00:00:00", "2016-08-01T00:00:00", "2016-07-01T00:00:00", "2016-06-01T00:00:00", "2016-05-01T00:00:00", "2016-04-01T00:00:00", "2016-03-01T00:00:00", "2016-02-01T00:00:00", "2016-01-01T00:00:00", "2015-12-01T00:00:00", "2015-11-01T00:00:00", "2015-10-01T00:00:00", "2015-09-01T00:00:00", "2015-08-01T00:00:00", "2015-07-01T00:00:00", "2015-06-01T00:00:00", "2015-05-01T00:00:00", "2015-04-01T00:00:00", "2015-03-01T00:00:00", "2015-02-01T00:00:00", "2015-01-01T00:00:00", "2014-12-01T00:00:00", "2014-11-01T00:00:00", "2014-10-01T00:00:00", "2014-09-01T00:00:00", "2014-08-01T00:00:00", "2014-07-01T00:00:00", "2014-06-01T00:00:00", "2014-05-01T00:00:00", "2014-04-01T00:00:00", "2014-03-01T00:00:00", "2014-02-01T00:00:00", "2014-01-01T00:00:00", "2013-12-01T00:00:00", "2013-11-01T00:00:00", "2013-10-01T00:00:00", "2013-09-01T00:00:00", "2013-08-01T00:00:00", "2013-07-01T00:00:00", "2013-06-01T00:00:00", "2013-05-01T00:00:00", "2013-04-01T00:00:00", "2013-03-01T00:00:00", "2013-02-01T00:00:00", "2013-01-01T00:00:00", "2012-12-01T00:00:00", "2012-11-01T00:00:00", "2012-10-01T00:00:00", "2012-09-01T00:00:00", "2012-08-01T00:00:00", "2012-07-01T00:00:00", "2012-06-01T00:00:00", "2012-05-01T00:00:00", "2012-04-01T00:00:00", "2012-03-01T00:00:00", "2012-02-01T00:00:00", "2012-01-01T00:00:00", "2011-12-01T00:00:00", "2011-11-01T00:00:00", "2011-10-01T00:00:00", "2011-09-01T00:00:00", "2011-08-01T00:00:00", "2011-07-01T00:00:00", "2011-06-01T00:00:00", "2011-05-01T00:00:00", "2011-04-01T00:00:00", "2011-03-01T00:00:00", "2011-02-01T00:00:00", "2011-01-01T00:00:00", "2010-12-01T00:00:00", "2010-11-01T00:00:00", "2010-10-01T00:00:00", "2010-09-01T00:00:00", "2010-08-01T00:00:00", "2010-07-01T00:00:00" ], "xaxis": "x", "y": [ 191.97, 187.29, 248.48, 240.08, 200.84, 250.22, 258.08, 267.43, 261.77, 203.93, 164.31, 207.46, 205.71, 173.22, 123.18, 194.7, 227.54, 265.25, 275.61, 297.15, 224.47, 252.75, 290.25, 359.2, 290.14, 312.24, 352.26, 381.59, 371.33, 258.49, 245.24, 229.07, 226.57, 208.41, 236.48, 222.64, 225.17, 264.51, 235.22, 189.2, 129.35, 143, 166.11, 95.38, 71.99, 55.67, 52.13, 34.93, 44.53, 43.37, 27.89, 22, 20.99, 16.06, 15.04, 16.11, 14.9, 12.34, 15.91, 18.66, 21.33, 20.47, 22.19, 23.37, 22.49, 17.65, 20.11, 19.88, 22.86, 18.98, 19.59, 17.74, 22.87, 23.62, 20.76, 20.59, 22.1, 22.74, 23.73, 21.56, 24.11, 22.73, 20.94, 18.55, 16.67, 16.8, 14.25, 12.63, 13.18, 13.6, 14.13, 15.65, 14.15, 14.88, 16.05, 15.32, 12.8, 12.75, 16, 15.35, 13.8, 16.56, 16.6, 17.74, 17.88, 16.72, 15.07, 12.58, 13.56, 13.57, 14.83, 16.3, 16.11, 16.18, 17.98, 14.89, 16, 13.85, 13.86, 13.9, 16.32, 12.09, 10.03, 8.49, 10.66, 12.89, 11.27, 8.95, 7.16, 6.52, 3.6, 2.53, 2.32, 2.5, 2.26, 2.25, 1.88, 1.95, 1.9, 1.83, 2.09, 1.97, 2.21, 2.48, 2.23, 1.94, 1.9, 2.18, 1.96, 1.63, 1.65, 1.88, 1.94, 2.01, 1.84, 1.85, 1.59, 1.61, 1.78, 2.36, 1.46, 1.36, 1.3, 1.33 ], "yaxis": "y" } ], "layout": { "annotations": [ { "font": {}, "showarrow": false, "text": "company=tesla", "x": 0.5, "xanchor": "center", "xref": "paper", "y": 0.2866666666666666, "yanchor": "bottom", "yref": "paper" }, { "font": {}, "showarrow": false, "text": "company=walmart", "x": 0.5, "xanchor": "center", "xref": "paper", "y": 0.6433333333333333, "yanchor": "bottom", "yref": "paper" }, { "font": {}, "showarrow": false, "text": "company=apple", "x": 0.5, "xanchor": "center", "xref": "paper", "y": 0.9999999999999999, "yanchor": "bottom", "yref": "paper" } ], "legend": { "title": { "text": "company" }, "tracegroupgap": 0 }, "margin": { "t": 60 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "title": { "text": "Date" } }, "xaxis2": { "anchor": "y2", "domain": [ 0, 1 ], "matches": "x", "showticklabels": false }, "xaxis3": { "anchor": "y3", "domain": [ 0, 1 ], "matches": "x", "showticklabels": false }, "yaxis": { "anchor": "x", "domain": [ 0, 0.2866666666666666 ], "title": { "text": "value" } }, "yaxis2": { "anchor": "x2", "domain": [ 0.35666666666666663, 0.6433333333333333 ], "title": { "text": "value" } }, "yaxis3": { "anchor": "x3", "domain": [ 0.7133333333333333, 0.9999999999999999 ], "title": { "text": "value" } } } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = px.area(df, facet_col='company', facet_col_wrap=1)\n", "fig.update_yaxes(matches=None)\n", "fig.show()" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "n_obs = 20\n", "df_train, df_test = df[0:-n_obs], df[-n_obs:]" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "def adf_test(df):\n", " result = adfuller(df.values)\n", " print('ADF Statistics: %f' % result[0])\n", " print('p-value: %f' % result[1])\n", " print('Critical values:')\n", " for key, value in result[4].items():\n", " print('\\t%s: %.3f' % (key, value))" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ADF Test: Apple time series\n", "ADF Statistics: -2.793474\n", "p-value: 0.059212\n", "Critical values:\n", "\t1%: -3.480\n", "\t5%: -2.883\n", "\t10%: -2.578\n", "ADF Test: Walmart time series\n", "ADF Statistics: -1.407972\n", "p-value: 0.578448\n", "Critical values:\n", "\t1%: -3.478\n", "\t5%: -2.882\n", "\t10%: -2.578\n", "ADF Test: Tesla time series\n", "ADF Statistics: -1.195298\n", "p-value: 0.675615\n", "Critical values:\n", "\t1%: -3.482\n", "\t5%: -2.884\n", "\t10%: -2.579\n" ] } ], "source": [ "print('ADF Test: Apple time series')\n", "adf_test(df_train['apple'])\n", "print('ADF Test: Walmart time series')\n", "adf_test(df_train['walmart'])\n", "print('ADF Test: Tesla time series')\n", "adf_test(df_train['tesla'])" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "def kpss_test(df): \n", " statistic, p_value, n_lags, critical_values = kpss(df.values)\n", " \n", " print(f'KPSS Statistic: {statistic}')\n", " print(f'p-value: {p_value}')\n", " print(f'num lags: {n_lags}')\n", " print('Critial Values:')\n", " for key, value in critical_values.items():\n", " print(f' {key} : {value}')" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "KPSS Test: Apple time series\n", "KPSS Statistic: 1.4799049926667052\n", "p-value: 0.01\n", "num lags: 8\n", "Critial Values:\n", " 10% : 0.347\n", " 5% : 0.463\n", " 2.5% : 0.574\n", " 1% : 0.739\n", "KPSS Test: Walmart time series\n", "KPSS Statistic: 1.5504555338108945\n", "p-value: 0.01\n", "num lags: 8\n", "Critial Values:\n", " 10% : 0.347\n", " 5% : 0.463\n", " 2.5% : 0.574\n", " 1% : 0.739\n", "KPSS Test: Tesla time series\n", "KPSS Statistic: 1.2070673514705184\n", "p-value: 0.01\n", "num lags: 8\n", "Critial Values:\n", " 10% : 0.347\n", " 5% : 0.463\n", " 2.5% : 0.574\n", " 1% : 0.739\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/tmp/ipykernel_347985/249017143.py:2: InterpolationWarning:\n", "\n", "The test statistic is outside of the range of p-values available in the\n", "look-up table. The actual p-value is smaller than the p-value returned.\n", "\n", "\n", "/tmp/ipykernel_347985/249017143.py:2: InterpolationWarning:\n", "\n", "The test statistic is outside of the range of p-values available in the\n", "look-up table. The actual p-value is smaller than the p-value returned.\n", "\n", "\n", "/tmp/ipykernel_347985/249017143.py:2: InterpolationWarning:\n", "\n", "The test statistic is outside of the range of p-values available in the\n", "look-up table. The actual p-value is smaller than the p-value returned.\n", "\n", "\n" ] } ], "source": [ "print('KPSS Test: Apple time series')\n", "kpss_test(df_train['apple'])\n", "print('KPSS Test: Walmart time series')\n", "kpss_test(df_train['walmart'])\n", "print('KPSS Test: Tesla time series')\n", "kpss_test(df_train['tesla'])" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "company=apple
Date=%{x}
value=%{y}", "legendgroup": "apple", "line": { "color": "#636efa", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "apple", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "2024-01-01T00:00:00", "2023-12-01T00:00:00", "2023-11-01T00:00:00", "2023-10-01T00:00:00", "2023-09-01T00:00:00", "2023-08-01T00:00:00", "2023-07-01T00:00:00", "2023-06-01T00:00:00", "2023-05-01T00:00:00", "2023-04-01T00:00:00", "2023-03-01T00:00:00", "2023-02-01T00:00:00", "2023-01-01T00:00:00", "2022-12-01T00:00:00", "2022-11-01T00:00:00", "2022-10-01T00:00:00", "2022-09-01T00:00:00", "2022-08-01T00:00:00", "2022-07-01T00:00:00", "2022-06-01T00:00:00", "2022-05-01T00:00:00", "2022-04-01T00:00:00", "2022-03-01T00:00:00", "2022-02-01T00:00:00", "2022-01-01T00:00:00", "2021-12-01T00:00:00", "2021-11-01T00:00:00", "2021-10-01T00:00:00", "2021-09-01T00:00:00", "2021-08-01T00:00:00", "2021-07-01T00:00:00", "2021-06-01T00:00:00", "2021-05-01T00:00:00", "2021-04-01T00:00:00", "2021-03-01T00:00:00", "2021-02-01T00:00:00", "2021-01-01T00:00:00", "2020-12-01T00:00:00", "2020-11-01T00:00:00", "2020-10-01T00:00:00", "2020-09-01T00:00:00", "2020-08-01T00:00:00", "2020-07-01T00:00:00", "2020-06-01T00:00:00", "2020-05-01T00:00:00", "2020-04-01T00:00:00", "2020-03-01T00:00:00", "2020-02-01T00:00:00", "2020-01-01T00:00:00", "2019-12-01T00:00:00", "2019-11-01T00:00:00", "2019-10-01T00:00:00", "2019-09-01T00:00:00", "2019-08-01T00:00:00", "2019-07-01T00:00:00", "2019-06-01T00:00:00", "2019-05-01T00:00:00", "2019-04-01T00:00:00", "2019-03-01T00:00:00", "2019-02-01T00:00:00", "2019-01-01T00:00:00", "2018-12-01T00:00:00", "2018-11-01T00:00:00", "2018-10-01T00:00:00", "2018-09-01T00:00:00", "2018-08-01T00:00:00", "2018-07-01T00:00:00", "2018-06-01T00:00:00", "2018-05-01T00:00:00", "2018-04-01T00:00:00", "2018-03-01T00:00:00", "2018-02-01T00:00:00", "2018-01-01T00:00:00", "2017-12-01T00:00:00", "2017-11-01T00:00:00", "2017-10-01T00:00:00", "2017-09-01T00:00:00", "2017-08-01T00:00:00", "2017-07-01T00:00:00", "2017-06-01T00:00:00", "2017-05-01T00:00:00", "2017-04-01T00:00:00", "2017-03-01T00:00:00", "2017-02-01T00:00:00", "2017-01-01T00:00:00", "2016-12-01T00:00:00", "2016-11-01T00:00:00", "2016-10-01T00:00:00", "2016-09-01T00:00:00", "2016-08-01T00:00:00", "2016-07-01T00:00:00", "2016-06-01T00:00:00", "2016-05-01T00:00:00", "2016-04-01T00:00:00", "2016-03-01T00:00:00", "2016-02-01T00:00:00", "2016-01-01T00:00:00", "2015-12-01T00:00:00", "2015-11-01T00:00:00", "2015-10-01T00:00:00", "2015-09-01T00:00:00", "2015-08-01T00:00:00", "2015-07-01T00:00:00", "2015-06-01T00:00:00", "2015-05-01T00:00:00", "2015-04-01T00:00:00", "2015-03-01T00:00:00", "2015-02-01T00:00:00", "2015-01-01T00:00:00", "2014-12-01T00:00:00", "2014-11-01T00:00:00", "2014-10-01T00:00:00", "2014-09-01T00:00:00", "2014-08-01T00:00:00", "2014-07-01T00:00:00", "2014-06-01T00:00:00", "2014-05-01T00:00:00", "2014-04-01T00:00:00", "2014-03-01T00:00:00", "2014-02-01T00:00:00", "2014-01-01T00:00:00", "2013-12-01T00:00:00", "2013-11-01T00:00:00", "2013-10-01T00:00:00", "2013-09-01T00:00:00", "2013-08-01T00:00:00", "2013-07-01T00:00:00", "2013-06-01T00:00:00", "2013-05-01T00:00:00", "2013-04-01T00:00:00", "2013-03-01T00:00:00", "2013-02-01T00:00:00", "2013-01-01T00:00:00", "2012-12-01T00:00:00", "2012-11-01T00:00:00", "2012-10-01T00:00:00", "2012-09-01T00:00:00", "2012-08-01T00:00:00", "2012-07-01T00:00:00", "2012-06-01T00:00:00", "2012-05-01T00:00:00", "2012-04-01T00:00:00", "2012-03-01T00:00:00" ], "xaxis": "x3", "y": [ 1.8799999999999955, 8.129999999999995, -2.5800000000000125, -19.17999999999998, 0.4399999999999977, 16.659999999999997, 8.579999999999984, -2.4799999999999898, -16.72, -7.569999999999993, -4.780000000000001, -17.49000000000001, -3.1200000000000045, -14.359999999999985, 18.099999999999994, 5.310000000000002, -15.140000000000015, 19.02000000000001, 5.289999999999992, -25.789999999999992, 12.120000000000005, 8.810000000000002, 16.960000000000008, -9.490000000000009, 9.659999999999997, 2.789999999999992, -12.269999999999982, -15.5, -8.300000000000011, 10.330000000000013, -5.969999999999999, -8.900000000000006, -12.350000000000009, 6.8500000000000085, -9.310000000000002, -0.8900000000000006, 10.700000000000003, 0.7299999999999898, -13.64, -10.189999999999998, 6.950000000000003, 13.22999999999999, -22.779999999999987, -15.060000000000002, -11.710000000000008, -6.039999999999992, -9.880000000000003, 4.770000000000003, 9.039999999999992, -3.969999999999999, -6.599999999999994, -4.6200000000000045, -6.199999999999996, -3.8000000000000043, 1.0700000000000003, -3.780000000000001, -5.709999999999994, 6.399999999999999, -2.6799999999999997, -4.200000000000003, -1.6799999999999997, -2.1700000000000017, 5.210000000000001, 10.07, 1.7199999999999989, 0.46999999999999886, -9.339999999999996, -1.2899999999999991, 0.4399999999999977, -5.409999999999997, 0.6299999999999955, 2.5900000000000034, -2.6700000000000017, 0.45000000000000284, 0.6499999999999986, -0.7000000000000028, -3.729999999999997, 2.469999999999999, -3.8200000000000003, -1.1700000000000017, 2.1799999999999997, -2.280000000000001, 0.010000000000005116, -1.6700000000000017, -3.91, -1.3900000000000006, -1.3200000000000003, 0.7600000000000016, -0.129999999999999, -1.740000000000002, -0.46999999999999886, -2.150000000000002, 1.0700000000000003, -1.5399999999999991, 3.8200000000000003, -3.0799999999999983, 0.1599999999999966, 1.990000000000002, 3.259999999999998, 0.3000000000000007, -2.3000000000000007, 0.610000000000003, 2.139999999999997, 1.0300000000000011, 1.2100000000000009, -1.2800000000000011, -0.17999999999999972, 1.009999999999998, -2.8299999999999983, -1.6999999999999993, 2.1400000000000006, -2.7300000000000004, -1.8099999999999987, 0.4399999999999977, -1.7300000000000004, -0.6699999999999982, -0.620000000000001, -1.5399999999999991, -1.8999999999999986, -0.38000000000000256, -0.9100000000000001, 2.16, -0.17999999999999972, -1.1899999999999977, -1.6400000000000006, 0.36999999999999744, -1.2399999999999984, -2, 1.8999999999999986, -0.24999999999999822, 0, -0.05000000000000071, 0.5099999999999998, 2.740000000000002, 1.889999999999997, 0.360000000000003, 2.5699999999999967, -0.06999999999999673, -1.9500000000000028, -0.9499999999999993, -0.23000000000000043, 0.23000000000000043, 0.5500000000000007 ], "yaxis": "y3" }, { "hovertemplate": "company=walmart
Date=%{x}
value=%{y}", "legendgroup": "walmart", "line": { "color": "#EF553B", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "walmart", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "2024-01-01T00:00:00", "2023-12-01T00:00:00", "2023-11-01T00:00:00", "2023-10-01T00:00:00", "2023-09-01T00:00:00", "2023-08-01T00:00:00", "2023-07-01T00:00:00", "2023-06-01T00:00:00", "2023-05-01T00:00:00", "2023-04-01T00:00:00", "2023-03-01T00:00:00", "2023-02-01T00:00:00", "2023-01-01T00:00:00", "2022-12-01T00:00:00", "2022-11-01T00:00:00", "2022-10-01T00:00:00", "2022-09-01T00:00:00", "2022-08-01T00:00:00", "2022-07-01T00:00:00", "2022-06-01T00:00:00", "2022-05-01T00:00:00", "2022-04-01T00:00:00", "2022-03-01T00:00:00", "2022-02-01T00:00:00", "2022-01-01T00:00:00", "2021-12-01T00:00:00", "2021-11-01T00:00:00", "2021-10-01T00:00:00", "2021-09-01T00:00:00", "2021-08-01T00:00:00", "2021-07-01T00:00:00", "2021-06-01T00:00:00", "2021-05-01T00:00:00", "2021-04-01T00:00:00", "2021-03-01T00:00:00", "2021-02-01T00:00:00", "2021-01-01T00:00:00", "2020-12-01T00:00:00", "2020-11-01T00:00:00", "2020-10-01T00:00:00", "2020-09-01T00:00:00", "2020-08-01T00:00:00", "2020-07-01T00:00:00", "2020-06-01T00:00:00", "2020-05-01T00:00:00", "2020-04-01T00:00:00", "2020-03-01T00:00:00", "2020-02-01T00:00:00", "2020-01-01T00:00:00", "2019-12-01T00:00:00", "2019-11-01T00:00:00", "2019-10-01T00:00:00", "2019-09-01T00:00:00", "2019-08-01T00:00:00", "2019-07-01T00:00:00", "2019-06-01T00:00:00", "2019-05-01T00:00:00", "2019-04-01T00:00:00", "2019-03-01T00:00:00", "2019-02-01T00:00:00", "2019-01-01T00:00:00", "2018-12-01T00:00:00", "2018-11-01T00:00:00", "2018-10-01T00:00:00", "2018-09-01T00:00:00", "2018-08-01T00:00:00", "2018-07-01T00:00:00", "2018-06-01T00:00:00", "2018-05-01T00:00:00", "2018-04-01T00:00:00", "2018-03-01T00:00:00", "2018-02-01T00:00:00", "2018-01-01T00:00:00", "2017-12-01T00:00:00", "2017-11-01T00:00:00", "2017-10-01T00:00:00", "2017-09-01T00:00:00", "2017-08-01T00:00:00", "2017-07-01T00:00:00", "2017-06-01T00:00:00", "2017-05-01T00:00:00", "2017-04-01T00:00:00", "2017-03-01T00:00:00", "2017-02-01T00:00:00", "2017-01-01T00:00:00", "2016-12-01T00:00:00", "2016-11-01T00:00:00", "2016-10-01T00:00:00", "2016-09-01T00:00:00", "2016-08-01T00:00:00", "2016-07-01T00:00:00", "2016-06-01T00:00:00", "2016-05-01T00:00:00", "2016-04-01T00:00:00", "2016-03-01T00:00:00", "2016-02-01T00:00:00", "2016-01-01T00:00:00", "2015-12-01T00:00:00", "2015-11-01T00:00:00", "2015-10-01T00:00:00", "2015-09-01T00:00:00", "2015-08-01T00:00:00", "2015-07-01T00:00:00", "2015-06-01T00:00:00", "2015-05-01T00:00:00", "2015-04-01T00:00:00", "2015-03-01T00:00:00", "2015-02-01T00:00:00", "2015-01-01T00:00:00", "2014-12-01T00:00:00", "2014-11-01T00:00:00", "2014-10-01T00:00:00", "2014-09-01T00:00:00", "2014-08-01T00:00:00", "2014-07-01T00:00:00", "2014-06-01T00:00:00", "2014-05-01T00:00:00", "2014-04-01T00:00:00", "2014-03-01T00:00:00", "2014-02-01T00:00:00", "2014-01-01T00:00:00", "2013-12-01T00:00:00", "2013-11-01T00:00:00", "2013-10-01T00:00:00", "2013-09-01T00:00:00", "2013-08-01T00:00:00", "2013-07-01T00:00:00", "2013-06-01T00:00:00", "2013-05-01T00:00:00", "2013-04-01T00:00:00", "2013-03-01T00:00:00", "2013-02-01T00:00:00", "2013-01-01T00:00:00", "2012-12-01T00:00:00", "2012-11-01T00:00:00", "2012-10-01T00:00:00", "2012-09-01T00:00:00", "2012-08-01T00:00:00", "2012-07-01T00:00:00", "2012-06-01T00:00:00", "2012-05-01T00:00:00", "2012-04-01T00:00:00", "2012-03-01T00:00:00" ], "xaxis": "x2", "y": [ -10.310000000000002, -7.599999999999994, -1.960000000000008, 7.719999999999999, -3.4799999999999898, 2.680000000000007, -2.75, -2.680000000000007, -10.310000000000002, 4.099999999999994, -3.5200000000000102, -5.319999999999993, 1.740000000000009, -2.0800000000000125, 10.629999999999995, -10.089999999999975, -12.630000000000024, 2.8500000000000227, -0.5, -10.470000000000013, 7.049999999999997, 24.360000000000014, -4.070000000000022, -13.759999999999991, 4.650000000000006, 4.8799999999999955, -4.060000000000002, 8.789999999999992, -10.039999999999992, 8.719999999999999, -5.549999999999983, -1.5300000000000011, 1.009999999999991, -2.1200000000000045, -4.079999999999984, -5.910000000000025, 10.570000000000022, 3.6599999999999966, 8.639999999999986, -14.039999999999992, 1.1599999999999966, -1.0600000000000023, -9.449999999999989, -9.620000000000005, 4.280000000000001, -2.510000000000005, -7.929999999999993, -5.939999999999998, 6.809999999999988, 4.3500000000000085, 0.25, -1.8299999999999983, 1.4200000000000017, -4.420000000000002, -3.8800000000000097, 0.10999999999999943, -9.049999999999997, 1.4000000000000057, -5.310000000000002, 1.4599999999999937, -3.1599999999999966, -2.6799999999999926, 4.5, 2.6299999999999955, -6.3700000000000045, 1.9500000000000028, -6.6299999999999955, -3.5799999999999983, -3.1099999999999994, 5.9199999999999875, 0.5100000000000051, 1.0400000000000063, 16.58999999999999, -7.849999999999994, -1.519999999999996, -9.920000000000002, -9.170000000000002, -0.07000000000000739, 1.9200000000000017, -4.309999999999988, 2.9199999999999875, -3.4199999999999875, -3.1000000000000085, -1.1499999999999915, -4.190000000000012, 2.3800000000000097, 1.3100000000000023, -0.4100000000000108, 2.1000000000000085, -0.6800000000000068, 1.5300000000000011, 0.04999999999999716, -2.239999999999995, -3.9099999999999966, 1.6199999999999903, -2.1499999999999915, 0.01999999999999602, -5.060000000000002, -2.4599999999999937, -1.6000000000000014, 7.600000000000001, -0.10999999999999943, 7.25, -1.0499999999999972, 3.339999999999989, 3.780000000000001, 4.200000000000003, 1.6800000000000068, 1.0499999999999972, 0.8999999999999915, 1.6600000000000108, -11.27000000000001, 0.20000000000000284, -0.9699999999999989, -1.9200000000000017, 1.4899999999999949, 1.7000000000000028, 2.9399999999999977, -3.279999999999987, -1.730000000000004, -0.01999999999999602, 4.009999999999991, 2.3200000000000074, -4.260000000000005, -2.7900000000000063, -0.9799999999999898, 4.959999999999994, -3.450000000000003, 0.3500000000000085, 2.8799999999999955, -2.8900000000000006, -4.049999999999997, -0.8299999999999983, -1.7199999999999989, 3.789999999999992, 3, -1.2199999999999989, -1.2000000000000028, 1.8300000000000125, -4.710000000000008, -3.9000000000000057, -6.909999999999997, 2.2900000000000063 ], "yaxis": "y2" }, { "hovertemplate": "company=tesla
Date=%{x}
value=%{y}", "legendgroup": "tesla", "line": { "color": "#00cc96", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "tesla", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "2024-01-01T00:00:00", "2023-12-01T00:00:00", "2023-11-01T00:00:00", "2023-10-01T00:00:00", "2023-09-01T00:00:00", "2023-08-01T00:00:00", "2023-07-01T00:00:00", "2023-06-01T00:00:00", "2023-05-01T00:00:00", "2023-04-01T00:00:00", "2023-03-01T00:00:00", "2023-02-01T00:00:00", "2023-01-01T00:00:00", "2022-12-01T00:00:00", "2022-11-01T00:00:00", "2022-10-01T00:00:00", "2022-09-01T00:00:00", "2022-08-01T00:00:00", "2022-07-01T00:00:00", "2022-06-01T00:00:00", "2022-05-01T00:00:00", "2022-04-01T00:00:00", "2022-03-01T00:00:00", "2022-02-01T00:00:00", "2022-01-01T00:00:00", "2021-12-01T00:00:00", "2021-11-01T00:00:00", "2021-10-01T00:00:00", "2021-09-01T00:00:00", "2021-08-01T00:00:00", "2021-07-01T00:00:00", "2021-06-01T00:00:00", "2021-05-01T00:00:00", "2021-04-01T00:00:00", "2021-03-01T00:00:00", "2021-02-01T00:00:00", "2021-01-01T00:00:00", "2020-12-01T00:00:00", "2020-11-01T00:00:00", "2020-10-01T00:00:00", "2020-09-01T00:00:00", "2020-08-01T00:00:00", "2020-07-01T00:00:00", "2020-06-01T00:00:00", "2020-05-01T00:00:00", "2020-04-01T00:00:00", "2020-03-01T00:00:00", "2020-02-01T00:00:00", "2020-01-01T00:00:00", "2019-12-01T00:00:00", "2019-11-01T00:00:00", "2019-10-01T00:00:00", "2019-09-01T00:00:00", "2019-08-01T00:00:00", "2019-07-01T00:00:00", "2019-06-01T00:00:00", "2019-05-01T00:00:00", "2019-04-01T00:00:00", "2019-03-01T00:00:00", "2019-02-01T00:00:00", "2019-01-01T00:00:00", "2018-12-01T00:00:00", "2018-11-01T00:00:00", "2018-10-01T00:00:00", "2018-09-01T00:00:00", "2018-08-01T00:00:00", "2018-07-01T00:00:00", "2018-06-01T00:00:00", "2018-05-01T00:00:00", "2018-04-01T00:00:00", "2018-03-01T00:00:00", "2018-02-01T00:00:00", "2018-01-01T00:00:00", "2017-12-01T00:00:00", "2017-11-01T00:00:00", "2017-10-01T00:00:00", "2017-09-01T00:00:00", "2017-08-01T00:00:00", "2017-07-01T00:00:00", "2017-06-01T00:00:00", "2017-05-01T00:00:00", "2017-04-01T00:00:00", "2017-03-01T00:00:00", "2017-02-01T00:00:00", "2017-01-01T00:00:00", "2016-12-01T00:00:00", "2016-11-01T00:00:00", "2016-10-01T00:00:00", "2016-09-01T00:00:00", "2016-08-01T00:00:00", "2016-07-01T00:00:00", "2016-06-01T00:00:00", "2016-05-01T00:00:00", "2016-04-01T00:00:00", "2016-03-01T00:00:00", "2016-02-01T00:00:00", "2016-01-01T00:00:00", "2015-12-01T00:00:00", "2015-11-01T00:00:00", "2015-10-01T00:00:00", "2015-09-01T00:00:00", "2015-08-01T00:00:00", "2015-07-01T00:00:00", "2015-06-01T00:00:00", "2015-05-01T00:00:00", "2015-04-01T00:00:00", "2015-03-01T00:00:00", "2015-02-01T00:00:00", "2015-01-01T00:00:00", "2014-12-01T00:00:00", "2014-11-01T00:00:00", "2014-10-01T00:00:00", "2014-09-01T00:00:00", "2014-08-01T00:00:00", "2014-07-01T00:00:00", "2014-06-01T00:00:00", "2014-05-01T00:00:00", "2014-04-01T00:00:00", "2014-03-01T00:00:00", "2014-02-01T00:00:00", "2014-01-01T00:00:00", "2013-12-01T00:00:00", "2013-11-01T00:00:00", "2013-10-01T00:00:00", "2013-09-01T00:00:00", "2013-08-01T00:00:00", "2013-07-01T00:00:00", "2013-06-01T00:00:00", "2013-05-01T00:00:00", "2013-04-01T00:00:00", "2013-03-01T00:00:00", "2013-02-01T00:00:00", "2013-01-01T00:00:00", "2012-12-01T00:00:00", "2012-11-01T00:00:00", "2012-10-01T00:00:00", "2012-09-01T00:00:00", "2012-08-01T00:00:00", "2012-07-01T00:00:00", "2012-06-01T00:00:00", "2012-05-01T00:00:00", "2012-04-01T00:00:00", "2012-03-01T00:00:00" ], "xaxis": "x", "y": [ -4.680000000000007, 61.19, -8.399999999999977, -39.24000000000001, 49.379999999999995, 7.859999999999985, 9.350000000000023, -5.660000000000025, -57.839999999999975, -39.620000000000005, 43.150000000000006, -1.75, -32.49000000000001, -50.03999999999999, 71.51999999999998, 32.84, 37.71000000000001, 10.360000000000014, 21.539999999999964, -72.67999999999998, 28.28, 37.5, 68.94999999999999, -69.06, 22.100000000000023, 40.01999999999998, 29.329999999999984, -10.259999999999991, -112.83999999999997, -13.25, -16.170000000000016, -2.5, -18.159999999999997, 28.069999999999993, -13.840000000000003, 2.530000000000001, 39.34, -29.289999999999992, -46.02000000000001, -59.849999999999994, 13.650000000000006, 23.110000000000014, -70.73000000000002, -23.39, -16.319999999999993, -3.539999999999999, -17.200000000000003, 9.600000000000001, -1.1600000000000037, -15.479999999999997, -5.890000000000001, -1.0100000000000016, -4.93, -1.0199999999999996, 1.0700000000000003, -1.209999999999999, -2.5600000000000005, 3.5700000000000003, 2.75, 2.669999999999998, -0.8599999999999994, 1.7200000000000024, 1.1799999999999997, -0.8800000000000026, -4.84, 2.460000000000001, -0.23000000000000043, 2.9800000000000004, -3.879999999999999, 0.6099999999999994, -1.8500000000000014, 5.130000000000003, 0.75, -2.8599999999999994, -0.1700000000000017, 1.5100000000000016, 0.639999999999997, 0.990000000000002, -2.1700000000000017, 2.5500000000000007, -1.379999999999999, -1.7899999999999991, -2.3900000000000006, -1.879999999999999, 0.129999999999999, -2.5500000000000007, -1.6199999999999992, 0.5499999999999989, 0.41999999999999993, 0.5300000000000011, 1.5199999999999996, -1.5, 0.7300000000000004, 1.17, -0.7300000000000004, -2.5199999999999996, -0.05000000000000071, 3.25, -0.6500000000000004, -1.549999999999999, 2.759999999999998, 0.0400000000000027, 1.139999999999997, 0.14000000000000057, -1.1600000000000001, -1.6499999999999986, -2.49, 0.9800000000000004, 0.009999999999999787, 1.2599999999999998, 1.4700000000000006, -0.19000000000000128, 0.07000000000000028, 1.8000000000000007, -3.09, 1.1099999999999994, -2.1500000000000004, 0.009999999999999787, 0.040000000000000924, 2.42, -4.23, -2.0600000000000005, -1.5399999999999991, 2.17, 2.2300000000000004, -1.620000000000001, -2.3200000000000003, -1.7899999999999991, -0.6400000000000006, -2.9199999999999995, -1.0700000000000003, -0.20999999999999996, 0.18000000000000016, -0.2400000000000002, -0.009999999999999787, -0.3700000000000001, 0.07000000000000006, -0.050000000000000044, -0.06999999999999984, 0.2599999999999998, -0.11999999999999988, 0.24, 0.27 ], "yaxis": "y" } ], "layout": { "annotations": [ { "font": {}, "showarrow": false, "text": "company=tesla", "x": 0.5, "xanchor": "center", "xref": "paper", "y": 0.2866666666666666, "yanchor": "bottom", "yref": "paper" }, { "font": {}, "showarrow": false, "text": "company=walmart", "x": 0.5, "xanchor": "center", "xref": "paper", "y": 0.6433333333333333, "yanchor": "bottom", "yref": "paper" }, { "font": {}, "showarrow": false, "text": "company=apple", "x": 0.5, "xanchor": "center", "xref": "paper", "y": 0.9999999999999999, "yanchor": "bottom", "yref": "paper" } ], "legend": { "title": { "text": "company" }, "tracegroupgap": 0 }, "margin": { "t": 60 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "title": { "text": "Date" } }, "xaxis2": { "anchor": "y2", "domain": [ 0, 1 ], "matches": "x", "showticklabels": false }, "xaxis3": { "anchor": "y3", "domain": [ 0, 1 ], "matches": "x", "showticklabels": false }, "yaxis": { "anchor": "x", "domain": [ 0, 0.2866666666666666 ], "title": { "text": "value" } }, "yaxis2": { "anchor": "x2", "domain": [ 0.35666666666666663, 0.6433333333333333 ], "title": { "text": "value" } }, "yaxis3": { "anchor": "x3", "domain": [ 0.7133333333333333, 0.9999999999999999 ], "title": { "text": "value" } } } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "df_train_transformed = df_train.diff().dropna()\n", "\n", "fig = px.line(df_train_transformed, facet_col=\"company\", facet_col_wrap=1)\n", "fig.update_yaxes(matches=None)\n", "fig.show()" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ADF Test: Apple time series transformed\n", "ADF Statistics: -3.799168\n", "p-value: 0.002916\n", "Critical values:\n", "\t1%: -3.480\n", "\t5%: -2.883\n", "\t10%: -2.578\n", "ADF Test: Walmart time series transformed\n", "ADF Statistics: -10.306569\n", "p-value: 0.000000\n", "Critical values:\n", "\t1%: -3.478\n", "\t5%: -2.882\n", "\t10%: -2.578\n", "ADF Test: Tesla time series transformed\n", "ADF Statistics: -2.927547\n", "p-value: 0.042237\n", "Critical values:\n", "\t1%: -3.482\n", "\t5%: -2.884\n", "\t10%: -2.579\n" ] } ], "source": [ "print('ADF Test: Apple time series transformed')\n", "adf_test(df_train_transformed['apple'])\n", "print('ADF Test: Walmart time series transformed')\n", "adf_test(df_train_transformed['walmart'])\n", "print('ADF Test: Tesla time series transformed')\n", "adf_test(df_train_transformed['tesla'])" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "KPSS Test: Apple time series transformed\n", "KPSS Statistic: 0.30642603993334216\n", "p-value: 0.1\n", "num lags: 7\n", "Critial Values:\n", " 10% : 0.347\n", " 5% : 0.463\n", " 2.5% : 0.574\n", " 1% : 0.739\n", "KPSS Test: Walmart time series transformed\n", "KPSS Statistic: 0.19811078226585627\n", "p-value: 0.1\n", "num lags: 8\n", "Critial Values:\n", " 10% : 0.347\n", " 5% : 0.463\n", " 2.5% : 0.574\n", " 1% : 0.739\n", "KPSS Test: Tesla time series transformed\n", "KPSS Statistic: 0.09114707308088876\n", "p-value: 0.1\n", "num lags: 17\n", "Critial Values:\n", " 10% : 0.347\n", " 5% : 0.463\n", " 2.5% : 0.574\n", " 1% : 0.739\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/tmp/ipykernel_347985/249017143.py:2: InterpolationWarning:\n", "\n", "The test statistic is outside of the range of p-values available in the\n", "look-up table. The actual p-value is greater than the p-value returned.\n", "\n", "\n", "/tmp/ipykernel_347985/249017143.py:2: InterpolationWarning:\n", "\n", "The test statistic is outside of the range of p-values available in the\n", "look-up table. The actual p-value is greater than the p-value returned.\n", "\n", "\n", "/tmp/ipykernel_347985/249017143.py:2: InterpolationWarning:\n", "\n", "The test statistic is outside of the range of p-values available in the\n", "look-up table. The actual p-value is greater than the p-value returned.\n", "\n", "\n" ] } ], "source": [ "print('KPSS Test: Apple time series transformed')\n", "kpss_test(df_train_transformed['apple'])\n", "print('KPSS Test: Walmart time series transformed')\n", "kpss_test(df_train_transformed['walmart'])\n", "print('KPSS Test: Tesla time series transformed')\n", "kpss_test(df_train_transformed['tesla'])" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/statsmodels/tsa/base/tsa_model.py:473: ValueWarning:\n", "\n", "No frequency information was provided, so inferred frequency -1MS will be used.\n", "\n", "/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/statsmodels/tsa/base/tsa_model.py:473: ValueWarning:\n", "\n", "A date index has been provided, but it is not monotonic and so will be ignored when e.g. forecasting.\n", "\n" ] } ], "source": [ "model = VAR(df_train_transformed)" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Lag Order = 1\n", "AIC : 13.121845837129593\n", "BIC : 13.371634039180403\n", "FPE : 499763.6483155377\n", "HQIC: 13.223349623202385 \n", "\n", "Lag Order = 2\n", "AIC : 13.018387880139725\n", "BIC : 13.457564885089665\n", "FPE : 450734.1429337017\n", "HQIC: 13.196854225926092 \n", "\n", "Lag Order = 3\n", "AIC : 12.924920345350833\n", "BIC : 13.555272293052827\n", "FPE : 410713.6140093425\n", "HQIC: 13.181076523988663 \n", "\n", "Lag Order = 4\n", "AIC : 12.765344110806351\n", "BIC : 13.58868571794374\n", "FPE : 350455.45003947406\n", "HQIC: 13.099928235318213 \n", "\n", "Lag Order = 5\n", "AIC : 12.679059830627413\n", "BIC : 13.697235025464702\n", "FPE : 321966.3544416425\n", "HQIC: 13.092821062630037 \n", "\n", "Lag Order = 6\n", "AIC : 12.592854593217835\n", "BIC : 13.80773716819742\n", "FPE : 296040.6198897234\n", "HQIC: 13.086553356094514 \n", "\n", "Lag Order = 7\n", "AIC : 12.578950684208595\n", "BIC : 13.992444966992267\n", "FPE : 292889.94491444435\n", "HQIC: 13.153358880821687 \n", "\n", "Lag Order = 8\n", "AIC : 12.557421041800211\n", "BIC : 14.171462585377117\n", "FPE : 287906.2769831479\n", "HQIC: 13.213322276819387 \n", "\n", "Lag Order = 9\n", "AIC : 12.299921356873089\n", "BIC : 14.116477649379629\n", "FPE : 223834.39221817514\n", "HQIC: 13.03811116379309 \n", "\n", "Lag Order = 10\n", "AIC : 12.169635543959231\n", "BIC : 14.19070673888121\n", "FPE : 197959.9758313992\n", "HQIC: 12.990921616878586 \n", "\n", "Lag Order = 11\n", "AIC : 12.13748096072811\n", "BIC : 14.365100628181215\n", "FPE : 193510.55627011927\n", "HQIC: 13.042683390957396 \n", "\n", "Lag Order = 12\n", "AIC : 11.761102756127734\n", "BIC : 14.197338655939397\n", "FPE : 134383.62461393472\n", "HQIC: 12.751054273692711 \n", "\n", "Lag Order = 13\n", "AIC : 11.747271045494621\n", "BIC : 14.394225922838235\n", "FPE : 134468.2646332004\n", "HQIC: 12.822817265595509 \n", "\n", "Lag Order = 14\n", "AIC : 11.708962819408555\n", "BIC : 14.568775223770228\n", "FPE : 131716.1307288914\n", "HQIC: 12.870962493892204 \n", "\n", "Lag Order = 15\n", "AIC : 11.523062909058199\n", "BIC : 14.597908037346535\n", "FPE : 111727.82568470361\n", "HQIC: 12.772388182954504 \n", "\n" ] } ], "source": [ "for i in [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]:\n", " result = model.fit(i)\n", " print('Lag Order =', i)\n", " print('AIC : ', result.aic)\n", " print('BIC : ', result.bic)\n", " print('FPE : ', result.fpe)\n", " print('HQIC: ', result.hqic, '\\n')" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "data": { "text/plain": [ " Summary of Regression Results \n", "==================================\n", "Model: VAR\n", "Method: OLS\n", "Date: Sun, 25, Feb, 2024\n", "Time: 21:40:09\n", "--------------------------------------------------------------------\n", "No. of Equations: 3.00000 BIC: 14.5979\n", "Nobs: 128.000 HQIC: 12.7724\n", "Log likelihood: -1144.35 FPE: 111728.\n", "AIC: 11.5231 Det(Omega_mle): 44477.8\n", "--------------------------------------------------------------------\n", "Results for equation apple\n", "==============================================================================\n", " coefficient std. error t-stat prob\n", "------------------------------------------------------------------------------\n", "const -0.699238 0.584786 -1.196 0.232\n", "L1.apple 0.014847 0.140038 0.106 0.916\n", "L1.walmart -0.113138 0.105005 -1.077 0.281\n", "L1.tesla 0.081087 0.038983 2.080 0.038\n", "L2.apple -0.167780 0.135627 -1.237 0.216\n", "L2.walmart -0.031901 0.104304 -0.306 0.760\n", "L2.tesla 0.109001 0.039080 2.789 0.005\n", "L3.apple 0.085712 0.136509 0.628 0.530\n", "L3.walmart 0.157405 0.102108 1.542 0.123\n", "L3.tesla -0.081028 0.038433 -2.108 0.035\n", "L4.apple -0.440097 0.112933 -3.897 0.000\n", "L4.walmart -0.028011 0.102538 -0.273 0.785\n", "L4.tesla 0.196295 0.038369 5.116 0.000\n", "L5.apple 0.187708 0.125176 1.500 0.134\n", "L5.walmart -0.059267 0.102669 -0.577 0.564\n", "L5.tesla -0.089774 0.042168 -2.129 0.033\n", "L6.apple -0.021143 0.124388 -0.170 0.865\n", "L6.walmart -0.236903 0.105059 -2.255 0.024\n", "L6.tesla 0.021333 0.040789 0.523 0.601\n", "L7.apple 0.034935 0.121061 0.289 0.773\n", "L7.walmart -0.196441 0.105540 -1.861 0.063\n", "L7.tesla 0.124142 0.039365 3.154 0.002\n", "L8.apple 0.263352 0.114911 2.292 0.022\n", "L8.walmart 0.124926 0.105791 1.181 0.238\n", "L8.tesla -0.064692 0.037117 -1.743 0.081\n", "L9.apple -0.161093 0.118119 -1.364 0.173\n", "L9.walmart 0.142378 0.105329 1.352 0.176\n", "L9.tesla -0.003729 0.036768 -0.101 0.919\n", "L10.apple 0.052834 0.118872 0.444 0.657\n", "L10.walmart -0.012512 0.106188 -0.118 0.906\n", "L10.tesla 0.014551 0.036445 0.399 0.690\n", "L11.apple -0.196153 0.120203 -1.632 0.103\n", "L11.walmart -0.189079 0.103137 -1.833 0.067\n", "L11.tesla 0.046769 0.033933 1.378 0.168\n", "L12.apple 0.281041 0.113450 2.477 0.013\n", "L12.walmart 0.248444 0.097517 2.548 0.011\n", "L12.tesla -0.131892 0.034494 -3.824 0.000\n", "L13.apple -0.033669 0.107860 -0.312 0.755\n", "L13.walmart 0.034415 0.101916 0.338 0.736\n", "L13.tesla -0.018055 0.036536 -0.494 0.621\n", "L14.apple -0.255695 0.103146 -2.479 0.013\n", "L14.walmart 0.139620 0.095459 1.463 0.144\n", "L14.tesla 0.100374 0.036446 2.754 0.006\n", "L15.apple 0.196757 0.104793 1.878 0.060\n", "L15.walmart 0.017978 0.097782 0.184 0.854\n", "L15.tesla -0.030502 0.036230 -0.842 0.400\n", "==============================================================================\n", "\n", "Results for equation walmart\n", "==============================================================================\n", " coefficient std. error t-stat prob\n", "------------------------------------------------------------------------------\n", "const -0.103331 0.633837 -0.163 0.870\n", "L1.apple 0.144375 0.151784 0.951 0.342\n", "L1.walmart -0.076127 0.113813 -0.669 0.504\n", "L1.tesla -0.048764 0.042252 -1.154 0.248\n", "L2.apple -0.125694 0.147003 -0.855 0.393\n", "L2.walmart -0.017047 0.113053 -0.151 0.880\n", "L2.tesla -0.008949 0.042358 -0.211 0.833\n", "L3.apple 0.162286 0.147959 1.097 0.273\n", "L3.walmart -0.060079 0.110672 -0.543 0.587\n", "L3.tesla 0.031460 0.041656 0.755 0.450\n", "L4.apple 0.080359 0.122405 0.657 0.512\n", "L4.walmart -0.068210 0.111139 -0.614 0.539\n", "L4.tesla 0.023108 0.041587 0.556 0.578\n", "L5.apple 0.025574 0.135675 0.188 0.850\n", "L5.walmart -0.232336 0.111281 -2.088 0.037\n", "L5.tesla 0.020971 0.045705 0.459 0.646\n", "L6.apple -0.201452 0.134822 -1.494 0.135\n", "L6.walmart -0.134846 0.113871 -1.184 0.236\n", "L6.tesla 0.068019 0.044210 1.539 0.124\n", "L7.apple 0.186968 0.131215 1.425 0.154\n", "L7.walmart -0.110714 0.114393 -0.968 0.333\n", "L7.tesla -0.016329 0.042667 -0.383 0.702\n", "L8.apple 0.175006 0.124550 1.405 0.160\n", "L8.walmart -0.016260 0.114665 -0.142 0.887\n", "L8.tesla -0.072481 0.040230 -1.802 0.072\n", "L9.apple 0.198956 0.128027 1.554 0.120\n", "L9.walmart -0.084669 0.114164 -0.742 0.458\n", "L9.tesla -0.004090 0.039852 -0.103 0.918\n", "L10.apple -0.091041 0.128843 -0.707 0.480\n", "L10.walmart 0.052878 0.115095 0.459 0.646\n", "L10.tesla -0.003499 0.039502 -0.089 0.929\n", "L11.apple -0.212327 0.130285 -1.630 0.103\n", "L11.walmart -0.065408 0.111788 -0.585 0.558\n", "L11.tesla 0.070514 0.036780 1.917 0.055\n", "L12.apple 0.341238 0.122966 2.775 0.006\n", "L12.walmart -0.128880 0.105697 -1.219 0.223\n", "L12.tesla -0.035130 0.037387 -0.940 0.347\n", "L13.apple -0.009063 0.116907 -0.078 0.938\n", "L13.walmart 0.138496 0.110464 1.254 0.210\n", "L13.tesla -0.016126 0.039601 -0.407 0.684\n", "L14.apple 0.050583 0.111798 0.452 0.651\n", "L14.walmart 0.123218 0.103466 1.191 0.234\n", "L14.tesla 0.005768 0.039503 0.146 0.884\n", "L15.apple 0.153644 0.113583 1.353 0.176\n", "L15.walmart -0.039947 0.105984 -0.377 0.706\n", "L15.tesla -0.054155 0.039269 -1.379 0.168\n", "==============================================================================\n", "\n", "Results for equation tesla\n", "==============================================================================\n", " coefficient std. error t-stat prob\n", "------------------------------------------------------------------------------\n", "const -2.063049 1.878392 -1.098 0.272\n", "L1.apple -0.171895 0.449815 -0.382 0.702\n", "L1.walmart -0.105253 0.337288 -0.312 0.755\n", "L1.tesla 0.190132 0.125216 1.518 0.129\n", "L2.apple -0.046830 0.435648 -0.107 0.914\n", "L2.walmart -0.125800 0.335034 -0.375 0.707\n", "L2.tesla 0.315252 0.125529 2.511 0.012\n", "L3.apple 0.806135 0.438482 1.838 0.066\n", "L3.walmart -0.279177 0.327980 -0.851 0.395\n", "L3.tesla -0.426441 0.123450 -3.454 0.001\n", "L4.apple -0.685840 0.362751 -1.891 0.059\n", "L4.walmart 0.055336 0.329363 0.168 0.867\n", "L4.tesla 0.397299 0.123244 3.224 0.001\n", "L5.apple 0.071231 0.402077 0.177 0.859\n", "L5.walmart -0.108462 0.329783 -0.329 0.742\n", "L5.tesla -0.050922 0.135447 -0.376 0.707\n", "L6.apple -0.389905 0.399548 -0.976 0.329\n", "L6.walmart -0.362135 0.337460 -1.073 0.283\n", "L6.tesla -0.029577 0.131017 -0.226 0.821\n", "L7.apple 0.402571 0.388859 1.035 0.301\n", "L7.walmart -0.773885 0.339006 -2.283 0.022\n", "L7.tesla 0.070900 0.126445 0.561 0.575\n", "L8.apple 0.057018 0.369107 0.154 0.877\n", "L8.walmart -0.253383 0.339812 -0.746 0.456\n", "L8.tesla -0.060940 0.119222 -0.511 0.609\n", "L9.apple -0.814436 0.379410 -2.147 0.032\n", "L9.walmart 0.692883 0.338329 2.048 0.041\n", "L9.tesla 0.170148 0.118103 1.441 0.150\n", "L10.apple 0.165284 0.381830 0.433 0.665\n", "L10.walmart -0.070246 0.341086 -0.206 0.837\n", "L10.tesla 0.111133 0.117065 0.949 0.342\n", "L11.apple -0.257494 0.386104 -0.667 0.505\n", "L11.walmart -0.834862 0.331288 -2.520 0.012\n", "L11.tesla 0.318169 0.108998 2.919 0.004\n", "L12.apple 1.048785 0.364413 2.878 0.004\n", "L12.walmart 0.390809 0.313235 1.248 0.212\n", "L12.tesla -0.268612 0.110798 -2.424 0.015\n", "L13.apple -0.201846 0.346456 -0.583 0.560\n", "L13.walmart 0.385814 0.327363 1.179 0.239\n", "L13.tesla -0.250162 0.117359 -2.132 0.033\n", "L14.apple -0.934654 0.331317 -2.821 0.005\n", "L14.walmart -0.212581 0.306624 -0.693 0.488\n", "L14.tesla 0.296885 0.117067 2.536 0.011\n", "L15.apple 1.015922 0.336607 3.018 0.003\n", "L15.walmart -0.438696 0.314087 -1.397 0.162\n", "L15.tesla -0.205261 0.116373 -1.764 0.078\n", "==============================================================================\n", "\n", "Correlation matrix of residuals\n", " apple walmart tesla\n", "apple 1.000000 0.281952 0.608528\n", "walmart 0.281952 1.000000 0.187816\n", "tesla 0.608528 0.187816 1.000000\n", "\n" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "results = model.fit(maxlags=15, ic='aic')\n", "results.summary()" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [], "source": [ "out = durbin_watson(results.resid)" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "apple : 2.12\n", "walmart : 1.9\n", "tesla : 2.13\n" ] } ], "source": [ "for col, val in zip(df.columns, out):\n", " print(col, ':', round(val, 2))" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [], "source": [ "maxlag=15\n", "test = 'ssr_chi2test'" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [], "source": [ "def grangers_causation_matrix(data, variables, test='ssr_chi2test', verbose=False): \n", " \n", " df = pd.DataFrame(np.zeros((len(variables), len(variables))), columns=variables, index=variables)\n", " for c in df.columns:\n", " for r in df.index:\n", " test_result = grangercausalitytests(data[[r, c]], maxlag=maxlag, verbose=False)\n", " p_values = [round(test_result[i+1][0][test][1],4) for i in range(maxlag)]\n", " if verbose: print(f'Y = {r}, X = {c}, P Values = {p_values}')\n", " min_p_value = np.min(p_values)\n", " df.loc[r, c] = min_p_value\n", " df.columns = [var + '_x' for var in variables]\n", " df.index = [var + '_y' for var in variables]\n", " return df" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/statsmodels/tsa/stattools.py:1545: FutureWarning:\n", "\n", "verbose is deprecated since functions should not print results\n", "\n", "/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/statsmodels/tsa/stattools.py:1545: FutureWarning:\n", "\n", "verbose is deprecated since functions should not print results\n", "\n", "/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/statsmodels/tsa/stattools.py:1545: FutureWarning:\n", "\n", "verbose is deprecated since functions should not print results\n", "\n", "/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/statsmodels/tsa/stattools.py:1545: FutureWarning:\n", "\n", "verbose is deprecated since functions should not print results\n", "\n", "/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/statsmodels/tsa/stattools.py:1545: FutureWarning:\n", "\n", "verbose is deprecated since functions should not print results\n", "\n", "/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/statsmodels/tsa/stattools.py:1545: FutureWarning:\n", "\n", "verbose is deprecated since functions should not print results\n", "\n", "/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/statsmodels/tsa/stattools.py:1545: FutureWarning:\n", "\n", "verbose is deprecated since functions should not print results\n", "\n", "/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/statsmodels/tsa/stattools.py:1545: FutureWarning:\n", "\n", "verbose is deprecated since functions should not print results\n", "\n", "/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/statsmodels/tsa/stattools.py:1545: FutureWarning:\n", "\n", "verbose is deprecated since functions should not print results\n", "\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
apple_xwalmart_xtesla_x
apple_y1.00.00030.0
walmart_y0.01.00000.0
tesla_y0.00.00001.0
\n", "
" ], "text/plain": [ " apple_x walmart_x tesla_x\n", "apple_y 1.0 0.0003 0.0\n", "walmart_y 0.0 1.0000 0.0\n", "tesla_y 0.0 0.0000 1.0" ] }, "execution_count": 38, "metadata": {}, "output_type": "execute_result" } ], "source": [ "grangers_causation_matrix(df_train_transformed, variables = df_train_transformed.columns)" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [], "source": [ "lag_order = results.k_ar\n", "\n", "df_input = df_train_transformed.values[-lag_order:]\n", "df_forecast = results.forecast(y=df_input, steps=n_obs)\n", "df_forecast = (pd.DataFrame(df_forecast, index=df_test.index, columns=df_test.columns + '_pred'))" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [], "source": [ "def invert_transformation(df, pred):\n", " forecast = df_forecast.copy()\n", " columns = df.columns\n", " for col in columns:\n", " forecast[str(col)+'_pred'] = df[col].iloc[-1] + forecast[str(col)+'_pred'].cumsum()\n", " return forecast" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [], "source": [ "output = invert_transformation(df_train, df_forecast)\n", "\n", "combined = pd.concat([output['apple_pred'], df_test['apple'], output['walmart_pred'], df_test['walmart'], output['tesla_pred'], df_test['tesla']], axis=1)" ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Forecast accuracy of Apple\n", "RMSE: 4.37\n", "MAE: 3.67\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/sklearn/metrics/_regression.py:483: FutureWarning:\n", "\n", "'squared' is deprecated in version 1.4 and will be removed in 1.6. To calculate the root mean squared error, use the function'root_mean_squared_error'.\n", "\n" ] } ], "source": [ "rmse = mean_squared_error(combined['apple_pred'], combined['apple'], squared=False)\n", "mae = mean_absolute_error(combined['apple_pred'], combined['apple'])\n", "\n", "print('Forecast accuracy of Apple')\n", "print('RMSE: ', round(rmse,2))\n", "print('MAE: ', round(mae,2))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "py311-kfp240-airflow251", "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.12.1" } }, "nbformat": 4, "nbformat_minor": 2 }