Commit df0d3448 authored by 李宗熹's avatar 李宗熹

修改基金诊断

parent b4c95f2e
...@@ -602,14 +602,18 @@ class PortfolioDiagnose(object): ...@@ -602,14 +602,18 @@ class PortfolioDiagnose(object):
raise ValueError raise ValueError
w_low = 1000000 / self.invest_amount w_low = 1000000 / self.invest_amount
ef = EfficientFrontier(mu, S, weight_bounds=[w_low, 1], expected_drawdown=dd) try:
# ef = EfficientFrontier(mu, S, weight_bounds=[0, 1], expected_drawdown=dd) ef = EfficientFrontier(mu, S, weight_bounds=[w_low, 1], expected_drawdown=dd)
ef.add_sector_constraints(propose_risk_mapper, risk_lower, risk_upper) # ef = EfficientFrontier(mu, S, weight_bounds=[0, 1], expected_drawdown=dd)
ef.efficient_return(target_return=self.expect_return, target_drawdown=self.expect_drawdown) ef.add_sector_constraints(propose_risk_mapper, risk_lower, risk_upper)
clean_weights = ef.clean_weights() ef.efficient_return(target_return=self.expect_return, target_drawdown=self.expect_drawdown)
ef.portfolio_performance(verbose=True) clean_weights = ef.clean_weights()
self.new_weights = np.array(list(clean_weights.values())) ef.portfolio_performance(verbose=True)
print(clean_weights) self.new_weights = np.array(list(clean_weights.values()))
except:
self.new_weights = np.asarray([1/len(self.propose_portfolio.columns)] * len(self.propose_portfolio.columns))
print(self.new_weights)
end4 = time.time() end4 = time.time()
print("模型计算一次时间:", end4 - end3) print("模型计算一次时间:", end4 - end3)
# S = np.asmatrix(S) # S = np.asmatrix(S)
...@@ -1066,7 +1070,7 @@ class PortfolioDiagnose(object): ...@@ -1066,7 +1070,7 @@ class PortfolioDiagnose(object):
radar_data.append(get_radar_data(fund)) radar_data.append(get_radar_data(fund))
return radar_data return radar_data
#
# portfolio = ['HF00002JJ2', 'HF00005DBQ', 'HF0000681Q', 'HF00006693', 'HF00006AZF', 'HF00006BGS'] # portfolio = ['HF00002JJ2', 'HF00005DBQ', 'HF0000681Q', 'HF00006693', 'HF00006AZF', 'HF00006BGS']
# portfolio_diagnose = PortfolioDiagnose(client_type=1, portfolio=portfolio, invest_amount=10000000) # portfolio_diagnose = PortfolioDiagnose(client_type=1, portfolio=portfolio, invest_amount=10000000)
# portfolio_diagnose.optimize() # portfolio_diagnose.optimize()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment