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
3e54d3bc
Commit
3e54d3bc
authored
Sep 05, 2017
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
38fd0ff5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
31 deletions
+57
-31
models.py
alphamind/data/dbmodel/models.py
+27
-0
data_preparing.py
alphamind/model/data_preparing.py
+30
-31
No files found.
alphamind/data/dbmodel/models.py
View file @
3e54d3bc
...
@@ -227,6 +227,18 @@ class Performance(Base):
...
@@ -227,6 +227,18 @@ class Performance(Base):
ic
=
Column
(
Float
(
53
))
ic
=
Column
(
Float
(
53
))
class
PnlLog
(
Base
):
__tablename__
=
'pnl_log'
__table_args__
=
(
Index
(
'pnl_log_trade_date_portfolio_name_uindex'
,
'trade_date'
,
'portfolio_name'
,
unique
=
True
),
)
trade_date
=
Column
(
DateTime
,
primary_key
=
True
,
nullable
=
False
)
portfolio_name
=
Column
(
String
(
50
),
primary_key
=
True
,
nullable
=
False
)
excess_return
=
Column
(
Float
(
53
))
pct_change
=
Column
(
Float
(
53
))
class
Positions
(
Base
):
class
Positions
(
Base
):
__tablename__
=
'positions'
__tablename__
=
'positions'
...
@@ -258,6 +270,21 @@ class QuantileAnalysis(Base):
...
@@ -258,6 +270,21 @@ class QuantileAnalysis(Base):
q10
=
Column
(
Float
(
53
))
q10
=
Column
(
Float
(
53
))
class
RebalanceLog
(
Base
):
__tablename__
=
'rebalance_log'
__table_args__
=
(
Index
(
'rebalance_log_trade_date_code_portfolio_name_uindex'
,
'trade_date'
,
'code'
,
'portfolio_name'
,
unique
=
True
),
)
trade_date
=
Column
(
DateTime
,
primary_key
=
True
,
nullable
=
False
)
code
=
Column
(
Integer
,
primary_key
=
True
,
nullable
=
False
)
portfolio_name
=
Column
(
String
(
50
),
primary_key
=
True
,
nullable
=
False
)
factor_date
=
Column
(
DateTime
,
nullable
=
False
)
weight
=
Column
(
Float
(
53
),
nullable
=
False
)
price
=
Column
(
Float
(
53
),
nullable
=
False
)
class
RiskCovDay
(
Base
):
class
RiskCovDay
(
Base
):
__tablename__
=
'risk_cov_day'
__tablename__
=
'risk_cov_day'
__table_args__
=
(
__table_args__
=
(
...
...
alphamind/model/data_preparing.py
View file @
3e54d3bc
...
@@ -221,16 +221,16 @@ def fetch_data_package(engine: SqlEngine,
...
@@ -221,16 +221,16 @@ def fetch_data_package(engine: SqlEngine,
def
fetch_train_phase
(
engine
,
def
fetch_train_phase
(
engine
,
alpha_factors
:
Iterable
[
object
],
alpha_factors
:
Iterable
[
object
],
ref_date
,
ref_date
,
frequency
,
frequency
,
universe
,
universe
,
batch
,
batch
,
neutralized_risk
:
Iterable
[
str
]
=
None
,
neutralized_risk
:
Iterable
[
str
]
=
None
,
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
):
transformer
=
Transformer
(
alpha_factors
)
transformer
=
Transformer
(
alpha_factors
)
p
=
Period
(
frequency
)
p
=
Period
(
frequency
)
...
@@ -290,16 +290,16 @@ def fetch_train_phase(engine,
...
@@ -290,16 +290,16 @@ def fetch_train_phase(engine,
def
fetch_predict_phase
(
engine
,
def
fetch_predict_phase
(
engine
,
alpha_factors
:
Iterable
[
object
],
alpha_factors
:
Iterable
[
object
],
ref_date
,
ref_date
,
frequency
,
frequency
,
universe
,
universe
,
batch
,
batch
,
neutralized_risk
:
Iterable
[
str
]
=
None
,
neutralized_risk
:
Iterable
[
str
]
=
None
,
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
):
transformer
=
Transformer
(
alpha_factors
)
transformer
=
Transformer
(
alpha_factors
)
p
=
Period
(
frequency
)
p
=
Period
(
frequency
)
...
@@ -367,17 +367,6 @@ if __name__ == '__main__':
...
@@ -367,17 +367,6 @@ if __name__ == '__main__':
universe
=
Universe
(
'zz500'
,
[
'ashare_ex'
])
universe
=
Universe
(
'zz500'
,
[
'ashare_ex'
])
neutralized_risk
=
[
'SIZE'
]
neutralized_risk
=
[
'SIZE'
]
res
=
fetch_train_phase
(
engine
,
res
=
fetch_train_phase
(
engine
,
[
'EPS'
,
'CFinc1'
],
'2017-09-04'
,
'2w'
,
universe
,
4
,
warm_start
=
1
,
neutralized_risk
=
neutralized_risk
)
print
(
res
)
res
=
fetch_predict_phase
(
engine
,
[
'EPS'
,
'CFinc1'
],
[
'EPS'
,
'CFinc1'
],
'2017-09-04'
,
'2017-09-04'
,
'2w'
,
'2w'
,
...
@@ -388,3 +377,13 @@ if __name__ == '__main__':
...
@@ -388,3 +377,13 @@ if __name__ == '__main__':
print
(
res
)
print
(
res
)
res
=
fetch_predict_phase
(
engine
,
[
'EPS'
,
'CFinc1'
],
'2017-09-04'
,
'2w'
,
universe
,
4
,
warm_start
=
1
,
neutralized_risk
=
neutralized_risk
)
print
(
res
)
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