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
bbebe443
Unverified
Commit
bbebe443
authored
Jul 31, 2018
by
iLampard
Committed by
GitHub
Jul 31, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3 from alpha-miner/master
merge update
parents
3946e0ad
20cc62c1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
3 deletions
+3
-3
linearbuilder.py
alphamind/portfolio/linearbuilder.py
+1
-1
test_sql_engine.py
alphamind/tests/data/engines/test_sql_engine.py
+2
-2
No files found.
alphamind/portfolio/linearbuilder.py
View file @
bbebe443
...
@@ -106,7 +106,7 @@ def linear_builder(er: np.ndarray,
...
@@ -106,7 +106,7 @@ def linear_builder(er: np.ndarray,
objective
=
Minimize
(
-
w
.
T
*
er
)
objective
=
Minimize
(
-
w
.
T
*
er
)
prob
=
Problem
(
objective
,
constraints
)
prob
=
Problem
(
objective
,
constraints
)
prob
.
solve
(
solver
=
'ECOS'
,
feastol
=
1e-
9
,
abstol
=
1e-9
,
reltol
=
1e-9
)
prob
.
solve
(
solver
=
'ECOS'
,
feastol
=
1e-
10
,
abstol
=
1e-10
,
reltol
=
1e-10
)
if
prob
.
status
==
'optimal'
or
prob
.
status
==
'optimal_inaccurate'
:
if
prob
.
status
==
'optimal'
or
prob
.
status
==
'optimal_inaccurate'
:
return
prob
.
status
,
prob
.
value
,
w
.
value
.
flatten
()
return
prob
.
status
,
prob
.
value
,
w
.
value
.
flatten
()
...
...
alphamind/tests/data/engines/test_sql_engine.py
View file @
bbebe443
...
@@ -536,13 +536,13 @@ class TestSqlEngine(unittest.TestCase):
...
@@ -536,13 +536,13 @@ class TestSqlEngine(unittest.TestCase):
series
=
(
ind_matrix
[
cols
]
*
np
.
array
(
range
(
1
,
len
(
cols
)
+
1
)))
.
sum
(
axis
=
1
)
series
=
(
ind_matrix
[
cols
]
*
np
.
array
(
range
(
1
,
len
(
cols
)
+
1
)))
.
sum
(
axis
=
1
)
df3
[
'cat'
]
=
series
.
values
df3
[
'cat'
]
=
series
.
values
expected_rank
=
df3
[[
'ROE'
,
'cat'
]]
.
groupby
(
'cat'
)
.
transform
(
lambda
x
:
rankdata
(
x
.
values
)
-
1.
)
expected_rank
=
df3
[[
'ROE'
,
'cat'
]]
.
groupby
(
'cat'
)
.
transform
(
lambda
x
:
rankdata
(
x
.
values
))
expected_rank
[
np
.
isnan
(
df3
.
ROE
)]
=
np
.
nan
expected_rank
[
np
.
isnan
(
df3
.
ROE
)]
=
np
.
nan
df3
[
'rank'
]
=
expected_rank
[
'ROE'
]
.
values
df3
[
'rank'
]
=
expected_rank
[
'ROE'
]
.
values
np
.
testing
.
assert_array_almost_equal
(
df3
[
'rank'
]
.
values
,
np
.
testing
.
assert_array_almost_equal
(
df3
[
'rank'
]
.
values
,
df1
[
'f'
]
.
values
)
df1
[
'f'
]
.
values
)
expected_quantile
=
df3
[[
'ROE'
,
'cat'
]]
.
groupby
(
'cat'
)
.
transform
(
lambda
x
:
(
rankdata
(
x
.
values
)
-
1.
)
/
((
len
(
x
)
-
1.
)
if
len
(
x
)
>
1
else
1.
))
expected_quantile
=
df3
[[
'ROE'
,
'cat'
]]
.
groupby
(
'cat'
)
.
transform
(
lambda
x
:
rankdata
(
x
.
values
)
/
(
len
(
x
)
+
1
))
expected_quantile
[
np
.
isnan
(
df3
.
ROE
)]
=
np
.
nan
expected_quantile
[
np
.
isnan
(
df3
.
ROE
)]
=
np
.
nan
df3
[
'quantile'
]
=
expected_quantile
[
'ROE'
]
.
values
df3
[
'quantile'
]
=
expected_quantile
[
'ROE'
]
.
values
np
.
testing
.
assert_array_almost_equal
(
df3
[
'quantile'
]
.
values
,
np
.
testing
.
assert_array_almost_equal
(
df3
[
'quantile'
]
.
values
,
...
...
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