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
5e4c6ca9
Commit
5e4c6ca9
authored
Apr 29, 2017
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restructure
parent
5b7abf91
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
52 deletions
+53
-52
aggregate.pyx
alphamind/aggregate.pyx
+31
-0
benchmarks.py
alphamind/benchmarks/benchmarks.py
+21
-21
impl.pyx
alphamind/portfolio/impl.pyx
+0
-30
rankbuilder.py
alphamind/portfolio/rankbuilder.py
+1
-1
No files found.
alphamind/aggregate.pyx
View file @
5e4c6ca9
...
...
@@ -5,12 +5,17 @@ Created on 2017-4-26
@author: cheng.li
"""
import numpy as np
cimport numpy as np
cimport cython
from libc.math cimport sqrt
from libc.math cimport fabs
from libc.stdlib cimport calloc
from libc.stdlib cimport free
from numpy import array
from cpython.dict cimport PyDict_GetItem, PyDict_SetItem
from cpython.ref cimport PyObject
from cpython.list cimport PyList_Append
np.import_array()
...
...
@@ -18,6 +23,32 @@ cdef extern from "numpy/arrayobject.h":
void PyArray_ENABLEFLAGS(np.ndarray arr, int flags)
cdef inline object _groupby_core(dict d, object key, object item):
cdef PyObject *obj = PyDict_GetItem(d, key)
if obj is NULL:
val = []
PyList_Append(val, item)
PyDict_SetItem(d, key, val)
else:
PyList_Append(<object>obj, item)
@cython.boundscheck(False)
@cython.wraparound(False)
@cython.initializedcheck(False)
cpdef list groupby(long[:] groups):
cdef size_t length = groups.shape[0]
cdef dict group_ids = {}
cdef size_t i
cdef long curr_tag
for i in range(length):
_groupby_core(group_ids, groups[i], i)
return [array(v, dtype=np.int64) for v in group_ids.values()]
@cython.boundscheck(False)
@cython.wraparound(False)
@cython.initializedcheck(False)
...
...
alphamind/benchmarks/benchmarks.py
View file @
5e4c6ca9
...
...
@@ -18,30 +18,30 @@ from alphamind.benchmarks.settlement.simplesettle import benchmark_simple_settle
if
__name__
==
'__main__'
:
#
benchmark_neutralize(3000, 10, 1000)
#
benchmark_neutralize(30, 10, 50000)
#
benchmark_neutralize(50000, 50, 20)
#
benchmark_standardize(3000, 10, 1000)
#
benchmark_standardize_with_group(3000, 10, 1000, 30)
#
benchmark_standardize(30, 10, 50000)
#
benchmark_standardize_with_group(30, 10, 5000, 5)
#
benchmark_standardize(50000, 50, 20)
#
benchmark_standardize_with_group(50000, 50, 20, 50)
#
benchmark_winsorize_normal(3000, 10, 1000)
#
benchmark_winsorize_normal_with_group(3000, 10, 1000, 30)
#
benchmark_winsorize_normal(30, 10, 50000)
#
benchmark_winsorize_normal_with_group(30, 10, 5000, 5)
#
benchmark_winsorize_normal(50000, 50, 20)
#
benchmark_winsorize_normal_with_group(50000, 50, 20, 50)
benchmark_neutralize
(
3000
,
10
,
1000
)
benchmark_neutralize
(
30
,
10
,
50000
)
benchmark_neutralize
(
50000
,
50
,
20
)
benchmark_standardize
(
3000
,
10
,
1000
)
benchmark_standardize_with_group
(
3000
,
10
,
1000
,
30
)
benchmark_standardize
(
30
,
10
,
50000
)
benchmark_standardize_with_group
(
30
,
10
,
5000
,
5
)
benchmark_standardize
(
50000
,
50
,
20
)
benchmark_standardize_with_group
(
50000
,
50
,
20
,
50
)
benchmark_winsorize_normal
(
3000
,
10
,
1000
)
benchmark_winsorize_normal_with_group
(
3000
,
10
,
1000
,
30
)
benchmark_winsorize_normal
(
30
,
10
,
50000
)
benchmark_winsorize_normal_with_group
(
30
,
10
,
5000
,
5
)
benchmark_winsorize_normal
(
50000
,
50
,
20
)
benchmark_winsorize_normal_with_group
(
50000
,
50
,
20
,
50
)
benchmark_build_rank
(
3000
,
1000
,
300
)
benchmark_build_rank_with_group
(
3000
,
1000
,
10
,
30
)
benchmark_build_rank
(
30
,
50000
,
3
)
benchmark_build_rank_with_group
(
30
,
50000
,
1
,
3
)
benchmark_build_rank
(
50000
,
20
,
3000
)
benchmark_build_rank_with_group
(
50000
,
20
,
10
,
300
)
#
benchmark_simple_settle(3000, 10, 1000)
#
benchmark_simple_settle_with_group(3000, 10, 1000, 30)
#
benchmark_simple_settle(30, 10, 50000)
#
benchmark_simple_settle_with_group(30, 10, 5000, 5)
#
benchmark_simple_settle(50000, 50, 20)
#
benchmark_simple_settle_with_group(50000, 50, 20, 50)
benchmark_simple_settle
(
3000
,
10
,
1000
)
benchmark_simple_settle_with_group
(
3000
,
10
,
1000
,
30
)
benchmark_simple_settle
(
30
,
10
,
50000
)
benchmark_simple_settle_with_group
(
30
,
10
,
5000
,
5
)
benchmark_simple_settle
(
50000
,
50
,
20
)
benchmark_simple_settle_with_group
(
50000
,
50
,
20
,
50
)
alphamind/portfolio/impl.pyx
View file @
5e4c6ca9
...
...
@@ -7,37 +7,7 @@ Created on 2017-4-29
import numpy as np
cimport numpy as np
from numpy import array
cimport cython
from cpython.dict cimport PyDict_GetItem, PyDict_SetItem
from cpython.ref cimport PyObject
from cpython.list cimport PyList_Append
cdef inline object _groupby_core(dict d, object key, object item):
cdef PyObject *obj = PyDict_GetItem(d, key)
if obj is NULL:
val = []
PyList_Append(val, item)
PyDict_SetItem(d, key, val)
else:
PyList_Append(<object>obj, item)
@cython.boundscheck(False)
@cython.wraparound(False)
@cython.initializedcheck(False)
cpdef list groupby(long[:] groups):
cdef size_t length = groups.shape[0]
cdef dict group_ids = {}
cdef size_t i
cdef long curr_tag
for i in range(length):
_groupby_core(group_ids, groups[i], i)
return [array(v, dtype=np.int64) for v in group_ids.values()]
@cython.boundscheck(False)
...
...
alphamind/portfolio/rankbuilder.py
View file @
5e4c6ca9
...
...
@@ -7,7 +7,7 @@ Created on 2017-4-26
import
numpy
as
np
from
numpy
import
zeros
from
alphamind.
portfolio.impl
import
groupby
from
alphamind.
aggregate
import
groupby
from
alphamind.portfolio.impl
import
set_value_bool
from
alphamind.portfolio.impl
import
set_value_double
...
...
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