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
a9c036c5
Commit
a9c036c5
authored
Dec 04, 2020
by
赵杰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
月度回报净值表
parent
6545cbcf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
4 deletions
+34
-4
result_service_v2.py
app/service/result_service_v2.py
+34
-4
No files found.
app/service/result_service_v2.py
View file @
a9c036c5
...
...
@@ -183,7 +183,9 @@ class UserCustomerResultAdaptor(UserCustomerDataAdaptor):
#
fund_id_list
=
list
(
cur_folio_order_data
[
"fund_id"
]
.
unique
())
fund_id_list_earn
=
[
i
+
"_earn"
for
i
in
fund_id_list
]
fund_id_list_amount
=
[
i
+
"_net_amount"
for
i
in
fund_id_list
]
profit_df
=
cur_folio_result_cnav_data
[
fund_id_list_earn
]
amount_df
=
cur_folio_result_cnav_data
[
fund_id_list_amount
]
.
copy
()
# 持仓周期
first_trade_date
=
cur_folio_order_data
[
"confirm_share_date"
]
.
min
()
...
...
@@ -282,6 +284,28 @@ class UserCustomerResultAdaptor(UserCustomerDataAdaptor):
month_result
.
sort_values
(
by
=
"datetime"
,
inplace
=
True
)
report_data
[
"month_return"
]
=
month_result
#
amount_df
[
"date"
]
=
amount_df
.
index
grouped_amount
=
amount_df
.
groupby
(
amount_df
[
"date"
]
.
apply
(
year_month
))
month_amount
=
grouped_amount
.
last
()
del
month_amount
[
"date"
]
month_amount_sum
=
month_amount
.
sum
(
axis
=
1
)
# 月度回报表格数据
start_year
=
self
.
start_date
.
year
now_year
=
datetime
.
datetime
.
now
()
.
year
month_return_data_dict
=
{}
for
i
in
range
(
now_year
-
start_year
+
1
):
month_return_data_dict
[
start_year
+
i
]
=
{
j
+
1
:
{
"profit"
:
0
,
"net_amount"
:
0
}
for
j
in
range
(
12
)}
for
d_index
,
d_row
in
month_sum
.
items
():
cur_year
=
int
(
d_index
[:
4
])
cur_month
=
int
(
d_index
[
5
:])
cur_profit
=
round
(
d_row
/
10000.0
,
2
)
cur_net_amount
=
round
(
month_amount_sum
.
loc
[
d_index
]
/
10000
,
2
)
month_return_data_dict
[
cur_year
][
cur_month
][
"profit"
]
=
cur_profit
month_return_data_dict
[
cur_year
][
cur_month
][
"net_amount"
]
=
cur_net_amount
# 组合月度回报表
report_data
[
"month_return_data_dict"
]
=
month_return_data_dict
# # 贡献分解
# month_earn = sum_group.div(month_sum, axis='rows')
...
...
@@ -296,7 +320,7 @@ class UserCustomerResultAdaptor(UserCustomerDataAdaptor):
index_result
=
self
.
signal_fund_profit_result
(
index_df
[
index_df
.
index
>=
pd
.
to_datetime
(
first_trade_date
)],
"index"
)
report_data
[
"index_result"
]
=
index_result
self
.
__month_return
()
self
.
__month_return
(
cur_folio_result_cnav_data
,
fund_id_list
)
self
.
total_result_data
=
report_data
return
report_data
...
...
@@ -490,6 +514,12 @@ class UserCustomerResultAdaptor(UserCustomerDataAdaptor):
def
get_group_data
(
self
):
return
self
.
group_result_data
def
__month_return
(
self
):
pass
def
__month_return
(
self
,
folio_cnav_data
):
# 月度回报
def
year_month
(
x
):
a
=
x
.
year
b
=
x
.
month
return
str
(
a
)
+
"-"
+
str
(
b
)
p_folio_cnav_data
=
folio_cnav_data
.
copy
()
p_folio_cnav_data
[
"date"
]
=
p_folio_cnav_data
.
index
grouped_data
=
p_folio_cnav_data
.
groupby
(
p_folio_cnav_data
[
"date"
]
.
apply
(
year_month
))
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