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
70b16fcb
Commit
70b16fcb
authored
Oct 25, 2017
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update db models
parent
e8f3cb15
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
11 deletions
+39
-11
models.py
alphamind/data/dbmodel/models.py
+23
-1
sqlengine.py
alphamind/data/engines/sqlengine.py
+3
-1
formula_expression.py
alphamind/examples/formula_expression.py
+13
-9
No files found.
alphamind/data/dbmodel/models.py
View file @
70b16fcb
...
...
@@ -2385,8 +2385,30 @@ class FactorLog(Base):
minimum
=
Column
(
Float
(
53
))
class
FactorCorrelation
(
Base
):
__tablename__
=
'factor_correlation'
__table_args__
=
(
Index
(
'factor_correlation_idx'
,
'trade_date'
,
'factor'
,
'source'
,
unique
=
True
),
)
trade_date
=
Column
(
DateTime
,
primary_key
=
True
,
nullable
=
False
)
factor
=
Column
(
String
(
30
),
primary_key
=
True
,
nullable
=
False
)
source
=
Column
(
String
(
30
),
primary_key
=
True
,
nullable
=
False
)
BETA
=
Column
(
Float
(
53
))
MOMENTUM
=
Column
(
Float
(
53
))
SIZE
=
Column
(
Float
(
53
))
EARNYILD
=
Column
(
Float
(
53
))
RESVOL
=
Column
(
Float
(
53
))
GROWTH
=
Column
(
Float
(
53
))
BTOP
=
Column
(
Float
(
53
))
LEVERAGE
=
Column
(
Float
(
53
))
LIQUIDTY
=
Column
(
Float
(
53
))
SIZENL
=
Column
(
Float
(
53
))
if
__name__
==
'__main__'
:
from
sqlalchemy
import
create_engine
engine
=
create_engine
(
'postgresql+psycopg2://postgres:
we083826@192.168.0.102
/alpha'
)
engine
=
create_engine
(
'postgresql+psycopg2://postgres:
A12345678!@10.63.6.220
/alpha'
)
Base
.
metadata
.
create_all
(
engine
)
alphamind/data/engines/sqlengine.py
View file @
70b16fcb
...
...
@@ -626,7 +626,7 @@ if __name__ == '__main__':
from
alphamind.api
import
alpha_logger
# db_url = 'postgresql+psycopg2://postgres:we083826@localhost/alpha'
db_url
=
'postgresql+psycopg2://postgres:
we083826@192.168.0.102
/alpha'
db_url
=
'postgresql+psycopg2://postgres:
A12345678!@10.63.6.220
/alpha'
universe
=
Universe
(
'custom'
,
[
'zz500'
])
engine
=
SqlEngine
(
db_url
)
...
...
@@ -651,5 +651,7 @@ if __name__ == '__main__':
alpha_logger
.
info
(
'end'
)
data2
=
engine
.
fetch_codes_range
(
universe
,
start_date
=
start_date
,
end_date
=
end_date
,
dates
=
dates
)
alpha_logger
.
info
(
'end'
)
data2
=
engine
.
fetch_dx_return_range
(
universe
,
start_date
=
start_date
,
end_date
=
end_date
,
dates
=
dates
)
alpha_logger
.
info
(
'end'
)
print
(
data1
)
alphamind/examples/formula_expression.py
View file @
70b16fcb
...
...
@@ -17,13 +17,17 @@ import datetime as dt
start
=
dt
.
datetime
.
now
()
# formula1 = CSRank(DIFF(LOG("turnoverVol")))
# formula2 = CSRank((LAST('highestPrice') - LAST('lowestPrice')) / LAST('lowestPrice'))
# expression = -CORR(6, formula1 ^ formula2)
formula1
=
CSRank
(
DIFF
(
LOG
(
"turnoverVol"
)))
formula2
=
CSRank
((
LAST
(
'closePrice'
)
-
LAST
(
'openPrice'
))
/
LAST
(
'openPrice'
))
expression
=
-
CORR
(
6
,
formula1
^
formula2
)
# expression1 = -0.6 * LAST('con_pe_rolling') - 0.6 * LAST('con_pb_rolling') + 0.6 * LAST('con_eps') + 1.2 * LAST('con_target_price')
# expression2 = LAST("IVR")
factor1
=
LAST
(
'RVOL'
)
factor2
=
LAST
(
'IVR'
)
expression
=
RES
(
20
,
factor2
^
factor1
)
#expression = expression1 + expression2
# factor1 = LAST('RVOL')
# factor2 = LAST('IVR')
# expression = RES(20, factor2 ^ factor1)
# expression = MA(1, "EPS")
...
...
@@ -33,14 +37,14 @@ alpha_factor = {alpha_factor_name: expression}
# end of formula definition
engine
=
SqlEngine
(
'postgresql+psycopg2://postgres:A12345678!@10.63.6.220/alpha'
)
universe
=
Universe
(
'custom'
,
[
'
zz500
'
])
universe
=
Universe
(
'custom'
,
[
'
ashare_ex
'
])
benchmark_code
=
905
neutralize_risk
=
[
'SIZE'
]
+
industry_styles
freq
=
'1w'
n_bins
=
5
dates
=
makeSchedule
(
'2012-01-01'
,
'2017-
09-18
'
,
'2017-
10-11
'
,
tenor
=
freq
,
calendar
=
'china.sse'
)
...
...
@@ -71,7 +75,7 @@ for i, value in enumerate(factor_groups):
er
=
factor_processing
(
total_data
[[
alpha_factor_name
]]
.
values
,
pre_process
=
[
winsorize_normal
,
standardize
],
risk_factors
=
risk_exp
,
post_process
=
[
standardize
])
post_process
=
[
winsorize_normal
,
standardize
])
res
=
er_quantile_analysis
(
er
,
n_bins
=
n_bins
,
dx_return
=
dx_return
,
...
...
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