Real Estate Investment Trust Analysis Investment - GitHub

Here is the Git Hub link to the work I did on this project:

In case this is more helpful (or what we are supposed to post), here is the “raw file”:

{
“cells”: [
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“# REIT STOCK ANALYSIS”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“In this project, you will analyze Real Estate Investment Trusts, commonly known as REITs. REITs are companies that own or operate real estate that produces income. REITs, like the stocks of regular public companies, are traded on different stock exchanges. Investing in a REIT allows you to invest in portfolios of real estate assets the same way you can invest in a company by buying its stock.\n”,
“\n”,
“Using financial statistics and NumPy you will analyze two REITs: Sabra Health Care REIT Inc. (NASDAQ: SBRA), which invests in health care real estate, and Equity Residential (NASDAQ:EQR), which invests in rental apartment properties.”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“The time period for analysis we will be using is Jan 1 2018 to Dec 31 2018. The REIT data for SBRA (SBRA.csv) and EQR (EQR.csv) can be found in the same folder as this file.”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“1. Import the numpy module as np”
]
},
{
“cell_type”: “code”,
“execution_count”: 6,
“metadata”: {},
“outputs”: ,
“source”: [
“import numpy as np\n”,
“import csv”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“2. Load the adjusted closings for SBRA”
]
},
{
“cell_type”: “code”,
“execution_count”: 14,
“metadata”: {},
“outputs”: [
{
“name”: “stdout”,
“output_type”: “stream”,
“text”: [
“[15.36233 16.012386 16.528606 16.882313 17.427212 17.522808 17.513248\n”,
" 17.427212 17.264698 17.417652 17.847836 18.105947 18.344938 18.306698\n",
" 18.497892 18.77512 19.09059 19.386936 19.377378 19.55901 19.635489\n",
" 19.425177 19.664167 19.539892 19.635489 19.80756 19.654606 19.60681\n",
" 19.358257 19.32958 19.339357 19.544678 19.388243 19.241585 19.222029\n",
" 19.143812 18.635395 18.381187 18.038986 17.716337 17.31547 17.247028\n",
" 17.256807 17.149258 17.119926 17.071039 17.383911 17.608788 17.941214\n",
" 17.970543 17.892326 17.726112 17.765223 17.980322 18.58651 18.293192\n",
" 18.449629 18.762501 18.870049 19.192698 19.036261 18.899382 18.879826\n",
" 18.694059 18.762501 18.958044 18.870049 18.801609 19.04604 19.241585\n",
" 19.241585 19.222029 18.821163 18.361633 18.713614 18.410519 18.713614\n",
" 18.909159 18.909159 19.153589 18.967821 19.124256 19.094927 19.143812\n",
" 19.554455 19.456682 19.143812 19.319801 18.840717 19.310024 19.241585\n",
" 19.417574 19.574011 19.75 19.709999 19.530001 19.73 19.700001\n",
" 19.709999 19.75 19.540001 19.219999 19.370001 19.290001 19.24\n",
" 19.1 19.32 19.450001 19.49 19.32 19.290001 19.32\n",
" 19.48 19.43 19.790001 19.58 20.139999 20.049999 19.57\n",
" 19.309999 19.26 18.870001 19.450001 19.690001]\n"
]
}
],
“source”: [
“with open(‘SBRA.csv’, ‘r’) as file:\n”,
" csv_reader = csv.reader(file)\n",
" for row in csv_reader:\n",
" #print(row)\n",
" pass\n",
" \n",
“adj_closings_sbra = np.genfromtxt(‘SBRA.csv’, delimiter=‘,’, skip_header=1, usecols=5)\n”,
“print(adj_closings_sbra)”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“3. Load the adjusted closings for EQR”
]
},
{
“cell_type”: “code”,
“execution_count”: 15,
“metadata”: {},
“outputs”: [
{
“name”: “stdout”,
“output_type”: “stream”,
“text”: [
“[62.800674 63.19466 63.588642 64.120514 65.322166 65.322166 66.395767\n”,
" 66.533653 66.61245 67.429955 68.040634 68.858147 69.064987 69.340775\n",
" 69.28167 69.291527 69.606705 70.640915 71.281136 70.916695 71.468269\n",
" 70.936401 71.694817 71.852402 71.901649 72.433533 72.335037 72.354729\n",
" 71.448578 72.187286 72.019852 72.10849 72.423676 71.586472 72.748718\n",
" 73.113152 72.394127 72.610817 72.226692 72.581276 72.394127 72.866913\n",
" 72.817657 72.443382 72.325188 72.532021 73.319992 73.920807 73.782921\n",
" 73.930656 73.635178 72.866913 72.394127 72.512329 73.664719 73.841385\n",
" 73.910858 74.575829 74.41703 75.062149 74.754478 74.41703 75.121704\n",
" 74.823952 74.714775 75.042297 74.992676 74.823952 75.776741 76.114189\n",
" 76.868484 77.017357 75.1614 73.732208 74.506355 73.613106 74.397179\n",
" 74.903351 75.399597 75.627869 74.734627 75.846214 75.945465 75.82637\n",
" 76.014938 75.637794 74.208603 73.881088 74.258232 75.260651 75.270569\n",
" 75.240791 75.61795 76.233284 76.044716 75.181252 75.786667 76.064568\n",
" 76.531036 76.610435 75.637794 75.101845 75.250725 75.995094 75.667564\n",
" 74.913277 76.669983 77.205933 77.394508 77.245636 77.215858 77.066986\n",
" 77.344879 77.672401 78.079323 77.463982 77.841125 78.238121 77.44413\n",
" 77.682327 76.332542 75.082001 75.610001 75.919998]\n"
]
}
],
“source”: [
“adj_closings_eqr = np.genfromtxt(‘EQR.csv’, delimiter=‘,’, skip_header=1, usecols=5)\n”,
“print(adj_closings_eqr)”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Simple Rate of Return Function”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“4. To calculate the daily rate of return for the SBRA stock, we need the daily adjusted closing price. The formula we are using for the daily rate of return is out[n] = a[n+1] - a[n] "
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“5. Create a function that returns the daily rate of return\n”,
“\n”,
" step 1. define a function named rate_of_return\n”,
" \n",
" step 2. create parameter for adj_closings\n",
" \n",
" step 3. Within the function use np.diff() and set it to the variable daily_simple_ror\n",
" \n",
" step 4. return daily_simple_ror"
]
},
{
“cell_type”: “code”,
“execution_count”: 22,
“metadata”: {},
“outputs”: ,
“source”: [
“def simple_rate_of_return(adj_closings):\n”,
" daily_simple_ror = np.diff(adj_closings)/adj_closings[:-1]\n",
" return daily_simple_ror"
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Calculate Daily Rate of Return for SBRA”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“6. Call the function simple_rate_of_return with the arguments adj_closings_sbra. Then print the results. "
]
},
{
“cell_type”: “code”,
“execution_count”: 23,
“metadata”: {},
“outputs”: [
{
“name”: “stdout”,
“output_type”: “stream”,
“text”: [
“[ 0.04231494 0.03223879 0.02139969 0.03227632 0.00548544 -0.00054557\n”,
" -0.00491262 -0.0093253 0.00885935 0.02469816 0.01446175 0.01319959\n”,
" -0.0020845 0.01044394 0.01498701 0.01680256 0.01552315 -0.00049301\n",
" 0.0093734 0.00391017 -0.01071081 0.01230311 -0.00631987 0.0048924\n",
" 0.00876327 -0.007722 -0.0024318 -0.01267687 -0.00148138 0.00050581\n",
" 0.01061674 -0.00800397 -0.00756427 -0.00101634 -0.00406913 -0.02655777\n",
" -0.01364114 -0.01861692 -0.0178862 -0.02262697 -0.00395265 0.000567\n",
" -0.00623227 -0.00171039 -0.00285556 0.01832765 0.01293593 0.01887841\n",
" 0.00163473 -0.00435251 -0.00928968 0.00220641 0.01210787 0.03371397\n",
" -0.01578123 0.00855165 0.01695817 0.00573207 0.01709847 -0.00815086\n",
" -0.00719044 -0.00103474 -0.00983944 0.00366116 0.01042201 -0.00464157\n",
" -0.00362691 0.01300054 0.01026696 0. -0.00101634 -0.02085451\n",
" -0.0244156 0.01916937 -0.0161965 0.01646314 0.01044934 0.\n",
" 0.01292654 -0.00969886 0.00824739 -0.0015336 0.0025601 0.02145043\n",
" -0.00500004 -0.01608034 0.009193 -0.02479756 0.02490919 -0.00354422\n",
" 0.00914628 0.00805646 0.00899095 -0.00202537 -0.00913232 0.0102406\n",
" -0.00152048 0.00050751 0.00202948 -0.01063286 -0.01637676 0.00780447\n",
" -0.0041301 -0.00259207 -0.00727651 0.01151832 0.00672883 0.0020565\n",
" -0.00872242 -0.00155274 0.00155516 0.00828157 -0.00256674 0.0185281\n",
" -0.01061147 0.02860056 -0.00446872 -0.0239401 -0.01328569 -0.00258928\n",
" -0.02024917 0.03073662 0.01233933]\n"
]
}
],
“source”: [
“sbra_daily_simple_ror = simple_rate_of_return(adj_closings_sbra)\n”,
“print(daily_simple_ror)”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Calculate Daily Rate of Return for EQR”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“7. Call the function simple_rate_of_return with the arguments adj_closings_eqr. Then print the results. "
]
},
{
“cell_type”: “code”,
“execution_count”: 24,
“metadata”: {
“scrolled”: true
},
“outputs”: [
{
“name”: “stdout”,
“output_type”: “stream”,
“text”: [
“[ 0.0062736 0.00623442 0.00836426 0.01874052 0. 0.01643548\n”,
" 0.00207673 0.00118432 0.01227256 0.00905649 0.01201507 0.00300386\n”,
" 0.00399317 -0.00085238 0.00014227 0.00454858 0.01485791 0.00906303\n",
" -0.00511273 0.00777777 -0.00744202 0.01069149 0.002198 0.00068539\n",
" 0.00739738 -0.00135981 0.00027223 -0.01252373 0.01033902 -0.00231944\n",
" 0.00123074 0.004371 -0.01155981 0.01623555 0.00500949 -0.00983441\n",
" 0.0029932 -0.00529019 0.00490932 -0.00257847 0.00653072 -0.00067597\n",
" -0.00513989 -0.00163154 0.00285976 0.01086377 0.00819442 -0.00186532\n",
" 0.00200229 -0.00399669 -0.0104334 -0.00648835 0.00163276 0.01589233\n",
" 0.00239824 0.00094084 0.00899693 -0.00212936 0.00866897 -0.00409888\n",
" -0.00451408 0.00946926 -0.00396359 -0.00145912 0.00438363 -0.00066124\n",
" -0.00224987 0.01273374 0.00445319 0.00991004 0.00193672 -0.02409791\n",
" -0.01901497 0.01049944 -0.0119889 0.01065127 0.00680365 0.00662515\n",
" 0.0030275 -0.01181102 0.01487379 0.00130858 -0.00156816 0.00248684\n",
" -0.00496145 -0.0188952 -0.00441344 0.00510474 0.0134991 0.00013178\n",
" -0.00039561 0.00501269 0.00813741 -0.00247357 -0.01135469 0.00805274\n",
" 0.00366689 0.00613253 0.00103747 -0.01269593 -0.00708573 0.00198237\n",
" 0.00989185 -0.00430988 -0.00996843 0.02344986 0.00699035 0.00244249\n",
" -0.00192355 -0.0003855 -0.001928 0.00360586 0.00423457 0.00523895\n",
" -0.00788097 0.00486862 0.00510008 -0.01014839 0.00307573 -0.0173757\n",
" -0.0163828 0.00703231 0.00409995]\n"
]
}
],
“source”: [
“eqr_daily_simple_ror = simple_rate_of_return(adj_closings_eqr)\n”,
“print(eqr_daily_simple_ror)”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Calculate Average Daily Return for SBRA”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“8. Use np.mean() with the argument daily_simple_returns_sbra to calculate the average daily return for SBRA. Then set it to the variable name average_daily_simple_return_sbra
]
},
{
“cell_type”: “code”,
“execution_count”: 26,
“metadata”: {},
“outputs”: [
{
“name”: “stdout”,
“output_type”: “stream”,
“text”: [
“0.00210937212011956\n”
]
}
],
“source”: [
“average_daily_simple_return_sbra = np.mean(sbra_daily_simple_ror)\n”,
“print(average_daily_simple_return_sbra)”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Calculate Average Daily Return for EQR”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“9. Use np.mean() with the argument daily_simple_returns_eqr to calculate the average daily return for EQR. Then set it to the variable name average_daily_simple_return_eqr
]
},
{
“cell_type”: “code”,
“execution_count”: 28,
“metadata”: {},
“outputs”: [
{
“name”: “stdout”,
“output_type”: “stream”,
“text”: [
“0.0015777637451981398\n”
]
}
],
“source”: [
“average_daily_simple_return_eqr = np.mean(eqr_daily_simple_ror)\n”,
“print(average_daily_simple_return_eqr)”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Compare the Average Daily Return between EQR and SBRA”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“10. Based on the average daily simple returns of EQR and SBRA, which stock is more likely to be profitable in the future?”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”:
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Daily Log Returns Function”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“11. Create a function that returns the daily rate of return\n”,
“\n”,
" step 1. define a function named log_returns\n",
" \n",
" step 2. create parameter for adj_closings\n",
" \n",
" step 3. use np.log() to get the log of each adjusted closing price and set it to the variable log_adj_closings\n",
" \n",
" step 4. use np.diff() to get the diff of each daily log adjusted closing price and set it to the variable daily_log_returns\n",
" \n",
" step 5. return daily_log_returns"
]
},
{
“cell_type”: “code”,
“execution_count”: 29,
“metadata”: {},
“outputs”: ,
“source”: [
“def log_returns(adj_closings):\n”,
" log_adj_closings = np.log(adj_closings)\n",
" daily_log_returns = np.diff(log_adj_closings)\n",
" return daily_log_returns"
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Calculate Daily Log Returns for SBRA”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“12. Call the function log_returns with the arguments adj_closings_sbra. Set it to the variable daily_log_returns_sbra. Then print the results. "
]
},
{
“cell_type”: “code”,
“execution_count”: 33,
“metadata”: {
“scrolled”: true
},
“outputs”: [
{
“name”: “stdout”,
“output_type”: “stream”,
“text”: [
“[ 0.04144414 0.03173003 0.02117393 0.03176639 0.00547045 -0.00054572\n”,
" -0.00492473 -0.00936905 0.00882034 0.02439809 0.01435818 0.01311323\n”,
" -0.00208667 0.01038978 0.01487581 0.01666295 0.01540389 -0.00049313\n",
" 0.00932975 0.00390254 -0.01076858 0.01222804 -0.00633993 0.00488047\n",
" 0.00872509 -0.00775197 -0.00243476 -0.01275791 -0.00148248 0.00050568\n",
" 0.01056078 -0.00803617 -0.00759303 -0.00101686 -0.00407743 -0.0269168\n",
" -0.01373503 -0.01879239 -0.0180481 -0.02288689 -0.00396048 0.00056684\n",
" -0.00625177 -0.00171186 -0.00285965 0.01816172 0.01285297 0.01870243\n",
" 0.00163339 -0.00436201 -0.0093331 0.00220398 0.01203516 0.03315811\n",
" -0.01590708 0.00851529 0.01681599 0.00571571 0.01695394 -0.00818426\n",
" -0.00721641 -0.00103528 -0.00988817 0.00365448 0.01036808 -0.00465237\n",
" -0.0036335 0.01291675 0.01021462 0. -0.00101686 -0.02107504\n",
" -0.0247186 0.01898796 -0.01632909 0.01632909 0.01039513 0.\n",
" 0.01284371 -0.0097462 0.00821357 -0.00153478 0.00255683 0.02122361\n",
" -0.00501258 -0.01621103 0.009151 -0.0251102 0.02460401 -0.00355052\n",
" 0.00910471 0.00802418 0.00895077 -0.00202742 -0.00917427 0.01018852\n",
" -0.00152163 0.00050738 0.00202742 -0.01068979 -0.01651235 0.00777418\n",
" -0.00413865 -0.00259543 -0.00730311 0.01145249 0.00670629 0.00205439\n",
" -0.00876068 -0.00155395 0.00155395 0.00824747 -0.00257003 0.01835855\n",
" -0.01066817 0.0281992 -0.00447873 -0.02423132 -0.01337474 -0.00259264\n",
" -0.02045699 0.03027371 0.01226382]\n"
]
}
],
“source”: [
“daily_log_returns_sbra = log_returns(adj_closings_sbra)\n”,
“print(daily_log_returns_sbra)”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Calculate Daily Log Returns for EQR”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“13. Call the function log_returns with the arguments adj_closings_eqr. Set it to the variable daily_log_returns_eqr. Then print the results. "
]
},
{
“cell_type”: “code”,
“execution_count”: 34,
“metadata”: {},
“outputs”: [
{
“name”: “stdout”,
“output_type”: “stream”,
“text”: [
“[ 0.006254 0.00621507 0.00832947 0.01856708 0. 0.01630188\n”,
" 0.00207458 0.00118362 0.01219786 0.00901573 0.01194346 0.00299935\n”,
" 0.00398522 -0.00085275 0.00014226 0.00453827 0.01474861 0.00902221\n",
" -0.00512584 0.00774768 -0.00746985 0.01063474 0.00219559 0.00068516\n",
" 0.00737016 -0.00136074 0.0002722 -0.01260281 0.01028593 -0.00232213\n",
" 0.00122999 0.00436147 -0.01162714 0.01610517 0.00499698 -0.00988309\n",
" 0.00298873 -0.00530423 0.00489731 -0.0025818 0.00650949 -0.0006762\n",
" -0.00515315 -0.00163287 0.00285568 0.01080518 0.00816103 -0.00186706\n",
" 0.00200029 -0.0040047 -0.01048821 -0.00650949 0.00163143 0.01576737\n",
" 0.00239537 0.0009404 0.0089567 -0.00213163 0.00863161 -0.00410731\n",
" -0.0045243 0.0094247 -0.00397147 -0.00146018 0.00437405 -0.00066146\n",
" -0.00225241 0.01265335 0.0044433 0.00986126 0.00193485 -0.02439301\n",
" -0.01919808 0.01044471 -0.01206134 0.01059494 0.0067806 0.0066033\n",
" 0.00302292 -0.01188132 0.01476426 0.00130773 -0.0015694 0.00248375\n",
" -0.00497379 -0.01907599 -0.00442321 0.00509176 0.01340879 0.00013177\n",
" -0.00039569 0.00500017 0.00810448 -0.00247663 -0.01141964 0.00802049\n",
" 0.00366018 0.0061138 0.00103694 -0.01277722 -0.00711095 0.00198041\n",
" 0.00984325 -0.0043192 -0.01001845 0.02317914 0.00696603 0.00243952\n",
" -0.0019254 -0.00038557 -0.00192986 0.00359938 0.00422563 0.00522528\n",
" -0.00791219 0.00485681 0.00508712 -0.01020024 0.00307101 -0.01752843\n",
" -0.01651849 0.0070077 0.00409157]\n"
]
}
],
“source”: [
“daily_log_returns_eqr = log_returns(adj_closings_eqr)\n”,
“print(daily_log_returns_eqr)”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Annualize Daily Log Return Function”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“14. Create a function that returns the daily rate of return\n”,
“\n”,
" step 1. define a function named annualize_log_return\n",
" \n",
" step 2. create parameter for daily_log_returns\n",
" \n",
" step 3. use np.mean() with the argument daily_log_returns to calculate the average daily return. Then set it to the variable name average_daily_log_returns\n",
" \n",
" step 4. then multiply average_daily_log_returns by 250 and set it to the variable annualized_log_return\n",
" \n",
" step 5. return annualized_log_return"
]
},
{
“cell_type”: “code”,
“execution_count”: 35,
“metadata”: {},
“outputs”: ,
“source”: [
“def annualize_log_return(daily_log_returns):\n”,
" average_daily_log_returns = np.mean(daily_log_returns)\n",
" annualized_log_return = 250 * average_daily_log_returns\n",
" return annualized_log_return"
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Calculate Annualize Daily Log Return for SBRA”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
"10. Call the function annualize_log_return with the arguments daily_log_returns_sbra. Set it to the variable annualized_log_return_sbra. Then print the results. "
]
},
{
“cell_type”: “code”,
“execution_count”: 37,
“metadata”: {},
“outputs”: [
{
“name”: “stdout”,
“output_type”: “stream”,
“text”: [
“0.5044563709645333\n”
]
}
],
“source”: [
“annualized_log_return_sbra = annualize_log_return(daily_log_returns_sbra)\n”,
“print(annualized_log_return_sbra)”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Calculate Annualize Daily Log Return for EQR”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
"11. Call the function annualize_log_return with the arguments daily_log_returns_eqr. Set it to the variable annualized_log_return_eqr. Then print the results. "
]
},
{
“cell_type”: “code”,
“execution_count”: 38,
“metadata”: {},
“outputs”: [
{
“name”: “stdout”,
“output_type”: “stream”,
“text”: [
“0.3855982155640554\n”
]
}
],
“source”: [
“annualized_log_return_eqr = annualize_log_return(daily_log_returns_eqr)\n”,
“print(annualized_log_return_eqr)”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Compare the Annualize Daily Log Return between EQR and SBRA”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“12. Based on the differences between the Annualize Daily Log Return for EQR and SBRA, Which could be more profitable in the future and why?”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”:
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Calculate Variance of Daily Log Return for SBRA”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
"13. Calculate the variance of the daily logarithmetic return for SBRA. Use the function .var() with the argument log_daily_ror. Set it to the variable daily_varaince_sbra. Then print the results. "
]
},
{
“cell_type”: “code”,
“execution_count”: 39,
“metadata”: {},
“outputs”: [
{
“name”: “stdout”,
“output_type”: “stream”,
“text”: [
“0.00017844226355047074\n”
]
}
],
“source”: [
“daily_variance_sbra = np.var(daily_log_returns_sbra)\n”,
“print(daily_variance_sbra)”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Calculate Variance of Daily Log Return for EQR”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
"14. Calculate the variance of the daily logarithmetic return for EQR. Use the function .var() with the argument daily_log_returns_eqr. Set it to the variable daily_varaince_eqr. Then print the results. "
]
},
{
“cell_type”: “code”,
“execution_count”: 40,
“metadata”: {},
“outputs”: [
{
“name”: “stdout”,
“output_type”: “stream”,
“text”: [
“6.833881310511606e-05\n”
]
}
],
“source”: [
“daily_variance_eqr = np.var(daily_log_returns_eqr)\n”,
“print(daily_variance_eqr)”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Compare the Variance of Daily Log Return between EQR and SBRA”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“15. Explain which investment is more riskier based on the Variance of daily log return between EQR and SBRA ?”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”:
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Calculate the Daily Standard Deviation for SBRA”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
"16. Calculate the Standard Deviation of the daily logarithmetic return for SBRA. Use the function .std() with the argument daily_log_returns_sbra. Set it to the variable daily_sd_sbra. Then print the results. "
]
},
{
“cell_type”: “code”,
“execution_count”: 41,
“metadata”: {},
“outputs”: [
{
“name”: “stdout”,
“output_type”: “stream”,
“text”: [
“0.013358228308816658\n”
]
}
],
“source”: [
“daily_sd_sbra = np.std(daily_log_returns_sbra)\n”,
“print(daily_sd_sbra)”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Calculate the Daily Standard Deviation for EQR”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
"17. Calculate the Standard Deviation of the daily logarithmetic return for EQR. Use the function .std() with the argument daily_log_returns_eqr. Set it to the variable daily_sd_eqr. Then print the results. "
]
},
{
“cell_type”: “code”,
“execution_count”: 42,
“metadata”: {},
“outputs”: [
{
“name”: “stdout”,
“output_type”: “stream”,
“text”: [
“0.00826672928703463\n”
]
}
],
“source”: [
“daily_sd_eqr = np.std(daily_log_returns_eqr)\n”,
“print(daily_sd_eqr)”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Compare the Daily Standard Deviation between EQR and SBRA”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“18. Has your previous variance risk assessment changed based on the Daily Standard Deviation and why?”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”:
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Calculate the Correlation between SBRA and EQR”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“19. Calculate the Correlation of the daily logarithmetic return between SBRA and ERQ assets. Use the function .corrcoef() with the arguments daily_log_returns_sbra and daily_log_returns_eqr. Set it to the variable corr_sbra_eqr. Then print the results. "
]
},
{
“cell_type”: “code”,
“execution_count”: 43,
“metadata”: {},
“outputs”: [
{
“name”: “stdout”,
“output_type”: “stream”,
“text”: [
“[[1. 0.62096591]\n”,
" [0.62096591 1. ]]\n”
]
}
],
“source”: [
“corr_sbra_eqr = np.corrcoef(daily_log_returns_sbra, daily_log_returns_eqr)\n”,
“print(corr_sbra_eqr)”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Interpret the Correlation between SBRA and EQR”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“20. Interpret and explain the correlation between the stocks SBRA and EQR?”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## Final Analysis”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“21. Which stock would you invest in based on risk and profitability?”
]
}
],
“metadata”: {
“kernelspec”: {
“display_name”: “Python 3 (ipykernel)”,
“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.11.4”
},
“latex_envs”: {
“LaTeX_envs_menu_present”: true,
“autoclose”: false,
“autocomplete”: true,
“bibliofile”: “biblio.bib”,
“cite_by”: “apalike”,
“current_citInitial”: 1,
“eqLabelWithNumbers”: true,
“eqNumInitial”: 1,
“hotkeys”: {
“equation”: “Ctrl-E”,
“itemize”: “Ctrl-I”
},
“labels_anchors”: false,
“latex_user_defs”: false,
“report_style_numbering”: false,
“user_envs_cfg”: false
}
},
“nbformat”: 4,
“nbformat_minor”: 2
}

Thanks for sharing. I just finished this today. Here’s my work that I completed using Jupyter Notebook.
myFunReitAnalysis.txt (9.7 KB)