def returns(tickers, rate): rets = {} for x in tickers: stock = yfinance.parse_yfin(prefix + x + postfix) rets.update({x:risk_free_rate(stock, rate)}) return rets;
# Define view 2 # International Bonds will outperform US Bonds by 0.0025 with a # confidence of 50%. P2 = np.array([-1,1,0,0,0,0,0,0]) Q2 = np.array([0.0025]) conf2 = 0.50 # Define View 3 # US Large and Small Growth will outperform US Large and Small Value # by 0.02 with a confidence of 65%. P3 = np.array([0,0,0.90,-0.90,0.10,-0.10,0,0]) Q3 = np.array([0.02]) conf3 = 0.65 # Combine the views P=np.array([P1,P2,P3]) Q=np.array([Q1,Q2,Q3]); # Apply the views with simple Omega Omega = np.dot(np.dot(P,tauV),P.T) res = altblacklitterman(delta, weq, V, tau, P, Q, Omega) display('Simple Omega',assets,res) # Now apply the views using the Idzorek's method tauV = tau * V Omega = np.array([[bl_omega(conf1, P1, tauV), 0, 0],[0, bl_omega(conf2, P2, tauV), 0],[0, 0, bl_omega(conf3, P3, tauV)]]) res = altblacklitterman(delta, weq, V, tau, P, Q, Omega) display('Idzorek Method',assets,res) print(yfinance.parse_yfin("data/aapl.csv"))