Commit 251d5948 authored by pengxiong's avatar pengxiong

Merge branch 'dev' of http://47.100.44.39:10001/pengxiong/fund_report into dev

parents d18d8290 fe4a5eb0
...@@ -602,6 +602,7 @@ class PortfolioDiagnose(object): ...@@ -602,6 +602,7 @@ class PortfolioDiagnose(object):
raise ValueError raise ValueError
w_low = 1000000 / self.invest_amount w_low = 1000000 / self.invest_amount
try:
ef = EfficientFrontier(mu, S, weight_bounds=[w_low, 1], expected_drawdown=dd) ef = EfficientFrontier(mu, S, weight_bounds=[w_low, 1], expected_drawdown=dd)
# ef = EfficientFrontier(mu, S, weight_bounds=[0, 1], expected_drawdown=dd) # ef = EfficientFrontier(mu, S, weight_bounds=[0, 1], expected_drawdown=dd)
ef.add_sector_constraints(propose_risk_mapper, risk_lower, risk_upper) ef.add_sector_constraints(propose_risk_mapper, risk_lower, risk_upper)
...@@ -609,7 +610,10 @@ class PortfolioDiagnose(object): ...@@ -609,7 +610,10 @@ class PortfolioDiagnose(object):
clean_weights = ef.clean_weights() clean_weights = ef.clean_weights()
ef.portfolio_performance(verbose=True) ef.portfolio_performance(verbose=True)
self.new_weights = np.array(list(clean_weights.values())) self.new_weights = np.array(list(clean_weights.values()))
print(clean_weights) 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)
...@@ -1069,7 +1073,7 @@ class PortfolioDiagnose(object): ...@@ -1069,7 +1073,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