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
7d9c6260
Commit
7d9c6260
authored
Jul 12, 2019
by
李煜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code update
parent
c007ed3f
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
28 additions
and
32 deletions
+28
-32
client.py
client.py
+13
-13
cluster_work.py
cluster_work.py
+0
-0
__init__.py
factor/__init__.py
+2
-1
factor_cash_flow.py
factor/factor_cash_flow.py
+3
-4
factor_constrain.py
factor/factor_constrain.py
+3
-4
factor_earning.py
factor/factor_earning.py
+4
-5
factor_growth.py
factor/factor_growth.py
+0
-1
factor_per_share_indicators.py
factor/factor_per_share_indicators.py
+2
-2
historical_value.py
factor/historical_value.py
+0
-1
init.py
init.py
+1
-1
No files found.
client.py
View file @
7d9c6260
...
...
@@ -540,7 +540,7 @@ if __name__ == '__main__':
ttm_factor_sets
,
balance_sets
=
get_basic_growth_data
(
date_index
)
growth_sets
=
pd
.
merge
(
ttm_factor_sets
,
balance_sets
,
on
=
'symbol'
)
cache_data
.
set_cache
(
session1
,
date_index
,
growth_sets
.
to_json
(
orient
=
'records'
))
factor_growth
.
factor_calculate
(
date_index
=
date_index
,
session
=
session1
)
factor_growth
.
factor_calculate
.
delay
(
date_index
=
date_index
,
session
=
session1
)
time1
=
time
.
time
()
print
(
'growth_cal_time:{}'
.
format
(
time1
-
start_time
))
...
...
@@ -550,7 +550,7 @@ if __name__ == '__main__':
valuation_sets
=
pd
.
merge
(
valuation_sets
,
ttm_factor_sets
,
on
=
'symbol'
)
valuation_sets
=
pd
.
merge
(
valuation_sets
,
cash_flow_sets
,
on
=
'symbol'
)
cache_data
.
set_cache
(
session2
,
date_index
,
valuation_sets
.
to_json
(
orient
=
'records'
))
historical_value
.
factor_calculate
(
date_index
=
date_index
,
session
=
session2
)
historical_value
.
factor_calculate
.
delay
(
date_index
=
date_index
,
session
=
session2
)
time2
=
time
.
time
()
print
(
'history_cal_time:{}'
.
format
(
time2
-
time1
))
...
...
@@ -561,32 +561,32 @@ if __name__ == '__main__':
valuation_sets
=
pd
.
merge
(
valuation_sets
,
cash_flow_sets
,
on
=
'symbol'
)
valuation_sets
=
pd
.
merge
(
valuation_sets
,
balance_sets
,
on
=
'symbol'
)
cache_data
.
set_cache
(
session3
,
date_index
,
valuation_sets
.
to_json
(
orient
=
'records'
))
factor_per_share_indicators
.
factor_calculate
(
date_index
=
date_index
,
session
=
session3
)
factor_per_share_indicators
.
factor_calculate
.
delay
(
date_index
=
date_index
,
session
=
session3
)
time3
=
time
.
time
()
print
(
'per_share_cal_time:{}'
.
format
(
time3
-
time2
))
# cash flow
tp_cash_flow
,
ttm_cash_flow_sets
=
get_basic_cash_flow
(
date_index
)
cache_data
.
set_cache
(
session4
+
"1"
,
date_index
,
tp_cash_flow
.
to_json
(
orient
=
'records'
))
cache_data
.
set_cache
(
session4
+
"2"
,
date_index
,
ttm_cash_flow_sets
.
to_json
(
orient
=
'records'
))
factor_cash_flow
.
factor_calculate
(
date_index
=
date_index
,
session
=
session4
)
cache_data
.
set_cache
(
session4
+
date_index
+
"1"
,
date_index
,
tp_cash_flow
.
to_json
(
orient
=
'records'
))
cache_data
.
set_cache
(
session4
+
date_index
+
"2"
,
date_index
,
ttm_cash_flow_sets
.
to_json
(
orient
=
'records'
))
factor_cash_flow
.
factor_calculate
.
delay
(
date_index
=
date_index
,
session
=
session4
)
time4
=
time
.
time
()
print
(
'cash_flow_cal_time:{}'
.
format
(
time4
-
time3
))
# constrain
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
+
'2'
,
date_index
,
ttm_factors_sets
.
to_json
(
orient
=
'records'
))
factor_constrain
.
factor_calculate
(
date_index
=
date_index
,
session
=
session5
)
cache_data
.
set_cache
(
session5
+
date_index
+
'1'
,
date_index
,
balance_sets
.
to_json
(
orient
=
'records'
))
cache_data
.
set_cache
(
session5
+
date_index
+
'2'
,
date_index
,
ttm_factors_sets
.
to_json
(
orient
=
'records'
))
factor_constrain
.
factor_calculate
.
delay
(
date_index
=
date_index
,
session
=
session5
)
time5
=
time
.
time
()
print
(
'constrain_cal_time:{}'
.
format
(
time5
-
time4
))
# earning
# tp_earning, ttm_earning_5y, ttm_earning = get_basic_earning(date_index)
# cache_data.set_cache(session6 + "1", date_index, tp_earning.to_json(orient='records'))
# cache_data.set_cache(session6 + "2", date_index, ttm_earning_5y.to_json(orient='records'))
# cache_data.set_cache(session6 + "3", date_index, ttm_earning.to_json(orient='records'))
# factor_earning.factor_calculate(date_index=date_index, session=session6)
# cache_data.set_cache(session6 +
date_index +
"1", date_index, tp_earning.to_json(orient='records'))
# cache_data.set_cache(session6 +
date_index +
"2", date_index, ttm_earning_5y.to_json(orient='records'))
# cache_data.set_cache(session6 +
date_index +
"3", date_index, ttm_earning.to_json(orient='records'))
# factor_earning.factor_calculate
.delay
(date_index=date_index, session=session6)
# time6 = time.time()
# print('earning_cal_time:{}'.format(time6 - time5))
print
(
'---------------------->'
)
q5_
cluster_work.py
→
cluster_work.py
View file @
7d9c6260
File moved
factor/__init__.py
View file @
7d9c6260
...
...
@@ -13,4 +13,5 @@ app = create_app('factor', ['factor.factor_growth',
'factor.historical_value'
,
'factor.factor_cash_flow'
,
'factor.factor_constrain'
,
'factor.factor_earning'
])
'factor.factor_earning'
,
'factor.factor_per_share_indicators'
])
factor/factor_cash_flow.py
View file @
7d9c6260
...
...
@@ -8,8 +8,7 @@ import numpy as np
from
pandas.io.json
import
json_normalize
from
factor.ttm_fundamental
import
*
from
factor.factor_base
import
FactorBase
from
vision.fm.signletion_engine
import
*
from
vision.utillities.calc_tools
import
CalcTools
from
factor.utillities.calc_tools
import
CalcTools
from
ultron.cluster.invoke.cache_data
import
cache_data
...
...
@@ -272,8 +271,8 @@ def factor_calculate(**kwargs):
session
=
kwargs
[
'session'
]
cash_flow
=
FactorCashFlow
(
'factor_cash_flow'
)
# 注意, 这里的name要与client中新建table时的name一致, 不然回报错
content1
=
cache_data
.
get_cache
(
session
+
"1"
,
date_index
)
content2
=
cache_data
.
get_cache
(
session
+
"2"
,
date_index
)
content1
=
cache_data
.
get_cache
(
session
+
date_index
+
"1"
,
date_index
)
content2
=
cache_data
.
get_cache
(
session
+
date_index
+
"2"
,
date_index
)
tp_cash_flow
=
json_normalize
(
json
.
loads
(
str
(
content1
,
encoding
=
'utf8'
)))
ttm_factor_sets
=
json_normalize
(
json
.
loads
(
str
(
content2
,
encoding
=
'utf8'
)))
tp_cash_flow
.
set_index
(
'symbol'
,
inplace
=
True
)
...
...
factor/factor_constrain.py
View file @
7d9c6260
...
...
@@ -9,8 +9,7 @@ from pandas.io.json import json_normalize
from
factor
import
app
from
factor.factor_base
import
FactorBase
from
factor.ttm_fundamental
import
*
from
vision.fm.signletion_engine
import
*
from
vision.utillities.calc_tools
import
CalcTools
from
factor.utillities.calc_tools
import
CalcTools
from
ultron.cluster.invoke.cache_data
import
cache_data
...
...
@@ -190,8 +189,8 @@ def factor_calculate(**kwargs):
date_index
=
kwargs
[
'date_index'
]
session
=
kwargs
[
'session'
]
constrain
=
FactorConstrain
(
'factor_constrain'
)
# 注意, 这里的name要与client中新建table时的name一致, 不然回报错
content1
=
cache_data
.
get_cache
(
session
+
'1'
,
date_index
)
content2
=
cache_data
.
get_cache
(
session
+
'2'
,
date_index
)
content1
=
cache_data
.
get_cache
(
session
+
date_index
+
'1'
,
date_index
)
content2
=
cache_data
.
get_cache
(
session
+
date_index
+
'2'
,
date_index
)
balance_sets
=
json_normalize
(
json
.
loads
(
str
(
content1
,
encoding
=
'utf8'
)))
ttm_factors_sets
=
json_normalize
(
json
.
loads
(
str
(
content2
,
encoding
=
'utf8'
)))
balance_sets
.
set_index
(
'symbol'
,
inplace
=
True
)
...
...
factor/factor_earning.py
View file @
7d9c6260
...
...
@@ -14,8 +14,7 @@ from factor import app
import
numpy
as
np
from
factor.ttm_fundamental
import
*
from
factor.factor_base
import
FactorBase
from
vision.fm.signletion_engine
import
*
from
vision.utillities.calc_tools
import
CalcTools
from
factor.utillities.calc_tools
import
CalcTools
from
pandas.io.json
import
json_normalize
from
ultron.cluster.invoke.cache_data
import
cache_data
...
...
@@ -600,9 +599,9 @@ def factor_calculate(**kwargs):
date_index
=
kwargs
[
'date_index'
]
session
=
kwargs
[
'session'
]
earning
=
FactorEarning
(
'factor_earning'
)
# 注意, 这里的name要与client中新建table时的name一致, 不然回报错
content1
=
cache_data
.
get_cache
(
session
+
"1"
,
date_index
)
content2
=
cache_data
.
get_cache
(
session
+
"2"
,
date_index
)
content3
=
cache_data
.
get_cache
(
session
+
"3"
,
date_index
)
content1
=
cache_data
.
get_cache
(
session
+
date_index
+
"1"
,
date_index
)
content2
=
cache_data
.
get_cache
(
session
+
date_index
+
"2"
,
date_index
)
content3
=
cache_data
.
get_cache
(
session
+
date_index
+
"3"
,
date_index
)
tp_earning
=
json_normalize
(
json
.
loads
(
str
(
content1
,
encoding
=
'utf8'
)))
ttm_earning_5y
=
json_normalize
(
json
.
loads
(
str
(
content2
,
encoding
=
'utf8'
)))
ttm_earning
=
json_normalize
(
json
.
loads
(
str
(
content3
,
encoding
=
'utf8'
)))
...
...
factor/factor_growth.py
View file @
7d9c6260
...
...
@@ -14,7 +14,6 @@ from pandas.io.json import json_normalize
from
factor
import
app
from
factor.factor_base
import
FactorBase
from
factor.ttm_fundamental
import
*
from
vision.fm.signletion_engine
import
*
from
ultron.cluster.invoke.cache_data
import
cache_data
...
...
factor/factor_per_share_indicators.py
View file @
7d9c6260
...
...
@@ -13,10 +13,10 @@ import sys
sys
.
path
.
append
(
".."
)
import
json
from
factor
import
app
from
pandas.io.json
import
json_normalize
from
factor.ttm_fundamental
import
*
from
factor.factor_base
import
FactorBase
from
vision.fm.signletion_engine
import
*
from
ultron.cluster.invoke.cache_data
import
cache_data
...
...
@@ -526,7 +526,7 @@ def calculate(trade_date, valuation_sets, per_share):
per_share
.
_storage_data
(
factor_share_indicators
,
trade_date
)
#
@app.task()
@
app
.
task
()
def
factor_calculate
(
**
kwargs
):
print
(
"per_share_kwargs: {}"
.
format
(
kwargs
))
date_index
=
kwargs
[
'date_index'
]
...
...
factor/historical_value.py
View file @
7d9c6260
...
...
@@ -17,7 +17,6 @@ from pandas.io.json import json_normalize
from
factor
import
app
from
factor.factor_base
import
FactorBase
from
factor.ttm_fundamental
import
*
from
vision.fm.signletion_engine
import
*
from
factor.utillities.calc_tools
import
CalcTools
from
ultron.cluster.invoke.cache_data
import
cache_data
...
...
init.py
View file @
7d9c6260
from
ultron.config
import
config_setting
config_setting
.
set_queue
(
qtype
=
'redis'
,
host
=
'10.15.5.
3
4'
,
port
=
6379
,
pwd
=
''
,
db
=
1
)
config_setting
.
set_queue
(
qtype
=
'redis'
,
host
=
'10.15.5.
16
4'
,
port
=
6379
,
pwd
=
''
,
db
=
1
)
config_setting
.
update
()
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