Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
F
fund_report
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
彭熊
fund_report
Commits
72b0c9f6
Commit
72b0c9f6
authored
Dec 16, 2020
by
赵杰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
主观版本bug修复
parent
4d4f38fe
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
17 deletions
+23
-17
portfolio_diagnose.py
app/service/portfolio_diagnose.py
+9
-5
draw.py
app/utils/draw.py
+3
-1
jinjia2html_v2.py
app/utils/jinjia2html_v2.py
+11
-11
No files found.
app/service/portfolio_diagnose.py
View file @
72b0c9f6
...
...
@@ -564,6 +564,7 @@ class PortfolioDiagnose(object):
prod
.
drop
(
columns
=
proposal
,
inplace
=
True
)
prod
.
dropna
(
how
=
'all'
,
inplace
=
True
)
prod
.
fillna
(
method
=
'bfill'
,
inplace
=
True
)
self
.
new_correlation
=
self
.
new_correlation
.
fillna
(
1
)
.
round
(
2
)
self
.
new_correlation
.
columns
=
self
.
new_correlation
.
columns
.
map
(
lambda
x
:
get_fund_name
(
x
)
.
values
[
0
][
0
])
self
.
new_correlation
.
index
=
self
.
new_correlation
.
index
.
map
(
lambda
x
:
get_fund_name
(
x
)
.
values
[
0
][
0
])
...
...
@@ -912,13 +913,16 @@ class PortfolioDiagnose(object):
suggestions
[
"before_optimization"
]
=
0
suggestions
[
"after_optimization"
]
=
value
[
"asset"
]
suggestions_result
[
key
][
suggestions
[
"fund_name"
]]
=
suggestions
else
:
suggestions_result
[
key
][
value
[
"fund_name"
]][
"after_optimization"
]
=
value
[
"asset"
]
for
key
,
value
in
suggestions_result
.
items
():
suggestions_result
[
key
]
=
list
(
value
.
values
())
suggestions_result_asset
=
{
"before"
:
total_asset
,
"after"
:
total_asset
}
# 旧组合累积收益df
old_return_df
=
group_result_data
[
"return_df"
]
old_return_df
[
"cum_return_ratio"
]
=
old_return_df
[
"cum_return_ratio"
]
-
1
# old_return_df["cum_return_ratio"] = old_return_df["cum_return_ratio"]
# 新组合累积收益df
propose_fund_return_limit_data
=
propose_fund_return
[
propose_fund_return
.
index
>=
group_order_start_date
]
start_return
=
propose_fund_return_limit_data
[
'return'
]
.
values
[
0
]
...
...
@@ -988,11 +992,11 @@ class PortfolioDiagnose(object):
proposal_fund_name
=
[
get_fund_name
(
x
)
.
values
[
0
][
0
]
for
x
in
proposal_fund
]
sentence
=
[]
if
hold_fund
is
not
None
:
if
len
(
hold_fund
)
>
0
:
sentence
.
append
(
"在保留"
+
""
.
join
([
i
+
","
for
i
in
hold_fund_name
])
.
rstrip
(
","
)
+
"的基础上"
)
if
abandon_fund
is
not
None
:
if
len
(
abandon_fund
)
>
0
:
sentence
.
append
(
"建议赎回"
+
""
.
join
([
i
+
","
for
i
in
abandon_fund_name
])
.
rstrip
(
","
))
if
proposal_fund
is
not
None
:
if
len
(
proposal_fund
)
>
0
:
sentence
.
append
(
"增配"
+
""
.
join
([
i
+
","
for
i
in
proposal_fund_name
])
.
rstrip
(
","
)
+
"后"
)
if
new_volatility
<
old_volatility
*
0.9
:
sentence
.
append
(
"整体组合波动率大幅降低"
)
...
...
@@ -1134,7 +1138,7 @@ class PortfolioDiagnose(object):
evaluation_dict
[
'status'
]
=
""
return
evaluation_dict
except
Exception
as
e
:
raise
e
pass
i
=
1
for
k
,
v
in
evaluation
.
items
():
...
...
app/utils/draw.py
View file @
72b0c9f6
...
...
@@ -110,7 +110,9 @@ def draw_contribution_chart(xlabels, product_list, cumulative):
max_x_count
=
max
([
x
[
'data'
]
.
size
for
x
in
product_list
])
loc
=
np
.
arange
(
max_x_count
)
# the x locations for the groups
width
=
0.35
# the width of the bars: can also be len(x) sequence
color_list
=
[
'#333333'
,
'#928C8C'
,
'#F9A3A3'
,
'#FFDBDB'
]
color_list
=
[
'#333333'
,
'#928C8C'
,
'#AFAFAF'
,
'#D56666'
,
'#DE7A7A'
,
'#ED9494'
,
'#F4A9A9'
,
'#FFC8C8'
,
'#DEA27A'
,
'#EFAF85'
,
'#FBBF98'
,
'#FFD2B5'
,
'#E1C277'
,
'#EBCD85'
,
'#FEDF96'
]
# 坐标轴
ax1
.
tick_params
(
labelsize
=
fontsize
)
...
...
app/utils/jinjia2html_v2.py
View file @
72b0c9f6
...
...
@@ -71,12 +71,12 @@ class DataIntegrate:
self
.
get_old_compare_pic
(
cur_group_portfolio_result
)
# 旧相关性
self
.
get_old_correlation
(
portfolio_diagnose
,
cur_group_portfolio_result
)
# #
#
新增基金
#
self.propose_fund(portfolio_diagnose, cur_group_portfolio_result)
# #
#
新收益比较
#
self.get_transfer_suggestions(portfolio_diagnose, group_name, cur_group_portfolio_result)
# #
#
新相关性
#
self.get_new_correlation(portfolio_diagnose, cur_group_portfolio_result)
# # 新增基金
self
.
propose_fund
(
portfolio_diagnose
,
cur_group_portfolio_result
)
# # 新收益比较
self
.
get_transfer_suggestions
(
portfolio_diagnose
,
group_name
,
cur_group_portfolio_result
)
# # 新相关性
self
.
get_new_correlation
(
portfolio_diagnose
,
cur_group_portfolio_result
)
self
.
all_folio_result
[
group_name
]
=
cur_group_portfolio_result
...
...
@@ -238,9 +238,9 @@ class DataIntegrate:
# 个基点评
'box5'
:
'block'
,
# 优化组合建议
'box6'
:
None
,
'box6'
:
'block'
,
# 新增基金
'box7'
:
None
,
'box7'
:
'block'
,
# 结尾
'box8'
:
'block'
,
'cover_back'
:
template_folder
+
'/v2/img/cover-back.png'
,
...
...
@@ -315,9 +315,9 @@ class DataIntegrate:
template
=
env
.
get_template
(
'/v2/monthReportV2.1.html'
)
# 获取一个模板文件
monthReport_html
=
template
.
render
(
data
)
# 渲染
# 保存 monthReport_html
#
save_file = "app/html/monthReport.html"
#
with open(save_file, 'w', encoding="utf-8") as f:
#
f.write(monthReport_html)
save_file
=
"app/html/monthReport.html"
with
open
(
save_file
,
'w'
,
encoding
=
"utf-8"
)
as
f
:
f
.
write
(
monthReport_html
)
# save_file = "app/html/v2/monthReportV2.html"
# with open(save_file, 'w', encoding="utf-8") as f:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment