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
0d692780
Commit
0d692780
authored
Feb 14, 2018
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed
parent
e62c5ebf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
sqlengine.py
alphamind/data/engines/sqlengine.py
+4
-4
No files found.
alphamind/data/engines/sqlengine.py
View file @
0d692780
...
@@ -155,9 +155,9 @@ class SqlEngine(object):
...
@@ -155,9 +155,9 @@ class SqlEngine(object):
dates
:
Iterable
[
str
]
=
None
)
->
pd
.
DataFrame
:
dates
:
Iterable
[
str
]
=
None
)
->
pd
.
DataFrame
:
return
universe
.
query
(
self
,
start_date
,
end_date
,
dates
)
return
universe
.
query
(
self
,
start_date
,
end_date
,
dates
)
def
_create_stats
(
self
,
table
,
horizon
,
offset
):
def
_create_stats
(
self
,
table
,
horizon
,
offset
,
code_attr
=
'code'
):
stats
=
func
.
sum
(
self
.
ln_func
(
1.
+
table
.
chgPct
))
.
over
(
stats
=
func
.
sum
(
self
.
ln_func
(
1.
+
table
.
chgPct
))
.
over
(
partition_by
=
table
.
code
,
partition_by
=
getattr
(
table
,
code_attr
)
,
order_by
=
table
.
trade_date
,
order_by
=
table
.
trade_date
,
rows
=
(
1
+
DAILY_RETURN_OFFSET
+
offset
,
1
+
horizon
+
DAILY_RETURN_OFFSET
+
offset
))
.
label
(
'dx'
)
rows
=
(
1
+
DAILY_RETURN_OFFSET
+
offset
,
1
+
horizon
+
DAILY_RETURN_OFFSET
+
offset
))
.
label
(
'dx'
)
return
stats
return
stats
...
@@ -244,7 +244,7 @@ class SqlEngine(object):
...
@@ -244,7 +244,7 @@ class SqlEngine(object):
else
:
else
:
end_date
=
expiry_date
end_date
=
expiry_date
stats
=
self
.
_create_stats
(
IndexMarket
,
horizon
,
offset
)
stats
=
self
.
_create_stats
(
IndexMarket
,
horizon
,
offset
,
code_attr
=
'indexCode'
)
query
=
select
([
IndexMarket
.
trade_date
,
IndexMarket
.
indexCode
.
label
(
'code'
),
stats
])
.
where
(
query
=
select
([
IndexMarket
.
trade_date
,
IndexMarket
.
indexCode
.
label
(
'code'
),
stats
])
.
where
(
and_
(
and_
(
...
@@ -272,7 +272,7 @@ class SqlEngine(object):
...
@@ -272,7 +272,7 @@ class SqlEngine(object):
end_date
=
advanceDateByCalendar
(
'china.sse'
,
end_date
,
end_date
=
advanceDateByCalendar
(
'china.sse'
,
end_date
,
str
(
1
+
horizon
+
offset
+
DAILY_RETURN_OFFSET
)
+
'b'
)
.
strftime
(
'
%
Y-
%
m-
%
d'
)
str
(
1
+
horizon
+
offset
+
DAILY_RETURN_OFFSET
)
+
'b'
)
.
strftime
(
'
%
Y-
%
m-
%
d'
)
stats
=
self
.
_create_stats
(
IndexMarket
,
horizon
,
offset
)
stats
=
self
.
_create_stats
(
IndexMarket
,
horizon
,
offset
,
code_attr
=
'indexCode'
)
query
=
select
([
IndexMarket
.
trade_date
,
IndexMarket
.
indexCode
.
label
(
'code'
),
stats
])
\
query
=
select
([
IndexMarket
.
trade_date
,
IndexMarket
.
indexCode
.
label
(
'code'
),
stats
])
\
.
where
(
.
where
(
...
...
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