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
1ed27984
Commit
1ed27984
authored
May 06, 2017
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed linear build benchmark typo
parent
0dce4df3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
linearbuild.py
alphamind/benchmarks/portfolio/linearbuild.py
+4
-4
linearbuilder.py
alphamind/portfolio/linearbuilder.py
+8
-1
No files found.
alphamind/benchmarks/portfolio/linearbuild.py
View file @
1ed27984
...
@@ -15,14 +15,14 @@ from alphamind.portfolio.linearbuilder import linear_build
...
@@ -15,14 +15,14 @@ from alphamind.portfolio.linearbuilder import linear_build
solvers
.
options
[
'show_progress'
]
=
False
solvers
.
options
[
'show_progress'
]
=
False
def
benchmark_build_linear
(
n_samples
:
int
,
n_risks
:
int
,
n_
inds
,
n_
loop
:
int
)
->
None
:
def
benchmark_build_linear
(
n_samples
:
int
,
n_risks
:
int
,
n_loop
:
int
)
->
None
:
print
(
"-"
*
60
)
print
(
"-"
*
60
)
print
(
"Starting portfolio construction by linear programming"
)
print
(
"Starting portfolio construction by linear programming"
)
print
(
"Parameters(n_samples: {0}, n_risks: {1}, n_
inds: {2})"
.
format
(
n_samples
,
n_risks
,
n_inds
))
print
(
"Parameters(n_samples: {0}, n_risks: {1}, n_
loop: {2})"
.
format
(
n_samples
,
n_risks
,
n_loop
))
er
=
np
.
random
.
randn
(
n_samples
)
er
=
np
.
random
.
randn
(
n_samples
)
risk_exp
=
np
.
random
.
randn
(
n_samples
,
n_risks
)
risk_exp
=
np
.
random
.
randn
(
n_samples
,
n_risks
)
bm
=
np
.
random
.
rand
int
(
n_inds
,
size
=
n_samples
)
.
astype
(
float
)
bm
=
np
.
random
.
rand
(
n_samples
)
bm
/=
bm
.
sum
()
bm
/=
bm
.
sum
()
lbound
=
-
0.04
lbound
=
-
0.04
...
@@ -62,4 +62,4 @@ def benchmark_build_linear(n_samples: int, n_risks: int, n_inds, n_loop: int) ->
...
@@ -62,4 +62,4 @@ def benchmark_build_linear(n_samples: int, n_risks: int, n_inds, n_loop: int) ->
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
benchmark_build_linear
(
1000
,
30
,
30
,
1
)
benchmark_build_linear
(
500
,
30
,
10
)
\ No newline at end of file
\ No newline at end of file
alphamind/portfolio/linearbuilder.py
View file @
1ed27984
...
@@ -6,6 +6,7 @@ Created on 2017-5-5
...
@@ -6,6 +6,7 @@ Created on 2017-5-5
"""
"""
import
numpy
as
np
import
numpy
as
np
from
typing
import
Tuple
import
cvxpy
import
cvxpy
from
cvxopt
import
solvers
from
cvxopt
import
solvers
...
@@ -13,7 +14,13 @@ from cvxopt import solvers
...
@@ -13,7 +14,13 @@ from cvxopt import solvers
solvers
.
options
[
'glpk'
]
=
{
'msg_lev'
:
'GLP_MSG_OFF'
}
solvers
.
options
[
'glpk'
]
=
{
'msg_lev'
:
'GLP_MSG_OFF'
}
def
linear_build
(
er
,
lbound
,
ubound
,
risk_exposure
,
bm
,
risk_target
=
None
,
solver
=
None
):
def
linear_build
(
er
:
np
.
np
.
ndarray
,
lbound
:
np
.
ndarray
,
ubound
:
np
.
ndarray
,
risk_exposure
:
np
.
ndarray
,
bm
:
np
.
ndarray
,
risk_target
:
np
.
ndarray
=
None
,
solver
:
str
=
None
)
->
Tuple
[
str
,
np
.
ndarray
,
np
.
ndarray
]:
n
,
m
=
risk_exposure
.
shape
n
,
m
=
risk_exposure
.
shape
w
=
cvxpy
.
Variable
(
n
)
w
=
cvxpy
.
Variable
(
n
)
...
...
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