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
1d5dac73
Commit
1d5dac73
authored
Feb 08, 2018
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added model composer api
parent
6e2b07e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
10 deletions
+16
-10
api.py
alphamind/api.py
+8
-0
composer.py
alphamind/model/composer.py
+8
-10
No files found.
alphamind/api.py
View file @
1d5dac73
...
@@ -43,6 +43,10 @@ from alphamind.model import load_model
...
@@ -43,6 +43,10 @@ from alphamind.model import load_model
from
alphamind.model.data_preparing
import
fetch_data_package
from
alphamind.model.data_preparing
import
fetch_data_package
from
alphamind.model.data_preparing
import
fetch_train_phase
from
alphamind.model.data_preparing
import
fetch_train_phase
from
alphamind.model.data_preparing
import
fetch_predict_phase
from
alphamind.model.data_preparing
import
fetch_predict_phase
from
alphamind.model.composer
import
ModelComposer
from
alphamind.model.composer
import
DataMeta
from
alphamind.model.composer
import
train_model
from
alphamind.model.composer
import
predict_by_model
from
alphamind.execution.naiveexecutor
import
NaiveExecutor
from
alphamind.execution.naiveexecutor
import
NaiveExecutor
from
alphamind.execution.thresholdexecutor
import
ThresholdExecutor
from
alphamind.execution.thresholdexecutor
import
ThresholdExecutor
...
@@ -79,6 +83,10 @@ __all__ = [
...
@@ -79,6 +83,10 @@ __all__ = [
'fetch_data_package'
,
'fetch_data_package'
,
'fetch_train_phase'
,
'fetch_train_phase'
,
'fetch_predict_phase'
,
'fetch_predict_phase'
,
'ModelComposer'
,
'DataMeta'
,
'train_model'
,
'predict_by_model'
,
'LinearRegression'
,
'LinearRegression'
,
'LassoRegression'
,
'LassoRegression'
,
'ConstLinearModel'
,
'ConstLinearModel'
,
...
...
alphamind/model/composer.py
View file @
1d5dac73
...
@@ -7,20 +7,18 @@ Created on 2017-9-27
...
@@ -7,20 +7,18 @@ Created on 2017-9-27
import
copy
import
copy
import
bisect
import
bisect
from
typing
import
Union
from
typing
import
Iterable
from
typing
import
Iterable
import
pandas
as
pd
import
pandas
as
pd
from
alphamind.model.modelbase
import
ModelBase
from
alphamind.model.modelbase
import
ModelBase
from
alphamind.model.data_preparing
import
fetch_train_phase
from
alphamind.model.data_preparing
import
fetch_train_phase
from
alphamind.model.data_preparing
import
fetch_predict_phase
from
alphamind.model.data_preparing
import
fetch_predict_phase
from
alphamind.data.transformer
import
Transformer
from
alphamind.data.engines.universe
import
Universe
from
alphamind.data.engines.universe
import
Universe
from
alphamind.data.engines.sqlengine
import
SqlEngine
class
DataMeta
(
object
):
class
DataMeta
(
object
):
def
__init__
(
self
,
def
__init__
(
self
,
engine
,
freq
:
str
,
freq
:
str
,
universe
:
Universe
,
universe
:
Universe
,
batch
:
int
,
batch
:
int
,
...
@@ -28,8 +26,9 @@ class DataMeta(object):
...
@@ -28,8 +26,9 @@ class DataMeta(object):
risk_model
:
str
=
'short'
,
risk_model
:
str
=
'short'
,
pre_process
:
Iterable
[
object
]
=
None
,
pre_process
:
Iterable
[
object
]
=
None
,
post_process
:
Iterable
[
object
]
=
None
,
post_process
:
Iterable
[
object
]
=
None
,
warm_start
:
int
=
0
):
warm_start
:
int
=
0
,
self
.
engine
=
engine
data_source
:
str
=
None
):
self
.
engine
=
SqlEngine
(
data_source
)
self
.
alpha_model
=
alpha_model
self
.
alpha_model
=
alpha_model
self
.
freq
=
freq
self
.
freq
=
freq
self
.
universe
=
universe
self
.
universe
=
universe
...
@@ -124,10 +123,9 @@ if __name__ == '__main__':
...
@@ -124,10 +123,9 @@ if __name__ == '__main__':
from
alphamind.data.standardize
import
standardize
from
alphamind.data.standardize
import
standardize
from
alphamind.data.winsorize
import
winsorize_normal
from
alphamind.data.winsorize
import
winsorize_normal
from
alphamind.data.engines.sqlengine
import
industry_styles
from
alphamind.data.engines.sqlengine
import
industry_styles
from
alphamind.data.engines.sqlengine
import
SqlEngine
from
alphamind.model.linearmodel
import
ConstLinearModel
from
alphamind.model.linearmodel
import
ConstLinearModel
engine
=
SqlEngine
(
"postgres+psycopg2://postgres:we083826@localhost/alpha"
)
data_source
=
"postgres+psycopg2://postgres:we083826@localhost/alpha"
alpha_model
=
ConstLinearModel
([
'EPS'
],
np
.
array
([
1.
]))
alpha_model
=
ConstLinearModel
([
'EPS'
],
np
.
array
([
1.
]))
alpha_factors
=
[
'EPS'
]
alpha_factors
=
[
'EPS'
]
freq
=
'1w'
freq
=
'1w'
...
@@ -138,14 +136,14 @@ if __name__ == '__main__':
...
@@ -138,14 +136,14 @@ if __name__ == '__main__':
pre_process
=
[
winsorize_normal
,
standardize
]
pre_process
=
[
winsorize_normal
,
standardize
]
pos_process
=
[
winsorize_normal
,
standardize
]
pos_process
=
[
winsorize_normal
,
standardize
]
data_meta
=
DataMeta
(
engine
,
data_meta
=
DataMeta
(
freq
,
freq
,
universe
,
universe
,
batch
,
batch
,
neutralized_risk
,
neutralized_risk
,
risk_model
,
risk_model
,
pre_process
,
pre_process
,
pos_process
)
pos_process
,
data_source
=
data_source
)
composer
=
ModelComposer
(
alpha_model
,
data_meta
)
composer
=
ModelComposer
(
alpha_model
,
data_meta
)
...
...
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