{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "wrds_sp500_1.ipynb", "provenance": [], "collapsed_sections": [], "authorship_tag": "ABX9TyNkYy+6D/IpfNp0R4T4FSwc", "include_colab_link": true }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "view-in-github", "colab_type": "text" }, "source": [ "\"Open" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "BK41lkVxd9-K" }, "outputs": [], "source": [ "" ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "y2C0OgijlDzv", "outputId": "31538ae4-da6c-4973-c94e-cfe5e84b8cdb" }, "source": [ "!pip install wrds" ], "execution_count": 1, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n", "Collecting wrds\n", " Downloading wrds-3.1.1-py3-none-any.whl (12 kB)\n", "Collecting mock\n", " Downloading mock-4.0.3-py3-none-any.whl (28 kB)\n", "Requirement already satisfied: sqlalchemy in /usr/local/lib/python3.7/dist-packages (from wrds) (1.4.37)\n", "Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from wrds) (1.21.6)\n", "Collecting psycopg2-binary\n", " Downloading psycopg2_binary-2.9.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB)\n", "\u001b[K |████████████████████████████████| 3.0 MB 8.6 MB/s \n", "\u001b[?25hRequirement already satisfied: pandas in /usr/local/lib/python3.7/dist-packages (from wrds) (1.3.5)\n", "Requirement already satisfied: pytz>=2017.3 in /usr/local/lib/python3.7/dist-packages (from pandas->wrds) (2022.1)\n", "Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.7/dist-packages (from pandas->wrds) (2.8.2)\n", "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/dist-packages (from python-dateutil>=2.7.3->pandas->wrds) (1.15.0)\n", "Requirement already satisfied: importlib-metadata in /usr/local/lib/python3.7/dist-packages (from sqlalchemy->wrds) (4.11.4)\n", "Requirement already satisfied: greenlet!=0.4.17 in /usr/local/lib/python3.7/dist-packages (from sqlalchemy->wrds) (1.1.2)\n", "Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.7/dist-packages (from importlib-metadata->sqlalchemy->wrds) (3.8.0)\n", "Requirement already satisfied: typing-extensions>=3.6.4 in /usr/local/lib/python3.7/dist-packages (from importlib-metadata->sqlalchemy->wrds) (4.1.1)\n", "Installing collected packages: psycopg2-binary, mock, wrds\n", "Successfully installed mock-4.0.3 psycopg2-binary-2.9.3 wrds-3.1.1\n" ] } ] }, { "cell_type": "code", "metadata": { "id": "TlUrRmTnlFD_" }, "source": [ "import wrds" ], "execution_count": 2, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "Kfij7381Oe4W" }, "source": [ "# Now I am connecting to WRDS site - you must ahve a WRDS account user id and password\n", "conn=wrds.Connection()" ], "execution_count": null, "outputs": [] }, { "cell_type": "code", "metadata": { "collapsed": true, "id": "zgpZF6Vo11y5" }, "source": [ "import pandas as pd \n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import seaborn as sns\n", "\n", "plt.style.use('fivethirtyeight')\n", "\n", "%matplotlib inline\n", "%config InlineBackend.figure_format = 'retina'" ], "execution_count": 4, "outputs": [] }, { "cell_type": "code", "source": [ "help(wrds)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "eneGwr9g3tDo", "outputId": "b7e4f31e-b675-430d-8c33-6b82b43d3d22" }, "execution_count": 5, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Help on package wrds:\n", "\n", "NAME\n", " wrds\n", "\n", "DESCRIPTION\n", " WRDS Python Data Access Library\n", " ==============================\n", " \n", " WRDS-Py is a library for extracting data from WRDS data sources and getting it into Pandas.\n", " \n", " >>> import wrds\n", " >>> db = wrds.Connection()\n", " >>> db.list_libraries()\n", " ['aha', 'aha_sample', 'ahasamp', 'audit', 'audit_audit_comp', ...]\n", " >>> db.list_tables(library='crsp')\n", " ['acti', 'asia', 'asib', 'asic', 'asio', 'asix', 'bmdebt', 'bmheader', ...]\n", " >>> data = db.raw_sql('SELECT * FROM crsp.stocknames', index_col='permno')\n", " >>> data.head()\n", " permco namedt nameenddt cusip ncusip ticker permno\n", " 10000.0 7952.0 1986-01-07 1987-06-11 68391610 68391610 OMFGA\n", " 10001.0 7953.0 1986-01-09 1993-11-21 36720410 39040610 GFGC\n", " 10001.0 7953.0 1993-11-22 2008-02-04 36720410 29274A10 EWST\n", " 10001.0 7953.0 2008-02-05 2009-08-03 36720410 29274A20 EWST\n", " 10001.0 7953.0 2009-08-04 2009-12-17 36720410 29269V10 EGAS\n", " ...\n", "\n", "PACKAGE CONTENTS\n", " sql\n", " test\n", "\n", "DATA\n", " __copyright__ = '2017-2021 Wharton Research Data Services'\n", " __title__ = 'wrds-py'\n", "\n", "VERSION\n", " 3.1.1\n", "\n", "AUTHOR\n", " Wharton Research Data Services\n", "\n", "FILE\n", " /usr/local/lib/python3.7/dist-packages/wrds/__init__.py\n", "\n", "\n" ] } ] }, { "cell_type": "code", "source": [ "#listing all dtabases or libraries in WRDS\n", "conn.list_libraries()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "pf-sgx9YwW3W", "outputId": "caf994c4-d58f-46da-8852-108995a059f0" }, "execution_count": 6, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "['compbd',\n", " 'compgd',\n", " 'compnad',\n", " 'compsegd',\n", " 'crspa',\n", " 'evts',\n", " 'issm',\n", " 'nastraq',\n", " 'tass',\n", " 'wrds_lib_internal',\n", " 'aha',\n", " 'estimize',\n", " 'levin',\n", " 'ciqsamp_capstrct',\n", " 'toyo',\n", " 'ahasamp',\n", " 'ciqsamp_pplintel',\n", " 'crspm',\n", " 'tresgsmp',\n", " 'trsdcgs',\n", " 'columnar',\n", " 'trws',\n", " 'lspd',\n", " 'twoiq',\n", " 'wcai',\n", " 'tresg',\n", " 'wind',\n", " 'wqa',\n", " 'msrb_all',\n", " 'custom_jl',\n", " 'risk',\n", " 'centris',\n", " 'wrdsapps_link_supplychain',\n", " 'block_all',\n", " 'zacks',\n", " 'crsp',\n", " 'contrib',\n", " 'audit',\n", " 'boardex_trial',\n", " 'emdb',\n", " 'calcbnch',\n", " 'comp_na_monthly_all',\n", " 'auditsmp',\n", " 'boardsmp',\n", " 'comp_segments_hist',\n", " 'wrdsrpts_rep_usage',\n", " 'public_all',\n", " 'pwt_all',\n", " 'msfanly',\n", " 'etfg',\n", " 'snlsamp_fig',\n", " 'wrdsapps_backtest_plus',\n", " 'pacap',\n", " 'ciqsamp_transcripts',\n", " 'ciq',\n", " 'tr_ds',\n", " 'ppublica',\n", " 'crsp_a_stock',\n", " 'preqin',\n", " 'etfg_samp',\n", " 'fisdsamp',\n", " 'windsmp',\n", " 'rent',\n", " 'sustainalyticssamp_all',\n", " 'wrdsapps_evtstudy_int_ginsight',\n", " 'compmcur',\n", " 'tr_dealscan',\n", " 'markit',\n", " 'secsamp_all',\n", " 'rpna',\n", " 'ibes',\n", " 'rpa',\n", " 'sdcsamp',\n", " 'wrdssec_midas',\n", " 'cisdmsmp',\n", " 'cboe_all',\n", " 'snl',\n", " 'cboe',\n", " 'sprat',\n", " 'ciqsamp',\n", " 'fjc_litigation',\n", " 'trucost',\n", " 'sustain',\n", " 'trdssamp',\n", " 'risksamp',\n", " 'midas',\n", " 'snlsamp',\n", " 'public',\n", " 'pwt',\n", " 'repsamp',\n", " 'snapsamp',\n", " 'taqsamp',\n", " 'totalq',\n", " 'optionm',\n", " 'comp_execucomp',\n", " 'fjc_linking',\n", " 'compa',\n", " 'bank',\n", " 'blab',\n", " 'compb',\n", " 'compg',\n", " 'block',\n", " 'taqmsec',\n", " 'trsamp_ds_eq',\n", " 'contrib_ceo_turnover',\n", " 'cisdm',\n", " 'clrvt',\n", " 'clrvtsmp',\n", " 'compm',\n", " 'compseg',\n", " 'compsamp',\n", " 'comph',\n", " 'compsnap',\n", " 'comscore',\n", " 'pitchbk',\n", " 'crspsamp',\n", " 'dmef',\n", " 'eursamp',\n", " 'contrib_kpss',\n", " 'auditsmp_all',\n", " 'crspq',\n", " 'execcomp',\n", " 'taqmsamp_all',\n", " 'ff',\n", " 'ftse',\n", " 'cusipm',\n", " 'boardex',\n", " 'eureka',\n", " 'eventus',\n", " 'ftsesamp',\n", " 'ginsight',\n", " 'ktsamp',\n", " 'factset',\n", " 'ifgrsamp',\n", " 'imssamp',\n", " 'gmi',\n", " 'fssamp',\n", " 'govpxsmp',\n", " 'hbsamp',\n", " 'hbase',\n", " 'hfr',\n", " 'ibescorp',\n", " 'mrktsamp_msf',\n", " 'iri',\n", " 'govpx',\n", " 'kld',\n", " 'ifgr',\n", " 'ibeskpi',\n", " 'fisd',\n", " 'lspdsamp',\n", " 'ims',\n", " 'ktmine',\n", " 'taq',\n", " 'aha_sample',\n", " 'compdcur',\n", " 'calcbench_trial',\n", " 'ciqsamp_common',\n", " 'ppubsamp_d4d',\n", " 'mrktsamp',\n", " 'otc',\n", " 'msrbsamp',\n", " 'contrib_general',\n", " 'preqsamp_all',\n", " 'twoiq_samp',\n", " 'msrb',\n", " 'mrktsamp_cdx',\n", " 'phlx_all',\n", " 'zacksamp_all',\n", " 'mfl',\n", " 'sustsamp',\n", " 'etfgsamp',\n", " 'phlx',\n", " 'ppubsamp',\n", " 'preqsamp',\n", " 'ciqsamp_keydev',\n", " 'tfn',\n", " 'toyosamp',\n", " 'wappsamp',\n", " 'wrdsapps_evtstudy_lr',\n", " 'crsp_a_ccm',\n", " 'zacksamp',\n", " 'revere',\n", " 'eurekahedge_sample',\n", " 'comp_na_daily_all',\n", " 'ims_obp_trial',\n", " 'wrdsrpts',\n", " 'compsamp_snapshot',\n", " 'comp_na_annual_all',\n", " 'rq_all',\n", " 'infogroupsamp_business',\n", " 'infogroupsamp_residential',\n", " 'ktmine_patents_samp',\n", " 'djones_all',\n", " 'doe_all',\n", " 'factsamp_all',\n", " 'toyosamp_all',\n", " 'wrdsapps_eushort',\n", " 'wrdsapps_subsidiary',\n", " 'wrdsappssamp_all',\n", " 'wrdsapps_link_datastream_wscope',\n", " 'wrdsapps_patents',\n", " 'dmef_all',\n", " 'macrofin_comm_trade',\n", " 'mrktsamp_cds',\n", " 'pitchsmp',\n", " 'wrdsapps_link_comp_eushort',\n", " 'totalq_all',\n", " 'trsamp_dscom',\n", " 'trsamp_dsecon',\n", " 'wrdsapps_finratio',\n", " 'reprisk',\n", " 'comp',\n", " 'trcstsmp',\n", " 'rpnasamp',\n", " 'audit_corp_legal',\n", " 'csmar',\n", " 'trsamp_dsfut',\n", " 'wrdsapps_backtest_basic',\n", " 'wrdsapps_link_crsp_bond',\n", " 'ff_all',\n", " 'wrdsapps_link_crsp_taq',\n", " 'contrib_intangible_value',\n", " 'wrdssec',\n", " 'wrdsapps',\n", " 'audit_common',\n", " 'contrib_char_returns',\n", " 'crsp_q_indexhist',\n", " 'bvd',\n", " 'secsamp',\n", " 'factsamp_revere',\n", " 'frb_all',\n", " 'hbase_sample',\n", " 'hfrsamp_hfrdb',\n", " 'trown',\n", " 'lvnsamp_all',\n", " 'risksamp_all',\n", " 'optionmsamp_europe',\n", " 'optionmsamp_us',\n", " 'reprisk_sample',\n", " 'wrdsapps_finratio_ccm',\n", " 'trace_standard',\n", " 'trdstrm',\n", " 'trace_enhanced',\n", " 'fjc',\n", " 'lvnsamp',\n", " 'omtrial',\n", " 'trace',\n", " 'bvdsamp',\n", " 'djones',\n", " 'doe',\n", " 'frb',\n", " 'hfrsamp',\n", " 'macrofin',\n", " 'comp_bank',\n", " 'trsamp',\n", " 'wrdsapps_link_crsp_factset',\n", " 'twoiqsmp',\n", " 'comp_bank_daily',\n", " 'audit_audit_comp',\n", " 'comp_segments_hist_daily',\n", " 'otc_endofday',\n", " 'dealscan',\n", " 'ravenpack_trial',\n", " 'msfinst',\n", " 'crsp_a_indexes',\n", " 'taqmsamp',\n", " 'iss',\n", " 'sdc']" ] }, "metadata": {}, "execution_count": 6 } ] }, { "cell_type": "code", "source": [ "conn.list_tables(library='comp')" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "dM7RPF23ZUJg", "outputId": "0ab1ee06-c513-4f5a-fc89-7d882ce1ba35" }, "execution_count": 7, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "['aco_amda',\n", " 'aco_imda',\n", " 'aco_indfnta',\n", " 'aco_indfntq',\n", " 'aco_indfntytd',\n", " 'aco_indsta',\n", " 'aco_indstq',\n", " 'aco_indstytd',\n", " 'aco_notesa',\n", " 'aco_notesq',\n", " 'aco_notessa',\n", " 'aco_notesytd',\n", " 'aco_pnfnda',\n", " 'aco_pnfndq',\n", " 'aco_pnfndytd',\n", " 'aco_pnfnta',\n", " 'aco_pnfntq',\n", " 'aco_pnfntytd',\n", " 'aco_transa',\n", " 'aco_transq',\n", " 'aco_transsa',\n", " 'aco_transytd',\n", " 'adsprate',\n", " 'asec_amda',\n", " 'asec_imda',\n", " 'asec_notesa',\n", " 'asec_notesq',\n", " 'asec_transa',\n", " 'asec_transq',\n", " 'bank_aacctchg',\n", " 'bank_adesind',\n", " 'bank_afnd1',\n", " 'bank_afnd2',\n", " 'bank_afnddc1',\n", " 'bank_afnddc2',\n", " 'bank_afntind',\n", " 'bank_funda',\n", " 'bank_funda_fncd',\n", " 'bank_fundq',\n", " 'bank_fundq_fncd',\n", " 'bank_iacctchg',\n", " 'bank_idesind',\n", " 'bank_ifndq',\n", " 'bank_ifndytd',\n", " 'bank_ifntq',\n", " 'bank_ifntytd',\n", " 'bank_names',\n", " 'bank_namesq',\n", " 'chars',\n", " 'co_aacctchg',\n", " 'co_aaudit',\n", " 'co_adesind',\n", " 'co_adjfact',\n", " 'co_afnd1',\n", " 'co_afnd2',\n", " 'co_afnddc1',\n", " 'co_afnddc2',\n", " 'co_afntind1',\n", " 'co_afntind2',\n", " 'co_ainvval',\n", " 'co_amkt',\n", " 'co_busdescl',\n", " 'co_cotype',\n", " 'co_filedate',\n", " 'co_fortune',\n", " 'co_hgic',\n", " 'co_iacctchg',\n", " 'co_iaudit',\n", " 'co_idesind',\n", " 'co_ifndq',\n", " 'co_ifndsa',\n", " 'co_ifndytd',\n", " 'co_ifntq',\n", " 'co_ifntsa',\n", " 'co_ifntytd',\n", " 'co_imkt',\n", " 'co_industry',\n", " 'co_ipcd',\n", " 'co_mthly',\n", " 'co_offtitl',\n", " 'company',\n", " 'currency',\n", " 'dd_group',\n", " 'dd_group_xref',\n", " 'dd_item',\n", " 'dd_package',\n", " 'ecind_desc',\n", " 'ecind_mth',\n", " 'exrt_dly',\n", " 'exrt_mth',\n", " 'filings',\n", " 'funda',\n", " 'funda_fncd',\n", " 'fundq',\n", " 'fundq_fncd',\n", " 'g_chars',\n", " 'g_co_aaudit',\n", " 'g_co_adesind',\n", " 'g_co_afnd1',\n", " 'g_co_afnd2',\n", " 'g_co_afnddc1',\n", " 'g_co_afnddc2',\n", " 'g_co_afntind1',\n", " 'g_co_afntind2',\n", " 'g_co_ainvval',\n", " 'g_co_gsuppl',\n", " 'g_co_hgic',\n", " 'g_co_iaudit',\n", " 'g_co_idesind',\n", " 'g_co_ifndq',\n", " 'g_co_ifndsa',\n", " 'g_co_ifndytd',\n", " 'g_co_ifntq',\n", " 'g_co_ifntsa',\n", " 'g_co_ifntytd',\n", " 'g_co_industry',\n", " 'g_co_ipcd',\n", " 'g_co_offtitl',\n", " 'g_company',\n", " 'g_currency',\n", " 'g_ecind_desc',\n", " 'g_ecind_mth',\n", " 'g_exrt_dly',\n", " 'g_exrt_mth',\n", " 'g_funda',\n", " 'g_funda_fncd',\n", " 'g_fundq',\n", " 'g_fundq_fncd',\n", " 'g_idx_daily',\n", " 'g_idx_index',\n", " 'g_idx_mth',\n", " 'g_idxcst_his',\n", " 'g_names',\n", " 'g_names_ix',\n", " 'g_names_ix_cst',\n", " 'g_namesq',\n", " 'g_sec_adesind',\n", " 'g_sec_adjfact',\n", " 'g_sec_afnd',\n", " 'g_sec_afnddc',\n", " 'g_sec_afnt',\n", " 'g_sec_divid',\n", " 'g_sec_dprc',\n", " 'g_sec_dtrt',\n", " 'g_sec_history',\n", " 'g_sec_idesind',\n", " 'g_sec_ifnd',\n", " 'g_sec_ifnt',\n", " 'g_sec_split',\n", " 'g_secd',\n", " 'g_secnamesd',\n", " 'g_security',\n", " 'g_sedolgvkey',\n", " 'g_tmptable_pkg6153_tbl4023',\n", " 'idx_ann',\n", " 'idx_anndes',\n", " 'idx_daily',\n", " 'idx_index',\n", " 'idx_mth',\n", " 'idx_qrt',\n", " 'idx_qrtdes',\n", " 'idxcst_his',\n", " 'io_qaggregate',\n", " 'io_qbuysell',\n", " 'io_qchanges',\n", " 'io_qfloatadj',\n", " 'io_qholders',\n", " 'it_mbuysell',\n", " 'it_msummary',\n", " 'it_r_rltn',\n", " 'names',\n", " 'names_aco_indsta',\n", " 'names_aco_indstq',\n", " 'names_aco_pnfnda',\n", " 'names_aco_pnfndq',\n", " 'names_adsprate',\n", " 'names_ix',\n", " 'names_ix_cst',\n", " 'names_seg',\n", " 'namesd',\n", " 'namesm',\n", " 'namesq',\n", " 'r_accstd',\n", " 'r_acqmeth',\n", " 'r_auditors',\n", " 'r_auopic',\n", " 'r_balpres',\n", " 'r_cf_formt',\n", " 'r_co_status',\n", " 'r_coindpre',\n", " 'r_compstat',\n", " 'r_consol',\n", " 'r_country',\n", " 'r_cstclscd',\n", " 'r_datacode',\n", " 'r_datafmt',\n", " 'r_divtaxmarker',\n", " 'r_docsrce',\n", " 'r_ex_codes',\n", " 'r_exchgtier',\n", " 'r_exrt_typ',\n", " 'r_fndfntcd',\n", " 'r_footnts',\n", " 'r_foricd',\n", " 'r_giccd',\n", " 'r_hcalendr',\n", " 'r_idxclscd',\n", " 'r_inactvcd',\n", " 'r_incstats',\n", " 'r_indfmt',\n", " 'r_indsec',\n", " 'r_invval',\n", " 'r_issuetyp',\n", " 'r_majidxcl',\n", " 'r_mic_codes',\n", " 'r_naiccd',\n", " 'r_notetype',\n", " 'r_ntsubtype',\n", " 'r_offcrso',\n", " 'r_ogmethod',\n", " 'r_opinions',\n", " 'r_prc_stat',\n", " 'r_qsrcdoc',\n", " 'r_sec_stat',\n", " 'r_secannfn',\n", " 'r_sectors',\n", " 'r_siccd',\n", " 'r_spiicd',\n", " 'r_spmicd',\n", " 'r_statalrt',\n", " 'r_states',\n", " 'r_stko',\n", " 'r_titles',\n", " 'r_updates',\n", " 'sec_adesind',\n", " 'sec_adjfact',\n", " 'sec_afnd',\n", " 'sec_afnddc',\n", " 'sec_afnt',\n", " 'sec_divid',\n", " 'sec_dprc',\n", " 'sec_dtrt',\n", " 'sec_history',\n", " 'sec_idesind',\n", " 'sec_ifnd',\n", " 'sec_ifnt',\n", " 'sec_mdivfn',\n", " 'sec_mshare',\n", " 'sec_msptfn',\n", " 'sec_mth',\n", " 'sec_mthdiv',\n", " 'sec_mthprc',\n", " 'sec_mthspt',\n", " 'sec_mthtrt',\n", " 'sec_shortint',\n", " 'sec_spind',\n", " 'sec_split',\n", " 'secd',\n", " 'secm',\n", " 'security',\n", " 'sedolgvkey',\n", " 'seg_ann',\n", " 'seg_annfund',\n", " 'seg_customer',\n", " 'seg_geo',\n", " 'seg_naics',\n", " 'seg_product',\n", " 'seg_type',\n", " 'spidx_cst',\n", " 'spind',\n", " 'spind_dly',\n", " 'spind_mth',\n", " 'tmptable_pkg6153_tbl4023',\n", " 'wrds_seg_customer',\n", " 'wrds_seg_geo',\n", " 'wrds_seg_product',\n", " 'wrds_segmerged',\n", " 'xfl_column',\n", " 'xfl_table']" ] }, "metadata": {}, "execution_count": 7 } ] }, { "cell_type": "markdown", "source": [ "https://www.fredasongdrechsler.com/home" ], "metadata": { "id": "UfM8hjAwe3tk" } }, { "cell_type": "code", "source": [ "sp500 = conn.raw_sql(\"\"\"\n", " select a.*, b.date, b.ret\n", " from crsp.msp500list as a,\n", " crsp.msf as b\n", " where a.permno=b.permno\n", " and b.date >= a.start and b.date<= a.ending\n", " and b.date>='01/01/2000'\n", " order by date;\n", " \"\"\", date_cols=['start', 'ending', 'date'])" ], "metadata": { "id": "0C-0_6lbeTQT" }, "execution_count": 8, "outputs": [] }, { "cell_type": "code", "source": [ "sp500" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 424 }, "id": "v5QyVuSTeTNy", "outputId": "cca941f1-cae2-413a-d954-c2742e2e074a" }, "execution_count": 9, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " permno start ending date ret\n", "0 40416.0 1967-05-18 2015-03-20 2000-01-31 -0.035985\n", "1 44062.0 1967-06-29 2000-12-11 2000-01-31 -0.089202\n", "2 26403.0 1976-07-01 2022-03-31 2000-01-31 0.241453\n", "3 60628.0 1980-11-06 2022-03-31 2000-01-31 -0.033588\n", "4 69032.0 1995-09-22 2022-03-31 2000-01-31 -0.069002\n", "... ... ... ... ... ...\n", "133917 17478.0 1957-03-01 2022-03-31 2022-03-31 0.091775\n", "133918 91152.0 2016-06-03 2022-03-31 2022-03-31 -0.022578\n", "133919 24985.0 1991-09-20 2022-03-31 2022-03-31 0.097731\n", "133920 29946.0 1982-10-14 2022-03-31 2022-03-31 0.030331\n", "133921 17700.0 2021-09-20 2022-03-31 2022-03-31 -0.062406\n", "\n", "[133922 rows x 5 columns]" ], "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", "
permnostartendingdateret
040416.01967-05-182015-03-202000-01-31-0.035985
144062.01967-06-292000-12-112000-01-31-0.089202
226403.01976-07-012022-03-312000-01-310.241453
360628.01980-11-062022-03-312000-01-31-0.033588
469032.01995-09-222022-03-312000-01-31-0.069002
..................
13391717478.01957-03-012022-03-312022-03-310.091775
13391891152.02016-06-032022-03-312022-03-31-0.022578
13391924985.01991-09-202022-03-312022-03-310.097731
13392029946.01982-10-142022-03-312022-03-310.030331
13392117700.02021-09-202022-03-312022-03-31-0.062406
\n", "

133922 rows × 5 columns

\n", "
\n", " \n", " \n", " \n", "\n", " \n", "
\n", "
\n", " " ] }, "metadata": {}, "execution_count": 9 } ] }, { "cell_type": "code", "source": [ "# Add Other Descriptive Variables\n", "\n", "mse = conn.raw_sql(\"\"\"\n", " select comnam, ncusip, namedt, nameendt, \n", " permno, shrcd, exchcd, hsiccd, ticker\n", " from crsp.msenames\n", " \"\"\", date_cols=['namedt', 'nameendt'])\n", "\n", "# if nameendt is missing then set to today date\n", "mse['nameendt']=mse['nameendt'].fillna(pd.to_datetime('today'))\n", "\n", "# Merge with SP500 data\n", "sp500_full = pd.merge(sp500, mse, how = 'left', on = 'permno')\n", "\n", "# Impose the date range restrictions\n", "sp500_full = sp500_full.loc[(sp500_full.date>=sp500_full.namedt) \\\n", " & (sp500_full.date<=sp500_full.nameendt)]" ], "metadata": { "id": "Rg8pOwHOeTK5" }, "execution_count": 10, "outputs": [] }, { "cell_type": "code", "source": [ "# Linking with Compustat through CCM\n", "\n", "ccm=conn.raw_sql(\"\"\"\n", " select gvkey, liid as iid, lpermno as permno, linktype, linkprim, \n", " linkdt, linkenddt\n", " from crsp.ccmxpf_linktable\n", " where substr(linktype,1,1)='L'\n", " and (linkprim ='C' or linkprim='P')\n", " \"\"\", date_cols=['linkdt', 'linkenddt'])\n", "\n", "# if linkenddt is missing then set to today date\n", "ccm['linkenddt']=ccm['linkenddt'].fillna(pd.to_datetime('today'))\n", "\n", "# Merge the CCM data with S&P500 data\n", "# First just link by matching PERMNO\n", "sp500ccm = pd.merge(sp500_full, ccm, how='left', on=['permno'])\n", "\n", "# Then set link date bounds\n", "sp500ccm = sp500ccm.loc[(sp500ccm['date']>=sp500ccm['linkdt'])\\\n", " &(sp500ccm['date']<=sp500ccm['linkenddt'])]\n", "\n", "# Rearrange columns for final output\n", "\n", "sp500ccm = sp500ccm.drop(columns=['namedt', 'nameendt', \\\n", " 'linktype', 'linkprim', 'linkdt', 'linkenddt'])\n", "sp500ccm = sp500ccm[['date', 'permno', 'comnam', 'ncusip', 'shrcd', 'exchcd', 'hsiccd', 'ticker', \\\n", " 'gvkey', 'iid', 'start', 'ending', 'ret']]" ], "metadata": { "id": "Xz7smpk-eTIE" }, "execution_count": 11, "outputs": [] }, { "cell_type": "code", "source": [ "sp500ccm" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 468 }, "id": "0lnwq6mVeTFL", "outputId": "41e22e0b-3819-4c38-f1a7-3ea714b28898" }, "execution_count": 12, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " date permno comnam ncusip shrcd \\\n", "0 2000-01-31 40416.0 AVON PRODUCTS INC 05430310 11.0 \n", "1 2000-01-31 44062.0 SPRINGS INDUSTRIES INC 85178310 11.0 \n", "2 2000-01-31 26403.0 DISNEY WALT CO 25468710 11.0 \n", "3 2000-01-31 60628.0 FEDEX CORP 31428X10 11.0 \n", "4 2000-01-31 69032.0 MORGAN STANLEY DEAN WITTER & CO 61744644 11.0 \n", "... ... ... ... ... ... \n", "169638 2022-03-31 17478.0 S & P GLOBAL INC 78409V10 11.0 \n", "169639 2022-03-31 91152.0 TRANSDIGM GROUP INC 89364110 11.0 \n", "169641 2022-03-31 24985.0 AMEREN CORP 02360810 11.0 \n", "169642 2022-03-31 29946.0 BROWN FORMAN CORP 11563720 11.0 \n", "169643 2022-03-31 17700.0 CERIDIAN H C M HOLDING INC 15677J10 11.0 \n", "\n", " exchcd hsiccd ticker gvkey iid start ending ret \n", "0 1.0 2844.0 AVP 001920 01 1967-05-18 2015-03-20 -0.035985 \n", "1 1.0 2221.0 SMI 009963 01 1967-06-29 2000-12-11 -0.089202 \n", "2 1.0 4833.0 DIS 003980 01 1976-07-01 2022-03-31 0.241453 \n", "3 1.0 4513.0 FDX 004598 01 1980-11-06 2022-03-31 -0.033588 \n", "4 1.0 6282.0 MWD 012124 01 1995-09-22 2022-03-31 -0.069002 \n", "... ... ... ... ... .. ... ... ... \n", "169638 1.0 6282.0 SPGI 007163 01 1957-03-01 2022-03-31 0.091775 \n", "169639 1.0 3728.0 TDG 148349 01 2016-06-03 2022-03-31 -0.022578 \n", "169641 1.0 4911.0 AEE 010860 01 1991-09-20 2022-03-31 0.097731 \n", "169642 1.0 2085.0 BF 002435 01 1982-10-14 2022-03-31 0.030331 \n", "169643 1.0 7372.0 CDAY 023546 01 2021-09-20 2022-03-31 -0.062406 \n", "\n", "[133640 rows x 13 columns]" ], "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", "
datepermnocomnamncusipshrcdexchcdhsiccdtickergvkeyiidstartendingret
02000-01-3140416.0AVON PRODUCTS INC0543031011.01.02844.0AVP001920011967-05-182015-03-20-0.035985
12000-01-3144062.0SPRINGS INDUSTRIES INC8517831011.01.02221.0SMI009963011967-06-292000-12-11-0.089202
22000-01-3126403.0DISNEY WALT CO2546871011.01.04833.0DIS003980011976-07-012022-03-310.241453
32000-01-3160628.0FEDEX CORP31428X1011.01.04513.0FDX004598011980-11-062022-03-31-0.033588
42000-01-3169032.0MORGAN STANLEY DEAN WITTER & CO6174464411.01.06282.0MWD012124011995-09-222022-03-31-0.069002
..........................................
1696382022-03-3117478.0S & P GLOBAL INC78409V1011.01.06282.0SPGI007163011957-03-012022-03-310.091775
1696392022-03-3191152.0TRANSDIGM GROUP INC8936411011.01.03728.0TDG148349012016-06-032022-03-31-0.022578
1696412022-03-3124985.0AMEREN CORP0236081011.01.04911.0AEE010860011991-09-202022-03-310.097731
1696422022-03-3129946.0BROWN FORMAN CORP1156372011.01.02085.0BF002435011982-10-142022-03-310.030331
1696432022-03-3117700.0CERIDIAN H C M HOLDING INC15677J1011.01.07372.0CDAY023546012021-09-202022-03-31-0.062406
\n", "

133640 rows × 13 columns

\n", "
\n", " \n", " \n", " \n", "\n", " \n", "
\n", "
\n", " " ] }, "metadata": {}, "execution_count": 12 } ] }, { "cell_type": "code", "source": [ "sp500ccm.info()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "Qypm8Yz0g7cS", "outputId": "3ab4f255-5790-4fe7-cfe6-a1658135b962" }, "execution_count": 14, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "\n", "Int64Index: 133640 entries, 0 to 169643\n", "Data columns (total 13 columns):\n", " # Column Non-Null Count Dtype \n", "--- ------ -------------- ----- \n", " 0 date 133640 non-null datetime64[ns]\n", " 1 permno 133640 non-null float64 \n", " 2 comnam 133640 non-null object \n", " 3 ncusip 133640 non-null object \n", " 4 shrcd 133640 non-null float64 \n", " 5 exchcd 133640 non-null float64 \n", " 6 hsiccd 133640 non-null float64 \n", " 7 ticker 133640 non-null object \n", " 8 gvkey 133640 non-null object \n", " 9 iid 133640 non-null object \n", " 10 start 133640 non-null datetime64[ns]\n", " 11 ending 133640 non-null datetime64[ns]\n", " 12 ret 133576 non-null float64 \n", "dtypes: datetime64[ns](3), float64(5), object(5)\n", "memory usage: 14.3+ MB\n" ] } ] }, { "cell_type": "code", "source": [ "import pandas as pd\n", "table=pd.read_html('https://en.wikipedia.org/wiki/List_of_S%26P_500_companies')\n", "df = table[0]\n", "df" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 554 }, "id": "8UKm8-8ohnk6", "outputId": "c814e0a4-1da0-4491-99b5-445fbe8106cf" }, "execution_count": 16, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " Symbol Security SEC filings GICS Sector \\\n", "0 MMM 3M reports Industrials \n", "1 AOS A. O. Smith reports Industrials \n", "2 ABT Abbott reports Health Care \n", "3 ABBV AbbVie reports Health Care \n", "4 ABMD Abiomed reports Health Care \n", ".. ... ... ... ... \n", "498 YUM Yum! Brands reports Consumer Discretionary \n", "499 ZBRA Zebra Technologies reports Information Technology \n", "500 ZBH Zimmer Biomet reports Health Care \n", "501 ZION Zions Bancorporation reports Financials \n", "502 ZTS Zoetis reports Health Care \n", "\n", " GICS Sub-Industry Headquarters Location \\\n", "0 Industrial Conglomerates Saint Paul, Minnesota \n", "1 Building Products Milwaukee, Wisconsin \n", "2 Health Care Equipment North Chicago, Illinois \n", "3 Pharmaceuticals North Chicago, Illinois \n", "4 Health Care Equipment Danvers, Massachusetts \n", ".. ... ... \n", "498 Restaurants Louisville, Kentucky \n", "499 Electronic Equipment & Instruments Lincolnshire, Illinois \n", "500 Health Care Equipment Warsaw, Indiana \n", "501 Regional Banks Salt Lake City, Utah \n", "502 Pharmaceuticals Parsippany, New Jersey \n", "\n", " Date first added CIK Founded \n", "0 1976-08-09 66740 1902 \n", "1 2017-07-26 91142 1916 \n", "2 1964-03-31 1800 1888 \n", "3 2012-12-31 1551152 2013 (1888) \n", "4 2018-05-31 815094 1981 \n", ".. ... ... ... \n", "498 1997-10-06 1041061 1997 \n", "499 2019-12-23 877212 1969 \n", "500 2001-08-07 1136869 1927 \n", "501 2001-06-22 109380 1873 \n", "502 2013-06-21 1555280 1952 \n", "\n", "[503 rows x 9 columns]" ], "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", "
SymbolSecuritySEC filingsGICS SectorGICS Sub-IndustryHeadquarters LocationDate first addedCIKFounded
0MMM3MreportsIndustrialsIndustrial ConglomeratesSaint Paul, Minnesota1976-08-09667401902
1AOSA. O. SmithreportsIndustrialsBuilding ProductsMilwaukee, Wisconsin2017-07-26911421916
2ABTAbbottreportsHealth CareHealth Care EquipmentNorth Chicago, Illinois1964-03-3118001888
3ABBVAbbViereportsHealth CarePharmaceuticalsNorth Chicago, Illinois2012-12-3115511522013 (1888)
4ABMDAbiomedreportsHealth CareHealth Care EquipmentDanvers, Massachusetts2018-05-318150941981
..............................
498YUMYum! BrandsreportsConsumer DiscretionaryRestaurantsLouisville, Kentucky1997-10-0610410611997
499ZBRAZebra TechnologiesreportsInformation TechnologyElectronic Equipment & InstrumentsLincolnshire, Illinois2019-12-238772121969
500ZBHZimmer BiometreportsHealth CareHealth Care EquipmentWarsaw, Indiana2001-08-0711368691927
501ZIONZions BancorporationreportsFinancialsRegional BanksSalt Lake City, Utah2001-06-221093801873
502ZTSZoetisreportsHealth CarePharmaceuticalsParsippany, New Jersey2013-06-2115552801952
\n", "

503 rows × 9 columns

\n", "
\n", " \n", " \n", " \n", "\n", " \n", "
\n", "
\n", " " ] }, "metadata": {}, "execution_count": 16 } ] }, { "cell_type": "code", "source": [ "" ], "metadata": { "id": "Kw357GHLiKyE" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "import bs4 as bs\n", "import pickle\n", "import requests\n", "\n", "def save_sp500_tickers():\n", " resp = requests.get('http://en.wikipedia.org/wiki/List_of_S%26P_500_companies')\n", " soup = bs.BeautifulSoup(resp.text, 'lxml')\n", " table = soup.find('table', {'class': 'wikitable sortable'})\n", " tickers = []\n", " for row in table.findAll('tr')[1:]:\n", " ticker = row.findAll('td')[0].text\n", " tickers.append(ticker)\n", " \n", " with open(\"sp500tickers.pickle\",\"wb\") as f:\n", " pickle.dump(tickers,f)\n", " \n", " return tickers\n", "\n", "save_sp500_tickers()\n" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "IRgpZpYRhpxs", "outputId": "96c2335e-10e0-4f89-ade7-218d9075d5bc" }, "execution_count": 17, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "['MMM\\n',\n", " 'AOS\\n',\n", " 'ABT\\n',\n", " 'ABBV\\n',\n", " 'ABMD\\n',\n", " 'ACN\\n',\n", " 'ATVI\\n',\n", " 'ADM\\n',\n", " 'ADBE\\n',\n", " 'ADP\\n',\n", " 'AAP\\n',\n", " 'AES\\n',\n", " 'AFL\\n',\n", " 'A\\n',\n", " 'APD\\n',\n", " 'AKAM\\n',\n", " 'ALK\\n',\n", " 'ALB\\n',\n", " 'ARE\\n',\n", " 'ALGN\\n',\n", " 'ALLE\\n',\n", " 'LNT\\n',\n", " 'ALL\\n',\n", " 'GOOGL\\n',\n", " 'GOOG\\n',\n", " 'MO\\n',\n", " 'AMZN\\n',\n", " 'AMCR\\n',\n", " 'AMD\\n',\n", " 'AEE\\n',\n", " 'AAL\\n',\n", " 'AEP\\n',\n", " 'AXP\\n',\n", " 'AIG\\n',\n", " 'AMT\\n',\n", " 'AWK\\n',\n", " 'AMP\\n',\n", " 'ABC\\n',\n", " 'AME\\n',\n", " 'AMGN\\n',\n", " 'APH\\n',\n", " 'ADI\\n',\n", " 'ANSS\\n',\n", " 'ANTM\\n',\n", " 'AON\\n',\n", " 'APA\\n',\n", " 'AAPL\\n',\n", " 'AMAT\\n',\n", " 'APTV\\n',\n", " 'ANET\\n',\n", " 'AJG\\n',\n", " 'AIZ\\n',\n", " 'T\\n',\n", " 'ATO\\n',\n", " 'ADSK\\n',\n", " 'AZO\\n',\n", " 'AVB\\n',\n", " 'AVY\\n',\n", " 'BKR\\n',\n", " 'BALL\\n',\n", " 'BAC\\n',\n", " 'BBWI\\n',\n", " 'BAX\\n',\n", " 'BDX\\n',\n", " 'WRB\\n',\n", " 'BRK.B\\n',\n", " 'BBY\\n',\n", " 'BIO\\n',\n", " 'TECH\\n',\n", " 'BIIB\\n',\n", " 'BLK\\n',\n", " 'BK\\n',\n", " 'BA\\n',\n", " 'BKNG\\n',\n", " 'BWA\\n',\n", " 'BXP\\n',\n", " 'BSX\\n',\n", " 'BMY\\n',\n", " 'AVGO\\n',\n", " 'BR\\n',\n", " 'BRO\\n',\n", " 'BF.B\\n',\n", " 'CHRW\\n',\n", " 'CDNS\\n',\n", " 'CZR\\n',\n", " 'CPT\\n',\n", " 'CPB\\n',\n", " 'COF\\n',\n", " 'CAH\\n',\n", " 'KMX\\n',\n", " 'CCL\\n',\n", " 'CARR\\n',\n", " 'CTLT\\n',\n", " 'CAT\\n',\n", " 'CBOE\\n',\n", " 'CBRE\\n',\n", " 'CDW\\n',\n", " 'CE\\n',\n", " 'CNC\\n',\n", " 'CNP\\n',\n", " 'CDAY\\n',\n", " 'CF\\n',\n", " 'CRL\\n',\n", " 'SCHW\\n',\n", " 'CHTR\\n',\n", " 'CVX\\n',\n", " 'CMG\\n',\n", " 'CB\\n',\n", " 'CHD\\n',\n", " 'CI\\n',\n", " 'CINF\\n',\n", " 'CTAS\\n',\n", " 'CSCO\\n',\n", " 'C\\n',\n", " 'CFG\\n',\n", " 'CTXS\\n',\n", " 'CLX\\n',\n", " 'CME\\n',\n", " 'CMS\\n',\n", " 'KO\\n',\n", " 'CTSH\\n',\n", " 'CL\\n',\n", " 'CMCSA\\n',\n", " 'CMA\\n',\n", " 'CAG\\n',\n", " 'COP\\n',\n", " 'ED\\n',\n", " 'STZ\\n',\n", " 'CEG\\n',\n", " 'COO\\n',\n", " 'CPRT\\n',\n", " 'GLW\\n',\n", " 'CTVA\\n',\n", " 'COST\\n',\n", " 'CTRA\\n',\n", " 'CCI\\n',\n", " 'CSX\\n',\n", " 'CMI\\n',\n", " 'CVS\\n',\n", " 'DHI\\n',\n", " 'DHR\\n',\n", " 'DRI\\n',\n", " 'DVA\\n',\n", " 'DE\\n',\n", " 'DAL\\n',\n", " 'XRAY\\n',\n", " 'DVN\\n',\n", " 'DXCM\\n',\n", " 'FANG\\n',\n", " 'DLR\\n',\n", " 'DFS\\n',\n", " 'DISH\\n',\n", " 'DIS\\n',\n", " 'DG\\n',\n", " 'DLTR\\n',\n", " 'D\\n',\n", " 'DPZ\\n',\n", " 'DOV\\n',\n", " 'DOW\\n',\n", " 'DTE\\n',\n", " 'DUK\\n',\n", " 'DRE\\n',\n", " 'DD\\n',\n", " 'DXC\\n',\n", " 'EMN\\n',\n", " 'ETN\\n',\n", " 'EBAY\\n',\n", " 'ECL\\n',\n", " 'EIX\\n',\n", " 'EW\\n',\n", " 'EA\\n',\n", " 'LLY\\n',\n", " 'EMR\\n',\n", " 'ENPH\\n',\n", " 'ETR\\n',\n", " 'EOG\\n',\n", " 'EPAM\\n',\n", " 'EFX\\n',\n", " 'EQIX\\n',\n", " 'EQR\\n',\n", " 'ESS\\n',\n", " 'EL\\n',\n", " 'ETSY\\n',\n", " 'RE\\n',\n", " 'EVRG\\n',\n", " 'ES\\n',\n", " 'EXC\\n',\n", " 'EXPE\\n',\n", " 'EXPD\\n',\n", " 'EXR\\n',\n", " 'XOM\\n',\n", " 'FFIV\\n',\n", " 'FDS\\n',\n", " 'FAST\\n',\n", " 'FRT\\n',\n", " 'FDX\\n',\n", " 'FITB\\n',\n", " 'FRC\\n',\n", " 'FE\\n',\n", " 'FIS\\n',\n", " 'FISV\\n',\n", " 'FLT\\n',\n", " 'FMC\\n',\n", " 'F\\n',\n", " 'FTNT\\n',\n", " 'FTV\\n',\n", " 'FBHS\\n',\n", " 'FOXA\\n',\n", " 'FOX\\n',\n", " 'BEN\\n',\n", " 'FCX\\n',\n", " 'GRMN\\n',\n", " 'IT\\n',\n", " 'GNRC\\n',\n", " 'GD\\n',\n", " 'GE\\n',\n", " 'GIS\\n',\n", " 'GM\\n',\n", " 'GPC\\n',\n", " 'GILD\\n',\n", " 'GL\\n',\n", " 'GPN\\n',\n", " 'GS\\n',\n", " 'HAL\\n',\n", " 'HIG\\n',\n", " 'HAS\\n',\n", " 'HCA\\n',\n", " 'PEAK\\n',\n", " 'HSIC\\n',\n", " 'HSY\\n',\n", " 'HES\\n',\n", " 'HPE\\n',\n", " 'HLT\\n',\n", " 'HOLX\\n',\n", " 'HD\\n',\n", " 'HON\\n',\n", " 'HRL\\n',\n", " 'HST\\n',\n", " 'HWM\\n',\n", " 'HPQ\\n',\n", " 'HUM\\n',\n", " 'HBAN\\n',\n", " 'HII\\n',\n", " 'IBM\\n',\n", " 'IEX\\n',\n", " 'IDXX\\n',\n", " 'ITW\\n',\n", " 'ILMN\\n',\n", " 'INCY\\n',\n", " 'IR\\n',\n", " 'INTC\\n',\n", " 'ICE\\n',\n", " 'IP\\n',\n", " 'IPG\\n',\n", " 'IFF\\n',\n", " 'INTU\\n',\n", " 'ISRG\\n',\n", " 'IVZ\\n',\n", " 'IQV\\n',\n", " 'IRM\\n',\n", " 'JBHT\\n',\n", " 'JKHY\\n',\n", " 'J\\n',\n", " 'JNJ\\n',\n", " 'JCI\\n',\n", " 'JPM\\n',\n", " 'JNPR\\n',\n", " 'K\\n',\n", " 'KDP\\n',\n", " 'KEY\\n',\n", " 'KEYS\\n',\n", " 'KMB\\n',\n", " 'KIM\\n',\n", " 'KMI\\n',\n", " 'KLAC\\n',\n", " 'KHC\\n',\n", " 'KR\\n',\n", " 'LHX\\n',\n", " 'LH\\n',\n", " 'LRCX\\n',\n", " 'LW\\n',\n", " 'LVS\\n',\n", " 'LDOS\\n',\n", " 'LEN\\n',\n", " 'LNC\\n',\n", " 'LIN\\n',\n", " 'LYV\\n',\n", " 'LKQ\\n',\n", " 'LMT\\n',\n", " 'L\\n',\n", " 'LOW\\n',\n", " 'LUMN\\n',\n", " 'LYB\\n',\n", " 'MTB\\n',\n", " 'MRO\\n',\n", " 'MPC\\n',\n", " 'MKTX\\n',\n", " 'MAR\\n',\n", " 'MMC\\n',\n", " 'MLM\\n',\n", " 'MAS\\n',\n", " 'MA\\n',\n", " 'MTCH\\n',\n", " 'MKC\\n',\n", " 'MCD\\n',\n", " 'MCK\\n',\n", " 'MDT\\n',\n", " 'MRK\\n',\n", " 'META\\n',\n", " 'MET\\n',\n", " 'MTD\\n',\n", " 'MGM\\n',\n", " 'MCHP\\n',\n", " 'MU\\n',\n", " 'MSFT\\n',\n", " 'MAA\\n',\n", " 'MRNA\\n',\n", " 'MHK\\n',\n", " 'MOH\\n',\n", " 'TAP\\n',\n", " 'MDLZ\\n',\n", " 'MPWR\\n',\n", " 'MNST\\n',\n", " 'MCO\\n',\n", " 'MS\\n',\n", " 'MOS\\n',\n", " 'MSI\\n',\n", " 'MSCI\\n',\n", " 'NDAQ\\n',\n", " 'NTAP\\n',\n", " 'NFLX\\n',\n", " 'NWL\\n',\n", " 'NEM\\n',\n", " 'NWSA\\n',\n", " 'NWS\\n',\n", " 'NEE\\n',\n", " 'NLSN\\n',\n", " 'NKE\\n',\n", " 'NI\\n',\n", " 'NDSN\\n',\n", " 'NSC\\n',\n", " 'NTRS\\n',\n", " 'NOC\\n',\n", " 'NLOK\\n',\n", " 'NCLH\\n',\n", " 'NRG\\n',\n", " 'NUE\\n',\n", " 'NVDA\\n',\n", " 'NVR\\n',\n", " 'NXPI\\n',\n", " 'ORLY\\n',\n", " 'OXY\\n',\n", " 'ODFL\\n',\n", " 'OMC\\n',\n", " 'ON\\n',\n", " 'OKE\\n',\n", " 'ORCL\\n',\n", " 'OGN\\n',\n", " 'OTIS\\n',\n", " 'PCAR\\n',\n", " 'PKG\\n',\n", " 'PARA\\n',\n", " 'PH\\n',\n", " 'PAYX\\n',\n", " 'PAYC\\n',\n", " 'PYPL\\n',\n", " 'PENN\\n',\n", " 'PNR\\n',\n", " 'PEP\\n',\n", " 'PKI\\n',\n", " 'PFE\\n',\n", " 'PM\\n',\n", " 'PSX\\n',\n", " 'PNW\\n',\n", " 'PXD\\n',\n", " 'PNC\\n',\n", " 'POOL\\n',\n", " 'PPG\\n',\n", " 'PPL\\n',\n", " 'PFG\\n',\n", " 'PG\\n',\n", " 'PGR\\n',\n", " 'PLD\\n',\n", " 'PRU\\n',\n", " 'PEG\\n',\n", " 'PTC\\n',\n", " 'PSA\\n',\n", " 'PHM\\n',\n", " 'PVH\\n',\n", " 'QRVO\\n',\n", " 'PWR\\n',\n", " 'QCOM\\n',\n", " 'DGX\\n',\n", " 'RL\\n',\n", " 'RJF\\n',\n", " 'RTX\\n',\n", " 'O\\n',\n", " 'REG\\n',\n", " 'REGN\\n',\n", " 'RF\\n',\n", " 'RSG\\n',\n", " 'RMD\\n',\n", " 'RHI\\n',\n", " 'ROK\\n',\n", " 'ROL\\n',\n", " 'ROP\\n',\n", " 'ROST\\n',\n", " 'RCL\\n',\n", " 'SPGI\\n',\n", " 'CRM\\n',\n", " 'SBAC\\n',\n", " 'SLB\\n',\n", " 'STX\\n',\n", " 'SEE\\n',\n", " 'SRE\\n',\n", " 'NOW\\n',\n", " 'SHW\\n',\n", " 'SBNY\\n',\n", " 'SPG\\n',\n", " 'SWKS\\n',\n", " 'SJM\\n',\n", " 'SNA\\n',\n", " 'SEDG\\n',\n", " 'SO\\n',\n", " 'LUV\\n',\n", " 'SWK\\n',\n", " 'SBUX\\n',\n", " 'STT\\n',\n", " 'STE\\n',\n", " 'SYK\\n',\n", " 'SIVB\\n',\n", " 'SYF\\n',\n", " 'SNPS\\n',\n", " 'SYY\\n',\n", " 'TMUS\\n',\n", " 'TROW\\n',\n", " 'TTWO\\n',\n", " 'TPR\\n',\n", " 'TGT\\n',\n", " 'TEL\\n',\n", " 'TDY\\n',\n", " 'TFX\\n',\n", " 'TER\\n',\n", " 'TSLA\\n',\n", " 'TXN\\n',\n", " 'TXT\\n',\n", " 'TMO\\n',\n", " 'TJX\\n',\n", " 'TSCO\\n',\n", " 'TT\\n',\n", " 'TDG\\n',\n", " 'TRV\\n',\n", " 'TRMB\\n',\n", " 'TFC\\n',\n", " 'TWTR\\n',\n", " 'TYL\\n',\n", " 'TSN\\n',\n", " 'USB\\n',\n", " 'UDR\\n',\n", " 'ULTA\\n',\n", " 'UNP\\n',\n", " 'UAL\\n',\n", " 'UPS\\n',\n", " 'URI\\n',\n", " 'UNH\\n',\n", " 'UHS\\n',\n", " 'VLO\\n',\n", " 'VTR\\n',\n", " 'VRSN\\n',\n", " 'VRSK\\n',\n", " 'VZ\\n',\n", " 'VRTX\\n',\n", " 'VFC\\n',\n", " 'VTRS\\n',\n", " 'VICI\\n',\n", " 'V\\n',\n", " 'VNO\\n',\n", " 'VMC\\n',\n", " 'WAB\\n',\n", " 'WBA\\n',\n", " 'WMT\\n',\n", " 'WBD\\n',\n", " 'WM\\n',\n", " 'WAT\\n',\n", " 'WEC\\n',\n", " 'WFC\\n',\n", " 'WELL\\n',\n", " 'WST\\n',\n", " 'WDC\\n',\n", " 'WRK\\n',\n", " 'WY\\n',\n", " 'WHR\\n',\n", " 'WMB\\n',\n", " 'WTW\\n',\n", " 'GWW\\n',\n", " 'WYNN\\n',\n", " 'XEL\\n',\n", " 'XYL\\n',\n", " 'YUM\\n',\n", " 'ZBRA\\n',\n", " 'ZBH\\n',\n", " 'ZION\\n',\n", " 'ZTS\\n']" ] }, "metadata": {}, "execution_count": 17 } ] }, { "cell_type": "code", "source": [ "" ], "metadata": { "id": "abhVpvPLiSBf" }, "execution_count": null, "outputs": [] } ] }