Commit 3105da32 authored by 赵杰's avatar 赵杰

修改综合数据和组合数据的错乱bug

parent bf7d04d8
......@@ -233,8 +233,8 @@ class UserCustomerDataAdaptor:
cnav_df[p_fund_id_ + "_earn"] = (cnav_df[p_fund_id_ + "_profit"] * cnav_df[p_fund_id_ + "_share"]).apply(lambda x: float(x)).fillna(0)
# cnav_df[p_fund_id_ + "_earn"] = cnav_df[p_fund_id_ + "_earn"].apply(lambda x: float(x))
cnav_df[p_fund_id_ + "_cum_earn"] = cnav_df[p_fund_id_ + "_earn"].cumsum().fillna(0)
# cnav_df[p_fund_id_ + "_net_amount"] = cnav_df[p_fund_id_ + "_cum_earn"] + cnav_df[p_fund_id_ + "_amount"].apply(lambda x: float(x))
cnav_df[p_fund_id_ + "_net_amount"] = cnav_df[p_fund_id_ + "_share"] * cnav_df[p_fund_id_]
cnav_df[p_fund_id_ + "_net_amount"] = cnav_df[p_fund_id_ + "_cum_earn"].apply(lambda x: Decimal(x)) + cnav_df[p_fund_id_ + "_amount"]
# cnav_df[p_fund_id_ + "_net_amount"] = cnav_df[p_fund_id_ + "_share"] * cnav_df[p_fund_id_]
self.group_data[p_folio] = {"result_cnav_data": cnav_df, "order_df": p_order_df}
return cnav_df
......@@ -311,6 +311,6 @@ class UserCustomerDataAdaptor:
cnav_df[p_fund_id_ + "_earn"] = (cnav_df[p_fund_id_ + "_profit"] * cnav_df[p_fund_id_ + "_share"]).apply(lambda x: float(x)).fillna(0)
# cnav_df[p_fund_id_ + "_earn"] = cnav_df[p_fund_id_ + "_earn"].apply(lambda x: float(x))
cnav_df[p_fund_id_ + "_cum_earn"] = cnav_df[p_fund_id_ + "_earn"].cumsum().fillna(0)
# cnav_df[p_fund_id_ + "_net_amount"] = cnav_df[p_fund_id_ + "_cum_earn"] + cnav_df[p_fund_id_ + "_amount"].apply(lambda x: float(x))
cnav_df[p_fund_id_ + "_net_amount"] = cnav_df[p_fund_id_ + "_share"] * cnav_df[p_fund_id_]
cnav_df[p_fund_id_ + "_net_amount"] = cnav_df[p_fund_id_ + "_cum_earn"].apply(lambda x: Decimal(x)) + cnav_df[p_fund_id_ + "_amount"]
# cnav_df[p_fund_id_ + "_net_amount"] = cnav_df[p_fund_id_ + "_share"] * cnav_df[p_fund_id_]
return cnav_df
......@@ -1054,7 +1054,7 @@
成立以来累计收益率:<span class="red">{{totoal_rate_of_return}}%</span>
</td>
<td>
年化收益率:<span class="green">{{annualised_return}}%</span>
年化收益率:<span class="green">{{now_annualised_return}}%</span>
</td>
<td>
最大回撤:<span class="red">{{now_withdrawal}}%</span>
......@@ -1073,7 +1073,7 @@
<table class="tss1_table">
<tr>
<td>
投资成本:<span class="red">{{cost_of_investment}}元</span>
投资成本:<span class="red">{{now_allocation_amount}}元</span>
</td>
<td>
期末资产:<span class="green">{{final_balance}}元</span>
......
......@@ -24,7 +24,7 @@ class DataIntegrate:
# 组合数据
self.group_result = self.d["default"]
self.get_portfolio_diagnose(self.group_result["fund_id_list"])
# 几月综述部分
# 投资总览
self.get_summarize()
# 月度回报
self.get_month_return()
......@@ -56,12 +56,19 @@ class DataIntegrate:
self.portfolio_diagnose.optimize()
def get_summarize(self):
"""几月综述部分."""
self.total_cost = self.df["total_cost"]/10000
self.now_yield = round((self.df['cumulative_return']-1)*100,2)
self.index_yield = round((self.df["index_result"]["return_ratio"]-1)*100, 2)
self.now_withdrawal = round(self.df["max_drawdown"][0]*100,2)
self.index_withdrawal = round(self.df["index_result"]["max_drawdown"][0]*100, 2)
"""投资总览."""
self.total_cost = round(self.df["total_cost"], 2) # 投资成本
self.now_yield = round((self.df['cumulative_return']-1)*100, 2) # 成立以来累计收益率
self.now_annualised_return = round(self.df["return_ratio_year"] * 100, 2) # 年化收益率
self.index_yield = round((self.df["index_result"]["return_ratio"]-1)*100, 2) # 指数收益率
self.now_withdrawal = round(self.df["max_drawdown"][0]*100, 2) # 最大回撤
self.index_withdrawal = round(self.df["index_result"]["max_drawdown"][0]*100, 2) # 指数最大回撤
self.now_month_income = int(self.df["cur_month_profit"]) # 本月收益
self.month_rise = round(self.df["cur_month_profit_ratio"] * 100, 2) # 本月涨幅
self.year_totoal_rate_of_return = round(self.df["cur_year_profit_ratio"] * 100, 2) # 今年累计收益率
self.now_year_income = int(self.df["cur_year_profit"]) # 今年累计收益
self.final_balance = int(self.df["total_cost"] + self.df["cumulative_profit"]) # 期末资产
self.total_profit = int(self.df["cumulative_profit"]) # 累计盈利
def get_month_return(self):
"""月度回报."""
......@@ -112,7 +119,6 @@ class DataIntegrate:
self.return_compare_pic = draw_combination_chart(self.return_compare_data["xlabels"], self.return_compare_data["new_combination"],
self.return_compare_data["origin_combination"], self.return_compare_data["index"])
def get_old_correlation(self):
"""旧相关性分析."""
old_correlation = self.portfolio_diagnose.old_correlation
......@@ -120,7 +126,6 @@ class DataIntegrate:
old_correlation_values = old_correlation.values.tolist()
self.old_correlation = list(zip(range(1, len(old_correlation_columns)+1), old_correlation_columns, old_correlation_values))
def get_new_correlation(self):
"""新相关性分析."""
new_correlation = self.portfolio_diagnose.new_correlation
......@@ -128,7 +133,6 @@ class DataIntegrate:
new_correlation_values = new_correlation.values.tolist()
self.new_correlation = list(zip(range(1, len(new_correlation_columns)+1), new_correlation_columns, new_correlation_values))
def propose_fund(self):
"""新增基金"""
# 优化组合建议1 -- 新增基金
......@@ -145,19 +149,13 @@ class DataIntegrate:
def objectives_performance(self, group_result):
"""目标与业绩"""
self.now_month_income = int(group_result["cur_month_profit"]) # 本月收益
self.now_year_income = int(group_result["cur_year_profit"]) # 今年累计收益
self.totoal_rate_of_return = round((group_result['cumulative_return']-1)*100, 2) # 成立以来累计收益率
self.month_rise = round(group_result["cur_month_profit_ratio"]*100, 2) # 本月涨幅s
self.year_totoal_rate_of_return = round(group_result["cur_year_profit_ratio"]*100, 2) # 今年累计收益率
self.annualised_return = round(group_result["return_ratio_year"]*100, 2) # 年化收益率
self.volatility = round(group_result["volatility"]*100, 2)
self.max_withdrawal = round(group_result["max_drawdown"][0]*100, 2)
self.sharpe_ratio = round(group_result["sharpe"], 2)
self.cost_of_investment = round(group_result["total_cost"]/10000.0, 2) # 投资成本
self.final_balance = int(group_result["total_cost"] + group_result["cumulative_profit"]) # 期末资产
self.total_profit = int(group_result["cumulative_profit"]) # 累计盈利
self.index_section_return = round((group_result["index_result"]["return_ratio"]-1)*100, 2)
self.index_annualised_return = round(group_result["index_result"]["return_ratio_year"]*100, 2) # 年化收益率
self.index_volatility = round(group_result["index_result"]["volatility"]*100, 2)
......@@ -205,7 +203,7 @@ class DataIntegrate:
# 'new_evaluation': self.new_evaluation,
'position_years': '5年', 'planned_allocation_amount': 2000.00,
'now_allocation_amount': self.total_cost, 'now_yield': self.now_yield, 'index_yield': self.index_yield,
'expected_yield': 20,
'expected_yield': 20, "now_annualised_return ": self.now_annualised_return,
'now_withdrawal': self.now_withdrawal, 'index_withdrawal': self.index_withdrawal, 'expected_withdrawal': 20,
'now_year_income': self.now_year_income, 'now_month_income': self.now_month_income,
'totoal_rate_of_return': self.totoal_rate_of_return,
......
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