Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
A
alpha-mind
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dr.李
alpha-mind
Commits
a63cf5e2
Commit
a63cf5e2
authored
May 30, 2018
by
Dr.李
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/alpha-miner/alpha-mind
parents
657d8d97
20a96928
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
linearbuilder.py
alphamind/portfolio/linearbuilder.py
+8
-4
No files found.
alphamind/portfolio/linearbuilder.py
View file @
a63cf5e2
...
...
@@ -46,11 +46,15 @@ def linear_builder(er: np.ndarray,
return
status
,
opt
.
feval
(),
opt
.
x_value
()
else
:
# we need to expand bounded condition and constraint matrix to handle L1 bound
w_l_bound
=
np
.
minimum
(
np
.
maximum
(
np
.
abs
(
current_position
-
lbound
),
np
.
abs
(
current_position
-
ubound
)),
turn_over_target
)
.
reshape
((
-
1
,
1
))
current_position
=
current_position
.
reshape
((
-
1
,
1
))
# we need to expand bounded condition and constraint matrix to handle L1 bound
lbound
=
np
.
concatenate
((
lbound
,
np
.
zeros
(
n
)),
axis
=
0
)
ubound
=
np
.
concatenate
((
ubound
,
np
.
inf
*
np
.
ones
(
n
)),
axis
=
0
)
ubound
=
np
.
concatenate
((
ubound
,
w_l_bound
.
flatten
(
)),
axis
=
0
)
risk_lbound
=
np
.
concatenate
((
risk_lbound
,
[[
0.
]]),
axis
=
0
)
risk_ubound
=
np
.
concatenate
((
risk_ubound
,
[[
turn_over_target
]]),
axis
=
0
)
...
...
@@ -71,11 +75,11 @@ def linear_builder(er: np.ndarray,
risk_constraints
=
np
.
concatenate
((
risk_constraints
,
turn_over_matrix
),
axis
=
0
)
risk_lbound
=
np
.
concatenate
((
risk_lbound
,
-
np
.
inf
*
np
.
ones
((
n
,
1
))
),
axis
=
0
)
risk_lbound
=
np
.
concatenate
((
risk_lbound
,
current_position
),
axis
=
0
)
risk_lbound
=
np
.
concatenate
((
risk_lbound
,
current_position
),
axis
=
0
)
risk_ubound
=
np
.
concatenate
((
risk_ubound
,
current_position
),
axis
=
0
)
risk_ubound
=
np
.
concatenate
((
risk_ubound
,
np
.
inf
*
np
.
ones
((
n
,
1
))
),
axis
=
0
)
risk_ubound
=
np
.
concatenate
((
risk_ubound
,
2.
*
w_l_bound
),
axis
=
0
)
cons_matrix
=
np
.
concatenate
((
risk_constraints
,
risk_lbound
,
risk_ubound
),
axis
=
1
)
opt
=
LPOptimizer
(
cons_matrix
,
lbound
,
ubound
,
-
er
,
method
)
...
...
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