All problems
Jensen Alpha
Problem
Compute Jensen's alpha: mean(portfolio) - (rf + beta * (mean(market) - rf)), the excess return left unexplained by CAPM.
Return 0.0 if either list is empty.
Hint
Compare the realized mean return with the CAPM-predicted return.
Test cases
case 1
in: [[0.02,0.03],[0.01,0.02],1.2,0.01]
expected: 0.009000000000000001
case 2
in: [[0.05],[0.04],1,0]
expected: 0.010000000000000002
case 3
in: [[0.1,0.1],[0.05,0.05],0,0.01]
expected: 0.09000000000000001
case 4
in: [[0],[-0.02],1.5,0]
expected: 0.03
Starter codePython
def jensen_alpha(portfolio, market, beta, rf):
# Your code here
pass4 test cases · run your code against them in the editor