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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"nbformat": 4,
|
3 |
+
"nbformat_minor": 0,
|
4 |
+
"metadata": {
|
5 |
+
"colab": {
|
6 |
+
"provenance": []
|
7 |
+
},
|
8 |
+
"kernelspec": {
|
9 |
+
"name": "python3",
|
10 |
+
"display_name": "Python 3"
|
11 |
+
},
|
12 |
+
"language_info": {
|
13 |
+
"name": "python"
|
14 |
+
}
|
15 |
+
},
|
16 |
+
"cells": [
|
17 |
+
{
|
18 |
+
"cell_type": "code",
|
19 |
+
"source": [
|
20 |
+
"import yfinance\n",
|
21 |
+
"\n",
|
22 |
+
"stocks = ['ARM', 'META', 'SPY', 'TSLA']\n",
|
23 |
+
"\n",
|
24 |
+
"data = yfinance.download(stocks,\n",
|
25 |
+
" '2024-04-01',\n",
|
26 |
+
" '2024-05-09')['Close']"
|
27 |
+
],
|
28 |
+
"metadata": {
|
29 |
+
"colab": {
|
30 |
+
"base_uri": "https://localhost:8080/"
|
31 |
+
},
|
32 |
+
"id": "mfJAaMYDQPfy",
|
33 |
+
"outputId": "ae6d7974-6068-40fa-ed90-c2c6dbc9cec0"
|
34 |
+
},
|
35 |
+
"execution_count": null,
|
36 |
+
"outputs": [
|
37 |
+
{
|
38 |
+
"output_type": "stream",
|
39 |
+
"name": "stderr",
|
40 |
+
"text": [
|
41 |
+
"[*********************100%%**********************] 4 of 4 completed\n"
|
42 |
+
]
|
43 |
+
}
|
44 |
+
]
|
45 |
+
},
|
46 |
+
{
|
47 |
+
"cell_type": "code",
|
48 |
+
"source": [
|
49 |
+
"data.head()"
|
50 |
+
],
|
51 |
+
"metadata": {
|
52 |
+
"colab": {
|
53 |
+
"base_uri": "https://localhost:8080/",
|
54 |
+
"height": 238
|
55 |
+
},
|
56 |
+
"id": "nNuUrUiIQqRA",
|
57 |
+
"outputId": "92863eca-deef-4765-ca5b-74ddf230f3ef"
|
58 |
+
},
|
59 |
+
"execution_count": null,
|
60 |
+
"outputs": [
|
61 |
+
{
|
62 |
+
"output_type": "execute_result",
|
63 |
+
"data": {
|
64 |
+
"text/plain": [
|
65 |
+
"Ticker ARM META SPY TSLA\n",
|
66 |
+
"Date \n",
|
67 |
+
"2024-04-01 126.910004 491.350006 522.159973 175.220001\n",
|
68 |
+
"2024-04-02 124.279999 497.369995 518.840027 166.630005\n",
|
69 |
+
"2024-04-03 125.309998 506.739990 519.409973 168.380005\n",
|
70 |
+
"2024-04-04 122.010002 510.920013 513.070007 171.110001\n",
|
71 |
+
"2024-04-05 124.820000 527.340027 518.429993 164.899994"
|
72 |
+
],
|
73 |
+
"text/html": [
|
74 |
+
"\n",
|
75 |
+
" <div id=\"df-0e5eb836-574f-4203-bb84-939eec9bd41e\" class=\"colab-df-container\">\n",
|
76 |
+
" <div>\n",
|
77 |
+
"<style scoped>\n",
|
78 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
79 |
+
" vertical-align: middle;\n",
|
80 |
+
" }\n",
|
81 |
+
"\n",
|
82 |
+
" .dataframe tbody tr th {\n",
|
83 |
+
" vertical-align: top;\n",
|
84 |
+
" }\n",
|
85 |
+
"\n",
|
86 |
+
" .dataframe thead th {\n",
|
87 |
+
" text-align: right;\n",
|
88 |
+
" }\n",
|
89 |
+
"</style>\n",
|
90 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
91 |
+
" <thead>\n",
|
92 |
+
" <tr style=\"text-align: right;\">\n",
|
93 |
+
" <th>Ticker</th>\n",
|
94 |
+
" <th>ARM</th>\n",
|
95 |
+
" <th>META</th>\n",
|
96 |
+
" <th>SPY</th>\n",
|
97 |
+
" <th>TSLA</th>\n",
|
98 |
+
" </tr>\n",
|
99 |
+
" <tr>\n",
|
100 |
+
" <th>Date</th>\n",
|
101 |
+
" <th></th>\n",
|
102 |
+
" <th></th>\n",
|
103 |
+
" <th></th>\n",
|
104 |
+
" <th></th>\n",
|
105 |
+
" </tr>\n",
|
106 |
+
" </thead>\n",
|
107 |
+
" <tbody>\n",
|
108 |
+
" <tr>\n",
|
109 |
+
" <th>2024-04-01</th>\n",
|
110 |
+
" <td>126.910004</td>\n",
|
111 |
+
" <td>491.350006</td>\n",
|
112 |
+
" <td>522.159973</td>\n",
|
113 |
+
" <td>175.220001</td>\n",
|
114 |
+
" </tr>\n",
|
115 |
+
" <tr>\n",
|
116 |
+
" <th>2024-04-02</th>\n",
|
117 |
+
" <td>124.279999</td>\n",
|
118 |
+
" <td>497.369995</td>\n",
|
119 |
+
" <td>518.840027</td>\n",
|
120 |
+
" <td>166.630005</td>\n",
|
121 |
+
" </tr>\n",
|
122 |
+
" <tr>\n",
|
123 |
+
" <th>2024-04-03</th>\n",
|
124 |
+
" <td>125.309998</td>\n",
|
125 |
+
" <td>506.739990</td>\n",
|
126 |
+
" <td>519.409973</td>\n",
|
127 |
+
" <td>168.380005</td>\n",
|
128 |
+
" </tr>\n",
|
129 |
+
" <tr>\n",
|
130 |
+
" <th>2024-04-04</th>\n",
|
131 |
+
" <td>122.010002</td>\n",
|
132 |
+
" <td>510.920013</td>\n",
|
133 |
+
" <td>513.070007</td>\n",
|
134 |
+
" <td>171.110001</td>\n",
|
135 |
+
" </tr>\n",
|
136 |
+
" <tr>\n",
|
137 |
+
" <th>2024-04-05</th>\n",
|
138 |
+
" <td>124.820000</td>\n",
|
139 |
+
" <td>527.340027</td>\n",
|
140 |
+
" <td>518.429993</td>\n",
|
141 |
+
" <td>164.899994</td>\n",
|
142 |
+
" </tr>\n",
|
143 |
+
" </tbody>\n",
|
144 |
+
"</table>\n",
|
145 |
+
"</div>\n",
|
146 |
+
" <div class=\"colab-df-buttons\">\n",
|
147 |
+
"\n",
|
148 |
+
" <div class=\"colab-df-container\">\n",
|
149 |
+
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-0e5eb836-574f-4203-bb84-939eec9bd41e')\"\n",
|
150 |
+
" title=\"Convert this dataframe to an interactive table.\"\n",
|
151 |
+
" style=\"display:none;\">\n",
|
152 |
+
"\n",
|
153 |
+
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
|
154 |
+
" <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
|
155 |
+
" </svg>\n",
|
156 |
+
" </button>\n",
|
157 |
+
"\n",
|
158 |
+
" <style>\n",
|
159 |
+
" .colab-df-container {\n",
|
160 |
+
" display:flex;\n",
|
161 |
+
" gap: 12px;\n",
|
162 |
+
" }\n",
|
163 |
+
"\n",
|
164 |
+
" .colab-df-convert {\n",
|
165 |
+
" background-color: #E8F0FE;\n",
|
166 |
+
" border: none;\n",
|
167 |
+
" border-radius: 50%;\n",
|
168 |
+
" cursor: pointer;\n",
|
169 |
+
" display: none;\n",
|
170 |
+
" fill: #1967D2;\n",
|
171 |
+
" height: 32px;\n",
|
172 |
+
" padding: 0 0 0 0;\n",
|
173 |
+
" width: 32px;\n",
|
174 |
+
" }\n",
|
175 |
+
"\n",
|
176 |
+
" .colab-df-convert:hover {\n",
|
177 |
+
" background-color: #E2EBFA;\n",
|
178 |
+
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
|
179 |
+
" fill: #174EA6;\n",
|
180 |
+
" }\n",
|
181 |
+
"\n",
|
182 |
+
" .colab-df-buttons div {\n",
|
183 |
+
" margin-bottom: 4px;\n",
|
184 |
+
" }\n",
|
185 |
+
"\n",
|
186 |
+
" [theme=dark] .colab-df-convert {\n",
|
187 |
+
" background-color: #3B4455;\n",
|
188 |
+
" fill: #D2E3FC;\n",
|
189 |
+
" }\n",
|
190 |
+
"\n",
|
191 |
+
" [theme=dark] .colab-df-convert:hover {\n",
|
192 |
+
" background-color: #434B5C;\n",
|
193 |
+
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
|
194 |
+
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
|
195 |
+
" fill: #FFFFFF;\n",
|
196 |
+
" }\n",
|
197 |
+
" </style>\n",
|
198 |
+
"\n",
|
199 |
+
" <script>\n",
|
200 |
+
" const buttonEl =\n",
|
201 |
+
" document.querySelector('#df-0e5eb836-574f-4203-bb84-939eec9bd41e button.colab-df-convert');\n",
|
202 |
+
" buttonEl.style.display =\n",
|
203 |
+
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
|
204 |
+
"\n",
|
205 |
+
" async function convertToInteractive(key) {\n",
|
206 |
+
" const element = document.querySelector('#df-0e5eb836-574f-4203-bb84-939eec9bd41e');\n",
|
207 |
+
" const dataTable =\n",
|
208 |
+
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
|
209 |
+
" [key], {});\n",
|
210 |
+
" if (!dataTable) return;\n",
|
211 |
+
"\n",
|
212 |
+
" const docLinkHtml = 'Like what you see? Visit the ' +\n",
|
213 |
+
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
|
214 |
+
" + ' to learn more about interactive tables.';\n",
|
215 |
+
" element.innerHTML = '';\n",
|
216 |
+
" dataTable['output_type'] = 'display_data';\n",
|
217 |
+
" await google.colab.output.renderOutput(dataTable, element);\n",
|
218 |
+
" const docLink = document.createElement('div');\n",
|
219 |
+
" docLink.innerHTML = docLinkHtml;\n",
|
220 |
+
" element.appendChild(docLink);\n",
|
221 |
+
" }\n",
|
222 |
+
" </script>\n",
|
223 |
+
" </div>\n",
|
224 |
+
"\n",
|
225 |
+
"\n",
|
226 |
+
"<div id=\"df-2a98e692-2e15-4bf2-b320-373fa67edeb6\">\n",
|
227 |
+
" <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-2a98e692-2e15-4bf2-b320-373fa67edeb6')\"\n",
|
228 |
+
" title=\"Suggest charts\"\n",
|
229 |
+
" style=\"display:none;\">\n",
|
230 |
+
"\n",
|
231 |
+
"<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
|
232 |
+
" width=\"24px\">\n",
|
233 |
+
" <g>\n",
|
234 |
+
" <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
|
235 |
+
" </g>\n",
|
236 |
+
"</svg>\n",
|
237 |
+
" </button>\n",
|
238 |
+
"\n",
|
239 |
+
"<style>\n",
|
240 |
+
" .colab-df-quickchart {\n",
|
241 |
+
" --bg-color: #E8F0FE;\n",
|
242 |
+
" --fill-color: #1967D2;\n",
|
243 |
+
" --hover-bg-color: #E2EBFA;\n",
|
244 |
+
" --hover-fill-color: #174EA6;\n",
|
245 |
+
" --disabled-fill-color: #AAA;\n",
|
246 |
+
" --disabled-bg-color: #DDD;\n",
|
247 |
+
" }\n",
|
248 |
+
"\n",
|
249 |
+
" [theme=dark] .colab-df-quickchart {\n",
|
250 |
+
" --bg-color: #3B4455;\n",
|
251 |
+
" --fill-color: #D2E3FC;\n",
|
252 |
+
" --hover-bg-color: #434B5C;\n",
|
253 |
+
" --hover-fill-color: #FFFFFF;\n",
|
254 |
+
" --disabled-bg-color: #3B4455;\n",
|
255 |
+
" --disabled-fill-color: #666;\n",
|
256 |
+
" }\n",
|
257 |
+
"\n",
|
258 |
+
" .colab-df-quickchart {\n",
|
259 |
+
" background-color: var(--bg-color);\n",
|
260 |
+
" border: none;\n",
|
261 |
+
" border-radius: 50%;\n",
|
262 |
+
" cursor: pointer;\n",
|
263 |
+
" display: none;\n",
|
264 |
+
" fill: var(--fill-color);\n",
|
265 |
+
" height: 32px;\n",
|
266 |
+
" padding: 0;\n",
|
267 |
+
" width: 32px;\n",
|
268 |
+
" }\n",
|
269 |
+
"\n",
|
270 |
+
" .colab-df-quickchart:hover {\n",
|
271 |
+
" background-color: var(--hover-bg-color);\n",
|
272 |
+
" box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
|
273 |
+
" fill: var(--button-hover-fill-color);\n",
|
274 |
+
" }\n",
|
275 |
+
"\n",
|
276 |
+
" .colab-df-quickchart-complete:disabled,\n",
|
277 |
+
" .colab-df-quickchart-complete:disabled:hover {\n",
|
278 |
+
" background-color: var(--disabled-bg-color);\n",
|
279 |
+
" fill: var(--disabled-fill-color);\n",
|
280 |
+
" box-shadow: none;\n",
|
281 |
+
" }\n",
|
282 |
+
"\n",
|
283 |
+
" .colab-df-spinner {\n",
|
284 |
+
" border: 2px solid var(--fill-color);\n",
|
285 |
+
" border-color: transparent;\n",
|
286 |
+
" border-bottom-color: var(--fill-color);\n",
|
287 |
+
" animation:\n",
|
288 |
+
" spin 1s steps(1) infinite;\n",
|
289 |
+
" }\n",
|
290 |
+
"\n",
|
291 |
+
" @keyframes spin {\n",
|
292 |
+
" 0% {\n",
|
293 |
+
" border-color: transparent;\n",
|
294 |
+
" border-bottom-color: var(--fill-color);\n",
|
295 |
+
" border-left-color: var(--fill-color);\n",
|
296 |
+
" }\n",
|
297 |
+
" 20% {\n",
|
298 |
+
" border-color: transparent;\n",
|
299 |
+
" border-left-color: var(--fill-color);\n",
|
300 |
+
" border-top-color: var(--fill-color);\n",
|
301 |
+
" }\n",
|
302 |
+
" 30% {\n",
|
303 |
+
" border-color: transparent;\n",
|
304 |
+
" border-left-color: var(--fill-color);\n",
|
305 |
+
" border-top-color: var(--fill-color);\n",
|
306 |
+
" border-right-color: var(--fill-color);\n",
|
307 |
+
" }\n",
|
308 |
+
" 40% {\n",
|
309 |
+
" border-color: transparent;\n",
|
310 |
+
" border-right-color: var(--fill-color);\n",
|
311 |
+
" border-top-color: var(--fill-color);\n",
|
312 |
+
" }\n",
|
313 |
+
" 60% {\n",
|
314 |
+
" border-color: transparent;\n",
|
315 |
+
" border-right-color: var(--fill-color);\n",
|
316 |
+
" }\n",
|
317 |
+
" 80% {\n",
|
318 |
+
" border-color: transparent;\n",
|
319 |
+
" border-right-color: var(--fill-color);\n",
|
320 |
+
" border-bottom-color: var(--fill-color);\n",
|
321 |
+
" }\n",
|
322 |
+
" 90% {\n",
|
323 |
+
" border-color: transparent;\n",
|
324 |
+
" border-bottom-color: var(--fill-color);\n",
|
325 |
+
" }\n",
|
326 |
+
" }\n",
|
327 |
+
"</style>\n",
|
328 |
+
"\n",
|
329 |
+
" <script>\n",
|
330 |
+
" async function quickchart(key) {\n",
|
331 |
+
" const quickchartButtonEl =\n",
|
332 |
+
" document.querySelector('#' + key + ' button');\n",
|
333 |
+
" quickchartButtonEl.disabled = true; // To prevent multiple clicks.\n",
|
334 |
+
" quickchartButtonEl.classList.add('colab-df-spinner');\n",
|
335 |
+
" try {\n",
|
336 |
+
" const charts = await google.colab.kernel.invokeFunction(\n",
|
337 |
+
" 'suggestCharts', [key], {});\n",
|
338 |
+
" } catch (error) {\n",
|
339 |
+
" console.error('Error during call to suggestCharts:', error);\n",
|
340 |
+
" }\n",
|
341 |
+
" quickchartButtonEl.classList.remove('colab-df-spinner');\n",
|
342 |
+
" quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
|
343 |
+
" }\n",
|
344 |
+
" (() => {\n",
|
345 |
+
" let quickchartButtonEl =\n",
|
346 |
+
" document.querySelector('#df-2a98e692-2e15-4bf2-b320-373fa67edeb6 button');\n",
|
347 |
+
" quickchartButtonEl.style.display =\n",
|
348 |
+
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
|
349 |
+
" })();\n",
|
350 |
+
" </script>\n",
|
351 |
+
"</div>\n",
|
352 |
+
"\n",
|
353 |
+
" </div>\n",
|
354 |
+
" </div>\n"
|
355 |
+
],
|
356 |
+
"application/vnd.google.colaboratory.intrinsic+json": {
|
357 |
+
"type": "dataframe",
|
358 |
+
"variable_name": "data",
|
359 |
+
"summary": "{\n \"name\": \"data\",\n \"rows\": 28,\n \"fields\": [\n {\n \"column\": \"Date\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": \"2024-04-01 00:00:00\",\n \"max\": \"2024-05-08 00:00:00\",\n \"num_unique_values\": 28,\n \"samples\": [\n \"2024-04-12 00:00:00\",\n \"2024-05-06 00:00:00\",\n \"2024-04-11 00:00:00\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"ARM\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 13.427250841587558,\n \"min\": 87.19000244140625,\n \"max\": 131.1300048828125,\n \"num_unique_values\": 28,\n \"samples\": [\n 126.33000183105469,\n 106.9800033569336,\n 131.1300048828125\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"META\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 30.431831533944457,\n \"min\": 430.1700134277344,\n \"max\": 527.3400268554688,\n \"num_unique_values\": 28,\n \"samples\": [\n 511.8999938964844,\n 465.67999267578125,\n 523.1599731445312\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"SPY\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 7.822782121778119,\n \"min\": 495.1600036621094,\n \"max\": 522.1599731445312,\n \"num_unique_values\": 28,\n \"samples\": [\n 510.8500061035156,\n 516.5700073242188,\n 518.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"TSLA\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 12.708960958084381,\n \"min\": 142.0500030517578,\n \"max\": 194.0500030517578,\n \"num_unique_values\": 28,\n \"samples\": [\n 171.0500030517578,\n 184.75999450683594,\n 174.60000610351562\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
|
360 |
+
}
|
361 |
+
},
|
362 |
+
"metadata": {},
|
363 |
+
"execution_count": 2
|
364 |
+
}
|
365 |
+
]
|
366 |
+
},
|
367 |
+
{
|
368 |
+
"cell_type": "code",
|
369 |
+
"source": [
|
370 |
+
"returns = data.pct_change()\n",
|
371 |
+
"returns.head()"
|
372 |
+
],
|
373 |
+
"metadata": {
|
374 |
+
"colab": {
|
375 |
+
"base_uri": "https://localhost:8080/",
|
376 |
+
"height": 238
|
377 |
+
},
|
378 |
+
"id": "vwy0TbMoQxh-",
|
379 |
+
"outputId": "f396857e-47c8-4cf6-e407-3f214bb02cd5"
|
380 |
+
},
|
381 |
+
"execution_count": null,
|
382 |
+
"outputs": [
|
383 |
+
{
|
384 |
+
"output_type": "execute_result",
|
385 |
+
"data": {
|
386 |
+
"text/plain": [
|
387 |
+
"Ticker ARM META SPY TSLA\n",
|
388 |
+
"Date \n",
|
389 |
+
"2024-04-01 NaN NaN NaN NaN\n",
|
390 |
+
"2024-04-02 -0.020723 0.012252 -0.006358 -0.049024\n",
|
391 |
+
"2024-04-03 0.008288 0.018839 0.001099 0.010502\n",
|
392 |
+
"2024-04-04 -0.026335 0.008249 -0.012206 0.016213\n",
|
393 |
+
"2024-04-05 0.023031 0.032138 0.010447 -0.036292"
|
394 |
+
],
|
395 |
+
"text/html": [
|
396 |
+
"\n",
|
397 |
+
" <div id=\"df-2de0aa29-47b8-4eb5-bb6e-2fd6b245c3c7\" class=\"colab-df-container\">\n",
|
398 |
+
" <div>\n",
|
399 |
+
"<style scoped>\n",
|
400 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
401 |
+
" vertical-align: middle;\n",
|
402 |
+
" }\n",
|
403 |
+
"\n",
|
404 |
+
" .dataframe tbody tr th {\n",
|
405 |
+
" vertical-align: top;\n",
|
406 |
+
" }\n",
|
407 |
+
"\n",
|
408 |
+
" .dataframe thead th {\n",
|
409 |
+
" text-align: right;\n",
|
410 |
+
" }\n",
|
411 |
+
"</style>\n",
|
412 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
413 |
+
" <thead>\n",
|
414 |
+
" <tr style=\"text-align: right;\">\n",
|
415 |
+
" <th>Ticker</th>\n",
|
416 |
+
" <th>ARM</th>\n",
|
417 |
+
" <th>META</th>\n",
|
418 |
+
" <th>SPY</th>\n",
|
419 |
+
" <th>TSLA</th>\n",
|
420 |
+
" </tr>\n",
|
421 |
+
" <tr>\n",
|
422 |
+
" <th>Date</th>\n",
|
423 |
+
" <th></th>\n",
|
424 |
+
" <th></th>\n",
|
425 |
+
" <th></th>\n",
|
426 |
+
" <th></th>\n",
|
427 |
+
" </tr>\n",
|
428 |
+
" </thead>\n",
|
429 |
+
" <tbody>\n",
|
430 |
+
" <tr>\n",
|
431 |
+
" <th>2024-04-01</th>\n",
|
432 |
+
" <td>NaN</td>\n",
|
433 |
+
" <td>NaN</td>\n",
|
434 |
+
" <td>NaN</td>\n",
|
435 |
+
" <td>NaN</td>\n",
|
436 |
+
" </tr>\n",
|
437 |
+
" <tr>\n",
|
438 |
+
" <th>2024-04-02</th>\n",
|
439 |
+
" <td>-0.020723</td>\n",
|
440 |
+
" <td>0.012252</td>\n",
|
441 |
+
" <td>-0.006358</td>\n",
|
442 |
+
" <td>-0.049024</td>\n",
|
443 |
+
" </tr>\n",
|
444 |
+
" <tr>\n",
|
445 |
+
" <th>2024-04-03</th>\n",
|
446 |
+
" <td>0.008288</td>\n",
|
447 |
+
" <td>0.018839</td>\n",
|
448 |
+
" <td>0.001099</td>\n",
|
449 |
+
" <td>0.010502</td>\n",
|
450 |
+
" </tr>\n",
|
451 |
+
" <tr>\n",
|
452 |
+
" <th>2024-04-04</th>\n",
|
453 |
+
" <td>-0.026335</td>\n",
|
454 |
+
" <td>0.008249</td>\n",
|
455 |
+
" <td>-0.012206</td>\n",
|
456 |
+
" <td>0.016213</td>\n",
|
457 |
+
" </tr>\n",
|
458 |
+
" <tr>\n",
|
459 |
+
" <th>2024-04-05</th>\n",
|
460 |
+
" <td>0.023031</td>\n",
|
461 |
+
" <td>0.032138</td>\n",
|
462 |
+
" <td>0.010447</td>\n",
|
463 |
+
" <td>-0.036292</td>\n",
|
464 |
+
" </tr>\n",
|
465 |
+
" </tbody>\n",
|
466 |
+
"</table>\n",
|
467 |
+
"</div>\n",
|
468 |
+
" <div class=\"colab-df-buttons\">\n",
|
469 |
+
"\n",
|
470 |
+
" <div class=\"colab-df-container\">\n",
|
471 |
+
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-2de0aa29-47b8-4eb5-bb6e-2fd6b245c3c7')\"\n",
|
472 |
+
" title=\"Convert this dataframe to an interactive table.\"\n",
|
473 |
+
" style=\"display:none;\">\n",
|
474 |
+
"\n",
|
475 |
+
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
|
476 |
+
" <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
|
477 |
+
" </svg>\n",
|
478 |
+
" </button>\n",
|
479 |
+
"\n",
|
480 |
+
" <style>\n",
|
481 |
+
" .colab-df-container {\n",
|
482 |
+
" display:flex;\n",
|
483 |
+
" gap: 12px;\n",
|
484 |
+
" }\n",
|
485 |
+
"\n",
|
486 |
+
" .colab-df-convert {\n",
|
487 |
+
" background-color: #E8F0FE;\n",
|
488 |
+
" border: none;\n",
|
489 |
+
" border-radius: 50%;\n",
|
490 |
+
" cursor: pointer;\n",
|
491 |
+
" display: none;\n",
|
492 |
+
" fill: #1967D2;\n",
|
493 |
+
" height: 32px;\n",
|
494 |
+
" padding: 0 0 0 0;\n",
|
495 |
+
" width: 32px;\n",
|
496 |
+
" }\n",
|
497 |
+
"\n",
|
498 |
+
" .colab-df-convert:hover {\n",
|
499 |
+
" background-color: #E2EBFA;\n",
|
500 |
+
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
|
501 |
+
" fill: #174EA6;\n",
|
502 |
+
" }\n",
|
503 |
+
"\n",
|
504 |
+
" .colab-df-buttons div {\n",
|
505 |
+
" margin-bottom: 4px;\n",
|
506 |
+
" }\n",
|
507 |
+
"\n",
|
508 |
+
" [theme=dark] .colab-df-convert {\n",
|
509 |
+
" background-color: #3B4455;\n",
|
510 |
+
" fill: #D2E3FC;\n",
|
511 |
+
" }\n",
|
512 |
+
"\n",
|
513 |
+
" [theme=dark] .colab-df-convert:hover {\n",
|
514 |
+
" background-color: #434B5C;\n",
|
515 |
+
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
|
516 |
+
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
|
517 |
+
" fill: #FFFFFF;\n",
|
518 |
+
" }\n",
|
519 |
+
" </style>\n",
|
520 |
+
"\n",
|
521 |
+
" <script>\n",
|
522 |
+
" const buttonEl =\n",
|
523 |
+
" document.querySelector('#df-2de0aa29-47b8-4eb5-bb6e-2fd6b245c3c7 button.colab-df-convert');\n",
|
524 |
+
" buttonEl.style.display =\n",
|
525 |
+
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
|
526 |
+
"\n",
|
527 |
+
" async function convertToInteractive(key) {\n",
|
528 |
+
" const element = document.querySelector('#df-2de0aa29-47b8-4eb5-bb6e-2fd6b245c3c7');\n",
|
529 |
+
" const dataTable =\n",
|
530 |
+
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
|
531 |
+
" [key], {});\n",
|
532 |
+
" if (!dataTable) return;\n",
|
533 |
+
"\n",
|
534 |
+
" const docLinkHtml = 'Like what you see? Visit the ' +\n",
|
535 |
+
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
|
536 |
+
" + ' to learn more about interactive tables.';\n",
|
537 |
+
" element.innerHTML = '';\n",
|
538 |
+
" dataTable['output_type'] = 'display_data';\n",
|
539 |
+
" await google.colab.output.renderOutput(dataTable, element);\n",
|
540 |
+
" const docLink = document.createElement('div');\n",
|
541 |
+
" docLink.innerHTML = docLinkHtml;\n",
|
542 |
+
" element.appendChild(docLink);\n",
|
543 |
+
" }\n",
|
544 |
+
" </script>\n",
|
545 |
+
" </div>\n",
|
546 |
+
"\n",
|
547 |
+
"\n",
|
548 |
+
"<div id=\"df-be760966-495f-47fc-be52-69a87fe8d7d2\">\n",
|
549 |
+
" <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-be760966-495f-47fc-be52-69a87fe8d7d2')\"\n",
|
550 |
+
" title=\"Suggest charts\"\n",
|
551 |
+
" style=\"display:none;\">\n",
|
552 |
+
"\n",
|
553 |
+
"<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
|
554 |
+
" width=\"24px\">\n",
|
555 |
+
" <g>\n",
|
556 |
+
" <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
|
557 |
+
" </g>\n",
|
558 |
+
"</svg>\n",
|
559 |
+
" </button>\n",
|
560 |
+
"\n",
|
561 |
+
"<style>\n",
|
562 |
+
" .colab-df-quickchart {\n",
|
563 |
+
" --bg-color: #E8F0FE;\n",
|
564 |
+
" --fill-color: #1967D2;\n",
|
565 |
+
" --hover-bg-color: #E2EBFA;\n",
|
566 |
+
" --hover-fill-color: #174EA6;\n",
|
567 |
+
" --disabled-fill-color: #AAA;\n",
|
568 |
+
" --disabled-bg-color: #DDD;\n",
|
569 |
+
" }\n",
|
570 |
+
"\n",
|
571 |
+
" [theme=dark] .colab-df-quickchart {\n",
|
572 |
+
" --bg-color: #3B4455;\n",
|
573 |
+
" --fill-color: #D2E3FC;\n",
|
574 |
+
" --hover-bg-color: #434B5C;\n",
|
575 |
+
" --hover-fill-color: #FFFFFF;\n",
|
576 |
+
" --disabled-bg-color: #3B4455;\n",
|
577 |
+
" --disabled-fill-color: #666;\n",
|
578 |
+
" }\n",
|
579 |
+
"\n",
|
580 |
+
" .colab-df-quickchart {\n",
|
581 |
+
" background-color: var(--bg-color);\n",
|
582 |
+
" border: none;\n",
|
583 |
+
" border-radius: 50%;\n",
|
584 |
+
" cursor: pointer;\n",
|
585 |
+
" display: none;\n",
|
586 |
+
" fill: var(--fill-color);\n",
|
587 |
+
" height: 32px;\n",
|
588 |
+
" padding: 0;\n",
|
589 |
+
" width: 32px;\n",
|
590 |
+
" }\n",
|
591 |
+
"\n",
|
592 |
+
" .colab-df-quickchart:hover {\n",
|
593 |
+
" background-color: var(--hover-bg-color);\n",
|
594 |
+
" box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
|
595 |
+
" fill: var(--button-hover-fill-color);\n",
|
596 |
+
" }\n",
|
597 |
+
"\n",
|
598 |
+
" .colab-df-quickchart-complete:disabled,\n",
|
599 |
+
" .colab-df-quickchart-complete:disabled:hover {\n",
|
600 |
+
" background-color: var(--disabled-bg-color);\n",
|
601 |
+
" fill: var(--disabled-fill-color);\n",
|
602 |
+
" box-shadow: none;\n",
|
603 |
+
" }\n",
|
604 |
+
"\n",
|
605 |
+
" .colab-df-spinner {\n",
|
606 |
+
" border: 2px solid var(--fill-color);\n",
|
607 |
+
" border-color: transparent;\n",
|
608 |
+
" border-bottom-color: var(--fill-color);\n",
|
609 |
+
" animation:\n",
|
610 |
+
" spin 1s steps(1) infinite;\n",
|
611 |
+
" }\n",
|
612 |
+
"\n",
|
613 |
+
" @keyframes spin {\n",
|
614 |
+
" 0% {\n",
|
615 |
+
" border-color: transparent;\n",
|
616 |
+
" border-bottom-color: var(--fill-color);\n",
|
617 |
+
" border-left-color: var(--fill-color);\n",
|
618 |
+
" }\n",
|
619 |
+
" 20% {\n",
|
620 |
+
" border-color: transparent;\n",
|
621 |
+
" border-left-color: var(--fill-color);\n",
|
622 |
+
" border-top-color: var(--fill-color);\n",
|
623 |
+
" }\n",
|
624 |
+
" 30% {\n",
|
625 |
+
" border-color: transparent;\n",
|
626 |
+
" border-left-color: var(--fill-color);\n",
|
627 |
+
" border-top-color: var(--fill-color);\n",
|
628 |
+
" border-right-color: var(--fill-color);\n",
|
629 |
+
" }\n",
|
630 |
+
" 40% {\n",
|
631 |
+
" border-color: transparent;\n",
|
632 |
+
" border-right-color: var(--fill-color);\n",
|
633 |
+
" border-top-color: var(--fill-color);\n",
|
634 |
+
" }\n",
|
635 |
+
" 60% {\n",
|
636 |
+
" border-color: transparent;\n",
|
637 |
+
" border-right-color: var(--fill-color);\n",
|
638 |
+
" }\n",
|
639 |
+
" 80% {\n",
|
640 |
+
" border-color: transparent;\n",
|
641 |
+
" border-right-color: var(--fill-color);\n",
|
642 |
+
" border-bottom-color: var(--fill-color);\n",
|
643 |
+
" }\n",
|
644 |
+
" 90% {\n",
|
645 |
+
" border-color: transparent;\n",
|
646 |
+
" border-bottom-color: var(--fill-color);\n",
|
647 |
+
" }\n",
|
648 |
+
" }\n",
|
649 |
+
"</style>\n",
|
650 |
+
"\n",
|
651 |
+
" <script>\n",
|
652 |
+
" async function quickchart(key) {\n",
|
653 |
+
" const quickchartButtonEl =\n",
|
654 |
+
" document.querySelector('#' + key + ' button');\n",
|
655 |
+
" quickchartButtonEl.disabled = true; // To prevent multiple clicks.\n",
|
656 |
+
" quickchartButtonEl.classList.add('colab-df-spinner');\n",
|
657 |
+
" try {\n",
|
658 |
+
" const charts = await google.colab.kernel.invokeFunction(\n",
|
659 |
+
" 'suggestCharts', [key], {});\n",
|
660 |
+
" } catch (error) {\n",
|
661 |
+
" console.error('Error during call to suggestCharts:', error);\n",
|
662 |
+
" }\n",
|
663 |
+
" quickchartButtonEl.classList.remove('colab-df-spinner');\n",
|
664 |
+
" quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
|
665 |
+
" }\n",
|
666 |
+
" (() => {\n",
|
667 |
+
" let quickchartButtonEl =\n",
|
668 |
+
" document.querySelector('#df-be760966-495f-47fc-be52-69a87fe8d7d2 button');\n",
|
669 |
+
" quickchartButtonEl.style.display =\n",
|
670 |
+
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
|
671 |
+
" })();\n",
|
672 |
+
" </script>\n",
|
673 |
+
"</div>\n",
|
674 |
+
"\n",
|
675 |
+
" </div>\n",
|
676 |
+
" </div>\n"
|
677 |
+
],
|
678 |
+
"application/vnd.google.colaboratory.intrinsic+json": {
|
679 |
+
"type": "dataframe",
|
680 |
+
"variable_name": "returns",
|
681 |
+
"summary": "{\n \"name\": \"returns\",\n \"rows\": 28,\n \"fields\": [\n {\n \"column\": \"Date\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": \"2024-04-01 00:00:00\",\n \"max\": \"2024-05-08 00:00:00\",\n \"num_unique_values\": 28,\n \"samples\": [\n \"2024-04-12 00:00:00\",\n \"2024-05-06 00:00:00\",\n \"2024-04-11 00:00:00\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"ARM\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.05166065364845085,\n \"min\": -0.16898585624248386,\n \"max\": 0.06789767178781414,\n \"num_unique_values\": 27,\n \"samples\": [\n -0.03660491781455699,\n -0.16898585624248386,\n -0.03174227877866398\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"META\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.02753598854622982,\n \"min\": -0.1056129586974417,\n \"max\": 0.03213812924957349,\n \"num_unique_values\": 27,\n \"samples\": [\n -0.021523013659411117,\n -0.04131124147675891,\n -0.022797388258059104\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"SPY\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.0084925113729149,\n \"min\": -0.015841247325688257,\n \"max\": 0.012395322615995186,\n \"num_unique_values\": 27,\n \"samples\": [\n -0.013803077020240084,\n -0.00872835011101658,\n -0.012528127278102708\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"TSLA\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.04872259693001104,\n \"min\": -0.05594859487563397,\n \"max\": 0.1530691710339953,\n \"num_unique_values\": 27,\n \"samples\": [\n -0.020332204625772565,\n -0.0192088959161848,\n -0.05594859487563397\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
|
682 |
+
}
|
683 |
+
},
|
684 |
+
"metadata": {},
|
685 |
+
"execution_count": 3
|
686 |
+
}
|
687 |
+
]
|
688 |
+
},
|
689 |
+
{
|
690 |
+
"cell_type": "code",
|
691 |
+
"source": [
|
692 |
+
"returns = returns.dropna()\n",
|
693 |
+
"\n",
|
694 |
+
"returns.head()"
|
695 |
+
],
|
696 |
+
"metadata": {
|
697 |
+
"colab": {
|
698 |
+
"base_uri": "https://localhost:8080/",
|
699 |
+
"height": 238
|
700 |
+
},
|
701 |
+
"id": "smRQAk1DQ5p0",
|
702 |
+
"outputId": "35971d47-108d-4a7e-d989-5287f8d1c274"
|
703 |
+
},
|
704 |
+
"execution_count": null,
|
705 |
+
"outputs": [
|
706 |
+
{
|
707 |
+
"output_type": "execute_result",
|
708 |
+
"data": {
|
709 |
+
"text/plain": [
|
710 |
+
"Ticker ARM META SPY TSLA\n",
|
711 |
+
"Date \n",
|
712 |
+
"2024-04-02 -0.020723 0.012252 -0.006358 -0.049024\n",
|
713 |
+
"2024-04-03 0.008288 0.018839 0.001099 0.010502\n",
|
714 |
+
"2024-04-04 -0.026335 0.008249 -0.012206 0.016213\n",
|
715 |
+
"2024-04-05 0.023031 0.032138 0.010447 -0.036292\n",
|
716 |
+
"2024-04-08 0.035491 -0.015341 0.000559 0.048999"
|
717 |
+
],
|
718 |
+
"text/html": [
|
719 |
+
"\n",
|
720 |
+
" <div id=\"df-6751159f-7e09-4cff-a0ed-a92bf7326819\" class=\"colab-df-container\">\n",
|
721 |
+
" <div>\n",
|
722 |
+
"<style scoped>\n",
|
723 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
724 |
+
" vertical-align: middle;\n",
|
725 |
+
" }\n",
|
726 |
+
"\n",
|
727 |
+
" .dataframe tbody tr th {\n",
|
728 |
+
" vertical-align: top;\n",
|
729 |
+
" }\n",
|
730 |
+
"\n",
|
731 |
+
" .dataframe thead th {\n",
|
732 |
+
" text-align: right;\n",
|
733 |
+
" }\n",
|
734 |
+
"</style>\n",
|
735 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
736 |
+
" <thead>\n",
|
737 |
+
" <tr style=\"text-align: right;\">\n",
|
738 |
+
" <th>Ticker</th>\n",
|
739 |
+
" <th>ARM</th>\n",
|
740 |
+
" <th>META</th>\n",
|
741 |
+
" <th>SPY</th>\n",
|
742 |
+
" <th>TSLA</th>\n",
|
743 |
+
" </tr>\n",
|
744 |
+
" <tr>\n",
|
745 |
+
" <th>Date</th>\n",
|
746 |
+
" <th></th>\n",
|
747 |
+
" <th></th>\n",
|
748 |
+
" <th></th>\n",
|
749 |
+
" <th></th>\n",
|
750 |
+
" </tr>\n",
|
751 |
+
" </thead>\n",
|
752 |
+
" <tbody>\n",
|
753 |
+
" <tr>\n",
|
754 |
+
" <th>2024-04-02</th>\n",
|
755 |
+
" <td>-0.020723</td>\n",
|
756 |
+
" <td>0.012252</td>\n",
|
757 |
+
" <td>-0.006358</td>\n",
|
758 |
+
" <td>-0.049024</td>\n",
|
759 |
+
" </tr>\n",
|
760 |
+
" <tr>\n",
|
761 |
+
" <th>2024-04-03</th>\n",
|
762 |
+
" <td>0.008288</td>\n",
|
763 |
+
" <td>0.018839</td>\n",
|
764 |
+
" <td>0.001099</td>\n",
|
765 |
+
" <td>0.010502</td>\n",
|
766 |
+
" </tr>\n",
|
767 |
+
" <tr>\n",
|
768 |
+
" <th>2024-04-04</th>\n",
|
769 |
+
" <td>-0.026335</td>\n",
|
770 |
+
" <td>0.008249</td>\n",
|
771 |
+
" <td>-0.012206</td>\n",
|
772 |
+
" <td>0.016213</td>\n",
|
773 |
+
" </tr>\n",
|
774 |
+
" <tr>\n",
|
775 |
+
" <th>2024-04-05</th>\n",
|
776 |
+
" <td>0.023031</td>\n",
|
777 |
+
" <td>0.032138</td>\n",
|
778 |
+
" <td>0.010447</td>\n",
|
779 |
+
" <td>-0.036292</td>\n",
|
780 |
+
" </tr>\n",
|
781 |
+
" <tr>\n",
|
782 |
+
" <th>2024-04-08</th>\n",
|
783 |
+
" <td>0.035491</td>\n",
|
784 |
+
" <td>-0.015341</td>\n",
|
785 |
+
" <td>0.000559</td>\n",
|
786 |
+
" <td>0.048999</td>\n",
|
787 |
+
" </tr>\n",
|
788 |
+
" </tbody>\n",
|
789 |
+
"</table>\n",
|
790 |
+
"</div>\n",
|
791 |
+
" <div class=\"colab-df-buttons\">\n",
|
792 |
+
"\n",
|
793 |
+
" <div class=\"colab-df-container\">\n",
|
794 |
+
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-6751159f-7e09-4cff-a0ed-a92bf7326819')\"\n",
|
795 |
+
" title=\"Convert this dataframe to an interactive table.\"\n",
|
796 |
+
" style=\"display:none;\">\n",
|
797 |
+
"\n",
|
798 |
+
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
|
799 |
+
" <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
|
800 |
+
" </svg>\n",
|
801 |
+
" </button>\n",
|
802 |
+
"\n",
|
803 |
+
" <style>\n",
|
804 |
+
" .colab-df-container {\n",
|
805 |
+
" display:flex;\n",
|
806 |
+
" gap: 12px;\n",
|
807 |
+
" }\n",
|
808 |
+
"\n",
|
809 |
+
" .colab-df-convert {\n",
|
810 |
+
" background-color: #E8F0FE;\n",
|
811 |
+
" border: none;\n",
|
812 |
+
" border-radius: 50%;\n",
|
813 |
+
" cursor: pointer;\n",
|
814 |
+
" display: none;\n",
|
815 |
+
" fill: #1967D2;\n",
|
816 |
+
" height: 32px;\n",
|
817 |
+
" padding: 0 0 0 0;\n",
|
818 |
+
" width: 32px;\n",
|
819 |
+
" }\n",
|
820 |
+
"\n",
|
821 |
+
" .colab-df-convert:hover {\n",
|
822 |
+
" background-color: #E2EBFA;\n",
|
823 |
+
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
|
824 |
+
" fill: #174EA6;\n",
|
825 |
+
" }\n",
|
826 |
+
"\n",
|
827 |
+
" .colab-df-buttons div {\n",
|
828 |
+
" margin-bottom: 4px;\n",
|
829 |
+
" }\n",
|
830 |
+
"\n",
|
831 |
+
" [theme=dark] .colab-df-convert {\n",
|
832 |
+
" background-color: #3B4455;\n",
|
833 |
+
" fill: #D2E3FC;\n",
|
834 |
+
" }\n",
|
835 |
+
"\n",
|
836 |
+
" [theme=dark] .colab-df-convert:hover {\n",
|
837 |
+
" background-color: #434B5C;\n",
|
838 |
+
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
|
839 |
+
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
|
840 |
+
" fill: #FFFFFF;\n",
|
841 |
+
" }\n",
|
842 |
+
" </style>\n",
|
843 |
+
"\n",
|
844 |
+
" <script>\n",
|
845 |
+
" const buttonEl =\n",
|
846 |
+
" document.querySelector('#df-6751159f-7e09-4cff-a0ed-a92bf7326819 button.colab-df-convert');\n",
|
847 |
+
" buttonEl.style.display =\n",
|
848 |
+
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
|
849 |
+
"\n",
|
850 |
+
" async function convertToInteractive(key) {\n",
|
851 |
+
" const element = document.querySelector('#df-6751159f-7e09-4cff-a0ed-a92bf7326819');\n",
|
852 |
+
" const dataTable =\n",
|
853 |
+
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
|
854 |
+
" [key], {});\n",
|
855 |
+
" if (!dataTable) return;\n",
|
856 |
+
"\n",
|
857 |
+
" const docLinkHtml = 'Like what you see? Visit the ' +\n",
|
858 |
+
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
|
859 |
+
" + ' to learn more about interactive tables.';\n",
|
860 |
+
" element.innerHTML = '';\n",
|
861 |
+
" dataTable['output_type'] = 'display_data';\n",
|
862 |
+
" await google.colab.output.renderOutput(dataTable, element);\n",
|
863 |
+
" const docLink = document.createElement('div');\n",
|
864 |
+
" docLink.innerHTML = docLinkHtml;\n",
|
865 |
+
" element.appendChild(docLink);\n",
|
866 |
+
" }\n",
|
867 |
+
" </script>\n",
|
868 |
+
" </div>\n",
|
869 |
+
"\n",
|
870 |
+
"\n",
|
871 |
+
"<div id=\"df-425dcda6-360d-41da-bd99-6796e140b2c5\">\n",
|
872 |
+
" <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-425dcda6-360d-41da-bd99-6796e140b2c5')\"\n",
|
873 |
+
" title=\"Suggest charts\"\n",
|
874 |
+
" style=\"display:none;\">\n",
|
875 |
+
"\n",
|
876 |
+
"<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
|
877 |
+
" width=\"24px\">\n",
|
878 |
+
" <g>\n",
|
879 |
+
" <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
|
880 |
+
" </g>\n",
|
881 |
+
"</svg>\n",
|
882 |
+
" </button>\n",
|
883 |
+
"\n",
|
884 |
+
"<style>\n",
|
885 |
+
" .colab-df-quickchart {\n",
|
886 |
+
" --bg-color: #E8F0FE;\n",
|
887 |
+
" --fill-color: #1967D2;\n",
|
888 |
+
" --hover-bg-color: #E2EBFA;\n",
|
889 |
+
" --hover-fill-color: #174EA6;\n",
|
890 |
+
" --disabled-fill-color: #AAA;\n",
|
891 |
+
" --disabled-bg-color: #DDD;\n",
|
892 |
+
" }\n",
|
893 |
+
"\n",
|
894 |
+
" [theme=dark] .colab-df-quickchart {\n",
|
895 |
+
" --bg-color: #3B4455;\n",
|
896 |
+
" --fill-color: #D2E3FC;\n",
|
897 |
+
" --hover-bg-color: #434B5C;\n",
|
898 |
+
" --hover-fill-color: #FFFFFF;\n",
|
899 |
+
" --disabled-bg-color: #3B4455;\n",
|
900 |
+
" --disabled-fill-color: #666;\n",
|
901 |
+
" }\n",
|
902 |
+
"\n",
|
903 |
+
" .colab-df-quickchart {\n",
|
904 |
+
" background-color: var(--bg-color);\n",
|
905 |
+
" border: none;\n",
|
906 |
+
" border-radius: 50%;\n",
|
907 |
+
" cursor: pointer;\n",
|
908 |
+
" display: none;\n",
|
909 |
+
" fill: var(--fill-color);\n",
|
910 |
+
" height: 32px;\n",
|
911 |
+
" padding: 0;\n",
|
912 |
+
" width: 32px;\n",
|
913 |
+
" }\n",
|
914 |
+
"\n",
|
915 |
+
" .colab-df-quickchart:hover {\n",
|
916 |
+
" background-color: var(--hover-bg-color);\n",
|
917 |
+
" box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
|
918 |
+
" fill: var(--button-hover-fill-color);\n",
|
919 |
+
" }\n",
|
920 |
+
"\n",
|
921 |
+
" .colab-df-quickchart-complete:disabled,\n",
|
922 |
+
" .colab-df-quickchart-complete:disabled:hover {\n",
|
923 |
+
" background-color: var(--disabled-bg-color);\n",
|
924 |
+
" fill: var(--disabled-fill-color);\n",
|
925 |
+
" box-shadow: none;\n",
|
926 |
+
" }\n",
|
927 |
+
"\n",
|
928 |
+
" .colab-df-spinner {\n",
|
929 |
+
" border: 2px solid var(--fill-color);\n",
|
930 |
+
" border-color: transparent;\n",
|
931 |
+
" border-bottom-color: var(--fill-color);\n",
|
932 |
+
" animation:\n",
|
933 |
+
" spin 1s steps(1) infinite;\n",
|
934 |
+
" }\n",
|
935 |
+
"\n",
|
936 |
+
" @keyframes spin {\n",
|
937 |
+
" 0% {\n",
|
938 |
+
" border-color: transparent;\n",
|
939 |
+
" border-bottom-color: var(--fill-color);\n",
|
940 |
+
" border-left-color: var(--fill-color);\n",
|
941 |
+
" }\n",
|
942 |
+
" 20% {\n",
|
943 |
+
" border-color: transparent;\n",
|
944 |
+
" border-left-color: var(--fill-color);\n",
|
945 |
+
" border-top-color: var(--fill-color);\n",
|
946 |
+
" }\n",
|
947 |
+
" 30% {\n",
|
948 |
+
" border-color: transparent;\n",
|
949 |
+
" border-left-color: var(--fill-color);\n",
|
950 |
+
" border-top-color: var(--fill-color);\n",
|
951 |
+
" border-right-color: var(--fill-color);\n",
|
952 |
+
" }\n",
|
953 |
+
" 40% {\n",
|
954 |
+
" border-color: transparent;\n",
|
955 |
+
" border-right-color: var(--fill-color);\n",
|
956 |
+
" border-top-color: var(--fill-color);\n",
|
957 |
+
" }\n",
|
958 |
+
" 60% {\n",
|
959 |
+
" border-color: transparent;\n",
|
960 |
+
" border-right-color: var(--fill-color);\n",
|
961 |
+
" }\n",
|
962 |
+
" 80% {\n",
|
963 |
+
" border-color: transparent;\n",
|
964 |
+
" border-right-color: var(--fill-color);\n",
|
965 |
+
" border-bottom-color: var(--fill-color);\n",
|
966 |
+
" }\n",
|
967 |
+
" 90% {\n",
|
968 |
+
" border-color: transparent;\n",
|
969 |
+
" border-bottom-color: var(--fill-color);\n",
|
970 |
+
" }\n",
|
971 |
+
" }\n",
|
972 |
+
"</style>\n",
|
973 |
+
"\n",
|
974 |
+
" <script>\n",
|
975 |
+
" async function quickchart(key) {\n",
|
976 |
+
" const quickchartButtonEl =\n",
|
977 |
+
" document.querySelector('#' + key + ' button');\n",
|
978 |
+
" quickchartButtonEl.disabled = true; // To prevent multiple clicks.\n",
|
979 |
+
" quickchartButtonEl.classList.add('colab-df-spinner');\n",
|
980 |
+
" try {\n",
|
981 |
+
" const charts = await google.colab.kernel.invokeFunction(\n",
|
982 |
+
" 'suggestCharts', [key], {});\n",
|
983 |
+
" } catch (error) {\n",
|
984 |
+
" console.error('Error during call to suggestCharts:', error);\n",
|
985 |
+
" }\n",
|
986 |
+
" quickchartButtonEl.classList.remove('colab-df-spinner');\n",
|
987 |
+
" quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
|
988 |
+
" }\n",
|
989 |
+
" (() => {\n",
|
990 |
+
" let quickchartButtonEl =\n",
|
991 |
+
" document.querySelector('#df-425dcda6-360d-41da-bd99-6796e140b2c5 button');\n",
|
992 |
+
" quickchartButtonEl.style.display =\n",
|
993 |
+
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
|
994 |
+
" })();\n",
|
995 |
+
" </script>\n",
|
996 |
+
"</div>\n",
|
997 |
+
"\n",
|
998 |
+
" </div>\n",
|
999 |
+
" </div>\n"
|
1000 |
+
],
|
1001 |
+
"application/vnd.google.colaboratory.intrinsic+json": {
|
1002 |
+
"type": "dataframe",
|
1003 |
+
"variable_name": "returns",
|
1004 |
+
"summary": "{\n \"name\": \"returns\",\n \"rows\": 27,\n \"fields\": [\n {\n \"column\": \"Date\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": \"2024-04-02 00:00:00\",\n \"max\": \"2024-05-08 00:00:00\",\n \"num_unique_values\": 27,\n \"samples\": [\n \"2024-04-12 00:00:00\",\n \"2024-04-19 00:00:00\",\n \"2024-04-15 00:00:00\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"ARM\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.05166065364845084,\n \"min\": -0.16898585624248386,\n \"max\": 0.06789767178781414,\n \"num_unique_values\": 27,\n \"samples\": [\n -0.03660491781455699,\n -0.16898585624248386,\n -0.03174227877866398\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"META\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.02753598854622982,\n \"min\": -0.1056129586974417,\n \"max\": 0.03213812924957349,\n \"num_unique_values\": 27,\n \"samples\": [\n -0.021523013659411117,\n -0.04131124147675891,\n -0.022797388258059104\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"SPY\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.0084925113729149,\n \"min\": -0.015841247325688257,\n \"max\": 0.012395322615995186,\n \"num_unique_values\": 27,\n \"samples\": [\n -0.013803077020240084,\n -0.00872835011101658,\n -0.012528127278102708\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"TSLA\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.04872259693001104,\n \"min\": -0.05594859487563397,\n \"max\": 0.1530691710339953,\n \"num_unique_values\": 27,\n \"samples\": [\n -0.020332204625772565,\n -0.0192088959161848,\n -0.05594859487563397\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
|
1005 |
+
}
|
1006 |
+
},
|
1007 |
+
"metadata": {},
|
1008 |
+
"execution_count": 4
|
1009 |
+
}
|
1010 |
+
]
|
1011 |
+
},
|
1012 |
+
{
|
1013 |
+
"cell_type": "code",
|
1014 |
+
"source": [
|
1015 |
+
"average_daily_returns = returns.mean()\n",
|
1016 |
+
"print(average_daily_returns)"
|
1017 |
+
],
|
1018 |
+
"metadata": {
|
1019 |
+
"colab": {
|
1020 |
+
"base_uri": "https://localhost:8080/"
|
1021 |
+
},
|
1022 |
+
"id": "0LSi1EluSjRA",
|
1023 |
+
"outputId": "a851a7e7-3e9b-4d2b-d06d-8f3ea46def2d"
|
1024 |
+
},
|
1025 |
+
"execution_count": null,
|
1026 |
+
"outputs": [
|
1027 |
+
{
|
1028 |
+
"output_type": "stream",
|
1029 |
+
"name": "stdout",
|
1030 |
+
"text": [
|
1031 |
+
"Ticker\n",
|
1032 |
+
"ARM -0.005259\n",
|
1033 |
+
"META -0.001060\n",
|
1034 |
+
"SPY -0.000319\n",
|
1035 |
+
"TSLA 0.000984\n",
|
1036 |
+
"dtype: float64\n"
|
1037 |
+
]
|
1038 |
+
}
|
1039 |
+
]
|
1040 |
+
},
|
1041 |
+
{
|
1042 |
+
"cell_type": "code",
|
1043 |
+
"source": [
|
1044 |
+
"standard_deviation_daily_returns = returns.std()\n",
|
1045 |
+
"\n",
|
1046 |
+
"print(standard_deviation_daily_returns)"
|
1047 |
+
],
|
1048 |
+
"metadata": {
|
1049 |
+
"colab": {
|
1050 |
+
"base_uri": "https://localhost:8080/"
|
1051 |
+
},
|
1052 |
+
"id": "BsjEGO46SwRP",
|
1053 |
+
"outputId": "d64644d9-7aee-4fd5-9b64-dfbebb695d10"
|
1054 |
+
},
|
1055 |
+
"execution_count": null,
|
1056 |
+
"outputs": [
|
1057 |
+
{
|
1058 |
+
"output_type": "stream",
|
1059 |
+
"name": "stdout",
|
1060 |
+
"text": [
|
1061 |
+
"Ticker\n",
|
1062 |
+
"ARM 0.051661\n",
|
1063 |
+
"META 0.027536\n",
|
1064 |
+
"SPY 0.008493\n",
|
1065 |
+
"TSLA 0.048723\n",
|
1066 |
+
"dtype: float64\n"
|
1067 |
+
]
|
1068 |
+
}
|
1069 |
+
]
|
1070 |
+
},
|
1071 |
+
{
|
1072 |
+
"cell_type": "code",
|
1073 |
+
"source": [
|
1074 |
+
"import numpy\n",
|
1075 |
+
"\n",
|
1076 |
+
"weights = numpy.array([0.25, 0.25, 0.25, 0.25])"
|
1077 |
+
],
|
1078 |
+
"metadata": {
|
1079 |
+
"id": "aHVZp77fS_5T"
|
1080 |
+
},
|
1081 |
+
"execution_count": null,
|
1082 |
+
"outputs": []
|
1083 |
+
},
|
1084 |
+
{
|
1085 |
+
"cell_type": "code",
|
1086 |
+
"source": [
|
1087 |
+
"covariance_matrix = (returns.cov())*250\n",
|
1088 |
+
"print(covariance_matrix)"
|
1089 |
+
],
|
1090 |
+
"metadata": {
|
1091 |
+
"colab": {
|
1092 |
+
"base_uri": "https://localhost:8080/"
|
1093 |
+
},
|
1094 |
+
"id": "wOj-twh_Tnf5",
|
1095 |
+
"outputId": "837404eb-1556-4b86-c405-565169571db8"
|
1096 |
+
},
|
1097 |
+
"execution_count": null,
|
1098 |
+
"outputs": [
|
1099 |
+
{
|
1100 |
+
"output_type": "stream",
|
1101 |
+
"name": "stdout",
|
1102 |
+
"text": [
|
1103 |
+
"Ticker ARM META SPY TSLA\n",
|
1104 |
+
"Ticker \n",
|
1105 |
+
"ARM 0.667206 0.131290 0.072585 0.167230\n",
|
1106 |
+
"META 0.131290 0.189558 0.024381 -0.086532\n",
|
1107 |
+
"SPY 0.072585 0.024381 0.018031 0.027256\n",
|
1108 |
+
"TSLA 0.167230 -0.086532 0.027256 0.593473\n"
|
1109 |
+
]
|
1110 |
+
}
|
1111 |
+
]
|
1112 |
+
},
|
1113 |
+
{
|
1114 |
+
"cell_type": "code",
|
1115 |
+
"source": [
|
1116 |
+
"expected_portfolio_performance = numpy.sum(average_daily_returns * weights)\n",
|
1117 |
+
"\n",
|
1118 |
+
"print(expected_portfolio_performance)"
|
1119 |
+
],
|
1120 |
+
"metadata": {
|
1121 |
+
"colab": {
|
1122 |
+
"base_uri": "https://localhost:8080/"
|
1123 |
+
},
|
1124 |
+
"id": "3Y7MpadBT1na",
|
1125 |
+
"outputId": "af1e83be-0f2e-48c6-b43f-635ae9e21d80"
|
1126 |
+
},
|
1127 |
+
"execution_count": null,
|
1128 |
+
"outputs": [
|
1129 |
+
{
|
1130 |
+
"output_type": "stream",
|
1131 |
+
"name": "stdout",
|
1132 |
+
"text": [
|
1133 |
+
"-0.001413485369940147\n"
|
1134 |
+
]
|
1135 |
+
}
|
1136 |
+
]
|
1137 |
+
},
|
1138 |
+
{
|
1139 |
+
"cell_type": "code",
|
1140 |
+
"source": [
|
1141 |
+
"returns['Portfolio Returns'] = returns.dot(weights)"
|
1142 |
+
],
|
1143 |
+
"metadata": {
|
1144 |
+
"id": "U_tB0NrYUCCt"
|
1145 |
+
},
|
1146 |
+
"execution_count": null,
|
1147 |
+
"outputs": []
|
1148 |
+
},
|
1149 |
+
{
|
1150 |
+
"cell_type": "code",
|
1151 |
+
"source": [
|
1152 |
+
"returns.head()"
|
1153 |
+
],
|
1154 |
+
"metadata": {
|
1155 |
+
"colab": {
|
1156 |
+
"base_uri": "https://localhost:8080/",
|
1157 |
+
"height": 238
|
1158 |
+
},
|
1159 |
+
"id": "92BQOPu4ULNT",
|
1160 |
+
"outputId": "a95b5cd1-071d-4fc3-e07b-b13412450a53"
|
1161 |
+
},
|
1162 |
+
"execution_count": null,
|
1163 |
+
"outputs": [
|
1164 |
+
{
|
1165 |
+
"output_type": "execute_result",
|
1166 |
+
"data": {
|
1167 |
+
"text/plain": [
|
1168 |
+
"Ticker ARM META SPY TSLA Portfolio Returns\n",
|
1169 |
+
"Date \n",
|
1170 |
+
"2024-04-02 -0.020723 0.012252 -0.006358 -0.049024 -0.015963\n",
|
1171 |
+
"2024-04-03 0.008288 0.018839 0.001099 0.010502 0.009682\n",
|
1172 |
+
"2024-04-04 -0.026335 0.008249 -0.012206 0.016213 -0.003520\n",
|
1173 |
+
"2024-04-05 0.023031 0.032138 0.010447 -0.036292 0.007331\n",
|
1174 |
+
"2024-04-08 0.035491 -0.015341 0.000559 0.048999 0.017427"
|
1175 |
+
],
|
1176 |
+
"text/html": [
|
1177 |
+
"\n",
|
1178 |
+
" <div id=\"df-2bd3b321-a16d-4a54-9583-dbb392386415\" class=\"colab-df-container\">\n",
|
1179 |
+
" <div>\n",
|
1180 |
+
"<style scoped>\n",
|
1181 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
1182 |
+
" vertical-align: middle;\n",
|
1183 |
+
" }\n",
|
1184 |
+
"\n",
|
1185 |
+
" .dataframe tbody tr th {\n",
|
1186 |
+
" vertical-align: top;\n",
|
1187 |
+
" }\n",
|
1188 |
+
"\n",
|
1189 |
+
" .dataframe thead th {\n",
|
1190 |
+
" text-align: right;\n",
|
1191 |
+
" }\n",
|
1192 |
+
"</style>\n",
|
1193 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
1194 |
+
" <thead>\n",
|
1195 |
+
" <tr style=\"text-align: right;\">\n",
|
1196 |
+
" <th>Ticker</th>\n",
|
1197 |
+
" <th>ARM</th>\n",
|
1198 |
+
" <th>META</th>\n",
|
1199 |
+
" <th>SPY</th>\n",
|
1200 |
+
" <th>TSLA</th>\n",
|
1201 |
+
" <th>Portfolio Returns</th>\n",
|
1202 |
+
" </tr>\n",
|
1203 |
+
" <tr>\n",
|
1204 |
+
" <th>Date</th>\n",
|
1205 |
+
" <th></th>\n",
|
1206 |
+
" <th></th>\n",
|
1207 |
+
" <th></th>\n",
|
1208 |
+
" <th></th>\n",
|
1209 |
+
" <th></th>\n",
|
1210 |
+
" </tr>\n",
|
1211 |
+
" </thead>\n",
|
1212 |
+
" <tbody>\n",
|
1213 |
+
" <tr>\n",
|
1214 |
+
" <th>2024-04-02</th>\n",
|
1215 |
+
" <td>-0.020723</td>\n",
|
1216 |
+
" <td>0.012252</td>\n",
|
1217 |
+
" <td>-0.006358</td>\n",
|
1218 |
+
" <td>-0.049024</td>\n",
|
1219 |
+
" <td>-0.015963</td>\n",
|
1220 |
+
" </tr>\n",
|
1221 |
+
" <tr>\n",
|
1222 |
+
" <th>2024-04-03</th>\n",
|
1223 |
+
" <td>0.008288</td>\n",
|
1224 |
+
" <td>0.018839</td>\n",
|
1225 |
+
" <td>0.001099</td>\n",
|
1226 |
+
" <td>0.010502</td>\n",
|
1227 |
+
" <td>0.009682</td>\n",
|
1228 |
+
" </tr>\n",
|
1229 |
+
" <tr>\n",
|
1230 |
+
" <th>2024-04-04</th>\n",
|
1231 |
+
" <td>-0.026335</td>\n",
|
1232 |
+
" <td>0.008249</td>\n",
|
1233 |
+
" <td>-0.012206</td>\n",
|
1234 |
+
" <td>0.016213</td>\n",
|
1235 |
+
" <td>-0.003520</td>\n",
|
1236 |
+
" </tr>\n",
|
1237 |
+
" <tr>\n",
|
1238 |
+
" <th>2024-04-05</th>\n",
|
1239 |
+
" <td>0.023031</td>\n",
|
1240 |
+
" <td>0.032138</td>\n",
|
1241 |
+
" <td>0.010447</td>\n",
|
1242 |
+
" <td>-0.036292</td>\n",
|
1243 |
+
" <td>0.007331</td>\n",
|
1244 |
+
" </tr>\n",
|
1245 |
+
" <tr>\n",
|
1246 |
+
" <th>2024-04-08</th>\n",
|
1247 |
+
" <td>0.035491</td>\n",
|
1248 |
+
" <td>-0.015341</td>\n",
|
1249 |
+
" <td>0.000559</td>\n",
|
1250 |
+
" <td>0.048999</td>\n",
|
1251 |
+
" <td>0.017427</td>\n",
|
1252 |
+
" </tr>\n",
|
1253 |
+
" </tbody>\n",
|
1254 |
+
"</table>\n",
|
1255 |
+
"</div>\n",
|
1256 |
+
" <div class=\"colab-df-buttons\">\n",
|
1257 |
+
"\n",
|
1258 |
+
" <div class=\"colab-df-container\">\n",
|
1259 |
+
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-2bd3b321-a16d-4a54-9583-dbb392386415')\"\n",
|
1260 |
+
" title=\"Convert this dataframe to an interactive table.\"\n",
|
1261 |
+
" style=\"display:none;\">\n",
|
1262 |
+
"\n",
|
1263 |
+
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
|
1264 |
+
" <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
|
1265 |
+
" </svg>\n",
|
1266 |
+
" </button>\n",
|
1267 |
+
"\n",
|
1268 |
+
" <style>\n",
|
1269 |
+
" .colab-df-container {\n",
|
1270 |
+
" display:flex;\n",
|
1271 |
+
" gap: 12px;\n",
|
1272 |
+
" }\n",
|
1273 |
+
"\n",
|
1274 |
+
" .colab-df-convert {\n",
|
1275 |
+
" background-color: #E8F0FE;\n",
|
1276 |
+
" border: none;\n",
|
1277 |
+
" border-radius: 50%;\n",
|
1278 |
+
" cursor: pointer;\n",
|
1279 |
+
" display: none;\n",
|
1280 |
+
" fill: #1967D2;\n",
|
1281 |
+
" height: 32px;\n",
|
1282 |
+
" padding: 0 0 0 0;\n",
|
1283 |
+
" width: 32px;\n",
|
1284 |
+
" }\n",
|
1285 |
+
"\n",
|
1286 |
+
" .colab-df-convert:hover {\n",
|
1287 |
+
" background-color: #E2EBFA;\n",
|
1288 |
+
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
|
1289 |
+
" fill: #174EA6;\n",
|
1290 |
+
" }\n",
|
1291 |
+
"\n",
|
1292 |
+
" .colab-df-buttons div {\n",
|
1293 |
+
" margin-bottom: 4px;\n",
|
1294 |
+
" }\n",
|
1295 |
+
"\n",
|
1296 |
+
" [theme=dark] .colab-df-convert {\n",
|
1297 |
+
" background-color: #3B4455;\n",
|
1298 |
+
" fill: #D2E3FC;\n",
|
1299 |
+
" }\n",
|
1300 |
+
"\n",
|
1301 |
+
" [theme=dark] .colab-df-convert:hover {\n",
|
1302 |
+
" background-color: #434B5C;\n",
|
1303 |
+
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
|
1304 |
+
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
|
1305 |
+
" fill: #FFFFFF;\n",
|
1306 |
+
" }\n",
|
1307 |
+
" </style>\n",
|
1308 |
+
"\n",
|
1309 |
+
" <script>\n",
|
1310 |
+
" const buttonEl =\n",
|
1311 |
+
" document.querySelector('#df-2bd3b321-a16d-4a54-9583-dbb392386415 button.colab-df-convert');\n",
|
1312 |
+
" buttonEl.style.display =\n",
|
1313 |
+
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
|
1314 |
+
"\n",
|
1315 |
+
" async function convertToInteractive(key) {\n",
|
1316 |
+
" const element = document.querySelector('#df-2bd3b321-a16d-4a54-9583-dbb392386415');\n",
|
1317 |
+
" const dataTable =\n",
|
1318 |
+
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
|
1319 |
+
" [key], {});\n",
|
1320 |
+
" if (!dataTable) return;\n",
|
1321 |
+
"\n",
|
1322 |
+
" const docLinkHtml = 'Like what you see? Visit the ' +\n",
|
1323 |
+
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
|
1324 |
+
" + ' to learn more about interactive tables.';\n",
|
1325 |
+
" element.innerHTML = '';\n",
|
1326 |
+
" dataTable['output_type'] = 'display_data';\n",
|
1327 |
+
" await google.colab.output.renderOutput(dataTable, element);\n",
|
1328 |
+
" const docLink = document.createElement('div');\n",
|
1329 |
+
" docLink.innerHTML = docLinkHtml;\n",
|
1330 |
+
" element.appendChild(docLink);\n",
|
1331 |
+
" }\n",
|
1332 |
+
" </script>\n",
|
1333 |
+
" </div>\n",
|
1334 |
+
"\n",
|
1335 |
+
"\n",
|
1336 |
+
"<div id=\"df-3de97fae-86d5-47ef-8a8e-20f27488e49b\">\n",
|
1337 |
+
" <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-3de97fae-86d5-47ef-8a8e-20f27488e49b')\"\n",
|
1338 |
+
" title=\"Suggest charts\"\n",
|
1339 |
+
" style=\"display:none;\">\n",
|
1340 |
+
"\n",
|
1341 |
+
"<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
|
1342 |
+
" width=\"24px\">\n",
|
1343 |
+
" <g>\n",
|
1344 |
+
" <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
|
1345 |
+
" </g>\n",
|
1346 |
+
"</svg>\n",
|
1347 |
+
" </button>\n",
|
1348 |
+
"\n",
|
1349 |
+
"<style>\n",
|
1350 |
+
" .colab-df-quickchart {\n",
|
1351 |
+
" --bg-color: #E8F0FE;\n",
|
1352 |
+
" --fill-color: #1967D2;\n",
|
1353 |
+
" --hover-bg-color: #E2EBFA;\n",
|
1354 |
+
" --hover-fill-color: #174EA6;\n",
|
1355 |
+
" --disabled-fill-color: #AAA;\n",
|
1356 |
+
" --disabled-bg-color: #DDD;\n",
|
1357 |
+
" }\n",
|
1358 |
+
"\n",
|
1359 |
+
" [theme=dark] .colab-df-quickchart {\n",
|
1360 |
+
" --bg-color: #3B4455;\n",
|
1361 |
+
" --fill-color: #D2E3FC;\n",
|
1362 |
+
" --hover-bg-color: #434B5C;\n",
|
1363 |
+
" --hover-fill-color: #FFFFFF;\n",
|
1364 |
+
" --disabled-bg-color: #3B4455;\n",
|
1365 |
+
" --disabled-fill-color: #666;\n",
|
1366 |
+
" }\n",
|
1367 |
+
"\n",
|
1368 |
+
" .colab-df-quickchart {\n",
|
1369 |
+
" background-color: var(--bg-color);\n",
|
1370 |
+
" border: none;\n",
|
1371 |
+
" border-radius: 50%;\n",
|
1372 |
+
" cursor: pointer;\n",
|
1373 |
+
" display: none;\n",
|
1374 |
+
" fill: var(--fill-color);\n",
|
1375 |
+
" height: 32px;\n",
|
1376 |
+
" padding: 0;\n",
|
1377 |
+
" width: 32px;\n",
|
1378 |
+
" }\n",
|
1379 |
+
"\n",
|
1380 |
+
" .colab-df-quickchart:hover {\n",
|
1381 |
+
" background-color: var(--hover-bg-color);\n",
|
1382 |
+
" box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
|
1383 |
+
" fill: var(--button-hover-fill-color);\n",
|
1384 |
+
" }\n",
|
1385 |
+
"\n",
|
1386 |
+
" .colab-df-quickchart-complete:disabled,\n",
|
1387 |
+
" .colab-df-quickchart-complete:disabled:hover {\n",
|
1388 |
+
" background-color: var(--disabled-bg-color);\n",
|
1389 |
+
" fill: var(--disabled-fill-color);\n",
|
1390 |
+
" box-shadow: none;\n",
|
1391 |
+
" }\n",
|
1392 |
+
"\n",
|
1393 |
+
" .colab-df-spinner {\n",
|
1394 |
+
" border: 2px solid var(--fill-color);\n",
|
1395 |
+
" border-color: transparent;\n",
|
1396 |
+
" border-bottom-color: var(--fill-color);\n",
|
1397 |
+
" animation:\n",
|
1398 |
+
" spin 1s steps(1) infinite;\n",
|
1399 |
+
" }\n",
|
1400 |
+
"\n",
|
1401 |
+
" @keyframes spin {\n",
|
1402 |
+
" 0% {\n",
|
1403 |
+
" border-color: transparent;\n",
|
1404 |
+
" border-bottom-color: var(--fill-color);\n",
|
1405 |
+
" border-left-color: var(--fill-color);\n",
|
1406 |
+
" }\n",
|
1407 |
+
" 20% {\n",
|
1408 |
+
" border-color: transparent;\n",
|
1409 |
+
" border-left-color: var(--fill-color);\n",
|
1410 |
+
" border-top-color: var(--fill-color);\n",
|
1411 |
+
" }\n",
|
1412 |
+
" 30% {\n",
|
1413 |
+
" border-color: transparent;\n",
|
1414 |
+
" border-left-color: var(--fill-color);\n",
|
1415 |
+
" border-top-color: var(--fill-color);\n",
|
1416 |
+
" border-right-color: var(--fill-color);\n",
|
1417 |
+
" }\n",
|
1418 |
+
" 40% {\n",
|
1419 |
+
" border-color: transparent;\n",
|
1420 |
+
" border-right-color: var(--fill-color);\n",
|
1421 |
+
" border-top-color: var(--fill-color);\n",
|
1422 |
+
" }\n",
|
1423 |
+
" 60% {\n",
|
1424 |
+
" border-color: transparent;\n",
|
1425 |
+
" border-right-color: var(--fill-color);\n",
|
1426 |
+
" }\n",
|
1427 |
+
" 80% {\n",
|
1428 |
+
" border-color: transparent;\n",
|
1429 |
+
" border-right-color: var(--fill-color);\n",
|
1430 |
+
" border-bottom-color: var(--fill-color);\n",
|
1431 |
+
" }\n",
|
1432 |
+
" 90% {\n",
|
1433 |
+
" border-color: transparent;\n",
|
1434 |
+
" border-bottom-color: var(--fill-color);\n",
|
1435 |
+
" }\n",
|
1436 |
+
" }\n",
|
1437 |
+
"</style>\n",
|
1438 |
+
"\n",
|
1439 |
+
" <script>\n",
|
1440 |
+
" async function quickchart(key) {\n",
|
1441 |
+
" const quickchartButtonEl =\n",
|
1442 |
+
" document.querySelector('#' + key + ' button');\n",
|
1443 |
+
" quickchartButtonEl.disabled = true; // To prevent multiple clicks.\n",
|
1444 |
+
" quickchartButtonEl.classList.add('colab-df-spinner');\n",
|
1445 |
+
" try {\n",
|
1446 |
+
" const charts = await google.colab.kernel.invokeFunction(\n",
|
1447 |
+
" 'suggestCharts', [key], {});\n",
|
1448 |
+
" } catch (error) {\n",
|
1449 |
+
" console.error('Error during call to suggestCharts:', error);\n",
|
1450 |
+
" }\n",
|
1451 |
+
" quickchartButtonEl.classList.remove('colab-df-spinner');\n",
|
1452 |
+
" quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
|
1453 |
+
" }\n",
|
1454 |
+
" (() => {\n",
|
1455 |
+
" let quickchartButtonEl =\n",
|
1456 |
+
" document.querySelector('#df-3de97fae-86d5-47ef-8a8e-20f27488e49b button');\n",
|
1457 |
+
" quickchartButtonEl.style.display =\n",
|
1458 |
+
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
|
1459 |
+
" })();\n",
|
1460 |
+
" </script>\n",
|
1461 |
+
"</div>\n",
|
1462 |
+
"\n",
|
1463 |
+
" </div>\n",
|
1464 |
+
" </div>\n"
|
1465 |
+
],
|
1466 |
+
"application/vnd.google.colaboratory.intrinsic+json": {
|
1467 |
+
"type": "dataframe",
|
1468 |
+
"variable_name": "returns",
|
1469 |
+
"summary": "{\n \"name\": \"returns\",\n \"rows\": 27,\n \"fields\": [\n {\n \"column\": \"Date\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": \"2024-04-02 00:00:00\",\n \"max\": \"2024-05-08 00:00:00\",\n \"num_unique_values\": 27,\n \"samples\": [\n \"2024-04-12 00:00:00\",\n \"2024-04-19 00:00:00\",\n \"2024-04-15 00:00:00\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"ARM\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.05166065364845084,\n \"min\": -0.16898585624248386,\n \"max\": 0.06789767178781414,\n \"num_unique_values\": 27,\n \"samples\": [\n -0.03660491781455699,\n -0.16898585624248386,\n -0.03174227877866398\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"META\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.02753598854622982,\n \"min\": -0.1056129586974417,\n \"max\": 0.03213812924957349,\n \"num_unique_values\": 27,\n \"samples\": [\n -0.021523013659411117,\n -0.04131124147675891,\n -0.022797388258059104\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"SPY\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.0084925113729149,\n \"min\": -0.015841247325688257,\n \"max\": 0.012395322615995186,\n \"num_unique_values\": 27,\n \"samples\": [\n -0.013803077020240084,\n -0.00872835011101658,\n -0.012528127278102708\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"TSLA\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.04872259693001104,\n \"min\": -0.05594859487563397,\n \"max\": 0.1530691710339953,\n \"num_unique_values\": 27,\n \"samples\": [\n -0.020332204625772565,\n -0.0192088959161848,\n -0.05594859487563397\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Portfolio Returns\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.02313377722945321,\n \"min\": -0.059558585936611036,\n \"max\": 0.038719721860631745,\n \"num_unique_values\": 27,\n \"samples\": [\n -0.02306580327999519,\n -0.059558585936611036,\n -0.03075409729761494\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
|
1470 |
+
}
|
1471 |
+
},
|
1472 |
+
"metadata": {},
|
1473 |
+
"execution_count": 11
|
1474 |
+
}
|
1475 |
+
]
|
1476 |
+
},
|
1477 |
+
{
|
1478 |
+
"cell_type": "code",
|
1479 |
+
"source": [
|
1480 |
+
"daily_cumulative_returns= (1+returns).cumprod()\n",
|
1481 |
+
"print(daily_cumulative_returns)"
|
1482 |
+
],
|
1483 |
+
"metadata": {
|
1484 |
+
"id": "o8z0mBEUUa77",
|
1485 |
+
"colab": {
|
1486 |
+
"base_uri": "https://localhost:8080/"
|
1487 |
+
},
|
1488 |
+
"outputId": "65e4933e-ea16-4109-c5c0-d1f740134aca"
|
1489 |
+
},
|
1490 |
+
"execution_count": null,
|
1491 |
+
"outputs": [
|
1492 |
+
{
|
1493 |
+
"output_type": "stream",
|
1494 |
+
"name": "stdout",
|
1495 |
+
"text": [
|
1496 |
+
"Ticker ARM META SPY TSLA Portfolio Returns\n",
|
1497 |
+
"Date \n",
|
1498 |
+
"2024-04-02 0.979277 1.012252 0.993642 0.950976 0.984037\n",
|
1499 |
+
"2024-04-03 0.987393 1.031322 0.994733 0.960963 0.993564\n",
|
1500 |
+
"2024-04-04 0.961390 1.039829 0.982592 0.976544 0.990067\n",
|
1501 |
+
"2024-04-05 0.983532 1.073247 0.992857 0.941103 0.997325\n",
|
1502 |
+
"2024-04-08 1.018438 1.056782 0.993412 0.987216 1.014706\n",
|
1503 |
+
"2024-04-09 0.999212 1.052000 0.994561 1.009474 1.014781\n",
|
1504 |
+
"2024-04-10 0.986368 1.057963 0.984602 0.980253 1.003075\n",
|
1505 |
+
"2024-04-11 1.033252 1.064740 0.992033 0.996462 1.022639\n",
|
1506 |
+
"2024-04-12 0.995430 1.041824 0.978340 0.976201 0.999051\n",
|
1507 |
+
"2024-04-15 0.963833 1.018073 0.966083 0.921584 0.968326\n",
|
1508 |
+
"2024-04-16 0.963045 1.017116 0.964321 0.896644 0.960908\n",
|
1509 |
+
"2024-04-17 0.847530 1.005739 0.958614 0.887170 0.925447\n",
|
1510 |
+
"2024-04-18 0.826728 1.021268 0.956642 0.855667 0.914649\n",
|
1511 |
+
"2024-04-19 0.687022 0.979078 0.948292 0.839231 0.860173\n",
|
1512 |
+
"2024-04-22 0.733670 0.980421 0.957025 0.810695 0.869738\n",
|
1513 |
+
"2024-04-23 0.756757 1.009667 0.968381 0.825705 0.889672\n",
|
1514 |
+
"2024-04-24 0.787014 1.004376 0.967922 0.925294 0.924120\n",
|
1515 |
+
"2024-04-25 0.771649 0.898301 0.964245 0.971236 0.905803\n",
|
1516 |
+
"2024-04-26 0.803325 0.902188 0.973380 0.960450 0.915709\n",
|
1517 |
+
"2024-04-29 0.813490 0.880472 0.976827 1.107465 0.948948\n",
|
1518 |
+
"2024-04-30 0.797494 0.875486 0.961353 1.045999 0.926015\n",
|
1519 |
+
"2024-05-01 0.750847 0.893843 0.958231 1.027223 0.912420\n",
|
1520 |
+
"2024-05-02 0.772201 0.898911 0.967194 1.027337 0.922360\n",
|
1521 |
+
"2024-05-03 0.801355 0.919833 0.979183 1.034071 0.940802\n",
|
1522 |
+
"2024-05-06 0.842960 0.947756 0.989295 1.054446 0.967216\n",
|
1523 |
+
"2024-05-07 0.849421 0.952966 0.990386 1.014781 0.961570\n",
|
1524 |
+
"2024-05-08 0.835789 0.961840 0.990482 0.997146 0.955796\n"
|
1525 |
+
]
|
1526 |
+
}
|
1527 |
+
]
|
1528 |
+
},
|
1529 |
+
{
|
1530 |
+
"cell_type": "code",
|
1531 |
+
"source": [
|
1532 |
+
"daily_cumulative_returns.tail()"
|
1533 |
+
],
|
1534 |
+
"metadata": {
|
1535 |
+
"colab": {
|
1536 |
+
"base_uri": "https://localhost:8080/",
|
1537 |
+
"height": 238
|
1538 |
+
},
|
1539 |
+
"id": "Roh4BE6fUmGt",
|
1540 |
+
"outputId": "66b911b4-5268-42ad-9f45-887f377dfe77"
|
1541 |
+
},
|
1542 |
+
"execution_count": null,
|
1543 |
+
"outputs": [
|
1544 |
+
{
|
1545 |
+
"output_type": "execute_result",
|
1546 |
+
"data": {
|
1547 |
+
"text/plain": [
|
1548 |
+
"Ticker ARM META SPY TSLA Portfolio Returns\n",
|
1549 |
+
"Date \n",
|
1550 |
+
"2024-05-02 0.772201 0.898911 0.967194 1.027337 0.922360\n",
|
1551 |
+
"2024-05-03 0.801355 0.919833 0.979183 1.034071 0.940802\n",
|
1552 |
+
"2024-05-06 0.842960 0.947756 0.989295 1.054446 0.967216\n",
|
1553 |
+
"2024-05-07 0.849421 0.952966 0.990386 1.014781 0.961570\n",
|
1554 |
+
"2024-05-08 0.835789 0.961840 0.990482 0.997146 0.955796"
|
1555 |
+
],
|
1556 |
+
"text/html": [
|
1557 |
+
"\n",
|
1558 |
+
" <div id=\"df-e16cfa33-3b61-42a3-a82b-ae1ecb73362c\" class=\"colab-df-container\">\n",
|
1559 |
+
" <div>\n",
|
1560 |
+
"<style scoped>\n",
|
1561 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
1562 |
+
" vertical-align: middle;\n",
|
1563 |
+
" }\n",
|
1564 |
+
"\n",
|
1565 |
+
" .dataframe tbody tr th {\n",
|
1566 |
+
" vertical-align: top;\n",
|
1567 |
+
" }\n",
|
1568 |
+
"\n",
|
1569 |
+
" .dataframe thead th {\n",
|
1570 |
+
" text-align: right;\n",
|
1571 |
+
" }\n",
|
1572 |
+
"</style>\n",
|
1573 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
1574 |
+
" <thead>\n",
|
1575 |
+
" <tr style=\"text-align: right;\">\n",
|
1576 |
+
" <th>Ticker</th>\n",
|
1577 |
+
" <th>ARM</th>\n",
|
1578 |
+
" <th>META</th>\n",
|
1579 |
+
" <th>SPY</th>\n",
|
1580 |
+
" <th>TSLA</th>\n",
|
1581 |
+
" <th>Portfolio Returns</th>\n",
|
1582 |
+
" </tr>\n",
|
1583 |
+
" <tr>\n",
|
1584 |
+
" <th>Date</th>\n",
|
1585 |
+
" <th></th>\n",
|
1586 |
+
" <th></th>\n",
|
1587 |
+
" <th></th>\n",
|
1588 |
+
" <th></th>\n",
|
1589 |
+
" <th></th>\n",
|
1590 |
+
" </tr>\n",
|
1591 |
+
" </thead>\n",
|
1592 |
+
" <tbody>\n",
|
1593 |
+
" <tr>\n",
|
1594 |
+
" <th>2024-05-02</th>\n",
|
1595 |
+
" <td>0.772201</td>\n",
|
1596 |
+
" <td>0.898911</td>\n",
|
1597 |
+
" <td>0.967194</td>\n",
|
1598 |
+
" <td>1.027337</td>\n",
|
1599 |
+
" <td>0.922360</td>\n",
|
1600 |
+
" </tr>\n",
|
1601 |
+
" <tr>\n",
|
1602 |
+
" <th>2024-05-03</th>\n",
|
1603 |
+
" <td>0.801355</td>\n",
|
1604 |
+
" <td>0.919833</td>\n",
|
1605 |
+
" <td>0.979183</td>\n",
|
1606 |
+
" <td>1.034071</td>\n",
|
1607 |
+
" <td>0.940802</td>\n",
|
1608 |
+
" </tr>\n",
|
1609 |
+
" <tr>\n",
|
1610 |
+
" <th>2024-05-06</th>\n",
|
1611 |
+
" <td>0.842960</td>\n",
|
1612 |
+
" <td>0.947756</td>\n",
|
1613 |
+
" <td>0.989295</td>\n",
|
1614 |
+
" <td>1.054446</td>\n",
|
1615 |
+
" <td>0.967216</td>\n",
|
1616 |
+
" </tr>\n",
|
1617 |
+
" <tr>\n",
|
1618 |
+
" <th>2024-05-07</th>\n",
|
1619 |
+
" <td>0.849421</td>\n",
|
1620 |
+
" <td>0.952966</td>\n",
|
1621 |
+
" <td>0.990386</td>\n",
|
1622 |
+
" <td>1.014781</td>\n",
|
1623 |
+
" <td>0.961570</td>\n",
|
1624 |
+
" </tr>\n",
|
1625 |
+
" <tr>\n",
|
1626 |
+
" <th>2024-05-08</th>\n",
|
1627 |
+
" <td>0.835789</td>\n",
|
1628 |
+
" <td>0.961840</td>\n",
|
1629 |
+
" <td>0.990482</td>\n",
|
1630 |
+
" <td>0.997146</td>\n",
|
1631 |
+
" <td>0.955796</td>\n",
|
1632 |
+
" </tr>\n",
|
1633 |
+
" </tbody>\n",
|
1634 |
+
"</table>\n",
|
1635 |
+
"</div>\n",
|
1636 |
+
" <div class=\"colab-df-buttons\">\n",
|
1637 |
+
"\n",
|
1638 |
+
" <div class=\"colab-df-container\">\n",
|
1639 |
+
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-e16cfa33-3b61-42a3-a82b-ae1ecb73362c')\"\n",
|
1640 |
+
" title=\"Convert this dataframe to an interactive table.\"\n",
|
1641 |
+
" style=\"display:none;\">\n",
|
1642 |
+
"\n",
|
1643 |
+
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
|
1644 |
+
" <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
|
1645 |
+
" </svg>\n",
|
1646 |
+
" </button>\n",
|
1647 |
+
"\n",
|
1648 |
+
" <style>\n",
|
1649 |
+
" .colab-df-container {\n",
|
1650 |
+
" display:flex;\n",
|
1651 |
+
" gap: 12px;\n",
|
1652 |
+
" }\n",
|
1653 |
+
"\n",
|
1654 |
+
" .colab-df-convert {\n",
|
1655 |
+
" background-color: #E8F0FE;\n",
|
1656 |
+
" border: none;\n",
|
1657 |
+
" border-radius: 50%;\n",
|
1658 |
+
" cursor: pointer;\n",
|
1659 |
+
" display: none;\n",
|
1660 |
+
" fill: #1967D2;\n",
|
1661 |
+
" height: 32px;\n",
|
1662 |
+
" padding: 0 0 0 0;\n",
|
1663 |
+
" width: 32px;\n",
|
1664 |
+
" }\n",
|
1665 |
+
"\n",
|
1666 |
+
" .colab-df-convert:hover {\n",
|
1667 |
+
" background-color: #E2EBFA;\n",
|
1668 |
+
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
|
1669 |
+
" fill: #174EA6;\n",
|
1670 |
+
" }\n",
|
1671 |
+
"\n",
|
1672 |
+
" .colab-df-buttons div {\n",
|
1673 |
+
" margin-bottom: 4px;\n",
|
1674 |
+
" }\n",
|
1675 |
+
"\n",
|
1676 |
+
" [theme=dark] .colab-df-convert {\n",
|
1677 |
+
" background-color: #3B4455;\n",
|
1678 |
+
" fill: #D2E3FC;\n",
|
1679 |
+
" }\n",
|
1680 |
+
"\n",
|
1681 |
+
" [theme=dark] .colab-df-convert:hover {\n",
|
1682 |
+
" background-color: #434B5C;\n",
|
1683 |
+
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
|
1684 |
+
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
|
1685 |
+
" fill: #FFFFFF;\n",
|
1686 |
+
" }\n",
|
1687 |
+
" </style>\n",
|
1688 |
+
"\n",
|
1689 |
+
" <script>\n",
|
1690 |
+
" const buttonEl =\n",
|
1691 |
+
" document.querySelector('#df-e16cfa33-3b61-42a3-a82b-ae1ecb73362c button.colab-df-convert');\n",
|
1692 |
+
" buttonEl.style.display =\n",
|
1693 |
+
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
|
1694 |
+
"\n",
|
1695 |
+
" async function convertToInteractive(key) {\n",
|
1696 |
+
" const element = document.querySelector('#df-e16cfa33-3b61-42a3-a82b-ae1ecb73362c');\n",
|
1697 |
+
" const dataTable =\n",
|
1698 |
+
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
|
1699 |
+
" [key], {});\n",
|
1700 |
+
" if (!dataTable) return;\n",
|
1701 |
+
"\n",
|
1702 |
+
" const docLinkHtml = 'Like what you see? Visit the ' +\n",
|
1703 |
+
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
|
1704 |
+
" + ' to learn more about interactive tables.';\n",
|
1705 |
+
" element.innerHTML = '';\n",
|
1706 |
+
" dataTable['output_type'] = 'display_data';\n",
|
1707 |
+
" await google.colab.output.renderOutput(dataTable, element);\n",
|
1708 |
+
" const docLink = document.createElement('div');\n",
|
1709 |
+
" docLink.innerHTML = docLinkHtml;\n",
|
1710 |
+
" element.appendChild(docLink);\n",
|
1711 |
+
" }\n",
|
1712 |
+
" </script>\n",
|
1713 |
+
" </div>\n",
|
1714 |
+
"\n",
|
1715 |
+
"\n",
|
1716 |
+
"<div id=\"df-b087f441-dd59-4af0-81da-6c3b9fe3d4a6\">\n",
|
1717 |
+
" <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-b087f441-dd59-4af0-81da-6c3b9fe3d4a6')\"\n",
|
1718 |
+
" title=\"Suggest charts\"\n",
|
1719 |
+
" style=\"display:none;\">\n",
|
1720 |
+
"\n",
|
1721 |
+
"<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
|
1722 |
+
" width=\"24px\">\n",
|
1723 |
+
" <g>\n",
|
1724 |
+
" <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
|
1725 |
+
" </g>\n",
|
1726 |
+
"</svg>\n",
|
1727 |
+
" </button>\n",
|
1728 |
+
"\n",
|
1729 |
+
"<style>\n",
|
1730 |
+
" .colab-df-quickchart {\n",
|
1731 |
+
" --bg-color: #E8F0FE;\n",
|
1732 |
+
" --fill-color: #1967D2;\n",
|
1733 |
+
" --hover-bg-color: #E2EBFA;\n",
|
1734 |
+
" --hover-fill-color: #174EA6;\n",
|
1735 |
+
" --disabled-fill-color: #AAA;\n",
|
1736 |
+
" --disabled-bg-color: #DDD;\n",
|
1737 |
+
" }\n",
|
1738 |
+
"\n",
|
1739 |
+
" [theme=dark] .colab-df-quickchart {\n",
|
1740 |
+
" --bg-color: #3B4455;\n",
|
1741 |
+
" --fill-color: #D2E3FC;\n",
|
1742 |
+
" --hover-bg-color: #434B5C;\n",
|
1743 |
+
" --hover-fill-color: #FFFFFF;\n",
|
1744 |
+
" --disabled-bg-color: #3B4455;\n",
|
1745 |
+
" --disabled-fill-color: #666;\n",
|
1746 |
+
" }\n",
|
1747 |
+
"\n",
|
1748 |
+
" .colab-df-quickchart {\n",
|
1749 |
+
" background-color: var(--bg-color);\n",
|
1750 |
+
" border: none;\n",
|
1751 |
+
" border-radius: 50%;\n",
|
1752 |
+
" cursor: pointer;\n",
|
1753 |
+
" display: none;\n",
|
1754 |
+
" fill: var(--fill-color);\n",
|
1755 |
+
" height: 32px;\n",
|
1756 |
+
" padding: 0;\n",
|
1757 |
+
" width: 32px;\n",
|
1758 |
+
" }\n",
|
1759 |
+
"\n",
|
1760 |
+
" .colab-df-quickchart:hover {\n",
|
1761 |
+
" background-color: var(--hover-bg-color);\n",
|
1762 |
+
" box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
|
1763 |
+
" fill: var(--button-hover-fill-color);\n",
|
1764 |
+
" }\n",
|
1765 |
+
"\n",
|
1766 |
+
" .colab-df-quickchart-complete:disabled,\n",
|
1767 |
+
" .colab-df-quickchart-complete:disabled:hover {\n",
|
1768 |
+
" background-color: var(--disabled-bg-color);\n",
|
1769 |
+
" fill: var(--disabled-fill-color);\n",
|
1770 |
+
" box-shadow: none;\n",
|
1771 |
+
" }\n",
|
1772 |
+
"\n",
|
1773 |
+
" .colab-df-spinner {\n",
|
1774 |
+
" border: 2px solid var(--fill-color);\n",
|
1775 |
+
" border-color: transparent;\n",
|
1776 |
+
" border-bottom-color: var(--fill-color);\n",
|
1777 |
+
" animation:\n",
|
1778 |
+
" spin 1s steps(1) infinite;\n",
|
1779 |
+
" }\n",
|
1780 |
+
"\n",
|
1781 |
+
" @keyframes spin {\n",
|
1782 |
+
" 0% {\n",
|
1783 |
+
" border-color: transparent;\n",
|
1784 |
+
" border-bottom-color: var(--fill-color);\n",
|
1785 |
+
" border-left-color: var(--fill-color);\n",
|
1786 |
+
" }\n",
|
1787 |
+
" 20% {\n",
|
1788 |
+
" border-color: transparent;\n",
|
1789 |
+
" border-left-color: var(--fill-color);\n",
|
1790 |
+
" border-top-color: var(--fill-color);\n",
|
1791 |
+
" }\n",
|
1792 |
+
" 30% {\n",
|
1793 |
+
" border-color: transparent;\n",
|
1794 |
+
" border-left-color: var(--fill-color);\n",
|
1795 |
+
" border-top-color: var(--fill-color);\n",
|
1796 |
+
" border-right-color: var(--fill-color);\n",
|
1797 |
+
" }\n",
|
1798 |
+
" 40% {\n",
|
1799 |
+
" border-color: transparent;\n",
|
1800 |
+
" border-right-color: var(--fill-color);\n",
|
1801 |
+
" border-top-color: var(--fill-color);\n",
|
1802 |
+
" }\n",
|
1803 |
+
" 60% {\n",
|
1804 |
+
" border-color: transparent;\n",
|
1805 |
+
" border-right-color: var(--fill-color);\n",
|
1806 |
+
" }\n",
|
1807 |
+
" 80% {\n",
|
1808 |
+
" border-color: transparent;\n",
|
1809 |
+
" border-right-color: var(--fill-color);\n",
|
1810 |
+
" border-bottom-color: var(--fill-color);\n",
|
1811 |
+
" }\n",
|
1812 |
+
" 90% {\n",
|
1813 |
+
" border-color: transparent;\n",
|
1814 |
+
" border-bottom-color: var(--fill-color);\n",
|
1815 |
+
" }\n",
|
1816 |
+
" }\n",
|
1817 |
+
"</style>\n",
|
1818 |
+
"\n",
|
1819 |
+
" <script>\n",
|
1820 |
+
" async function quickchart(key) {\n",
|
1821 |
+
" const quickchartButtonEl =\n",
|
1822 |
+
" document.querySelector('#' + key + ' button');\n",
|
1823 |
+
" quickchartButtonEl.disabled = true; // To prevent multiple clicks.\n",
|
1824 |
+
" quickchartButtonEl.classList.add('colab-df-spinner');\n",
|
1825 |
+
" try {\n",
|
1826 |
+
" const charts = await google.colab.kernel.invokeFunction(\n",
|
1827 |
+
" 'suggestCharts', [key], {});\n",
|
1828 |
+
" } catch (error) {\n",
|
1829 |
+
" console.error('Error during call to suggestCharts:', error);\n",
|
1830 |
+
" }\n",
|
1831 |
+
" quickchartButtonEl.classList.remove('colab-df-spinner');\n",
|
1832 |
+
" quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
|
1833 |
+
" }\n",
|
1834 |
+
" (() => {\n",
|
1835 |
+
" let quickchartButtonEl =\n",
|
1836 |
+
" document.querySelector('#df-b087f441-dd59-4af0-81da-6c3b9fe3d4a6 button');\n",
|
1837 |
+
" quickchartButtonEl.style.display =\n",
|
1838 |
+
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
|
1839 |
+
" })();\n",
|
1840 |
+
" </script>\n",
|
1841 |
+
"</div>\n",
|
1842 |
+
"\n",
|
1843 |
+
" </div>\n",
|
1844 |
+
" </div>\n"
|
1845 |
+
],
|
1846 |
+
"application/vnd.google.colaboratory.intrinsic+json": {
|
1847 |
+
"type": "dataframe",
|
1848 |
+
"summary": "{\n \"name\": \"daily_cumulative_returns\",\n \"rows\": 5,\n \"fields\": [\n {\n \"column\": \"Date\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": \"2024-05-02 00:00:00\",\n \"max\": \"2024-05-08 00:00:00\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"2024-05-03 00:00:00\",\n \"2024-05-08 00:00:00\",\n \"2024-05-06 00:00:00\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"ARM\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.03268724736387041,\n \"min\": 0.7722007499181814,\n \"max\": 0.8494208489566288,\n \"num_unique_values\": 5,\n \"samples\": [\n 0.8013552439807079,\n 0.835789115389434,\n 0.8429595797803437\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"META\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.026126472997597343,\n \"min\": 0.8989111370494823,\n \"max\": 0.9618398295164574,\n \"num_unique_values\": 5,\n \"samples\": [\n 0.9198330840355401,\n 0.9618398295164574,\n 0.9477561552684173\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"SPY\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.010174510968413989,\n \"min\": 0.9671940109425183,\n \"max\": 0.9904819002628732,\n \"num_unique_values\": 5,\n \"samples\": [\n 0.9791826927404093,\n 0.9904819002628732,\n 0.9892945340359032\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"TSLA\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.02140969763814976,\n \"min\": 0.9971464444896896,\n \"max\": 1.0544458008199447,\n \"num_unique_values\": 5,\n \"samples\": [\n 1.0340714597597993,\n 0.9971464444896896,\n 1.0544458008199447\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Portfolio Returns\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.01810684145461361,\n \"min\": 0.9223596625037148,\n \"max\": 0.9672162989216139,\n \"num_unique_values\": 5,\n \"samples\": [\n 0.940802335236565,\n 0.9557962381861789,\n 0.9672162989216139\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
|
1849 |
+
}
|
1850 |
+
},
|
1851 |
+
"metadata": {},
|
1852 |
+
"execution_count": 13
|
1853 |
+
}
|
1854 |
+
]
|
1855 |
+
},
|
1856 |
+
{
|
1857 |
+
"cell_type": "code",
|
1858 |
+
"source": [],
|
1859 |
+
"metadata": {
|
1860 |
+
"id": "HwVTimnSY8Wd"
|
1861 |
+
},
|
1862 |
+
"execution_count": null,
|
1863 |
+
"outputs": []
|
1864 |
+
}
|
1865 |
+
]
|
1866 |
+
}
|