Commit 613d1b43 authored by 赵杰's avatar 赵杰

订单新库版本v2_1 基金诊断v2

parent bf3634b4
...@@ -39,10 +39,10 @@ class UserCustomerDataAdaptor: ...@@ -39,10 +39,10 @@ class UserCustomerDataAdaptor:
p_end_date = pd.to_datetime(end_date).date() p_end_date = pd.to_datetime(end_date).date()
p_end_date = datetime.date(year=p_end_date.year, month=p_end_date.month, day=1) - datetime.timedelta(days=1) p_end_date = datetime.date(year=p_end_date.year, month=p_end_date.month, day=1) - datetime.timedelta(days=1)
self.end_date = pd.to_datetime(str(p_end_date)) self.end_date = pd.to_datetime(str(p_end_date))
self.end_date = pd.to_datetime("2020-12-11") # self.end_date = pd.to_datetime("2020-12-11")
p_start_date = datetime.date(year=p_end_date.year, month=p_end_date.month, day=1) p_start_date = datetime.date(year=p_end_date.year, month=p_end_date.month, day=1)
self.month_start_date = p_start_date self.month_start_date = p_start_date
self.month_start_date = pd.to_datetime("2020-11-01") # self.month_start_date = pd.to_datetime("2020-12-01")
self.user_customer_order_df = self.get_user_customer_order_data() self.user_customer_order_df = self.get_user_customer_order_data()
self.fund_nav_total, self.fund_cnav_total = self.get_customer_fund_nav_data() self.fund_nav_total, self.fund_cnav_total = self.get_customer_fund_nav_data()
self.index_df = self.get_customer_index_nav_data() self.index_df = self.get_customer_index_nav_data()
...@@ -70,7 +70,7 @@ class UserCustomerDataAdaptor: ...@@ -70,7 +70,7 @@ class UserCustomerDataAdaptor:
tamp_diagnose_app_session = tamp_diagnose_app.session tamp_diagnose_app_session = tamp_diagnose_app.session
tamp_product_session = tamp_product.session tamp_product_session = tamp_product.session
tamp_fund_session = tamp_fund.session tamp_fund_session = tamp_fund.session
sql_user = """select f1.fund_id, f2.realname,f3.customer_name,f1.type,f1.order_type,f1.pay_date,f1.subscription_fee,f1.confirm_share_date,f1.confirm_share,f1.confirm_amount,f1.nav,f1.folio_name from tamp_diagnose_app.customer_order_view f1, tamp_user.user_info f2,tamp_user.customer_info f3 where f2.id=f1.user_id and f3.id=f1.customer_id and user_id='{}' and customer_id='{}'""".format(self.user_id, self.customer_id) sql_user = """select f1.fund_id, f2.realname,f3.customer_name,f1.type,f1.order_type,f1.pay_date,f1.subscription_fee,f1.confirm_share_date,f1.confirm_share,f1.confirm_amount,f1.nav,f1.folio_name from tamp_diagnose_app.customer_order_view f1, tamp_user.user_info f2,tamp_user.customer_info f3 where f2.id=f1.user_id and f3.id=f1.customer_id and f1.delete_tag=0 and user_id='{}' and customer_id='{}'""".format(self.user_id, self.customer_id)
cur = tamp_diagnose_app_session.execute(sql_user) cur = tamp_diagnose_app_session.execute(sql_user)
data = cur.fetchall() data = cur.fetchall()
order_df = pd.DataFrame(list(data), columns=['fund_id', 'username', 'customer_name', 'type', 'order_type', 'pay_date', order_df = pd.DataFrame(list(data), columns=['fund_id', 'username', 'customer_name', 'type', 'order_type', 'pay_date',
......
This diff is collapsed.
...@@ -711,7 +711,7 @@ class PortfolioDiagnose(object): ...@@ -711,7 +711,7 @@ class PortfolioDiagnose(object):
group_hold_data = pd.DataFrame(group_result[group_name]["group_hoding_info"]) group_hold_data = pd.DataFrame(group_result[group_name]["group_hoding_info"])
profit_positive_num = len(group_hold_data[group_hold_data["profit"] > 0]["fund_name"].unique()) profit_positive_num = len(group_hold_data[group_hold_data["profit"] > 0]["fund_name"].unique())
if profit_positive_num > 0: if profit_positive_num > 0:
profit_positive_evaluate = str(profit_positive_num) + "只基金取得正收益取得正收益," profit_positive_evaluate = str(profit_positive_num) + "只基金取得正收益,"
else: else:
profit_positive_evaluate = "" profit_positive_evaluate = ""
...@@ -1143,23 +1143,25 @@ class PortfolioDiagnose(object): ...@@ -1143,23 +1143,25 @@ class PortfolioDiagnose(object):
ret = [] ret = []
fund_name = get_fund_name(fund_id).values[0][0] fund_name = get_fund_name(fund_id).values[0][0]
try:
default_evaluation = pd.read_csv("./app/service/evaluation.csv", encoding='utf-8', names=['fund_id', 'eval'])
if default_evaluation[default_evaluation['fund_id'] == fund_id]['eval'].values[0]:
ret.append('1、' + default_evaluation[default_evaluation['fund_id'] == fund_id]['eval'].values[0])
evaluation_dict = {'name': fund_name, 'data': ret}
if objective: # 默认评价
if fund_id in self.abandon_fund_score + self.abandon_fund_corr: # try:
evaluation_dict['status'] = "换仓" # default_evaluation = pd.read_csv("./app/service/evaluation.csv", encoding='utf-8', names=['fund_id', 'eval'])
elif fund_id in self.portfolio: # if default_evaluation[default_evaluation['fund_id'] == fund_id]['eval'].values[0]:
evaluation_dict['status'] = "保留" # ret.append('1、' + default_evaluation[default_evaluation['fund_id'] == fund_id]['eval'].values[0])
else: #
evaluation_dict['status'] = "" # evaluation_dict = {'name': fund_name, 'data': ret}
return evaluation_dict #
except Exception as e: # if objective:
pass # if fund_id in self.abandon_fund_score + self.abandon_fund_corr:
# evaluation_dict['status'] = "换仓"
# elif fund_id in self.portfolio:
# evaluation_dict['status'] = "保留"
# else:
# evaluation_dict['status'] = ""
# return evaluation_dict
# except Exception as e:
# pass
i = 1 i = 1
for k, v in evaluation.items(): for k, v in evaluation.items():
......
...@@ -10,7 +10,7 @@ import pandas as pd ...@@ -10,7 +10,7 @@ import pandas as pd
import numpy as np import numpy as np
import datetime import datetime
from decimal import Decimal from decimal import Decimal
from app.service.data_service import UserCustomerDataAdaptor from app.service.data_service_v2_1 import UserCustomerDataAdaptor
from app.utils.week_evaluation import * from app.utils.week_evaluation import *
...@@ -370,7 +370,7 @@ class UserCustomerResultAdaptor(UserCustomerDataAdaptor): ...@@ -370,7 +370,7 @@ class UserCustomerResultAdaptor(UserCustomerDataAdaptor):
# 基金持仓数据 # 基金持仓数据
total_market_values = p_sum_profit + p_total_amount # 月末总市值 total_market_values = p_sum_profit + p_total_amount # 月末总市值
fund_hoding_info = {"fund_strategy_name": dict_substrategy[int(row["substrategy"])], "fund_name": row["fund_name"]} fund_hoding_info = {"fund_strategy_name": dict_substrategy[int(row["substrategy"])], "fund_name": row["fund_name"]}
fund_hoding_info["confirm_date"] = row["confirm_share_date"] fund_hoding_info["confirm_date"] = row["confirm_share_date"].strftime("%Y-%m-%d")
fund_hoding_info["hold_year"] = "%.2f" % round((self.end_date - pd.to_datetime(row["confirm_share_date"])).days/365.0, 2) # 存续年数 fund_hoding_info["hold_year"] = "%.2f" % round((self.end_date - pd.to_datetime(row["confirm_share_date"])).days/365.0, 2) # 存续年数
fund_hoding_info["market_values"] = round((float(row["confirm_share"]) * (fund_basic_info["cur_cnav"] - confirm_cnav) + float(row["confirm_amount"]))/10000, 2) fund_hoding_info["market_values"] = round((float(row["confirm_share"]) * (fund_basic_info["cur_cnav"] - confirm_cnav) + float(row["confirm_amount"]))/10000, 2)
fund_hoding_info["weight"] = "%.2f" % round(float(fund_hoding_info["market_values"]) / total_market_values * 10000.0 * 100, 2) # 月末占比 fund_hoding_info["weight"] = "%.2f" % round(float(fund_hoding_info["market_values"]) / total_market_values * 10000.0 * 100, 2) # 月末占比
......
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