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
8c79003a
Commit
8c79003a
authored
May 03, 2018
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added strategy
parent
69504bfe
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
224 additions
and
164 deletions
+224
-164
composer.py
alphamind/model/composer.py
+8
-5
linearmodel.py
alphamind/model/linearmodel.py
+1
-1
constraints.py
alphamind/portfolio/constraints.py
+1
-1
strategy.py
alphamind/strategy/strategy.py
+214
-157
No files found.
alphamind/model/composer.py
View file @
8c79003a
...
...
@@ -20,6 +20,7 @@ from alphamind.data.winsorize import winsorize_normal
from
alphamind.data.rank
import
rank
from
alphamind.data.standardize
import
standardize
from
alphamind.model.loader
import
load_model
from
alphamind.model.linearmodel
import
ConstLinearModel
PROCESS_MAPPING
=
{
'winsorize_normal'
:
winsorize_normal
,
...
...
@@ -144,11 +145,13 @@ def train_model(ref_date: str,
x_values
:
pd
.
DataFrame
=
None
,
y_values
:
pd
.
DataFrame
=
None
):
base_model
=
copy
.
deepcopy
(
alpha_model
)
if
x_values
is
None
:
train_data
=
data_meta
.
fetch_train_data
(
ref_date
,
alpha_model
)
x_values
=
train_data
[
'train'
][
'x'
]
y_values
=
train_data
[
'train'
][
'y'
]
base_model
.
fit
(
x_values
,
y_values
)
if
not
isinstance
(
alpha_model
,
ConstLinearModel
):
if
x_values
is
None
:
train_data
=
data_meta
.
fetch_train_data
(
ref_date
,
alpha_model
)
x_values
=
train_data
[
'train'
][
'x'
]
y_values
=
train_data
[
'train'
][
'y'
]
base_model
.
fit
(
x_values
,
y_values
)
return
base_model
...
...
alphamind/model/linearmodel.py
View file @
8c79003a
...
...
@@ -22,7 +22,7 @@ class ConstLinearModelImpl(object):
self
.
weights
=
weights
.
flatten
()
def
fit
(
self
,
x
:
np
.
ndarray
,
y
:
np
.
ndarray
):
pass
raise
NotImplementedError
(
"Const linear model doesn't offer fit methodology"
)
def
predict
(
self
,
x
:
np
.
ndarray
):
return
x
@
self
.
weights
...
...
alphamind/portfolio/constraints.py
View file @
8c79003a
...
...
@@ -108,7 +108,7 @@ class LinearConstraints(object):
backbone
:
np
.
ndarray
=
None
):
pyFinAssert
(
len
(
bounds
)
==
cons_mat
.
shape
[
1
],
"Number of bounds should be same as number of col of cons_mat"
)
self
.
names
=
list
(
bounds
.
keys
(
))
self
.
names
=
list
(
set
(
bounds
.
keys
())
.
intersection
(
set
(
cons_mat
.
columns
)
))
self
.
bounds
=
bounds
self
.
cons_mat
=
cons_mat
self
.
backbone
=
backbone
...
...
alphamind/strategy/strategy.py
View file @
8c79003a
This diff is collapsed.
Click to expand it.
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