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
30aa9db2
Commit
30aa9db2
authored
Feb 09, 2018
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
misc
parent
4f20b165
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
2 deletions
+78
-2
sqlengine.py
alphamind/data/engines/sqlengine.py
+2
-2
transformer.py
alphamind/data/transformer.py
+5
-0
test_composer.py
alphamind/tests/model/test_composer.py
+55
-0
test_allocations.py
alphamind/tests/portfolio/test_allocations.py
+16
-0
No files found.
alphamind/data/engines/sqlengine.py
View file @
30aa9db2
...
...
@@ -613,7 +613,7 @@ class SqlEngine(object):
res
=
df
[[
'trade_date'
,
'code'
,
'industry_code'
,
'industry_name'
]
+
in_s
]
res
=
res
.
assign
(
**
dict
(
zip
(
out_s
,
[
0
]
*
len
(
out_s
))))
res
=
res
.
assign
(
**
dict
(
zip
(
out_s
,
[
0
]
*
len
(
out_s
))))
return
res
def
fetch_trade_status
(
self
,
...
...
@@ -923,4 +923,4 @@ if __name__ == '__main__':
ref_date
=
'2017-12-28'
codes
=
universe
.
query
(
engine
,
dates
=
[
ref_date
])
df
=
engine
.
fetch_trade_status
(
ref_date
,
codes
.
code
.
tolist
())
print
(
df
)
\ No newline at end of file
print
(
df
)
alphamind/data/transformer.py
View file @
30aa9db2
...
...
@@ -80,3 +80,8 @@ class Transformer(object):
return
transformed_data
else
:
return
pd
.
DataFrame
()
if
__name__
==
'__main__'
:
transformer
=
Transformer
([
'c'
,
'a'
])
alphamind/tests/model/test_composer.py
0 → 100644
View file @
30aa9db2
# -*- coding: utf-8 -*-
"""
Created on 2018-2-9
@author: cheng.li
"""
import
unittest
from
alphamind.data.engines.universe
import
Universe
from
alphamind.model.composer
import
DataMeta
from
alphamind.model.composer
import
Composer
class
TestComposer
(
unittest
.
TestCase
):
def
test_data_meta_persistence
(
self
):
freq
=
'5b'
universe
=
Universe
(
'custom'
,
[
'zz800'
])
batch
=
4
neutralized_risk
=
[
'SIZE'
]
risk_model
=
'long'
pre_process
=
[
'standardize'
,
'winsorize_normal'
]
post_process
=
[
'standardize'
,
'winsorize_normal'
]
warm_start
=
2
data_source
=
'postgresql://user:pwd@server/dummy'
data_meta
=
DataMeta
(
freq
=
freq
,
universe
=
universe
,
batch
=
batch
,
neutralized_risk
=
neutralized_risk
,
risk_model
=
risk_model
,
pre_process
=
pre_process
,
post_process
=
post_process
,
warm_start
=
warm_start
,
data_source
=
data_source
)
data_desc
=
data_meta
.
save
()
loaded_data
=
DataMeta
.
load
(
data_desc
)
self
.
assertEqual
(
data_meta
.
freq
,
loaded_data
.
freq
)
self
.
assertEqual
(
data_meta
.
universe
,
loaded_data
.
universe
)
self
.
assertEqual
(
data_meta
.
batch
,
loaded_data
.
batch
)
self
.
assertEqual
(
data_meta
.
neutralized_risk
,
loaded_data
.
neutralized_risk
)
self
.
assertEqual
(
data_meta
.
risk_model
,
loaded_data
.
risk_model
)
self
.
assertEqual
(
data_meta
.
pre_process
,
loaded_data
.
pre_process
)
self
.
assertEqual
(
data_meta
.
post_process
,
loaded_data
.
post_process
)
self
.
assertEqual
(
data_meta
.
warm_start
,
loaded_data
.
warm_start
)
self
.
assertEqual
(
data_meta
.
data_source
,
loaded_data
.
data_source
)
def
test_composer_persistence
(
self
):
pass
alphamind/tests/portfolio/test_allocations.py
0 → 100644
View file @
30aa9db2
# -*- coding: utf-8 -*-
"""
Created on 2018-2-7
@author: cheng.li
"""
import
unittest
from
alphamind.portfolio.allocations
import
Asset
from
alphamind.portfolio.allocations
import
Portfolio
from
alphamind.portfolio.allocations
import
Positions
from
alphamind.portfolio.allocations
import
Execution
class
TestAllocation
(
unittest
.
TestCase
):
pass
\ No newline at end of file
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