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
b7a8eb3a
Commit
b7a8eb3a
authored
Dec 09, 2020
by
赵杰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
旧组合收益比较剥离
parent
15325da2
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
9 deletions
+45
-9
data_service.py
app/service/data_service.py
+2
-2
portfolio_diagnose.py
app/service/portfolio_diagnose.py
+35
-1
result_service_v2.py
app/service/result_service_v2.py
+1
-1
jinjia2html.py
app/utils/jinjia2html.py
+7
-5
No files found.
app/service/data_service.py
View file @
b7a8eb3a
...
...
@@ -190,7 +190,7 @@ class UserCustomerDataAdaptor:
confirm_date_nav_data
=
p_nav_df
[
p_nav_df
.
index
==
confirm_share_date
][
cur_fund_id
]
.
tail
(
1
)
confirm_date_cnav_data
=
p_cnav_df
[
p_cnav_df
.
index
==
confirm_share_date
][
cur_fund_id
]
.
tail
(
1
)
diff_nav
=
Decimal
(
row
[
"nav"
])
-
Decimal
(
confirm_date_nav_data
.
values
[
0
])
cur_cnav
=
confirm_date_cnav_data
.
values
[
0
]
+
diff_nav
cur_cnav
=
Decimal
(
confirm_date_cnav_data
.
values
[
0
])
+
diff_nav
cnav_df
.
loc
[
confirm_share_date
,
cur_fund_id
]
=
cur_cnav
cnav_df
=
cnav_df
.
dropna
(
axis
=
0
,
how
=
"all"
)
.
fillna
(
method
=
'ffill'
)
...
...
@@ -285,7 +285,7 @@ class UserCustomerDataAdaptor:
confirm_date_nav_data
=
p_nav_df
[
p_nav_df
.
index
==
confirm_share_date
][
cur_fund_id
]
.
tail
(
1
)
confirm_date_cnav_data
=
p_cnav_df
[
p_cnav_df
.
index
==
confirm_share_date
][
cur_fund_id
]
.
tail
(
1
)
diff_nav
=
Decimal
(
row
[
"nav"
])
-
Decimal
(
confirm_date_nav_data
.
values
[
0
])
cur_cnav
=
confirm_date_cnav_data
.
values
[
0
]
+
diff_nav
cur_cnav
=
Decimal
(
confirm_date_cnav_data
.
values
[
0
])
+
diff_nav
cnav_df
.
loc
[
confirm_share_date
,
cur_fund_id
]
=
cur_cnav
cnav_df
=
cnav_df
.
dropna
(
axis
=
0
,
how
=
"all"
)
.
fillna
(
method
=
'ffill'
)
...
...
app/service/portfolio_diagnose.py
View file @
b7a8eb3a
...
...
@@ -749,7 +749,41 @@ class PortfolioDiagnose(object):
ret
=
[]
for
k
,
v
in
data
.
items
():
ret
.
append
(
sentence
[
k
]
.
format
(
*
data
[
k
])
.
replace
(
",;"
,
";"
))
return
ret
# 旧组合累积收益df
group_result_data
=
group_result
[
group_name
]
hold_info
=
group_result_data
[
"group_hoding_info"
]
group_order_df
=
data_adaptor
.
user_customer_order_df
[
data_adaptor
.
user_customer_order_df
[
"folio_name"
]
==
group_name
]
group_order_start_date
=
pd
.
to_datetime
(
group_order_df
[
"confirm_share_date"
]
.
min
())
old_return_df
=
group_result_data
[
"return_df"
]
old_return_df
[
"cum_return_ratio"
]
=
old_return_df
[
"cum_return_ratio"
]
-
1
# 指数收益
index_data
=
get_index_daily
(
self
.
index_id
,
self
.
start_date
)
index_data
=
pd
.
merge
(
index_data
,
self
.
propose_portfolio
,
how
=
'inner'
,
left_index
=
True
,
right_index
=
True
)
index_return
=
index_data
.
iloc
[:,
:]
/
index_data
.
iloc
[
0
,
:]
-
1
# 指数收益
index_return
=
index_return
[
index_return
.
index
>=
group_order_start_date
]
start_index_return
=
index_return
[
" close"
]
.
values
[
0
]
index_return
[
"new_index_return"
]
=
(
index_return
[
" close"
]
-
start_index_return
)
/
(
1
+
start_index_return
)
# 收益对比数据
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
[
"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"
]
=
""
old_return_compare_result
=
{
"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
}
return
ret
,
old_return_compare_result
def
new_evaluation
(
self
,
group_name
,
group_result
,
data_adaptor
):
try
:
...
...
app/service/result_service_v2.py
View file @
b7a8eb3a
...
...
@@ -369,8 +369,8 @@ class UserCustomerResultAdaptor(UserCustomerDataAdaptor):
fund_hoding_info
=
{
"fund_strategy_name"
:
dict_substrategy
[
int
(
row
[
"substrategy"
])],
"fund_name"
:
row
[
"fund_name"
]}
fund_hoding_info
[
"confirm_date"
]
=
row
[
"confirm_share_date"
]
fund_hoding_info
[
"hold_year"
]
=
round
((
self
.
end_date
-
pd
.
to_datetime
(
row
[
"confirm_share_date"
]))
.
days
/
365.0
,
2
)
# 存续年数
fund_hoding_info
[
"weight"
]
=
round
(
float
(
row
[
"confirm_amount"
])
/
total_market_values
*
100
,
2
)
# 月末占比
fund_hoding_info
[
"market_values"
]
=
round
((
float
(
row
[
"confirm_share"
])
*
(
fund_basic_info
[
"cur_cnav"
]
-
confirm_cnav
)
+
float
(
row
[
"confirm_amount"
]))
/
10000
,
2
)
fund_hoding_info
[
"weight"
]
=
round
(
fund_hoding_info
[
"market_values"
]
/
total_market_values
*
10000.0
*
100
,
2
)
# 月末占比
fund_hoding_info
[
"cost"
]
=
round
(
float
(
row
[
"confirm_amount"
])
/
10000
,
2
)
# 投资本金
# 当月收益
last_month_cnav_serise
=
p_result_cnav_data
[
p_result_cnav_data
.
index
<
pd
.
to_datetime
(
self
.
month_start_date
)][
row
[
"fund_id"
]]
.
dropna
()
...
...
app/utils/jinjia2html.py
View file @
b7a8eb3a
...
...
@@ -82,8 +82,8 @@ class DataIntegrate:
self
.
monthly_table_return
=
self
.
df
[
"month_return_data_dict"
]
def
comments_on_position_portfolio
(
self
):
"""旧持仓组合点评."""
self
.
old_evaluation
=
self
.
portfolio_diagnose
.
old_evaluation
(
'default'
,
self
.
d
,
self
.
user_customer
)
"""旧持仓组合点评.
旧贡献分解数据
"""
self
.
old_evaluation
,
self
.
old_return_compare_data
=
self
.
portfolio_diagnose
.
old_evaluation
(
'default'
,
self
.
d
,
self
.
user_customer
)
def
contribution_deco
(
self
):
"""贡献分解."""
...
...
@@ -116,12 +116,14 @@ class DataIntegrate:
def
get_old_compare_pic
(
self
):
"""旧收益比较"""
self
.
suggestions_result
,
self
.
suggestions_result_asset
,
self
.
return_compare_data
,
\
self
.
indicator_compare
,
self
.
new_group_evaluation
=
self
.
portfolio_diagnose
.
new_evaluation
(
"default"
,
self
.
d
,
self
.
user_customer
)
self
.
old_return_compare_pic
=
draw_old_combination_chart
(
self
.
return_compare_data
[
"xlabels"
],
self
.
return_compare_data
[
"origin_combination"
],
self
.
return_compare_data
[
"index"
])
self
.
old_return_compare_pic
=
draw_old_combination_chart
(
self
.
old_return_compare_data
[
"xlabels"
],
self
.
old_return_compare_data
[
"origin_combination"
],
self
.
old_return_compare_data
[
"index"
])
def
get_transfer_suggestions
(
self
):
"""新收益比较,调仓建议"""
self
.
suggestions_result
,
self
.
suggestions_result_asset
,
self
.
return_compare_data
,
\
self
.
indicator_compare
,
self
.
new_group_evaluation
=
self
.
portfolio_diagnose
.
new_evaluation
(
"default"
,
self
.
d
,
self
.
user_customer
)
self
.
return_compare_pic
=
draw_combination_chart
(
self
.
return_compare_data
[
"xlabels"
],
self
.
return_compare_data
[
"new_combination"
],
self
.
return_compare_data
[
"origin_combination"
],
self
.
return_compare_data
[
"index"
])
...
...
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