1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
Function Beta(RdtPtf As Variant, RdtBench As Variant) As Variant
' Calcul le beta par rapport à un indice
' RdtPtf = Vecteur des rendements du portefeuille
' RdtBench = Vecteur des rendements de l'indice (benchmark)
Dim i As Integer
Dim meanPtf As Double
Dim meanBench As Double
Dim diffBench As Double
Dim diffPtf As Double
Dim Denominator As Double
Dim Nominator As Double
meanPtf = Mean2(RdtPtf) ' Mean2 : fonction calculant la moyenne arithmétique simple
meanBench = Mean2(RdtBench)
For i = LBound(RdtPtf) To UBound(RdtPtf)
diffBench = RdtBench(i) - meanBench
diffPtf = RdtPtf(i) - meanPtf
Nominator = Nominator + (diffBench * diffPtf)
Denominator = Denominator + (diffBench ^ 2)
Next ' Next tout seul est plus rapide que Next i
Beta = Nominator / Denominator
End Function |
Partager