1
$\begingroup$

I've been doing my Dissertation and I was told to create a value - weighted portfolio on the 1979's 200 largest cap corporations (based on Market Value). I was also told that the correct way to build it would be to have today's returns weighted by yesterday's market values instead of today's because I can't use information from the future and I supposedly wouldn't have today's numbers available, ergo

Return(portfolio) = SUM( Return(today) * Market Value(yesterday))

I was also told that to have more accurate estimates of Market Values and isolate their variations from external factors, I should not use the stock Market Values (which I imported as MVp) but to create new ones based on the formula

MV t-1 = MV i, t-1 / SUMi=1N (MVi,t-1) where

MV i, t-1 = MV0 * PRODUCTj=1t-1(1+ri,j)

i = Denotes Stock, N = All stocks, j = Time Unit (here daily)

The problem is when I plot the holding period return, given the code below where I create a different value - weighted portfolio at every day depending on how the Market Value of each corporation changes, I get a HPR of about 100, which I was told is abnormally high compared to the SP base which is about 30.

import numpy as np
import pandas as pd
from matplotlib import pyplot as plt


#MVp, RIp are the imported matrices

#Compute Returns
RIp = RIp.pct_change(1)

#Do the shift so as to have TRI(t)*MV(t-1)
MVp = MVp.shift(1)

#To get initial MVs, as per the formula request
MV0 = MVp.iloc[[0]]

RIp += 1


initial = MV0*RIp; 
initial = initial.iloc[[0]]


newMV = initial.append(RIp) 
newMV = newMV[~newMV.index.duplicated(keep='first')]

MV = newMV.cumprod()
RI = RIp.copy()
RI -= 1 


#Calculating SUM(MV) and percentages
sum_cap = np.sum(MVp, axis=1)
p = MVp.divide(sum_cap, axis=0)

# R(p) = SUM(R(i,t) * p(i, t-1)|MV(t-1))
portfolio = RI.multiply(p)
portfolio = portfolio.sum(axis=1)
portfolio.dropna(inplace=True)


hdr = portfolio.add(1).cumprod().sub(1)


histogram = hdr.plot(title="Holding Period Returns over Time")

plt.show(histogram)

# Here I show for illustration the first and last 5 rows of my 
# suspected abnormal file of HPR and of the benchmarked SP HPR

hdr.head().values = 
   [-0.02332244],
   [-0.02610473],
   [-0.0138813 ],
   [-0.01069693],
   [ 0.01453517]

hdr.tail.values() = 
   [91.92066528],
   [91.76834481],
   [93.28143382],
   [93.36009697],
   [92.3151313 ]]

SP.head().values = 
  [-0.00510591,  0.00718603,  0.0099281 ,  0.03016258,  0.03110818]

SP.tail().values = 
[25.16423819, 25.00973891, 25.56883386, 25.56212091, 25.17984093]

#Here I also provide some initial values of MVp, RIp BEFORE I do any 
#Calculations with them (Data extracted from Thomson ReutersDataStream)


#two first rows of each original matrix, each row includes 200 corps

MVp = [[3.755470e+04, 2.498292e+04, 1.191806e+04, 1.145820e+04,
    9.636620e+03, 7.412540e+03, 6.129630e+03, 5.897540e+03,
    5.439700e+03, 5.226260e+03, 4.998420e+03, 4.843040e+03,
    4.666410e+03, 4.482140e+03, 4.354520e+03, 4.262710e+03,
    4.086790e+03, 3.856000e+03, 3.482870e+03, 3.447840e+03,
    3.248250e+03, 2.865640e+03, 2.601440e+03, 2.480580e+03,
    2.421320e+03, 2.374420e+03, 2.258650e+03, 2.238450e+03,
    2.155060e+03, 2.129760e+03, 2.100110e+03, 2.064440e+03,
    2.008780e+03, 1.929240e+03, 1.928700e+03, 1.790820e+03,
    1.778960e+03, 1.743590e+03, 1.729600e+03, 1.709660e+03,
    1.692570e+03, 1.616920e+03, 1.607260e+03, 1.591730e+03,
    1.569670e+03, 1.516010e+03, 1.449150e+03, 1.442600e+03,
    1.392930e+03, 1.357540e+03, 1.317370e+03, 1.256920e+03,
    1.177400e+03, 1.137850e+03, 1.125640e+03, 1.069700e+03,
    1.040250e+03, 1.038220e+03, 1.018250e+03, 1.003950e+03,
    9.914800e+02, 9.907800e+02, 9.890100e+02, 9.862300e+02,
    9.804600e+02, 9.760300e+02, 9.536700e+02, 9.364500e+02,
    9.228900e+02, 9.128400e+02, 9.060200e+02, 8.711100e+02,
    8.679000e+02, 8.614900e+02, 8.544900e+02, 8.351700e+02,
    7.912500e+02, 7.698300e+02, 7.363900e+02, 7.192600e+02,
    7.104100e+02, 6.990700e+02, 6.879700e+02, 6.814500e+02,
    6.786100e+02, 6.740100e+02, 6.669200e+02, 6.577700e+02,
    6.577000e+02, 6.564500e+02, 6.511000e+02, 6.507900e+02,
    6.044600e+02, 5.890800e+02, 5.845100e+02, 5.668000e+02,
    5.625900e+02, 5.460800e+02, 5.315100e+02, 5.311000e+02,
    5.281300e+02, 5.273000e+02, 5.268400e+02, 5.245500e+02,
    5.214500e+02, 5.068100e+02, 4.800800e+02, 4.576000e+02,
    4.330200e+02, 4.070700e+02, 4.019400e+02, 3.935600e+02,
    3.822100e+02, 3.751200e+02, 3.744500e+02, 3.531400e+02,
    3.486700e+02, 3.429200e+02, 3.275400e+02, 3.219900e+02,
    3.056700e+02, 2.976700e+02, 2.839400e+02, 2.683200e+02,
    2.591500e+02, 2.585400e+02, 2.553100e+02, 2.498600e+02,
    2.461800e+02, 2.429600e+02, 2.360200e+02, 2.357800e+02,
    2.252700e+02, 2.240800e+02, 2.223800e+02, 2.215600e+02,
    2.191300e+02, 2.189300e+02, 2.076600e+02, 1.994800e+02,
    1.969900e+02, 1.746300e+02, 1.645000e+02, 1.635700e+02,
    1.622000e+02, 1.596000e+02, 1.476200e+02, 1.405200e+02,
    1.297500e+02, 1.290700e+02, 1.269100e+02, 1.263900e+02,
    1.249000e+02, 1.230400e+02, 1.209200e+02, 1.195200e+02,
    1.164400e+02, 1.111200e+02, 1.023800e+02, 1.007200e+02,
    1.000300e+02, 9.685000e+01, 9.321000e+01, 9.026000e+01,
    8.602000e+01, 7.606000e+01, 7.286000e+01, 7.034000e+01,
    6.442000e+01, 6.298000e+01, 6.043000e+01, 5.485000e+01,
    4.970000e+01, 4.962000e+01, 4.680000e+01, 4.414000e+01,
    4.398000e+01, 4.300000e+01, 4.249000e+01, 4.231000e+01,
    4.203000e+01, 4.143000e+01, 4.100000e+01, 4.061000e+01,
    3.951000e+01, 3.583000e+01, 3.388000e+01, 3.211000e+01,
    3.083000e+01, 2.902000e+01, 2.756000e+01, 2.729000e+01,
    2.634000e+01, 2.566000e+01, 2.446000e+01, 2.407000e+01,
    2.201000e+01, 2.151000e+01, 1.219000e+01, 1.177000e+01],
   [3.646087e+04, 2.441641e+04, 1.134599e+04, 1.103382e+04,
    9.273380e+03, 7.084380e+03, 6.129630e+03, 5.809510e+03,
    5.326770e+03, 5.089560e+03, 4.888160e+03, 4.690270e+03,
    4.601590e+03, 4.295380e+03, 4.226980e+03, 4.170050e+03,
    4.038530e+03, 3.825870e+03, 3.387150e+03, 3.423980e+03,
    3.184090e+03, 2.747000e+03, 2.601440e+03, 2.352400e+03,
    2.380420e+03, 2.344070e+03, 2.224600e+03, 2.182020e+03,
    2.155060e+03, 2.129760e+03, 2.045260e+03, 2.049740e+03,
    1.920320e+03, 1.942420e+03, 1.822040e+03, 1.759590e+03,
    1.760930e+03, 1.718460e+03, 1.689380e+03, 1.626370e+03,
    1.674170e+03, 1.570150e+03, 1.556500e+03, 1.494430e+03,
    1.553650e+03, 1.508200e+03, 1.404750e+03, 1.433040e+03,
    1.320700e+03, 1.377210e+03, 1.308820e+03, 1.250640e+03,
    1.156920e+03, 1.160390e+03, 1.125640e+03, 1.030720e+03,
    1.033170e+03, 1.024850e+03, 1.013160e+03, 1.006910e+03,
    9.737700e+02, 1.000160e+03, 1.001370e+03, 9.625200e+02,
    9.665300e+02, 9.954200e+02, 9.536700e+02, 9.364500e+02,
    9.228900e+02, 9.128400e+02, 9.112000e+02, 8.793700e+02,
    8.136600e+02, 8.385600e+02, 8.440000e+02, 8.231300e+02,
    7.764600e+02, 7.644100e+02, 7.144100e+02, 7.146700e+02,
    7.016700e+02, 6.682800e+02, 6.660800e+02, 6.700300e+02,
    6.636400e+02, 6.919800e+02, 6.506500e+02, 6.208400e+02,
    6.641400e+02, 6.707200e+02, 6.511000e+02, 6.444100e+02,
    6.044600e+02, 5.723700e+02, 5.756300e+02, 5.623400e+02,
    5.340400e+02, 5.386200e+02, 5.315100e+02, 5.187500e+02,
    5.076300e+02, 4.986400e+02, 5.145000e+02, 5.056800e+02,
    5.077300e+02, 4.841200e+02, 4.800800e+02, 4.534700e+02,
    4.306600e+02, 4.031900e+02, 3.947600e+02, 3.888200e+02,
    3.637700e+02, 3.722500e+02, 3.613900e+02, 3.471600e+02,
    3.433600e+02, 3.364500e+02, 3.157300e+02, 3.104600e+02,
    3.087300e+02, 2.849200e+02, 2.853400e+02, 2.590700e+02,
    2.439600e+02, 2.595800e+02, 2.393500e+02, 2.394500e+02,
    2.439200e+02, 2.364400e+02, 2.360200e+02, 2.271500e+02,
    2.196900e+02, 2.240800e+02, 2.198700e+02, 2.130400e+02,
    2.222900e+02, 2.168000e+02, 2.179900e+02, 1.994800e+02,
    1.900500e+02, 1.643600e+02, 1.633000e+02, 1.608900e+02,
    1.599500e+02, 1.584000e+02, 1.448500e+02, 1.397500e+02,
    1.263100e+02, 1.273900e+02, 1.256100e+02, 1.191300e+02,
    1.249000e+02, 1.210500e+02, 1.125800e+02, 1.175300e+02,
    1.176900e+02, 1.086000e+02, 9.788000e+01, 1.007200e+02,
    9.900000e+01, 9.685000e+01, 9.412000e+01, 9.026000e+01,
    8.271000e+01, 7.606000e+01, 6.831000e+01, 6.937000e+01,
    6.401000e+01, 6.166000e+01, 5.951000e+01, 5.548000e+01,
    4.920000e+01, 4.657000e+01, 4.517000e+01, 4.365000e+01,
    4.277000e+01, 4.200000e+01, 4.174000e+01, 4.164000e+01,
    4.203000e+01, 4.143000e+01, 4.195000e+01, 3.998000e+01,
    3.805000e+01, 3.583000e+01, 3.297000e+01, 3.158000e+01,
    3.011000e+01, 2.989000e+01, 2.756000e+01, 2.691000e+01,
    2.596000e+01, 2.566000e+01, 2.243000e+01, 2.358000e+01,
    2.201000e+01, 2.151000e+01, 1.219000e+01, 1.177000e+01]]

RIp = [[  99.27,  191.97,  365.84,   90.35,  212.05,  271.67,   80.55,
      71.14,   93.73,   48.33,  199.29,   68.43,  147.77,  139.67,
      89.96,   59.38,  134.24,   82.52,  140.3 ,  273.98,  755.38,
     111.22,  130.25,  272.72,  134.92,  231.25,  103.86,  112.82,
     112.15,   56.31,  482.73,   93.89,  105.45,  191.54,  299.77,
     276.96,  119.5 ,   58.89,  244.59,  148.39,  112.28,  593.15,
      90.2 ,   89.24,  158.49,  175.58,   42.82,  165.3 ,  845.84,
     135.91,  153.93,   92.76,   58.27,   86.71,  124.23,  574.32,
     249.63,   88.86,  104.64,  210.75,   61.82,  207.45,  118.87,
     105.59,  193.09,  130.  ,  142.18,  137.71,   64.  ,  122.95,
     141.22,  113.79,  150.12,  360.03,  100.27,  162.94,  115.39,
     131.31,  127.04,   50.02,  173.76,  246.45,  107.3 ,  127.25,
      86.89,   69.9 ,  142.67,  616.3 ,  106.73,  127.17,   97.73,
      94.94,  115.37,   55.02,  759.08,  282.18,  622.75,  116.26,
      83.27,  117.99,  441.66,  120.06,  109.76,  210.99,  260.46,
     187.72,   95.74,  173.29,  159.29,  122.37,  167.7 ,   68.85,
      90.11,  334.02,  305.74,  114.66,  156.3 ,  188.23,   68.4 ,
     295.47,   86.67,  631.55,  216.47,  689.58,  701.61,   69.41,
     194.77,  233.46,   50.8 ,  363.41,   44.54,   30.84,  182.97,
     146.01,  235.51,   67.93,  105.96,  224.2 ,  145.76,   96.7 ,
     160.09,  256.83,  240.02,  138.9 ,   46.52,  128.23,  373.23,
     115.26,  208.97,  188.09,  252.86,  303.93,   69.86,   57.78,
     966.67,  139.54,  148.98,  468.61, 1779.62,  267.86,  109.04,
     253.42,  148.56,  176.16,  278.77,  151.44,  469.13,  151.17,
     123.51,  274.48,  114.99,   39.55,   90.77,  234.62,  125.87,
      60.76,  504.62,  124.94,  102.15,  589.2 ,  159.82,  290.07,
     409.97,   50.95,  280.37,   46.48,   20.88,  111.11,   65.81,
     133.59,  514.93,   61.97,   45.16,  114.52,   21.82,  534.35,
      91.94,  314.1 ,   54.79,  148.44],
   [  96.37,  187.61,  348.28,   87.  ,  204.05,  259.65,   80.55,
      70.08,   91.78,   47.07,  194.9 ,   66.27,  145.72,  133.85,
      87.33,   58.09,  132.65,   81.87,  136.44,  272.08,  740.46,
     106.61,  130.25,  258.63,  132.64,  228.3 ,  102.29,  109.98,
     112.15,   56.31,  470.12,   93.22,  100.81,  192.85,  283.19,
     272.13,  118.29,   58.04,  238.9 ,  141.17,  111.06,  575.99,
      87.36,   83.78,  156.87,  174.68,   41.51,  164.2 ,  801.98,
     137.88,  152.93,   92.29,   57.26,   88.43,  124.23,  553.39,
     247.94,   87.72,  104.12,  211.37,   60.71,  209.42,  120.36,
     103.05,  190.35,  132.59,  142.18,  137.71,   64.  ,  122.95,
     142.02,  114.87,  140.74,  350.45,   99.04,  160.59,  113.23,
     130.39,  123.25,   49.7 ,  171.63,  235.59,  103.88,  125.12,
      84.98,   71.76,  139.19,  581.7 ,  107.78,  129.93,   97.73,
      94.01,  115.37,   53.46,  747.54,  279.96,  591.14,  114.68,
      83.27,  115.24,  424.52,  113.53,  107.19,  203.4 ,  253.61,
     179.31,   95.74,  171.73,  158.42,  121.2 ,  164.71,   68.02,
      85.76,  331.47,  295.08,  112.71,  153.92,  184.68,   65.93,
     284.89,   87.54,  604.49,  217.54,  665.8 ,  660.48,   69.69,
     182.59,  223.73,   50.33,  353.66,   44.54,   29.71,  178.43,
     146.01,  232.86,   65.32,  107.49,  222.02,  149.15,   96.7 ,
     154.45,  241.72,  238.27,  136.63,   45.87,  127.26,  366.24,
     114.63,  203.42,  185.65,  250.28,  286.46,   69.86,   56.84,
     900.  ,  137.21,  150.58,  457.96, 1701.39,  267.86,  107.91,
     253.42,  150.  ,  176.16,  268.05,  151.44,  439.81,  149.08,
     122.71,  268.77,  113.24,   40.  ,   89.85,  220.19,  121.5 ,
      60.07,  490.73,  122.03,  100.34,  579.92,  159.82,  290.07,
     419.51,   50.16,  269.99,   46.48,   20.31,  109.26,   64.28,
     137.64,  514.93,   61.1 ,   44.52,  114.52,   20.  ,  523.52,
      91.94,  314.1 ,   54.79,  148.44]]
$\endgroup$
  • $\begingroup$ Could you make an MVCE? $\endgroup$ – Bob Jansen Jan 27 at 16:31
  • $\begingroup$ Comments are not for extended discussion; this conversation has been moved to chat. $\endgroup$ – Bob Jansen Jan 28 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.