{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "code",
"source": [
"import yfinance\n",
"\n",
"stocks = ['ARM', 'META', 'SPY', 'TSLA']\n",
"\n",
"data = yfinance.download(stocks,\n",
" '2024-04-01',\n",
" '2024-05-09')['Close']"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "mfJAaMYDQPfy",
"outputId": "ae6d7974-6068-40fa-ed90-c2c6dbc9cec0"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"[*********************100%%**********************] 4 of 4 completed\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"data.head()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 238
},
"id": "nNuUrUiIQqRA",
"outputId": "92863eca-deef-4765-ca5b-74ddf230f3ef"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"Ticker ARM META SPY TSLA\n",
"Date \n",
"2024-04-01 126.910004 491.350006 522.159973 175.220001\n",
"2024-04-02 124.279999 497.369995 518.840027 166.630005\n",
"2024-04-03 125.309998 506.739990 519.409973 168.380005\n",
"2024-04-04 122.010002 510.920013 513.070007 171.110001\n",
"2024-04-05 124.820000 527.340027 518.429993 164.899994"
],
"text/html": [
"\n",
"
\n",
"
\n",
"\n",
"
\n",
" \n",
" \n",
" Ticker | \n",
" ARM | \n",
" META | \n",
" SPY | \n",
" TSLA | \n",
"
\n",
" \n",
" Date | \n",
" | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" 2024-04-01 | \n",
" 126.910004 | \n",
" 491.350006 | \n",
" 522.159973 | \n",
" 175.220001 | \n",
"
\n",
" \n",
" 2024-04-02 | \n",
" 124.279999 | \n",
" 497.369995 | \n",
" 518.840027 | \n",
" 166.630005 | \n",
"
\n",
" \n",
" 2024-04-03 | \n",
" 125.309998 | \n",
" 506.739990 | \n",
" 519.409973 | \n",
" 168.380005 | \n",
"
\n",
" \n",
" 2024-04-04 | \n",
" 122.010002 | \n",
" 510.920013 | \n",
" 513.070007 | \n",
" 171.110001 | \n",
"
\n",
" \n",
" 2024-04-05 | \n",
" 124.820000 | \n",
" 527.340027 | \n",
" 518.429993 | \n",
" 164.899994 | \n",
"
\n",
" \n",
"
\n",
"
\n",
"
\n",
"
\n"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "dataframe",
"variable_name": "data",
"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}"
}
},
"metadata": {},
"execution_count": 2
}
]
},
{
"cell_type": "code",
"source": [
"returns = data.pct_change()\n",
"returns.head()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 238
},
"id": "vwy0TbMoQxh-",
"outputId": "f396857e-47c8-4cf6-e407-3f214bb02cd5"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"Ticker ARM META SPY TSLA\n",
"Date \n",
"2024-04-01 NaN NaN NaN NaN\n",
"2024-04-02 -0.020723 0.012252 -0.006358 -0.049024\n",
"2024-04-03 0.008288 0.018839 0.001099 0.010502\n",
"2024-04-04 -0.026335 0.008249 -0.012206 0.016213\n",
"2024-04-05 0.023031 0.032138 0.010447 -0.036292"
],
"text/html": [
"\n",
" \n",
"
\n",
"\n",
"
\n",
" \n",
" \n",
" Ticker | \n",
" ARM | \n",
" META | \n",
" SPY | \n",
" TSLA | \n",
"
\n",
" \n",
" Date | \n",
" | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" 2024-04-01 | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
"
\n",
" \n",
" 2024-04-02 | \n",
" -0.020723 | \n",
" 0.012252 | \n",
" -0.006358 | \n",
" -0.049024 | \n",
"
\n",
" \n",
" 2024-04-03 | \n",
" 0.008288 | \n",
" 0.018839 | \n",
" 0.001099 | \n",
" 0.010502 | \n",
"
\n",
" \n",
" 2024-04-04 | \n",
" -0.026335 | \n",
" 0.008249 | \n",
" -0.012206 | \n",
" 0.016213 | \n",
"
\n",
" \n",
" 2024-04-05 | \n",
" 0.023031 | \n",
" 0.032138 | \n",
" 0.010447 | \n",
" -0.036292 | \n",
"
\n",
" \n",
"
\n",
"
\n",
"
\n",
"
\n"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "dataframe",
"variable_name": "returns",
"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}"
}
},
"metadata": {},
"execution_count": 3
}
]
},
{
"cell_type": "code",
"source": [
"returns = returns.dropna()\n",
"\n",
"returns.head()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 238
},
"id": "smRQAk1DQ5p0",
"outputId": "35971d47-108d-4a7e-d989-5287f8d1c274"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"Ticker ARM META SPY TSLA\n",
"Date \n",
"2024-04-02 -0.020723 0.012252 -0.006358 -0.049024\n",
"2024-04-03 0.008288 0.018839 0.001099 0.010502\n",
"2024-04-04 -0.026335 0.008249 -0.012206 0.016213\n",
"2024-04-05 0.023031 0.032138 0.010447 -0.036292\n",
"2024-04-08 0.035491 -0.015341 0.000559 0.048999"
],
"text/html": [
"\n",
" \n",
"
\n",
"\n",
"
\n",
" \n",
" \n",
" Ticker | \n",
" ARM | \n",
" META | \n",
" SPY | \n",
" TSLA | \n",
"
\n",
" \n",
" Date | \n",
" | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" 2024-04-02 | \n",
" -0.020723 | \n",
" 0.012252 | \n",
" -0.006358 | \n",
" -0.049024 | \n",
"
\n",
" \n",
" 2024-04-03 | \n",
" 0.008288 | \n",
" 0.018839 | \n",
" 0.001099 | \n",
" 0.010502 | \n",
"
\n",
" \n",
" 2024-04-04 | \n",
" -0.026335 | \n",
" 0.008249 | \n",
" -0.012206 | \n",
" 0.016213 | \n",
"
\n",
" \n",
" 2024-04-05 | \n",
" 0.023031 | \n",
" 0.032138 | \n",
" 0.010447 | \n",
" -0.036292 | \n",
"
\n",
" \n",
" 2024-04-08 | \n",
" 0.035491 | \n",
" -0.015341 | \n",
" 0.000559 | \n",
" 0.048999 | \n",
"
\n",
" \n",
"
\n",
"
\n",
"
\n",
"
\n"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "dataframe",
"variable_name": "returns",
"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}"
}
},
"metadata": {},
"execution_count": 4
}
]
},
{
"cell_type": "code",
"source": [
"average_daily_returns = returns.mean()\n",
"print(average_daily_returns)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "0LSi1EluSjRA",
"outputId": "a851a7e7-3e9b-4d2b-d06d-8f3ea46def2d"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Ticker\n",
"ARM -0.005259\n",
"META -0.001060\n",
"SPY -0.000319\n",
"TSLA 0.000984\n",
"dtype: float64\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"standard_deviation_daily_returns = returns.std()\n",
"\n",
"print(standard_deviation_daily_returns)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "BsjEGO46SwRP",
"outputId": "d64644d9-7aee-4fd5-9b64-dfbebb695d10"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Ticker\n",
"ARM 0.051661\n",
"META 0.027536\n",
"SPY 0.008493\n",
"TSLA 0.048723\n",
"dtype: float64\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"import numpy\n",
"\n",
"weights = numpy.array([0.25, 0.25, 0.25, 0.25])"
],
"metadata": {
"id": "aHVZp77fS_5T"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"covariance_matrix = (returns.cov())*250\n",
"print(covariance_matrix)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "wOj-twh_Tnf5",
"outputId": "837404eb-1556-4b86-c405-565169571db8"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Ticker ARM META SPY TSLA\n",
"Ticker \n",
"ARM 0.667206 0.131290 0.072585 0.167230\n",
"META 0.131290 0.189558 0.024381 -0.086532\n",
"SPY 0.072585 0.024381 0.018031 0.027256\n",
"TSLA 0.167230 -0.086532 0.027256 0.593473\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"expected_portfolio_performance = numpy.sum(average_daily_returns * weights)\n",
"\n",
"print(expected_portfolio_performance)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "3Y7MpadBT1na",
"outputId": "af1e83be-0f2e-48c6-b43f-635ae9e21d80"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"-0.001413485369940147\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"returns['Portfolio Returns'] = returns.dot(weights)"
],
"metadata": {
"id": "U_tB0NrYUCCt"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"returns.head()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 238
},
"id": "92BQOPu4ULNT",
"outputId": "a95b5cd1-071d-4fc3-e07b-b13412450a53"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"Ticker ARM META SPY TSLA Portfolio Returns\n",
"Date \n",
"2024-04-02 -0.020723 0.012252 -0.006358 -0.049024 -0.015963\n",
"2024-04-03 0.008288 0.018839 0.001099 0.010502 0.009682\n",
"2024-04-04 -0.026335 0.008249 -0.012206 0.016213 -0.003520\n",
"2024-04-05 0.023031 0.032138 0.010447 -0.036292 0.007331\n",
"2024-04-08 0.035491 -0.015341 0.000559 0.048999 0.017427"
],
"text/html": [
"\n",
" \n",
"
\n",
"\n",
"
\n",
" \n",
" \n",
" Ticker | \n",
" ARM | \n",
" META | \n",
" SPY | \n",
" TSLA | \n",
" Portfolio Returns | \n",
"
\n",
" \n",
" Date | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" 2024-04-02 | \n",
" -0.020723 | \n",
" 0.012252 | \n",
" -0.006358 | \n",
" -0.049024 | \n",
" -0.015963 | \n",
"
\n",
" \n",
" 2024-04-03 | \n",
" 0.008288 | \n",
" 0.018839 | \n",
" 0.001099 | \n",
" 0.010502 | \n",
" 0.009682 | \n",
"
\n",
" \n",
" 2024-04-04 | \n",
" -0.026335 | \n",
" 0.008249 | \n",
" -0.012206 | \n",
" 0.016213 | \n",
" -0.003520 | \n",
"
\n",
" \n",
" 2024-04-05 | \n",
" 0.023031 | \n",
" 0.032138 | \n",
" 0.010447 | \n",
" -0.036292 | \n",
" 0.007331 | \n",
"
\n",
" \n",
" 2024-04-08 | \n",
" 0.035491 | \n",
" -0.015341 | \n",
" 0.000559 | \n",
" 0.048999 | \n",
" 0.017427 | \n",
"
\n",
" \n",
"
\n",
"
\n",
"
\n",
"
\n"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "dataframe",
"variable_name": "returns",
"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}"
}
},
"metadata": {},
"execution_count": 11
}
]
},
{
"cell_type": "code",
"source": [
"daily_cumulative_returns= (1+returns).cumprod()\n",
"print(daily_cumulative_returns)"
],
"metadata": {
"id": "o8z0mBEUUa77",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "65e4933e-ea16-4109-c5c0-d1f740134aca"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Ticker ARM META SPY TSLA Portfolio Returns\n",
"Date \n",
"2024-04-02 0.979277 1.012252 0.993642 0.950976 0.984037\n",
"2024-04-03 0.987393 1.031322 0.994733 0.960963 0.993564\n",
"2024-04-04 0.961390 1.039829 0.982592 0.976544 0.990067\n",
"2024-04-05 0.983532 1.073247 0.992857 0.941103 0.997325\n",
"2024-04-08 1.018438 1.056782 0.993412 0.987216 1.014706\n",
"2024-04-09 0.999212 1.052000 0.994561 1.009474 1.014781\n",
"2024-04-10 0.986368 1.057963 0.984602 0.980253 1.003075\n",
"2024-04-11 1.033252 1.064740 0.992033 0.996462 1.022639\n",
"2024-04-12 0.995430 1.041824 0.978340 0.976201 0.999051\n",
"2024-04-15 0.963833 1.018073 0.966083 0.921584 0.968326\n",
"2024-04-16 0.963045 1.017116 0.964321 0.896644 0.960908\n",
"2024-04-17 0.847530 1.005739 0.958614 0.887170 0.925447\n",
"2024-04-18 0.826728 1.021268 0.956642 0.855667 0.914649\n",
"2024-04-19 0.687022 0.979078 0.948292 0.839231 0.860173\n",
"2024-04-22 0.733670 0.980421 0.957025 0.810695 0.869738\n",
"2024-04-23 0.756757 1.009667 0.968381 0.825705 0.889672\n",
"2024-04-24 0.787014 1.004376 0.967922 0.925294 0.924120\n",
"2024-04-25 0.771649 0.898301 0.964245 0.971236 0.905803\n",
"2024-04-26 0.803325 0.902188 0.973380 0.960450 0.915709\n",
"2024-04-29 0.813490 0.880472 0.976827 1.107465 0.948948\n",
"2024-04-30 0.797494 0.875486 0.961353 1.045999 0.926015\n",
"2024-05-01 0.750847 0.893843 0.958231 1.027223 0.912420\n",
"2024-05-02 0.772201 0.898911 0.967194 1.027337 0.922360\n",
"2024-05-03 0.801355 0.919833 0.979183 1.034071 0.940802\n",
"2024-05-06 0.842960 0.947756 0.989295 1.054446 0.967216\n",
"2024-05-07 0.849421 0.952966 0.990386 1.014781 0.961570\n",
"2024-05-08 0.835789 0.961840 0.990482 0.997146 0.955796\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"daily_cumulative_returns.tail()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 238
},
"id": "Roh4BE6fUmGt",
"outputId": "66b911b4-5268-42ad-9f45-887f377dfe77"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"Ticker ARM META SPY TSLA Portfolio Returns\n",
"Date \n",
"2024-05-02 0.772201 0.898911 0.967194 1.027337 0.922360\n",
"2024-05-03 0.801355 0.919833 0.979183 1.034071 0.940802\n",
"2024-05-06 0.842960 0.947756 0.989295 1.054446 0.967216\n",
"2024-05-07 0.849421 0.952966 0.990386 1.014781 0.961570\n",
"2024-05-08 0.835789 0.961840 0.990482 0.997146 0.955796"
],
"text/html": [
"\n",
" \n",
"
\n",
"\n",
"
\n",
" \n",
" \n",
" Ticker | \n",
" ARM | \n",
" META | \n",
" SPY | \n",
" TSLA | \n",
" Portfolio Returns | \n",
"
\n",
" \n",
" Date | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" 2024-05-02 | \n",
" 0.772201 | \n",
" 0.898911 | \n",
" 0.967194 | \n",
" 1.027337 | \n",
" 0.922360 | \n",
"
\n",
" \n",
" 2024-05-03 | \n",
" 0.801355 | \n",
" 0.919833 | \n",
" 0.979183 | \n",
" 1.034071 | \n",
" 0.940802 | \n",
"
\n",
" \n",
" 2024-05-06 | \n",
" 0.842960 | \n",
" 0.947756 | \n",
" 0.989295 | \n",
" 1.054446 | \n",
" 0.967216 | \n",
"
\n",
" \n",
" 2024-05-07 | \n",
" 0.849421 | \n",
" 0.952966 | \n",
" 0.990386 | \n",
" 1.014781 | \n",
" 0.961570 | \n",
"
\n",
" \n",
" 2024-05-08 | \n",
" 0.835789 | \n",
" 0.961840 | \n",
" 0.990482 | \n",
" 0.997146 | \n",
" 0.955796 | \n",
"
\n",
" \n",
"
\n",
"
\n",
"
\n",
"
\n"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "dataframe",
"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}"
}
},
"metadata": {},
"execution_count": 13
}
]
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "HwVTimnSY8Wd"
},
"execution_count": null,
"outputs": []
}
]
}