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
feef4557
Commit
feef4557
authored
Dec 02, 2020
by
pengxiong@wealthgrow.cn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
模版
parent
1efe45c1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
76 deletions
+54
-76
portfolio_diagnose.py
app/service/portfolio_diagnose.py
+5
-5
monthReport.html
app/templates/monthReport.html
+6
-48
radar_chart.py
app/utils/radar_chart.py
+25
-22
jinjia2html.py
jinjia2html.py
+18
-1
No files found.
app/service/portfolio_diagnose.py
View file @
feef4557
...
...
@@ -649,10 +649,10 @@ portfolio = ['HF00002JJ2', 'HF00005DBQ', 'HF0000681Q', 'HF00006693', 'HF00006AZF
portfolio_diagnose
=
PortfolioDiagnose
(
client_type
=
1
,
portfolio
=
portfolio
,
invest_amount
=
10000000
)
portfolio_diagnose
.
optimize
()
if
__name__
==
'__main__'
:
#
print(portfolio_diagnose.single_fund_radar())
print
(
portfolio_diagnose
.
single_fund_radar
())
# print(portfolio_diagnose.propose_fund_radar())
# print(portfolio_diagnose.old_portfolio_evaluation())
print
(
'旧组合相关性:'
,
portfolio_diagnose
.
old_correlation
)
print
(
'新组合相关性:'
,
portfolio_diagnose
.
new_correlation
)
print
(
'旧组合个基评价:'
,
portfolio_diagnose
.
old_portfolio_evaluation
())
print
(
'新组合个基评价:'
,
portfolio_diagnose
.
propose_fund_evaluation
())
#
print('旧组合相关性:', portfolio_diagnose.old_correlation)
#
print('新组合相关性:', portfolio_diagnose.new_correlation)
#
print('旧组合个基评价:', portfolio_diagnose.old_portfolio_evaluation())
#
print('新组合个基评价:', portfolio_diagnose.propose_fund_evaluation())
app/templates/monthReport.html
View file @
feef4557
...
...
@@ -2505,6 +2505,7 @@
</div>
<div
class=
"content_wrap"
>
<ul
class=
"geji_list_wrap"
>
{% for single_fund in single_fund_data_list %}
<li
class=
"self_item"
>
<table>
<tr>
...
...
@@ -2512,62 +2513,18 @@
<div
class=
"self_item_left"
>
<div
class=
"self_header"
>
<div
class=
"self_title"
>
远澜银杏 1 号
{{single_fund.fund_name}}
<div
class=
"self_title_tri"
></div>
</div>
<div
class=
"self_type yellow"
>
保留
{{single_fund.status}}
</div>
</div>
<div
class=
"self_description"
>
<div
class=
"self_description_item"
>
<div
class=
"self_description_dot"
></div>
<div
class=
"self_description_text"
>
1、该基金整体表现
<span
class=
"self_description_red"
>
优秀
</span>
/
<span
class=
"self_description_red"
>
良好
</span>
/
<span
class=
"self_description_green"
>
一般
</span>
/
<span
class=
"self_description_green"
>
合格
</span>
/
<span
class=
"self_description_green"
>
较差
</span>
,
收益能力
<span
class=
"self_description_red"
>
优秀
</span>
/
<span
class=
"self_description_red"
>
良好
</span>
/
<span
class=
"self_description_green"
>
一般
</span>
/
<span
class=
"self_description_green"
>
合格
</span>
/
<span
class=
"self_description_green"
>
较差
</span>
,
回撤控制能力
<span
class=
"self_description_red"
>
优秀
</span>
/
<span
class=
"self_description_red"
>
良好
</span>
/
<span
class=
"self_description_green"
>
一般
</span>
/
<span
class=
"self_description_green"
>
合格
</span>
/
<span
class=
"self_description_green"
>
较差
</span>
,
风险收益比例
<span
class=
"self_description_red"
>
优秀
</span>
/
<span
class=
"self_description_red"
>
良好
</span>
/
<span
class=
"self_description_green"
>
一般
</span>
/
<span
class=
"self_description_green"
>
合格
</span>
/
<span
class=
"self_description_green"
>
较差
</span>
;
</div>
</div>
<div
class=
"self_description_item"
>
<div
class=
"self_description_dot"
></div>
<div
class=
"self_description_text"
>
2、在收益方面,该基金年化收益能力
<span
class=
"self_description_red"
>
高于
</span>
/
<span
class=
"self_description_green"
>
持平
</span>
/
<span
class=
"self_description_green"
>
低于
</span>
,
同类基金平均水平,有x%区间跑赢大盘/指数,绝对收益能力
<span
class=
"self_description_red"
>
优秀
</span>
/
<span
class=
"self_description_red"
>
良好
</span>
/
<span
class=
"self_description_green"
>
一般
</span>
/
<span
class=
"self_description_green"
>
合格
</span>
/
<span
class=
"self_description_green"
>
较差
</span>
;
</div>
</div>
<div
class=
"self_description_item"
>
<div
class=
"self_description_dot"
></div>
<div
class=
"self_description_text"
>
3、在风险方面,该基金抵御风险能力优秀,在同类基金中处于中等水平,最大回撤为x%,低于同类基金平均水平;
{{single_fund.evaluation}}
</div>
</div>
</div>
...
...
@@ -2575,12 +2532,13 @@
</td>
<td
style=
"padding: 0;text-align: left;vertical-align: middle;"
>
<div
class=
"self_item_right"
>
<img
src=
"./img/logo-blue.png"
alt=
""
class=
"self_img"
>
<img
src=
{{single_fund.radar_chart_path}}
alt=
""
class=
"self_img"
>
</div>
</td>
</tr>
</table>
</li>
{% endfor %}
<li
class=
"self_item"
>
<table>
<tr>
...
...
app/utils/radar_chart.py
View file @
feef4557
...
...
@@ -6,34 +6,38 @@
# @Email : acepengxiong@163.com
# @Software : PyCharm
# -----------------------------------------------------------------------------
from
io
import
BytesIO
,
StringIO
import
imgkit
import
pyecharts.options
as
opts
from
pyecharts.charts
import
Radar
,
Bar
from
snapshot_phantomjs
import
snapshot
from
pyecharts.render
import
make_snapshot
import
uuid
import
cv2
from
app.api.engine
import
work_dir
def
gen_radar_chart
():
def
gen_radar_chart
(
radar_chart_data
):
"""
Gallery 使用 pyecharts 1.1.0
参考地址: https://echarts.apache.org/examples/editor.html?c=radar
目前无法实现的功能:
1、雷达图周围的图例的 textStyle 暂时无法设置背景颜色
"""
v1
=
[[
4300
,
10000
,
28000
,
35000
,
50000
]]
htmldata
=
StringIO
()
# v1 = [[4300, 10000, 28000, 35000, 50000]]
radar_chart
=
radar_chart_data
[
'data'
][
0
:
5
]
v1
=
[[
data
[
'data'
]
for
data
in
radar_chart
]]
print
(
radar_chart
)
radar
=
Radar
(
init_opts
=
opts
.
InitOpts
(
bg_color
=
"#fff"
,
animation_opts
=
opts
.
AnimationOpts
(
animation
=
False
)))
.
add_schema
(
schema
=
[
opts
.
RadarIndicatorItem
(
name
=
"绝对收益"
,
max_
=
65
00
),
opts
.
RadarIndicatorItem
(
name
=
"
业绩持续性"
,
max_
=
160
00
),
opts
.
RadarIndicatorItem
(
name
=
"
风险调整后收益"
,
max_
=
300
00
),
opts
.
RadarIndicatorItem
(
name
=
"
极端风险"
,
max_
=
380
00
),
opts
.
RadarIndicatorItem
(
name
=
"
抗风险能力"
,
max_
=
520
00
),
opts
.
RadarIndicatorItem
(
name
=
"绝对收益"
,
max_
=
1
00
),
opts
.
RadarIndicatorItem
(
name
=
"
抗风险能力"
,
max_
=
1
00
),
opts
.
RadarIndicatorItem
(
name
=
"
极端风险"
,
max_
=
1
00
),
opts
.
RadarIndicatorItem
(
name
=
"
风险调整后收益"
,
max_
=
1
00
),
opts
.
RadarIndicatorItem
(
name
=
"
业绩持续性"
,
max_
=
1
00
),
],
# schema=[
# opts.RadarIndicatorItem(name=data['name'], max_=float(data['data'])) for data in radar_chart
# ],
splitarea_opt
=
opts
.
SplitAreaOpts
(
is_show
=
True
,
areastyle_opts
=
opts
.
AreaStyleOpts
(
opacity
=
1
,
color
=
[
'rgba(198, 167, 116, 0.5)'
,
...
...
@@ -51,7 +55,7 @@ def gen_radar_chart():
tooltip_opts
=
None
)
.
set_series_opts
(
label_opts
=
opts
.
LabelOpts
(
is_show
=
False
))
.
set_global_opts
(
title_opts
=
opts
.
TitleOpts
(
title
=
"综合评分"
,
subtitle
=
"66.32"
,
pos_top
=
"center"
,
pos_left
=
"46
%
"
,
title
=
"综合评分"
,
subtitle
=
radar_chart_data
[
'data'
][
5
][
'data'
]
,
pos_top
=
"center"
,
pos_left
=
"46
%
"
,
title_textstyle_opts
=
{
'color'
:
'#333'
,
'fontSize'
:
18
,
'lineHeight'
:
20
,
...
...
@@ -64,21 +68,20 @@ def gen_radar_chart():
}),
legend_opts
=
opts
.
LegendOpts
(
selected_mode
=
False
,
is_show
=
False
)
)
radar
.
render
()
imgkit
.
from_file
(
'render.html'
,
"radar_chart.png"
)
html_name
=
work_dir
+
'/app/html/'
+
str
(
uuid
.
uuid4
())
+
'.html'
img_name
=
work_dir
+
'/app/html/img/radar_chart_'
+
str
(
uuid
.
uuid4
())
+
'.png'
radar
.
render
(
html_name
)
imgkit
.
from_file
(
html_name
,
img_name
)
# 读取图片
img
=
cv2
.
imread
(
'radar_chart.png'
)
img
=
cv2
.
imread
(
img_name
)
# 获取宽度和高度
height
=
len
(
img
)
width
=
len
(
img
[
0
])
img
=
img
[
height
:
height
,
200
:
800
]
height
=
len
(
img
)
width
=
len
(
img
[
0
])
print
(
'图片大小
%
dX
%
d'
%
(
width
,
height
))
cv2
.
imshow
(
'radar_chart.png'
,
img
)
cv2
.
waitKey
(
0
)
img
=
img
[
0
:
height
,
160
:
750
]
cv2
.
imwrite
(
img_name
,
img
)
return
img_name
if
__name__
==
'__main__'
:
gen_radar_chart
()
\ No newline at end of file
jinjia2html.py
View file @
feef4557
from
jinja2
import
PackageLoader
,
Environment
from
app.service.portfolio_diagnose
import
portfolio_diagnose
from
app.service.result_service
import
UserCustomerResultAdaptor
import
numpy
as
np
# 准备数据
from
app.utils.draw
import
draw_month_return_chart
,
draw_contribution_chart
from
app.utils.radar_chart
import
gen_radar_chart
ifa_id
=
'USER_INFO15914346866762'
customer_id
=
'202009281545001'
...
...
@@ -37,6 +40,19 @@ print(group_result)
g_data
=
group_result
[
"contribution_decomposition"
]
contribution_decomposition
=
draw_contribution_chart
(
g_data
[
'xlabels'
],
g_data
[
'product_list'
],
g_data
[
'cumulative'
])
# 个基点评
single_fund_data_list
=
[]
portfolio_evaluation
=
portfolio_diagnose
.
old_portfolio_evaluation
()
radar_chart_data
=
portfolio_diagnose
.
single_fund_radar
()
# for one in radar_chart_data:
# print(gen_radar_chart(one))
radar_chart_path
=
gen_radar_chart
(
radar_chart_data
[
0
])
single_fund_data_list
.
append
({
'fund_name'
:
radar_chart_data
[
0
][
'name'
],
'status'
:
'保留'
,
'evaluation'
:
portfolio_evaluation
[
0
][
'data'
],
'radar_chart_path'
:
radar_chart_path
})
now_month_income
=
int
(
group_result
[
"cur_month_profit"
])
# 本月收益
now_year_income
=
int
(
group_result
[
"cur_year_profit"
])
# 今年累计收益
totoal_rate_of_return
=
round
((
group_result
[
'cumulative_return'
]
-
1
)
*
100
,
2
)
# 累计收益率
...
...
@@ -80,7 +96,8 @@ data = {'customer_name':'成龙', 'customer_gender':'女',
'monthly_return_performance_pic'
:
monthly_return_performance_pic
,
'group_nav_info'
:
group_nav_info
,
'group_hoding_info'
:
group_hoding_info
,
'contribution_decomposition'
:
contribution_decomposition
'contribution_decomposition'
:
contribution_decomposition
,
'single_fund_data_list'
:
single_fund_data_list
}
...
...
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