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
1c6b5c23
Commit
1c6b5c23
authored
Jan 07, 2021
by
pengxiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
持仓,诊断模版
parent
cf6e6059
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
251 additions
and
202 deletions
+251
-202
default_template_params.py
app/config/default_template_params.py
+67
-22
monthReportV2.1.html
app/templates/v2/monthReportV2.1.html
+120
-120
format_transfer.py
app/utils/format_transfer.py
+9
-1
jinjia2html_v2.py
app/utils/jinjia2html_v2.py
+55
-59
No files found.
app/config/default_template_params.py
View file @
1c6b5c23
...
...
@@ -7,47 +7,92 @@
# @Software : PyCharm
# -----------------------------------------------------------------------------
from
app.api.engine
import
template_folder
from
app.utils.format_transfer
import
img_transfer
default_template
=
{
hold_
default_template
=
{
# 封面 值为None不不显示,为block显示
'box0'
:
'block'
,
# 目录
'box1'
:
'block'
,
# 投资总览
'box2'
:
'block'
,
'box2
-section1'
:
'block'
,
'box2
-
section2'
:
'block'
,
'box2
-
section3'
:
'block'
,
'box2
-
section4'
:
'block'
,
'box2
_section1'
:
None
,
'box2
_
section2'
:
'block'
,
'box2
_
section3'
:
'block'
,
'box2
_
section4'
:
'block'
,
# 目标与业绩
'box3'
:
'block'
,
'box3
-
section1'
:
'block'
,
'box3
-
section2'
:
'block'
,
'box3
-
section3'
:
'block'
,
'box3
-
section4'
:
'block'
,
'box3
_
section1'
:
'block'
,
'box3
_
section2'
:
'block'
,
'box3
_
section3'
:
'block'
,
'box3
_
section4'
:
'block'
,
# 业绩的明细
'box4'
:
'block'
,
'box4
-
section1'
:
'block'
,
'box4
-
section2'
:
'block'
,
'box4
-
section3'
:
'block'
,
'box4
_
section1'
:
'block'
,
'box4
_
section2'
:
'block'
,
'box4
_
section3'
:
'block'
,
# 个基点评
'box5'
:
None
,
# 优化组合建议
'box6'
:
None
,
'box6
-
section1'
:
'block'
,
'box6
-
section2'
:
'block'
,
'box6
-
section3'
:
'block'
,
'box6
-
section4'
:
'block'
,
'box6
_
section1'
:
'block'
,
'box6
_
section2'
:
'block'
,
'box6
_
section3'
:
'block'
,
'box6
_
section4'
:
'block'
,
# 新增基金
'box7'
:
None
,
# 结尾
'box8'
:
'block'
,
'logo'
:
template_folder
+
'/v2/img/logo.png'
,
'logo'
:
img_transfer
(
template_folder
+
'/v2/img/logo.png'
)
,
'brand_name'
:
'资产管<br>理中心'
,
'cover_back'
:
template_folder
+
'/v2/img/cover-back.png'
,
'cover_back'
:
img_transfer
(
template_folder
+
'/v2/img/cover-back.png'
)
,
'scene'
:
template_folder
+
'/v2/img/scene.png'
,
'team'
:
template_folder
+
'/v2/img/default-user.png'
,
'red_rect'
:
template_folder
+
'/v2/img/red-rect.png'
,
'sh'
:
template_folder
+
'/v2/img/sh.png'
,
'scene'
:
img_transfer
(
template_folder
+
'/v2/img/scene.png'
),
'team'
:
img_transfer
(
template_folder
+
'/v2/img/default-user.png'
),
'red_rect'
:
img_transfer
(
template_folder
+
'/v2/img/red-rect.png'
),
'sh'
:
img_transfer
(
template_folder
+
'/v2/img/sh.png'
),
}
diagnose_default_template
=
{
# 封面 值为None不不显示,为block显示
'box0'
:
'block'
,
# 目录
'box1'
:
'block'
,
# 投资总览
'box2'
:
'block'
,
'box2_section1'
:
'block'
,
'box2_section2'
:
'block'
,
'box2_section3'
:
'block'
,
'box2_section4'
:
'block'
,
# 目标与业绩
'box3'
:
'block'
,
'box3_section1'
:
'block'
,
'box3_section2'
:
'block'
,
'box3_section3'
:
'block'
,
'box3_section4'
:
'block'
,
# 业绩的明细
'box4'
:
'block'
,
'box4_section1'
:
'block'
,
'box4_section2'
:
'block'
,
'box4_section3'
:
'block'
,
# 个基点评
'box5'
:
'block'
,
# 优化组合建议
'box6'
:
'block'
,
'box6_section1'
:
'block'
,
'box6_section2'
:
'block'
,
'box6_section3'
:
'block'
,
'box6_section4'
:
'block'
,
# 新增基金
'box7'
:
'block'
,
# 结尾
'box8'
:
'block'
,
'logo'
:
img_transfer
(
template_folder
+
'/v2/img/logo.png'
),
'brand_name'
:
'资产管<br>理中心'
,
'cover_back'
:
img_transfer
(
template_folder
+
'/v2/img/cover-back.png'
),
'scene'
:
img_transfer
(
template_folder
+
'/v2/img/scene.png'
),
'team'
:
img_transfer
(
template_folder
+
'/v2/img/default-user.png'
),
'red_rect'
:
img_transfer
(
template_folder
+
'/v2/img/red-rect.png'
),
'sh'
:
img_transfer
(
template_folder
+
'/v2/img/sh.png'
),
}
app/templates/v2/monthReportV2.1.html
View file @
1c6b5c23
...
...
@@ -242,7 +242,7 @@
/* 投资总览 */
.box2
{
display
:
{{
box2
}
}
;
display
:
{{
box2
}
}
}
.box2
.box2_content
{
padding
:
47px
34px
61px
34px
;
...
...
@@ -937,14 +937,14 @@
<div
class=
"dcell"
>
<img
src=
{{logo}}
alt=
""
class=
"cover_logo"
>
</div>
<!-- <div class="dcell">--
>
<!-- <div class="cover_line"></div>--
>
<!-- </div>--
>
<!-- <div class="dcell">--
>
<!-- <div class="cover_text">--
>
<!-- {{brand_name}}-->
<!-- </div>--
>
<!-- </div>--
>
<div
class=
"dcell"
>
<div
class=
"cover_line"
></div
>
</div
>
<div
class=
"dcell"
>
<div
class=
"cover_text"
>
{{brand_name}}
</div
>
</div
>
</div>
<img
src=
{{sh}}
alt=
""
class=
"cover_back fr"
>
<div
class=
"cover_title dtable"
>
...
...
@@ -1019,20 +1019,20 @@
<div
class=
"dcell"
>
<img
src=
{{logo}}
alt=
""
class=
"page_logo"
>
</div>
<!-- <div class="dcell">--
>
<!-- <div class="page_line"></div>--
>
<!-- </div>--
>
<!-- <div class="dcell">--
>
<!-- <div class="page_text">--
>
<!-- {{brand_name}}-->
<!-- </div>--
>
<!-- </div>--
>
<div
class=
"dcell"
>
<div
class=
"page_line"
></div
>
</div
>
<div
class=
"dcell"
>
<div
class=
"page_text"
>
{{brand_name}}
</div
>
</div
>
</div>
</div>
<div
class=
"box2_content"
>
<!-- 组合投资表现 -->
<div
class=
"tss1"
style=
"margin: 0;"
>
<div
class=
"tss1"
style=
"margin: 0;
display: {{box2_section1}}
"
>
<div
class=
"tss1_title"
>
组合投资表现
</div>
...
...
@@ -1094,7 +1094,7 @@
</div>
<!-- 资产盈亏情况 -->
<div
class=
"tss1"
>
<div
class=
"tss1"
style=
"display: {{box2_section2}}"
>
<div
class=
"tss1_title"
>
资产盈亏情况
</div>
...
...
@@ -1126,7 +1126,7 @@
</div>
<!-- 组合月度及累计回报率曲线 -->
<div
class=
"tss2"
>
<div
class=
"tss2"
style=
"display: {{box2_section3}}"
>
<div
class=
"tss2_title"
>
组合月度及累计回报率曲线
</div>
...
...
@@ -1136,7 +1136,7 @@
</div>
<!-- 组合月度及累计回报率曲线 -->
<div
class=
"tss3"
>
<div
class=
"tss3"
style=
"display: {{box2_section4}}"
>
<div
class=
"tss3_head dtable"
>
<div
class=
"tss3_title dcell"
>
月度收益
...
...
@@ -1299,21 +1299,21 @@
<div
class=
"dcell"
>
<img
src=
{{logo}}
alt=
""
class=
"page_logo"
>
</div>
<!-- <div class="dcell">--
>
<!-- <div class="page_line"></div>--
>
<!-- </div>--
>
<!-- <div class="dcell">--
>
<!-- <div class="page_text">--
>
<!-- {{brand_name}}-->
<!-- </div>--
>
<!-- </div>--
>
<div
class=
"dcell"
>
<div
class=
"page_line"
></div
>
</div
>
<div
class=
"dcell"
>
<div
class=
"page_text"
>
{{brand_name}}
</div
>
</div
>
</div>
</div>
<div
class=
"box3_content"
>
<!-- 投资目标 -->
<div
class=
"tss3"
style=
"margin: 0;"
>
<div
class=
"tss3"
style=
"margin: 0;
display: {{box3_section1}}
"
>
<div
class=
"tss3_head dtable"
>
<div
class=
"tss3_title dcell"
>
投资目标
...
...
@@ -1346,7 +1346,7 @@
</div>
<!-- 指标对比 -->
<div
class=
"tss3"
>
<div
class=
"tss3"
style=
"display: {{box3_section2}}"
>
<div
class=
"tss3_head dtable"
>
<div
class=
"tss3_title dcell"
>
指标对比
<span
class=
"tss3_start_time"
>
(起始日期{{start_date}})
</span>
...
...
@@ -1390,7 +1390,7 @@
</div>
<!-- 收益比较、相关性分析 -->
<div
class=
"par clearfix"
cellpadding=
"38"
>
<div
class=
"par clearfix"
cellpadding=
"38"
style=
"display: {{box3_section3}}"
>
<div
class=
"par_item fl"
>
<div
class=
"par_title"
>
收益比较
...
...
@@ -1399,7 +1399,7 @@
<img
src=
{{group_result["old_return_compare_pic"]}}
alt=
""
class=
"par_img"
>
</div>
</div>
<div
class=
"par_item fr"
>
<div
class=
"par_item fr"
style=
"display: {{box3_section4}}"
>
<div
class=
"par_title"
>
相关性分析
</div>
...
...
@@ -1524,21 +1524,21 @@
<div
class=
"dcell"
>
<img
src=
{{logo}}
alt=
""
class=
"page_logo"
>
</div>
<!-- <div class="dcell">--
>
<!-- <div class="page_line"></div>--
>
<!-- </div>--
>
<!-- <div class="dcell">--
>
<!-- <div class="page_text">--
>
<!-- {{brand_name}}-->
<!-- </div>--
>
<!-- </div>--
>
<div
class=
"dcell"
>
<div
class=
"page_line"
></div
>
</div
>
<div
class=
"dcell"
>
<div
class=
"page_text"
>
{{brand_name}}
</div
>
</div
>
</div>
</div>
<div
class=
"box4_content"
>
<!-- 持仓收益汇总 -->
<div
class=
"tss3"
style=
"margin: 0;"
>
<div
class=
"tss3"
style=
"margin: 0;
display: {{box4_section1}}
"
>
<div
class=
"tss3_head dtable"
>
<div
class=
"tss3_title dcell"
>
持仓收益汇总
...
...
@@ -1604,7 +1604,7 @@
</div>
<!-- 基金净值 -->
<div
class=
"tss3"
>
<div
class=
"tss3"
style=
"display: {{box4_section2}}"
>
<div
class=
"tss3_head dtable"
>
<div
class=
"tss3_title dcell"
>
基金净值
...
...
@@ -1652,7 +1652,7 @@
</div>
<!-- 贡献分解 -->
<div
class=
"page dtable"
style=
"page-break-before:always;"
>
<div
class=
"page dtable"
style=
"page-break-before:always;
display: {{box4_section3}}
"
>
<div
class=
"page_title dcell"
>
</div>
...
...
@@ -1660,14 +1660,14 @@
<div
class=
"dcell"
>
<img
src=
{{logo}}
alt=
""
class=
"page_logo"
>
</div>
<!-- <div class="dcell">--
>
<!-- <div class="page_line"></div>--
>
<!-- </div>--
>
<!-- <div class="dcell">--
>
<!-- <div class="page_text">--
>
<!-- {{brand_name}}-->
<!-- </div>--
>
<!-- </div>--
>
<div
class=
"dcell"
>
<div
class=
"page_line"
></div
>
</div
>
<div
class=
"dcell"
>
<div
class=
"page_text"
>
{{brand_name}}
</div
>
</div
>
</div>
</div>
<div
class=
"tss2"
>
...
...
@@ -1694,14 +1694,14 @@
<div
class=
"dcell"
>
<img
src=
{{logo}}
alt=
""
class=
"page_logo"
>
</div>
<!-- <div class="dcell">--
>
<!-- <div class="page_line"></div>--
>
<!-- </div>--
>
<!-- <div class="dcell">--
>
<!-- <div class="page_text">--
>
<!-- {{brand_name}}-->
<!-- </div>--
>
<!-- </div>--
>
<div
class=
"dcell"
>
<div
class=
"page_line"
></div
>
</div
>
<div
class=
"dcell"
>
<div
class=
"page_text"
>
{{brand_name}}
</div
>
</div
>
</div>
</div>
...
...
@@ -1716,14 +1716,14 @@
<div
class=
"dcell"
>
<img
src=
{{logo}}
alt=
""
class=
"page_logo"
>
</div>
<!-- <div class="dcell">--
>
<!-- <div class="page_line"></div>--
>
<!-- </div>--
>
<!-- <div class="dcell">--
>
<!-- <div class="page_text">--
>
<!-- {{brand_name}}-->
<!-- </div>--
>
<!-- </div>--
>
<div
class=
"dcell"
>
<div
class=
"page_line"
></div
>
</div
>
<div
class=
"dcell"
>
<div
class=
"page_text"
>
{{brand_name}}
</div
>
</div
>
</div>
</div>
{% endif %}
...
...
@@ -1775,14 +1775,14 @@
<div
class=
"dcell"
>
<img
src=
{{logo}}
alt=
""
class=
"page_logo"
>
</div>
<!-- <div class="dcell">--
>
<!-- <div class="page_line"></div>--
>
<!-- </div>--
>
<!-- <div class="dcell">--
>
<!-- <div class="page_text">--
>
<!-- {{brand_name}}-->
<!-- </div>--
>
<!-- </div>--
>
<div
class=
"dcell"
>
<div
class=
"page_line"
></div
>
</div
>
<div
class=
"dcell"
>
<div
class=
"page_text"
>
{{brand_name}}
</div
>
</div
>
</div>
</div>
{% endif %}
...
...
@@ -1818,21 +1818,21 @@
<div
class=
"dcell"
>
<img
src=
{{logo}}
alt=
""
class=
"page_logo"
>
</div>
<!-- <div class="dcell">--
>
<!-- <div class="page_line"></div>--
>
<!-- </div>--
>
<!-- <div class="dcell">--
>
<!-- <div class="page_text">--
>
<!-- {{brand_name}}-->
<!-- </div>--
>
<!-- </div>--
>
<div
class=
"dcell"
>
<div
class=
"page_line"
></div
>
</div
>
<div
class=
"dcell"
>
<div
class=
"page_text"
>
{{brand_name}}
</div
>
</div
>
</div>
</div>
<div
class=
"box6_content"
>
<!-- 调仓建议 -->
<div
class=
"tss3"
style=
"margin: 0;"
>
<div
class=
"tss3"
style=
"margin: 0;
display: {{box6_section1}}
"
>
<div
class=
"tss3_head dtable"
>
<div
class=
"tss3_title dcell"
>
调仓建议
...
...
@@ -1866,7 +1866,7 @@
</div>
<!-- 指标对比 -->
<div
class=
"tss3"
>
<div
class=
"tss3"
style=
"display: {{box6_section2}}"
>
<div
class=
"tss3_head dtable"
>
<div
class=
"tss3_title dcell"
>
指标对比
<span
class=
"tss3_start_time"
>
(起始日期2019-11-06)
</span>
...
...
@@ -1914,18 +1914,18 @@
<div
class=
"dcell"
>
<img
src=
{{logo}}
alt=
""
class=
"page_logo"
>
</div>
<!-- <div class="dcell">--
>
<!-- <div class="page_line"></div>--
>
<!-- </div>--
>
<!-- <div class="dcell">--
>
<!-- <div class="page_text">--
>
<!-- {{brand_name}}-->
<!-- </div>--
>
<!-- </div>--
>
<div
class=
"dcell"
>
<div
class=
"page_line"
></div
>
</div
>
<div
class=
"dcell"
>
<div
class=
"page_text"
>
{{brand_name}}
</div
>
</div
>
</div>
</div>
<div
class=
"par clearfix"
cellpadding=
"38"
>
<div
class=
"par_item fl"
>
<div
class=
"par_item fl"
style=
"display: {{box6_section3}}"
>
<div
class=
"par_title"
>
收益比较
</div>
...
...
@@ -1933,7 +1933,7 @@
<img
src=
{{group_result["return_compare_pic"]}}
alt=
""
class=
"par_img"
>
</div>
</div>
<div
class=
"par_item fr"
>
<div
class=
"par_item fr"
style=
"display: {{box6_section4}}"
>
<div
class=
"par_title"
>
相关性分析
</div>
...
...
@@ -2058,14 +2058,14 @@
<div
class=
"dcell"
>
<img
src=
{{logo}}
alt=
""
class=
"page_logo"
>
</div>
<!-- <div class="dcell">--
>
<!-- <div class="page_line"></div>--
>
<!-- </div>--
>
<!-- <div class="dcell">--
>
<!-- <div class="page_text">--
>
<!-- {{brand_name}}-->
<!-- </div>--
>
<!-- </div>--
>
<div
class=
"dcell"
>
<div
class=
"page_line"
></div
>
</div
>
<div
class=
"dcell"
>
<div
class=
"page_text"
>
{{brand_name}}
</div
>
</div
>
</div>
</div>
...
...
@@ -2081,14 +2081,14 @@
<div
class=
"dcell"
>
<img
src=
{{logo}}
alt=
""
class=
"page_logo"
>
</div>
<!-- <div class="dcell">--
>
<!-- <div class="page_line"></div>--
>
<!-- </div>--
>
<!-- <div class="dcell">--
>
<!-- <div class="page_text">--
>
<!-- {{brand_name}}-->
<!-- </div>--
>
<!-- </div>--
>
<div
class=
"dcell"
>
<div
class=
"page_line"
></div
>
</div
>
<div
class=
"dcell"
>
<div
class=
"page_text"
>
{{brand_name}}
</div
>
</div
>
</div>
</div>
<div
class=
"self_item"
>
...
...
@@ -2158,14 +2158,14 @@
<div
class=
"dcell"
>
<img
src=
{{logo}}
alt=
""
class=
"page_logo"
>
</div>
<!-- <div class="dcell">--
>
<!-- <div class="page_line"></div>--
>
<!-- </div>--
>
<!-- <div class="dcell">--
>
<!-- <div class="page_text">--
>
<!-- {{brand_name}}-->
<!-- </div>--
>
<!-- </div>--
>
<div
class=
"dcell"
>
<div
class=
"page_line"
></div
>
</div
>
<div
class=
"dcell"
>
<div
class=
"page_text"
>
{{brand_name}}
</div
>
</div
>
</div>
</div>
<div
class=
"box8_content"
>
...
...
app/utils/format_transfer.py
View file @
1c6b5c23
...
...
@@ -6,6 +6,7 @@
# @Email : acepengxiong@163.com
# @Software : PyCharm
# -----------------------------------------------------------------------------
import
base64
import
decimal
import
json
import
numpy
as
np
...
...
@@ -16,4 +17,11 @@ class npEncoder(json.JSONEncoder):
return
obj
.
tolist
()
elif
isinstance
(
obj
,
decimal
.
Decimal
):
return
obj
.
__str__
()
return
json
.
JSONEncoder
.
default
(
self
,
obj
)
\ No newline at end of file
return
json
.
JSONEncoder
.
default
(
self
,
obj
)
def
img_transfer
(
url
):
""""""
img_content
=
'data:image/png;base64,'
with
open
(
url
,
'rb'
)
as
f
:
img_content
+=
base64
.
b64encode
(
f
.
read
())
.
decode
(
'utf-8'
)
return
img_content
app/utils/jinjia2html_v2.py
View file @
1c6b5c23
...
...
@@ -4,7 +4,7 @@ import uuid
from
jinja2
import
PackageLoader
,
Environment
from
app.api.engine
import
work_dir
,
pdf_folder
,
template_folder
from
app.config.default_template_params
import
default_template
from
app.config.default_template_params
import
hold_default_template
,
diagnose_
default_template
from
app.service.portfolio_diagnose
import
PortfolioDiagnose
from
app.service.result_service_v2
import
UserCustomerResultAdaptor
import
numpy
as
np
...
...
@@ -19,12 +19,14 @@ from app.utils.radar_chart import gen_radar_chart
class
DataIntegrate
:
def
__init__
(
self
,
ifa_id
=
'USER_INFO15914346866762'
,
customer_id
=
'202009281545001'
,
pdf_name
=
str
(
uuid
.
uuid4
())
+
'.pdf'
):
def
__init__
(
self
,
ifa_id
=
'USER_INFO15914346866762'
,
customer_id
=
'202009281545001'
,
pdf_name
=
str
(
uuid
.
uuid4
())
+
'.pdf'
,
type
=
1
):
self
.
user_customer
=
UserCustomerResultAdaptor
(
ifa_id
,
customer_id
)
self
.
customer_name
=
self
.
user_customer
.
customer_real_name
self
.
ifa_name
=
self
.
user_customer
.
ifa_real_name
# self.pdf_name = self.ifa_name + "_" + self.customer_name + "_" + '.pdf'
self
.
pdf_name
=
pdf_name
# 1持仓报告2诊断报告
self
.
type
=
type
# 全部数据
self
.
df
=
self
.
user_customer
.
calculate_total_data
()
# 组合结果数据
...
...
@@ -41,11 +43,6 @@ class DataIntegrate:
# 月度回报表格
self
.
get_month_table_return
()
# 合并数据
self
.
get_template_data
()
# # 渲染模版
# self.render_data()
# 分组和计算个基点评以及新增基金等结果
def
get_group_result
(
self
):
...
...
@@ -73,12 +70,13 @@ 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)
if
self
.
type
==
2
:
# 新增基金
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
...
...
@@ -226,7 +224,9 @@ class DataIntegrate:
def
get_template_data
(
self
):
""""""
data
=
{
if
self
.
type
==
1
:
# 持仓报告数据
data
=
{
# 全局数据
'customer_name'
:
self
.
customer_name
,
'year_month'
:
self
.
user_customer
.
month_start_date
.
strftime
(
"
%
Y-
%
m"
),
...
...
@@ -235,10 +235,13 @@ class DataIntegrate:
'latest_worth_day'
:
self
.
user_customer
.
last_nav_date
,
'customer_level'
:
'平衡型'
,
# 综述数据
'now_allocation_amount'
:
'{:,}'
.
format
(
self
.
total_cost
),
'now_yield'
:
self
.
now_yield
,
'index_yield'
:
self
.
index_yield
,
'now_allocation_amount'
:
'{:,}'
.
format
(
self
.
total_cost
),
'now_yield'
:
self
.
now_yield
,
'index_yield'
:
self
.
index_yield
,
'now_annualised_return'
:
self
.
now_annualised_return
,
'now_withdrawal'
:
self
.
now_withdrawal
,
'index_withdrawal'
:
self
.
index_withdrawal
,
'expected_withdrawal'
:
20
,
'now_year_income'
:
'{:,}'
.
format
(
self
.
now_year_income
),
'now_month_income'
:
'{:,}'
.
format
(
self
.
now_month_income
),
'now_withdrawal'
:
self
.
now_withdrawal
,
'index_withdrawal'
:
self
.
index_withdrawal
,
'expected_withdrawal'
:
20
,
'now_year_income'
:
'{:,}'
.
format
(
self
.
now_year_income
),
'now_month_income'
:
'{:,}'
.
format
(
self
.
now_month_income
),
'final_balance'
:
'{:,}'
.
format
(
self
.
final_balance
),
'total_profit'
:
'{:,}'
.
format
(
self
.
total_profit
),
'total_profit_temp'
:
self
.
total_profit
,
'now_year_income_temp'
:
self
.
now_year_income
,
'now_month_income_temp'
:
self
.
now_month_income
,
...
...
@@ -250,46 +253,38 @@ class DataIntegrate:
# 组合数据
'all_folio_result'
:
self
.
all_folio_result
,
}
self
.
data
=
{
**
hold_default_template
,
**
data
}
elif
self
.
type
==
2
:
# 诊断报告数据
data
=
{
# 全局数据
'customer_name'
:
self
.
customer_name
,
'year_month'
:
self
.
user_customer
.
month_start_date
.
strftime
(
"
%
Y-
%
m"
),
'month'
:
self
.
user_customer
.
month_start_date
.
strftime
(
"
%
m"
),
'start_date'
:
self
.
user_customer
.
start_date
.
strftime
(
"
%
Y-
%
m-
%
d"
),
'latest_worth_day'
:
self
.
user_customer
.
last_nav_date
,
'customer_level'
:
'平衡型'
,
# 综述数据
'now_allocation_amount'
:
'{:,}'
.
format
(
self
.
total_cost
),
'now_yield'
:
self
.
now_yield
,
'index_yield'
:
self
.
index_yield
,
'now_annualised_return'
:
self
.
now_annualised_return
,
'now_withdrawal'
:
self
.
now_withdrawal
,
'index_withdrawal'
:
self
.
index_withdrawal
,
'expected_withdrawal'
:
20
,
'now_year_income'
:
'{:,}'
.
format
(
self
.
now_year_income
),
'now_month_income'
:
'{:,}'
.
format
(
self
.
now_month_income
),
'final_balance'
:
'{:,}'
.
format
(
self
.
final_balance
),
'total_profit'
:
'{:,}'
.
format
(
self
.
total_profit
),
'total_profit_temp'
:
self
.
total_profit
,
'now_year_income_temp'
:
self
.
now_year_income
,
'now_month_income_temp'
:
self
.
now_month_income
,
'monthly_return_performance_pic'
:
self
.
monthly_return_performance_pic
,
'month_rise'
:
self
.
month_rise
,
'year_totoal_rate_of_return'
:
self
.
year_totoal_rate_of_return
,
'monthly_table_return'
:
self
.
monthly_table_return
,
# 'totoal_rate_of_return': self.totoal_rate_of_return,
# 'annualised_return': self.annualised_return, 'cost_of_investment': self.cost_of_investment,
#
#
# 'index_comparison': {'section_return': self.totoal_rate_of_return, 'annualized_returns': self.annualised_return,
# 'volatility': self.volatility, 'max_withdrawal': self.max_withdrawal,
# 'sharpe_ratio': self.sharpe_ratio},
# 'index_comparison_500': {'section_return': self.index_section_return,
# 'annualized_returns': self.index_annualised_return,
# 'volatility': self.index_volatility, 'max_withdrawal': self.index_max_withdrawal,
# 'sharpe_ratio': self.index_sharpe_ratio},
#
# 'group_nav_info': self.group_nav_info,
# 'group_hoding_info': self.group_hoding_info,
# 'group_hoding_info_total': self.group_hoding_info_total,
# 'old_evaluation': self.old_evaluation,
# 'old_indicator_compare': self.old_indicator_compare,
# 'contribution_decomposition': self.contribution_decomposition,
# 'single_fund_data_list': self.single_fund_data_list,
# 'old_correlation': self.old_correlation,
# 'old_return_compare_pic': self.old_return_compare_pic,
# # 'new_correlation': self.new_correlation,
# # 'propose_fund_data_list': self.propose_fund_data_list,
# # 'suggestions_result': self.suggestions_result,
# # 'suggestions_result_asset': self.suggestions_result_asset,
# # 'return_compare_pic': self.return_compare_pic,
# # 'indicator_compare': self.indicator_compare,
# # 'new_group_evaluation': self.new_group_evaluation
# 'new_correlation': [],
# 'propose_fund_data_list': [],
# 'suggestions_result': {},
# 'suggestions_result_asset': {},
# 'return_compare_pic': [],
# 'indicator_compare': [],
# 'new_group_evaluation': []
}
self
.
data
=
{
**
default_template
,
**
data
}
# 组合数据
'all_folio_result'
:
self
.
all_folio_result
,
}
self
.
data
=
{
**
diagnose_default_template
,
**
data
}
return
self
.
data
def
render_data
(
self
):
...
...
@@ -300,9 +295,9 @@ class DataIntegrate:
template
=
env
.
get_template
(
'/v2/monthReportV2.1.html'
)
# 获取一个模板文件
monthReport_html
=
template
.
render
(
self
.
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:
...
...
@@ -312,6 +307,7 @@ class DataIntegrate:
if
__name__
==
'__main__'
:
start
=
time
.
time
()
dt
=
DataIntegrate
(
ifa_id
=
'USER_INFO1591785
3924996'
,
customer_id
=
'6741679287251775488'
)
dt
=
DataIntegrate
(
ifa_id
=
'USER_INFO1591785
0824287'
,
customer_id
=
'6716613802534121472'
,
type
=
1
)
data
=
dt
.
get_template_data
()
dt
.
render_data
()
print
(
'耗时{}秒'
.
format
(
round
(
time
.
time
()
-
start
,
2
)))
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