Pca, 特徵篩選, 歷史回測, 投資組合.
PCA(n_components=n_components) Pc = pca.fit(X_train) pcs = pca.components_ for i in range(n_components): pc_w = pcs[i] / sum(pcs[i]) eigen_port = pd.DataFrame(data={"weights":pc_w.squeeze()},index=coids) eigen_port.sort_values(by=["weights"],ascending=False,inplace=True) #權重與每天報酬內積，得出每日投資組合報酬