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
67332907
Commit
67332907
authored
Apr 28, 2017
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added simple settle benchmark
parent
39a5acaf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
15 deletions
+99
-15
benchmarks.py
alphamind/benchmarks/benchmarks.py
+23
-15
__init__.py
alphamind/benchmarks/settlement/__init__.py
+6
-0
simplesettle.py
alphamind/benchmarks/settlement/simplesettle.py
+70
-0
No files found.
alphamind/benchmarks/benchmarks.py
View file @
67332907
...
...
@@ -12,28 +12,36 @@ from alphamind.benchmarks.data.winsorize import benchmark_winsorize_normal
from
alphamind.benchmarks.data.winsorize
import
benchmark_winsorize_normal_with_group
from
alphamind.benchmarks.portfolio.rankbuild
import
benchmark_build_rank
from
alphamind.benchmarks.portfolio.rankbuild
import
benchmark_build_rank_with_group
from
alphamind.benchmarks.settlement.simplesettle
import
benchmark_simple_settle
from
alphamind.benchmarks.settlement.simplesettle
import
benchmark_simple_settle_with_group
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
)
alphamind/benchmarks/settlement/__init__.py
0 → 100644
View file @
67332907
# -*- coding: utf-8 -*-
"""
Created on 2017-4-28
@author: cheng.li
"""
\ No newline at end of file
alphamind/benchmarks/settlement/simplesettle.py
0 → 100644
View file @
67332907
# -*- coding: utf-8 -*-
"""
Created on 2017-4-28
@author: cheng.li
"""
import
datetime
as
dt
import
numpy
as
np
import
pandas
as
pd
from
alphamind.settlement.simplesettle
import
simple_settle
def
benchmark_simple_settle
(
n_samples
:
int
,
n_portfolios
:
int
,
n_loops
:
int
)
->
None
:
print
(
"-"
*
60
)
print
(
"Starting simple settle benchmarking"
)
print
(
"Parameters(n_samples: {0}, n_portfolios: {1}, n_loops: {2})"
.
format
(
n_samples
,
n_portfolios
,
n_loops
))
weights
=
np
.
random
.
randn
(
n_samples
,
n_portfolios
)
ret_series
=
np
.
random
.
randn
(
n_samples
)
start
=
dt
.
datetime
.
now
()
for
_
in
range
(
n_loops
):
calc_ret
=
simple_settle
(
weights
,
ret_series
)
impl_model_time
=
dt
.
datetime
.
now
()
-
start
print
(
'{0:20s}: {1}'
.
format
(
'Implemented model'
,
impl_model_time
))
start
=
dt
.
datetime
.
now
()
ret_series
.
shape
=
-
1
,
1
for
_
in
range
(
n_loops
):
exp_ret
=
(
weights
*
ret_series
)
.
sum
(
axis
=
0
)
benchmark_model_time
=
dt
.
datetime
.
now
()
-
start
np
.
testing
.
assert_array_almost_equal
(
calc_ret
,
exp_ret
)
print
(
'{0:20s}: {1}'
.
format
(
'Benchmark model'
,
benchmark_model_time
))
def
benchmark_simple_settle_with_group
(
n_samples
:
int
,
n_portfolios
:
int
,
n_loops
:
int
,
n_groups
:
int
)
->
None
:
print
(
"-"
*
60
)
print
(
"Starting simple settle with group-by values benchmarking"
)
print
(
"Parameters(n_samples: {0}, n_portfolios: {1}, n_loops: {2}, n_groups: {3})"
.
format
(
n_samples
,
n_portfolios
,
n_loops
,
n_groups
))
weights
=
np
.
random
.
randn
(
n_samples
,
n_portfolios
)
ret_series
=
np
.
random
.
randn
(
n_samples
)
groups
=
np
.
random
.
randint
(
n_groups
,
size
=
n_samples
)
start
=
dt
.
datetime
.
now
()
for
_
in
range
(
n_loops
):
calc_ret
=
simple_settle
(
weights
,
ret_series
,
groups
=
groups
)
impl_model_time
=
dt
.
datetime
.
now
()
-
start
print
(
'{0:20s}: {1}'
.
format
(
'Implemented model'
,
impl_model_time
))
start
=
dt
.
datetime
.
now
()
ret_series
.
shape
=
-
1
,
1
for
_
in
range
(
n_loops
):
ret_mat
=
weights
*
ret_series
exp_ret
=
pd
.
DataFrame
(
ret_mat
)
.
groupby
(
groups
)
.
sum
()
.
values
benchmark_model_time
=
dt
.
datetime
.
now
()
-
start
np
.
testing
.
assert_array_almost_equal
(
calc_ret
,
exp_ret
)
print
(
'{0:20s}: {1}'
.
format
(
'Benchmark model'
,
benchmark_model_time
))
if
__name__
==
'__main__'
:
benchmark_simple_settle
(
3000
,
3
,
1000
)
benchmark_simple_settle_with_group
(
3000
,
3
,
1000
,
30
)
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