Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
FactorCalculate
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
李煜
FactorCalculate
Commits
b4e50fc1
Commit
b4e50fc1
authored
Jul 05, 2019
by
李煜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code update
parent
d90df3fe
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
8 deletions
+7
-8
client.py
client.py
+3
-3
factor_constrain.py
factor/factor_constrain.py
+4
-4
factor_growth.py
factor/factor_growth.py
+0
-1
No files found.
client.py
View file @
b4e50fc1
import
time
import
time
import
collections
import
collections
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
from
factor
import
factor_growth
,
historical_value
,
factor_per_share_indicators
,
factor_cash_flow
,
factor_con
traria
n
,
factor_earning
from
factor
import
factor_growth
,
historical_value
,
factor_per_share_indicators
,
factor_cash_flow
,
factor_con
strai
n
,
factor_earning
from
factor.ttm_fundamental
import
*
from
factor.ttm_fundamental
import
*
from
vision.file_unit.balance
import
Balance
from
vision.file_unit.balance
import
Balance
from
vision.file_unit.cash_flow
import
CashFlow
from
vision.file_unit.cash_flow
import
CashFlow
...
@@ -527,7 +527,7 @@ if __name__ == '__main__':
...
@@ -527,7 +527,7 @@ if __name__ == '__main__':
cash_flow
.
create_dest_tables
()
cash_flow
.
create_dest_tables
()
# constrain
# constrain
constrain
=
factor_con
trarian
.
FactorContraria
n
(
'factor_constrain'
)
constrain
=
factor_con
strain
.
FactorConstrai
n
(
'factor_constrain'
)
constrain
.
create_dest_tables
()
constrain
.
create_dest_tables
()
# earning
# earning
...
@@ -577,7 +577,7 @@ if __name__ == '__main__':
...
@@ -577,7 +577,7 @@ if __name__ == '__main__':
balance_sets
,
ttm_factors_sets
=
get_basic_constrain
(
date_index
)
balance_sets
,
ttm_factors_sets
=
get_basic_constrain
(
date_index
)
cache_data
.
set_cache
(
session5
+
'1'
,
date_index
,
balance_sets
.
to_json
(
orient
=
'records'
))
cache_data
.
set_cache
(
session5
+
'1'
,
date_index
,
balance_sets
.
to_json
(
orient
=
'records'
))
cache_data
.
set_cache
(
session5
+
'2'
,
date_index
,
ttm_factors_sets
.
to_json
(
orient
=
'records'
))
cache_data
.
set_cache
(
session5
+
'2'
,
date_index
,
ttm_factors_sets
.
to_json
(
orient
=
'records'
))
factor_con
traria
n
.
factor_calculate
(
date_index
=
date_index
,
session
=
session5
)
factor_con
strai
n
.
factor_calculate
(
date_index
=
date_index
,
session
=
session5
)
time5
=
time
.
time
()
time5
=
time
.
time
()
print
(
'constrain_cal_time:{}'
.
format
(
time5
-
time4
))
print
(
'constrain_cal_time:{}'
.
format
(
time5
-
time4
))
...
...
factor/factor_con
traria
n.py
→
factor/factor_con
strai
n.py
View file @
b4e50fc1
...
@@ -14,9 +14,9 @@ from vision.utillities.calc_tools import CalcTools
...
@@ -14,9 +14,9 @@ from vision.utillities.calc_tools import CalcTools
from
ultron.cluster.invoke.cache_data
import
cache_data
from
ultron.cluster.invoke.cache_data
import
cache_data
class
FactorCon
traria
n
(
FactorBase
):
class
FactorCon
strai
n
(
FactorBase
):
def
__init__
(
self
,
name
):
def
__init__
(
self
,
name
):
super
(
FactorCon
traria
n
,
self
)
.
__init__
(
name
)
super
(
FactorCon
strai
n
,
self
)
.
__init__
(
name
)
# 构建因子表
# 构建因子表
def
create_dest_tables
(
self
):
def
create_dest_tables
(
self
):
...
@@ -36,7 +36,7 @@ class FactorContrarian(FactorBase):
...
@@ -36,7 +36,7 @@ class FactorContrarian(FactorBase):
`IntBDToCap` decimal(19,4),
`IntBDToCap` decimal(19,4),
PRIMARY KEY(`id`,`trade_date`,`symbol`)
PRIMARY KEY(`id`,`trade_date`,`symbol`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;"""
.
format
(
self
.
_name
)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;"""
.
format
(
self
.
_name
)
super
(
FactorCon
traria
n
,
self
)
.
_create_tables
(
create_sql
,
drop_sql
)
super
(
FactorCon
strai
n
,
self
)
.
_create_tables
(
create_sql
,
drop_sql
)
# 销售成本率=营业成本(TTM)/营业收入(TTM)
# 销售成本率=营业成本(TTM)/营业收入(TTM)
@
staticmethod
@
staticmethod
...
@@ -189,7 +189,7 @@ def factor_calculate(**kwargs):
...
@@ -189,7 +189,7 @@ def factor_calculate(**kwargs):
print
(
"constrain_kwargs: {}"
.
format
(
kwargs
))
print
(
"constrain_kwargs: {}"
.
format
(
kwargs
))
date_index
=
kwargs
[
'date_index'
]
date_index
=
kwargs
[
'date_index'
]
session
=
kwargs
[
'session'
]
session
=
kwargs
[
'session'
]
constrain
=
FactorCon
traria
n
(
'factor_constrain'
)
# 注意, 这里的name要与client中新建table时的name一致, 不然回报错
constrain
=
FactorCon
strai
n
(
'factor_constrain'
)
# 注意, 这里的name要与client中新建table时的name一致, 不然回报错
content1
=
cache_data
.
get_cache
(
session
+
'1'
,
date_index
)
content1
=
cache_data
.
get_cache
(
session
+
'1'
,
date_index
)
content2
=
cache_data
.
get_cache
(
session
+
'2'
,
date_index
)
content2
=
cache_data
.
get_cache
(
session
+
'2'
,
date_index
)
balance_sets
=
json_normalize
(
json
.
loads
(
str
(
content1
,
encoding
=
'utf8'
)))
balance_sets
=
json_normalize
(
json
.
loads
(
str
(
content1
,
encoding
=
'utf8'
)))
...
...
factor/factor_growth.py
View file @
b4e50fc1
...
@@ -15,7 +15,6 @@ from factor import app
...
@@ -15,7 +15,6 @@ from factor import app
from
factor.factor_base
import
FactorBase
from
factor.factor_base
import
FactorBase
from
factor.ttm_fundamental
import
*
from
factor.ttm_fundamental
import
*
from
vision.fm.signletion_engine
import
*
from
vision.fm.signletion_engine
import
*
from
factor.utillities
import
trade_date
as
td
from
ultron.cluster.invoke.cache_data
import
cache_data
from
ultron.cluster.invoke.cache_data
import
cache_data
...
...
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