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
f1a9a1e9
Commit
f1a9a1e9
authored
Dec 09, 2020
by
赵杰
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dev' into dev
parents
d928ec39
fe4a5eb0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
portfolio_diagnose.py
app/service/portfolio_diagnose.py
+13
-9
No files found.
app/service/portfolio_diagnose.py
View file @
f1a9a1e9
...
...
@@ -602,14 +602,18 @@ class PortfolioDiagnose(object):
raise
ValueError
w_low
=
1000000
/
self
.
invest_amount
ef
=
EfficientFrontier
(
mu
,
S
,
weight_bounds
=
[
w_low
,
1
],
expected_drawdown
=
dd
)
# ef = EfficientFrontier(mu, S, weight_bounds=[0, 1], expected_drawdown=dd)
ef
.
add_sector_constraints
(
propose_risk_mapper
,
risk_lower
,
risk_upper
)
ef
.
efficient_return
(
target_return
=
self
.
expect_return
,
target_drawdown
=
self
.
expect_drawdown
)
clean_weights
=
ef
.
clean_weights
()
ef
.
portfolio_performance
(
verbose
=
True
)
self
.
new_weights
=
np
.
array
(
list
(
clean_weights
.
values
()))
print
(
clean_weights
)
try
:
ef
=
EfficientFrontier
(
mu
,
S
,
weight_bounds
=
[
w_low
,
1
],
expected_drawdown
=
dd
)
# ef = EfficientFrontier(mu, S, weight_bounds=[0, 1], expected_drawdown=dd)
ef
.
add_sector_constraints
(
propose_risk_mapper
,
risk_lower
,
risk_upper
)
ef
.
efficient_return
(
target_return
=
self
.
expect_return
,
target_drawdown
=
self
.
expect_drawdown
)
clean_weights
=
ef
.
clean_weights
()
ef
.
portfolio_performance
(
verbose
=
True
)
self
.
new_weights
=
np
.
array
(
list
(
clean_weights
.
values
()))
except
:
self
.
new_weights
=
np
.
asarray
([
1
/
len
(
self
.
propose_portfolio
.
columns
)]
*
len
(
self
.
propose_portfolio
.
columns
))
print
(
self
.
new_weights
)
end4
=
time
.
time
()
print
(
"模型计算一次时间:"
,
end4
-
end3
)
# S = np.asmatrix(S)
...
...
@@ -1066,7 +1070,7 @@ class PortfolioDiagnose(object):
radar_data
.
append
(
get_radar_data
(
fund
))
return
radar_data
#
# portfolio = ['HF00002JJ2', 'HF00005DBQ', 'HF0000681Q', 'HF00006693', 'HF00006AZF', 'HF00006BGS']
# portfolio_diagnose = PortfolioDiagnose(client_type=1, portfolio=portfolio, invest_amount=10000000)
# portfolio_diagnose.optimize()
...
...
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