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
0a7c69fb
Commit
0a7c69fb
authored
Dec 07, 2020
by
赵杰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复self.portfolio全局变量
parent
ee172161
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
portfolio_diagnose.py
app/service/portfolio_diagnose.py
+11
-11
No files found.
app/service/portfolio_diagnose.py
View file @
0a7c69fb
...
...
@@ -308,7 +308,7 @@ class PortfolioDiagnose(object):
while
prod
is
None
:
# 获取的净值表为空时首先考虑基金净值数据不足半年,查找同一基金经理下的相同二级策略的基金ID作替换
result
=
fund_info
[
fund_info
[
'fund_id'
]
==
portfolio
[
0
]]
result
=
fund_info
[
fund_info
[
'fund_id'
]
==
self
.
portfolio
[
0
]]
manager
=
str
(
result
[
'manager'
]
.
values
)
strategy
=
result
[
'substrategy'
]
.
values
replaced_fund
=
replace_fund
(
manager
,
strategy
,
fund_rank
)
...
...
@@ -316,43 +316,43 @@ class PortfolioDiagnose(object):
if
replaced_fund
is
not
None
:
# 替换基金数据非空则记录替换的基金对
prod
=
get_nav
(
replaced_fund
,
self
.
start_date
,
invest_type
=
self
.
invest_type
)
self
.
replace_pair
[
portfolio
[
0
]]
=
replaced_fund
self
.
replace_pair
[
self
.
portfolio
[
0
]]
=
replaced_fund
else
:
# 替换基金数据为空则记录当前基金为找不到数据的基金, 继续尝试获取下一个基金ID的净值表
self
.
no_data_fund
.
append
(
portfolio
[
0
])
self
.
no_data_fund
.
append
(
self
.
portfolio
[
0
])
self
.
portfolio
.
pop
(
0
)
prod
=
get_nav
(
self
.
portfolio
[
0
],
self
.
start_date
,
invest_type
=
self
.
invest_type
)
# 记录基金的公布频率
self
.
freq_list
.
append
(
get_frequency
(
prod
))
prod
=
rename_col
(
prod
,
portfolio
[
0
])
prod
=
rename_col
(
prod
,
self
.
portfolio
[
0
])
# 循环拼接基金净值表构建组合
for
idx
in
range
(
len
(
portfolio
)
-
1
):
prod1
=
get_nav
(
portfolio
[
idx
+
1
],
self
.
start_date
,
invest_type
=
self
.
invest_type
)
for
idx
in
range
(
len
(
self
.
portfolio
)
-
1
):
prod1
=
get_nav
(
self
.
portfolio
[
idx
+
1
],
self
.
start_date
,
invest_type
=
self
.
invest_type
)
if
prod1
is
None
or
prod1
.
index
[
-
1
]
-
prod1
.
index
[
0
]
<
0.6
*
(
self
.
end_date
-
self
.
start_date
):
result
=
fund_info
[
fund_info
[
'fund_id'
]
==
portfolio
[
idx
+
1
]]
result
=
fund_info
[
fund_info
[
'fund_id'
]
==
self
.
portfolio
[
idx
+
1
]]
if
result
[
'fund_manager_id'
]
.
count
()
!=
0
:
manager
=
str
(
result
[
'fund_manager_id'
]
.
values
)
substrategy
=
result
[
'substrategy'
]
.
values
[
0
]
replaced_fund
=
replace_fund
(
manager
,
substrategy
,
fund_rank
)
else
:
self
.
no_data_fund
.
append
(
portfolio
[
idx
+
1
])
self
.
no_data_fund
.
append
(
self
.
portfolio
[
idx
+
1
])
continue
if
replaced_fund
is
not
None
:
prod1
=
get_nav
(
replaced_fund
,
self
.
start_date
,
invest_type
=
self
.
invest_type
)
self
.
replace_pair
[
portfolio
[
idx
+
1
]]
=
replaced_fund
self
.
replace_pair
[
self
.
portfolio
[
idx
+
1
]]
=
replaced_fund
self
.
freq_list
.
append
(
get_frequency
(
prod1
))
prod1
=
rename_col
(
prod1
,
replaced_fund
)
else
:
self
.
no_data_fund
.
append
(
portfolio
[
idx
+
1
])
self
.
no_data_fund
.
append
(
self
.
portfolio
[
idx
+
1
])
continue
else
:
self
.
freq_list
.
append
(
get_frequency
(
prod1
))
prod1
=
rename_col
(
prod1
,
portfolio
[
idx
+
1
])
prod1
=
rename_col
(
prod1
,
self
.
portfolio
[
idx
+
1
])
# 取prod表和prod1表的并集
prod
=
pd
.
merge
(
prod
,
prod1
,
on
=
[
'end_date'
],
how
=
'outer'
)
...
...
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