{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import yfinance as yf" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# Define the list of stock symbols\n", "stock_symbols = ['JPM', 'GS', 'MS', 'BLK', 'C']" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "[*********************100%%**********************] 5 of 5 completed\n" ] } ], "source": [ "# Download historical stock price data\n", "stock_data = yf.download(stock_symbols, start=\"2020-01-01\", end=\"2023-11-30\")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
PriceAdj CloseClose...OpenVolume
TickerBLKCGSJPMMSBLKCGSJPMMS...BLKCGSJPMMSBLKCGSJPMMS
Date
2020-01-02457.11093168.963692210.857330123.53360045.443264508.98001181.230003234.320007141.08999652.040001...510.00000080.129997231.000000139.78999351.200001560400127289003736300108037007808000
2020-01-03452.25219767.664719208.391678121.90343544.709740503.57000779.699997231.580002138.33999651.200001...501.72000179.800003231.600006137.50000051.220001337300124374002274500103868006706000
2020-01-06452.63839767.452461210.524353121.80647344.552567504.00000079.449997233.949997138.22999651.020000...500.17001378.720001229.929993136.55999850.669998411300100595003329300102590007476700
2020-01-07455.53024366.866661211.910172119.73569544.465233507.22000178.760002235.490005135.88000550.919998...502.88000579.290001235.000000137.27999951.040001453900104691005255200105313004538100
2020-01-08455.42251667.376060213.952820120.66974645.032845507.10000679.360001237.759995136.94000251.570000...507.76998978.769997235.679993135.69999750.95999972650011292400356470096953006185200
..................................................................
2023-11-22717.86529544.594376333.518433151.50654677.728569727.14001545.020000338.640015153.33000278.489998...727.00000045.310001336.940002153.41000478.7900014981009441200123520051745004265400
2023-11-24720.78753744.802391334.020691151.71405077.887024730.09997645.230000339.149994153.53999378.650002...726.71997144.889999338.799988153.58999678.260002279600594100046010034969002398000
2023-11-27721.36016844.653809332.602478151.36822577.193810730.67999345.080002337.709991153.19000277.949997...727.20001244.959999339.190002153.42999378.26999786810014679700125050062591005237800
2023-11-28727.36261044.435886332.543396151.71405076.134186736.76001044.860001337.649994153.53999376.879997...725.85998545.029999337.380005153.22000177.36000161020014064700141900065827009197900
2023-11-29737.76818845.317474337.865692152.48478777.787994747.29998845.750000340.260010154.32000778.550003...742.28002945.230000337.000000154.16999877.48000375000014027600203810091261007420700
\n", "

985 rows × 30 columns

\n", "
" ], "text/plain": [ "Price Adj Close \\\n", "Ticker BLK C GS JPM MS \n", "Date \n", "2020-01-02 457.110931 68.963692 210.857330 123.533600 45.443264 \n", "2020-01-03 452.252197 67.664719 208.391678 121.903435 44.709740 \n", "2020-01-06 452.638397 67.452461 210.524353 121.806473 44.552567 \n", "2020-01-07 455.530243 66.866661 211.910172 119.735695 44.465233 \n", "2020-01-08 455.422516 67.376060 213.952820 120.669746 45.032845 \n", "... ... ... ... ... ... \n", "2023-11-22 717.865295 44.594376 333.518433 151.506546 77.728569 \n", "2023-11-24 720.787537 44.802391 334.020691 151.714050 77.887024 \n", "2023-11-27 721.360168 44.653809 332.602478 151.368225 77.193810 \n", "2023-11-28 727.362610 44.435886 332.543396 151.714050 76.134186 \n", "2023-11-29 737.768188 45.317474 337.865692 152.484787 77.787994 \n", "\n", "Price Close ... \\\n", "Ticker BLK C GS JPM MS ... \n", "Date ... \n", "2020-01-02 508.980011 81.230003 234.320007 141.089996 52.040001 ... \n", "2020-01-03 503.570007 79.699997 231.580002 138.339996 51.200001 ... \n", "2020-01-06 504.000000 79.449997 233.949997 138.229996 51.020000 ... \n", "2020-01-07 507.220001 78.760002 235.490005 135.880005 50.919998 ... \n", "2020-01-08 507.100006 79.360001 237.759995 136.940002 51.570000 ... \n", "... ... ... ... ... ... ... \n", "2023-11-22 727.140015 45.020000 338.640015 153.330002 78.489998 ... \n", "2023-11-24 730.099976 45.230000 339.149994 153.539993 78.650002 ... \n", "2023-11-27 730.679993 45.080002 337.709991 153.190002 77.949997 ... \n", "2023-11-28 736.760010 44.860001 337.649994 153.539993 76.879997 ... \n", "2023-11-29 747.299988 45.750000 340.260010 154.320007 78.550003 ... \n", "\n", "Price Open Volume \\\n", "Ticker BLK C GS JPM MS BLK \n", "Date \n", "2020-01-02 510.000000 80.129997 231.000000 139.789993 51.200001 560400 \n", "2020-01-03 501.720001 79.800003 231.600006 137.500000 51.220001 337300 \n", "2020-01-06 500.170013 78.720001 229.929993 136.559998 50.669998 411300 \n", "2020-01-07 502.880005 79.290001 235.000000 137.279999 51.040001 453900 \n", "2020-01-08 507.769989 78.769997 235.679993 135.699997 50.959999 726500 \n", "... ... ... ... ... ... ... \n", "2023-11-22 727.000000 45.310001 336.940002 153.410004 78.790001 498100 \n", "2023-11-24 726.719971 44.889999 338.799988 153.589996 78.260002 279600 \n", "2023-11-27 727.200012 44.959999 339.190002 153.429993 78.269997 868100 \n", "2023-11-28 725.859985 45.029999 337.380005 153.220001 77.360001 610200 \n", "2023-11-29 742.280029 45.230000 337.000000 154.169998 77.480003 750000 \n", "\n", "Price \n", "Ticker C GS JPM MS \n", "Date \n", "2020-01-02 12728900 3736300 10803700 7808000 \n", "2020-01-03 12437400 2274500 10386800 6706000 \n", "2020-01-06 10059500 3329300 10259000 7476700 \n", "2020-01-07 10469100 5255200 10531300 4538100 \n", "2020-01-08 11292400 3564700 9695300 6185200 \n", "... ... ... ... ... \n", "2023-11-22 9441200 1235200 5174500 4265400 \n", "2023-11-24 5941000 460100 3496900 2398000 \n", "2023-11-27 14679700 1250500 6259100 5237800 \n", "2023-11-28 14064700 1419000 6582700 9197900 \n", "2023-11-29 14027600 2038100 9126100 7420700 \n", "\n", "[985 rows x 30 columns]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stock_data" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "py312", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.2" } }, "nbformat": 4, "nbformat_minor": 2 }