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
0ff9f4ab
Commit
0ff9f4ab
authored
Dec 04, 2020
by
赵杰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
收益比较数据图片,html模板
parent
7cca54ea
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
7 deletions
+29
-7
portfolio_diagnose.py
app/service/portfolio_diagnose.py
+16
-1
monthReport.html
app/templates/monthReport.html
+1
-1
draw.py
app/utils/draw.py
+7
-3
jinjia2html.py
app/utils/jinjia2html.py
+5
-2
No files found.
app/service/portfolio_diagnose.py
View file @
0ff9f4ab
...
@@ -736,6 +736,21 @@ class PortfolioDiagnose(object):
...
@@ -736,6 +736,21 @@ class PortfolioDiagnose(object):
exc
=
excess_return
(
sim
,
BANK_RATE
,
n_freq
)
exc
=
excess_return
(
sim
,
BANK_RATE
,
n_freq
)
new_sharpe
=
sharpe_ratio
(
exc
,
sim
,
n_freq
)
new_sharpe
=
sharpe_ratio
(
exc
,
sim
,
n_freq
)
# 收益对比数据
return_compare_df
=
pd
.
merge
(
index_return
[[
"new_index_return"
]],
old_return_df
[[
"cum_return_ratio"
]],
right_index
=
True
,
left_index
=
True
)
return_compare_df
=
pd
.
merge
(
return_compare_df
,
propose_fund_return_limit_data
[
"new_return"
],
right_index
=
True
,
left_index
=
True
)
return_compare_df
[
"date"
]
=
return_compare_df
.
index
return_compare_df
[
"date"
]
=
return_compare_df
[
"date"
]
.
apply
(
lambda
x
:
x
.
strftime
(
"
%
Y-
%
m-
%
d"
))
return_compare_df
.
iloc
[
1
:
-
1
,:][
"date"
]
=
""
return_compare_result
=
{
"new_combination"
:
{
"name"
:
"新组合"
,
"data"
:
return_compare_df
[
"new_return"
]
.
values
},
"index"
:
{
"name"
:
"中证500"
,
"data"
:
return_compare_df
[
"new_index_return"
]
.
values
},
"origin_combination"
:
{
"name"
:
"原组合"
,
"data"
:
return_compare_df
[
"cum_return_ratio"
]
.
values
},
"xlabels"
:
return_compare_df
[
"date"
]
.
values
}
# 指标对比
# 指标对比
odl_indicator
=
{
"group_name"
:
"现有持仓组合"
,
"return_ratio"
:
round
((
old_return
-
1
)
*
100
,
2
),
"return_ratio_year"
:
round
(
old_return_ratio_year
*
100
,
2
),
odl_indicator
=
{
"group_name"
:
"现有持仓组合"
,
"return_ratio"
:
round
((
old_return
-
1
)
*
100
,
2
),
"return_ratio_year"
:
round
(
old_return_ratio_year
*
100
,
2
),
"volatility"
:
round
(
old_volatility
*
100
,
2
),
"max_drawdown"
:
round
(
old_max_drawdown
[
0
]
*
100
,
2
),
"sharpe"
:
round
(
old_sharpe
,
2
)}
"volatility"
:
round
(
old_volatility
*
100
,
2
),
"max_drawdown"
:
round
(
old_max_drawdown
[
0
]
*
100
,
2
),
"sharpe"
:
round
(
old_sharpe
,
2
)}
...
@@ -760,7 +775,7 @@ class PortfolioDiagnose(object):
...
@@ -760,7 +775,7 @@ class PortfolioDiagnose(object):
sentence
.
join
(
"整体组合波动率大幅降低,"
)
sentence
.
join
(
"整体组合波动率大幅降低,"
)
if
new_return_ratio_year
>
old_return_ratio_year
:
if
new_return_ratio_year
>
old_return_ratio_year
:
sentence
.
join
(
"年化收益率提升{}个点。"
.
format
(
round
(
new_return_ratio_year
-
old_return_ratio_year
,
1
)))
sentence
.
join
(
"年化收益率提升{}个点。"
.
format
(
round
(
new_return_ratio_year
-
old_return_ratio_year
,
1
)))
return
suggestions_result
,
suggestions_result_asset
,
indicator_compare
,
sentence
return
suggestions_result
,
suggestions_result_asset
,
return_compare_result
,
indicator_compare
,
sentence
def
single_evaluation
(
self
,
fund_id
):
def
single_evaluation
(
self
,
fund_id
):
"""
"""
...
...
app/templates/monthReport.html
View file @
0ff9f4ab
...
@@ -2592,7 +2592,7 @@
...
@@ -2592,7 +2592,7 @@
【收益比较】
【收益比较】
</div>
</div>
<div
class=
"profit_chart_graphic"
>
<div
class=
"profit_chart_graphic"
>
<img
src=
"./img/logo-blue.png"
alt=
""
class=
"profit_chart_img"
>
<img
src=
{{return_compare_pic}}
alt=
""
class=
"profit_chart_img"
>
</div>
</div>
</div>
</div>
<div
class=
"profit_chart_item fr"
>
<div
class=
"profit_chart_item fr"
>
...
...
app/utils/draw.py
View file @
0ff9f4ab
...
@@ -260,7 +260,7 @@ def draw_combination_chart(xlabels, new_combination, origin_combination, index):
...
@@ -260,7 +260,7 @@ def draw_combination_chart(xlabels, new_combination, origin_combination, index):
fontsize
=
22
fontsize
=
22
# 初始化
# 初始化
fig
=
plt
.
figure
(
figsize
=
figsize
)
fig
=
plt
.
figure
(
figsize
=
figsize
)
ax1
=
fig
.
add_subplot
()
ax1
=
fig
.
add_subplot
(
111
)
ax2
=
ax1
.
twiny
()
ax2
=
ax1
.
twiny
()
ax3
=
ax1
.
twiny
()
ax3
=
ax1
.
twiny
()
# ax = plt.gca() # gca:get current axis得到当前轴
# ax = plt.gca() # gca:get current axis得到当前轴
...
@@ -291,8 +291,12 @@ def draw_combination_chart(xlabels, new_combination, origin_combination, index):
...
@@ -291,8 +291,12 @@ def draw_combination_chart(xlabels, new_combination, origin_combination, index):
ax3
.
plot
(
loc
,
index
[
'data'
],
color
=
'black'
,
marker
=
''
,
linewidth
=
3
,
label
=
index
[
'name'
])
ax3
.
plot
(
loc
,
index
[
'data'
],
color
=
'black'
,
marker
=
''
,
linewidth
=
3
,
label
=
index
[
'name'
])
ax3
.
legend
(
loc
=
'upper right'
,
fontsize
=
fontsize
)
ax3
.
legend
(
loc
=
'upper right'
,
fontsize
=
fontsize
)
plt
.
show
()
# plt.show()
imgdata
=
BytesIO
()
fig
.
savefig
(
imgdata
,
format
=
'png'
,
bbox_inches
=
'tight'
)
imgdata
.
seek
(
0
)
# rewind the data
return_compare_img
=
'data:image/png;base64,'
+
base64
.
b64encode
(
imgdata
.
getvalue
())
.
decode
(
'utf-8'
)
return
return_compare_img
def
draw_correlation_chart
():
def
draw_correlation_chart
():
"""相关性分析图"""
"""相关性分析图"""
...
...
app/utils/jinjia2html.py
View file @
0ff9f4ab
...
@@ -7,7 +7,7 @@ from app.service.result_service import UserCustomerResultAdaptor
...
@@ -7,7 +7,7 @@ from app.service.result_service import UserCustomerResultAdaptor
import
numpy
as
np
import
numpy
as
np
# 准备数据
# 准备数据
from
app.utils.draw
import
draw_month_return_chart
,
draw_contribution_chart
from
app.utils.draw
import
draw_month_return_chart
,
draw_contribution_chart
,
draw_combination_chart
from
app.utils.radar_chart
import
gen_radar_chart
from
app.utils.radar_chart
import
gen_radar_chart
...
@@ -76,8 +76,10 @@ class DataIntegrate:
...
@@ -76,8 +76,10 @@ class DataIntegrate:
# 调仓建议
# 调仓建议
def
get_transfer_suggestions
(
self
):
def
get_transfer_suggestions
(
self
):
self
.
suggestions_result
,
self
.
suggestions_result_asset
,
\
self
.
suggestions_result
,
self
.
suggestions_result_asset
,
return_compare_data
,
\
self
.
indicator_compare
,
self
.
new_group_evaluation
=
portfolio_diagnose
.
new_evaluation
(
"default"
,
self
.
d
,
self
.
user_customer
)
self
.
indicator_compare
,
self
.
new_group_evaluation
=
portfolio_diagnose
.
new_evaluation
(
"default"
,
self
.
d
,
self
.
user_customer
)
self
.
return_compare_pic
=
draw_combination_chart
(
return_compare_data
[
"xlabels"
],
return_compare_data
[
"new_combination"
],
return_compare_data
[
"origin_combination"
],
return_compare_data
[
"index"
])
# 收益比较
# 收益比较
...
@@ -163,6 +165,7 @@ class DataIntegrate:
...
@@ -163,6 +165,7 @@ class DataIntegrate:
'propose_fund_data_list'
:
self
.
propose_fund_data_list
,
'propose_fund_data_list'
:
self
.
propose_fund_data_list
,
'suggestions_result'
:
self
.
suggestions_result
,
'suggestions_result'
:
self
.
suggestions_result
,
'suggestions_result_asset'
:
self
.
suggestions_result_asset
,
'suggestions_result_asset'
:
self
.
suggestions_result_asset
,
'return_compare_pic'
:
self
.
return_compare_pic
,
'indicator_compare'
:
self
.
indicator_compare
,
'indicator_compare'
:
self
.
indicator_compare
,
'new_group_evaluation'
:
self
.
new_group_evaluation
'new_group_evaluation'
:
self
.
new_group_evaluation
...
...
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