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
93cd78f5
Commit
93cd78f5
authored
Feb 25, 2021
by
赵杰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
指数收益同步
parent
0bae380c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
10 deletions
+19
-10
portfolio_diagnose.py
app/service/portfolio_diagnose.py
+19
-10
No files found.
app/service/portfolio_diagnose.py
View file @
93cd78f5
...
...
@@ -1053,10 +1053,16 @@ class PortfolioDiagnose(object):
"volatility"
:
"
%.2
f"
%
round
(
old_volatility
,
2
),
"max_drawdown"
:
"
%.2
f"
%
round
(
old_max_drawdown
[
0
]
*
100
,
2
),
"sharpe"
:
"
%.2
f"
%
round
(
old_sharpe
,
2
)}
index_indicator
=
{
"group_name"
:
"中证500"
,
"return_ratio"
:
"
%.2
f"
%
round
(
index_return_ratio
*
100
,
2
),
"return_ratio_year"
:
"
%.2
f"
%
round
(
index_return_ratio_year
*
100
,
2
),
"volatility"
:
"
%.2
f"
%
round
(
index_volatility
,
2
),
"max_drawdown"
:
"
%.2
f"
%
round
(
index_drawdown
[
0
]
*
100
,
2
),
"sharpe"
:
"
%.2
f"
%
round
(
index_sharpe
,
2
)}
# index_indicator = {"group_name": "中证500", "return_ratio": "%.2f" % round(index_return_ratio * 100, 2),
# "return_ratio_year": "%.2f" % round(index_return_ratio_year * 100, 2),
# "volatility": "%.2f" % round(index_volatility, 2),
# "max_drawdown": "%.2f" % round(index_drawdown[0] * 100, 2), "sharpe": "%.2f" % round(index_sharpe, 2)}
index_indicator
=
{
"group_name"
:
"中证500"
,
"return_ratio"
:
round
((
group_result_data
[
"index_result"
][
"return_ratio"
]
-
1
)
*
100
,
2
),
"return_ratio_year"
:
round
(
group_result_data
[
"index_result"
][
"return_ratio_year"
]
*
100
,
2
),
"volatility"
:
round
(
group_result_data
[
"index_result"
][
"volatility"
],
2
),
"max_drawdown"
:
round
(
group_result_data
[
"index_result"
][
"max_drawdown"
][
0
]
*
100
,
2
),
"sharpe"
:
round
(
group_result_data
[
"index_result"
][
"sharpe"
],
2
)}
old_indicator_compare
=
[
old_indicator
,
index_indicator
]
return
ret
,
old_return_compare_result
,
old_indicator_compare
...
...
@@ -1208,10 +1214,10 @@ class PortfolioDiagnose(object):
index_return
=
index_return
[
index_return
.
index
>=
group_order_start_date
]
start_index_return
=
index_return
[
self
.
index_id
]
.
values
[
0
]
index_return
[
"new_index_return"
]
=
(
index_return
[
self
.
index_id
]
-
start_index_return
)
/
(
1
+
start_index_return
)
index_return_ratio
=
index_return
[
"new_index_return"
]
.
values
[
-
1
]
index_return_ratio_year
=
annual_return
(
index_return
[
"new_index_return"
]
.
values
[
-
1
],
index_return
[
"new_index_return"
],
n_freq
)
index_volatility
=
volatility
(
index_return
[
"new_index_return"
]
+
1
,
n_freq
)
index_drawdown
=
max_drawdown
(
index_return
[
"new_index_return"
]
+
1
)
#
index_return_ratio = index_return["new_index_return"].values[-1]
#
index_return_ratio_year = annual_return(index_return["new_index_return"].values[-1], index_return["new_index_return"], n_freq)
#
index_volatility = volatility(index_return["new_index_return"]+1, n_freq)
#
index_drawdown = max_drawdown(index_return["new_index_return"]+1)
index_sim
=
simple_return
(
index_return
[
"new_index_return"
]
+
1
)
index_exc
=
excess_return
(
index_sim
,
BANK_RATE
,
n_freq
)
try
:
...
...
@@ -1245,8 +1251,11 @@ class PortfolioDiagnose(object):
if
default
>
0
:
new_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
,
2
),
"max_drawdown"
:
round
(
old_max_drawdown
[
0
]
*
100
,
2
),
"sharpe"
:
round
(
old_sharpe
,
2
)}
index_indicator
=
{
"group_name"
:
"中证500"
,
"return_ratio"
:
round
(
index_return_ratio
*
100
,
2
),
"return_ratio_year"
:
round
(
index_return_ratio_year
*
100
,
2
),
"volatility"
:
round
(
index_volatility
,
2
),
"max_drawdown"
:
round
(
index_drawdown
[
0
]
*
100
,
2
),
"sharpe"
:
round
(
index_sharpe
,
2
)}
index_indicator
=
{
"group_name"
:
"中证500"
,
"return_ratio"
:
round
((
group_result_data
[
"index_result"
][
"return_ratio"
]
-
1
)
*
100
,
2
),
"return_ratio_year"
:
round
(
group_result_data
[
"index_result"
][
"return_ratio_year"
]
*
100
,
2
),
"volatility"
:
round
(
group_result_data
[
"index_result"
][
"volatility"
],
2
),
"max_drawdown"
:
round
(
group_result_data
[
"index_result"
][
"max_drawdown"
][
0
]
*
100
,
2
),
"sharpe"
:
round
(
group_result_data
[
"index_result"
][
"sharpe"
],
2
)}
indicator_compare
=
[
new_indicator
,
old_indicator
,
index_indicator
]
# 在保留{}的基础上,建议赎回{},并增配{}后,整体组合波动率大幅降低,最大回撤从{}降到不足{},年化收益率提升{}个点
...
...
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