Computational Investing Wiki


Passing by reference : This means that if we do in python

fred = squareArray

and then fred[1,1] = 0

Python does not make a copy of squareArray, rather its just passed as a reference, hence by changing fred[1,1], squareArray also gets changed.

Whereas if we want to pass by value something like

fred = squareArray.copy() should be done.

the general formula for the variance of returns for a portfolio is:

σ²(port) = ΣΣw(i)w(j)σ(i)σ(j)ρ(i,j)

where the first sum is taken over all is, and the second over all js.  Thus, for a 5-asset portfolio, the formula would be:

σ²(port) = w1²σ1² + w2²σ2² + w3²σ3² + w3²σ3² + w5²σ5²

+ 2w1w2σ1σ2ρ(1,2) + 2w1w3σ1σ3ρ(1,3) + 2w1w4σ1σ4ρ(1,4) + 2w1w5σ1σ5ρ(1,5)

+ 2w2w3σ2σ3ρ(2,3) + 2w2w4σ2σ4ρ(2,4) + 2w2w5σ2σ5ρ(2,5)

+ 2w3w4σ3σ4ρ(3,4) + 2w3w5σ3σ5ρ(3,5)

+ 2w4w5σ4σ5ρ(4,5)

ρ is covariance



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s