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
1dcc5b0d
Commit
1dcc5b0d
authored
Dec 25, 2017
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added more column to models
parent
f5d14113
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
253 additions
and
114 deletions
+253
-114
models.py
alphamind/data/dbmodel/models.py
+45
-0
factor_analysis_example.py
alphamind/examples/factor_analysis_example.py
+196
-111
create_view.sql
scripts/create_view.sql
+12
-3
No files found.
alphamind/data/dbmodel/models.py
View file @
1dcc5b0d
...
...
@@ -571,6 +571,51 @@ class FullFactor(Base):
DROE
=
Column
(
Float
(
53
))
IVR
=
Column
(
Float
(
53
))
xueqiu_hotness
=
Column
(
Float
(
53
))
con_eps
=
Column
(
Float
(
53
))
con_eps_rolling
=
Column
(
Float
(
53
))
con_na
=
Column
(
Float
(
53
))
con_na_rolling
=
Column
(
Float
(
53
))
con_np
=
Column
(
Float
(
53
))
con_npcgrate_1w
=
Column
(
Float
(
53
))
con_npcgrate_4w
=
Column
(
Float
(
53
))
con_npcgrate_13w
=
Column
(
Float
(
53
))
con_npcgrate_26w
=
Column
(
Float
(
53
))
con_npcgrate_52w
=
Column
(
Float
(
53
))
con_npcgrate_2y
=
Column
(
Float
(
53
))
con_np_rolling
=
Column
(
Float
(
53
))
con_np_yoy
=
Column
(
Float
(
53
))
con_pb
=
Column
(
Float
(
53
))
con_pb_order
=
Column
(
Float
(
53
))
con_pb_rolling
=
Column
(
Float
(
53
))
con_pb_rolling_order
=
Column
(
Float
(
53
))
con_or
=
Column
(
Float
(
53
))
con_pe
=
Column
(
Float
(
53
))
con_pe_order
=
Column
(
Float
(
53
))
con_pe_rolling
=
Column
(
Float
(
53
))
con_pe_rolling_order
=
Column
(
Float
(
53
))
con_peg
=
Column
(
Float
(
53
))
con_peg_order
=
Column
(
Float
(
53
))
con_peg_rolling
=
Column
(
Float
(
53
))
con_peg_rolling_order
=
Column
(
Float
(
53
))
con_roe
=
Column
(
Float
(
53
))
con_target_price
=
Column
(
Float
(
53
))
market_confidence_5d
=
Column
(
Float
(
53
))
market_confidence_10d
=
Column
(
Float
(
53
))
market_confidence_15d
=
Column
(
Float
(
53
))
market_confidence_25d
=
Column
(
Float
(
53
))
market_confidence_75d
=
Column
(
Float
(
53
))
mcap
=
Column
(
Float
(
53
))
optimism_confidence_5d
=
Column
(
Float
(
53
))
optimism_confidence_10d
=
Column
(
Float
(
53
))
optimism_confidence_15d
=
Column
(
Float
(
53
))
optimism_confidence_25d
=
Column
(
Float
(
53
))
optimism_confidence_75d
=
Column
(
Float
(
53
))
pessimism_confidence_5d
=
Column
(
Float
(
53
))
pessimism_confidence_10d
=
Column
(
Float
(
53
))
pessimism_confidence_15d
=
Column
(
Float
(
53
))
pessimism_confidence_25d
=
Column
(
Float
(
53
))
pessimism_confidence_75d
=
Column
(
Float
(
53
))
tcap
=
Column
(
Float
(
53
))
d_srisk
=
Column
(
Float
(
53
))
s_srisk
=
Column
(
Float
(
53
))
l_srisk
=
Column
(
Float
(
53
))
...
...
alphamind/examples/factor_analysis_example.py
View file @
1dcc5b0d
# -*- coding: utf-8 -*-
"""
Created on 2017-
8-16
Created on 2017-
11-8
@author: cheng.li
"""
...
...
@@ -10,120 +10,205 @@ import pandas as pd
from
matplotlib
import
pyplot
as
plt
from
alphamind.api
import
*
from
PyFin.api
import
*
from
PyFin.Math.Accumulators.StatefulAccumulators
import
MovingAverage
from
PyFin.Math.Accumulators.StatefulAccumulators
import
MovingSharp
from
PyFin.Math.Accumulators.StatefulAccumulators
import
MovingMaxDrawdown
strategies
=
{
'prod'
:
{
# 'factors': ['RVOL', 'EPS', 'DROEAfterNonRecurring', 'DivP', 'CFinc1', 'BDTO'],
# 'weights': [0.05, 0.3, 0.35, 0.075, 0.15, 0.05]
# 'factors': ['RVOL', 'EPS', 'DROEAfterNonRecurring', 'DivP', 'CFinc1', 'BDTO'],
# 'weights': [0.05, 0.3, 0.35, 0.075, 0.15, 0.05]
'factors'
:
[
'VAL'
,
'RVOL'
,
'ROEDiluted'
,
'GREV'
,
'EPS'
,
'CHV'
,
'CFinc1'
,
'BDTO'
],
'weights'
:
[
0.034129344
,
0.015881607
,
0.048765746
,
0.042747382
,
-
0.015900173
,
0.019044573
,
-
0.001792638
,
0.014277867
,
]
},
# 'candidate': {
# 'factors': ['RVOL', 'EPS', 'CFinc1', 'BDTO', 'VAL', 'GREV', 'ROEDiluted'],
# 'weights': [0.02, 0.2, 0.15, 0.05, 0.2, 0.2, 0.2]
# }
}
engine
=
SqlEngine
(
'postgresql+psycopg2://postgres:A12345678!@10.63.6.220/alpha'
)
universe
=
Universe
(
'custom'
,
[
'zz500'
])
benchmark_code
=
905
neutralize_risk
=
industry_styles
constraint_risk
=
industry_styles
freq
=
'2w'
if
freq
==
'1m'
:
horizon
=
21
elif
freq
==
'1w'
:
horizon
=
4
elif
freq
==
'2w'
:
horizon
=
8
elif
freq
==
'3w'
:
horizon
=
12
elif
freq
==
'1d'
:
horizon
=
0
dates
=
makeSchedule
(
'2012-01-01'
,
'2017-09-15'
,
tenor
=
freq
,
calendar
=
'china.sse'
,
dateGenerationRule
=
DateGeneration
.
Forward
)
total_data_dict
=
{}
for
strategy
in
strategies
:
factors
=
strategies
[
strategy
][
'factors'
]
factor_weights
=
strategies
[
strategy
][
'weights'
]
all_data
=
engine
.
fetch_data_range
(
universe
,
factors
,
dates
=
dates
,
benchmark
=
905
)
factor_all_data
=
all_data
[
'factor'
]
factor_groups
=
factor_all_data
.
groupby
(
'trade_date'
)
rets
=
[]
for
i
,
value
in
enumerate
(
factor_groups
):
plt
.
style
.
use
(
'ggplot'
)
"""
Back test parameter settings
"""
start_date
=
'2015-01-01'
end_date
=
'2017-11-28'
benchmark_code
=
300
universe_name
=
[
'hs300'
]
universe
=
Universe
(
universe_name
,
universe_name
)
frequency
=
'5b'
method
=
'risk_neutral'
use_rank
=
100
industry_lower
=
1.
industry_upper
=
1.
neutralize_risk
=
[
'SIZE'
]
+
industry_styles
constraint_risk
=
[
'SIZE'
]
+
industry_styles
size_risk_lower
=
0
size_risk_upper
=
0
turn_over_target_base
=
0.25
benchmark_total_lower
=
1.
benchmark_total_upper
=
1.
horizon
=
map_freq
(
frequency
)
executor
=
NaiveExecutor
()
engine
=
SqlEngine
()
"""
Model phase: we need 1 constant linear model and one linear regression model
"""
alpha_name
=
[
'alpha_factor'
]
#const_features = {alpha_name[0]: LAST('optimism_confidence_25d') + LAST('pessimism_confidence_25d')}
# const_features = {alpha_name[0]: CSRes(DIFF(1. / LAST('PE')), LAST('roe_q'))}
simple_expression
=
LAST
(
'cfinc1_q'
)
# CSRes(CSRes(LAST('DividendPS'), LAST('roe_q')), LAST('ep_q'))
const_features
=
{
alpha_name
[
0
]:
simple_expression
}
const_weights
=
np
.
array
([
1.
])
const_model
=
ConstLinearModel
(
features
=
alpha_name
,
weights
=
const_weights
)
ref_dates
=
makeSchedule
(
start_date
,
end_date
,
frequency
,
'china.sse'
)
const_model_factor_data
=
engine
.
fetch_data_range
(
universe
,
const_features
,
dates
=
ref_dates
,
benchmark
=
benchmark_code
)[
'factor'
]
.
dropna
()
horizon
=
map_freq
(
frequency
)
rets
=
[]
turn_overs
=
[]
leverags
=
[]
previous_pos
=
pd
.
DataFrame
()
index_dates
=
[]
factor_groups
=
const_model_factor_data
.
groupby
(
'trade_date'
)
for
i
,
value
in
enumerate
(
factor_groups
):
date
=
value
[
0
]
data
=
value
[
1
]
codes
=
data
.
code
.
tolist
()
ref_date
=
date
.
strftime
(
'
%
Y-
%
m-
%
d'
)
returns
=
engine
.
fetch_dx_return
(
ref_date
,
codes
,
horizon
=
horizon
)
index_dates
.
append
(
date
)
total_data
=
pd
.
merge
(
data
,
returns
,
on
=
[
'code'
])
.
dropna
(
)
print
(
date
,
': '
,
len
(
total_data
))
total_data
=
data
.
fillna
(
data
[
alpha_name
]
.
median
()
)
alpha_logger
.
info
(
'{0}: {1}'
.
format
(
date
,
len
(
total_data
)
))
risk_exp
=
total_data
[
neutralize_risk
]
.
values
.
astype
(
float
)
industry
=
total_data
.
industry_code
.
values
dx_return
=
total_data
.
dx
.
values
benchmark
=
total_data
.
weight
.
values
benchmark_w
=
total_data
.
weight
.
values
constraint_exp
=
total_data
[
constraint_risk
]
.
values
risk_exp_expand
=
np
.
concatenate
((
constraint_exp
,
np
.
ones
((
len
(
risk_exp
),
1
))),
axis
=
1
)
.
astype
(
float
)
risk_names
=
constraint_risk
+
[
'total'
]
risk_target
=
risk_exp_expand
.
T
@
benchmark
risk_target
=
risk_exp_expand
.
T
@
benchmark_w
lbound
=
np
.
maximum
(
0.
,
benchmark_w
-
0.02
)
# np.zeros(len(total_data))
ubound
=
0.02
+
benchmark_w
is_in_benchmark
=
(
benchmark_w
>
0.
)
.
astype
(
float
)
lbound
=
np
.
zeros
(
len
(
total_data
)
)
ubound
=
0.01
+
benchmark
risk_exp_expand
=
np
.
concatenate
((
risk_exp_expand
,
is_in_benchmark
.
reshape
((
-
1
,
1
))),
axis
=
1
)
.
astype
(
float
)
risk_names
.
append
(
'benchmark_total'
)
constraint
=
Constraints
(
risk_exp_expand
,
risk_names
)
for
i
,
name
in
enumerate
(
risk_names
):
constraint
.
set_constraints
(
name
,
lower_bound
=
risk_target
[
i
],
upper_bound
=
risk_target
[
i
])
if
name
==
'total'
:
constraint
.
set_constraints
(
name
,
lower_bound
=
risk_target
[
i
],
upper_bound
=
risk_target
[
i
])
elif
name
==
'SIZE'
:
base_target
=
abs
(
risk_target
[
i
])
constraint
.
set_constraints
(
name
,
lower_bound
=
risk_target
[
i
]
+
base_target
*
size_risk_lower
,
upper_bound
=
risk_target
[
i
]
+
base_target
*
size_risk_upper
)
elif
name
==
'benchmark_total'
:
base_target
=
benchmark_w
.
sum
()
constraint
.
set_constraints
(
name
,
lower_bound
=
benchmark_total_lower
*
base_target
,
upper_bound
=
benchmark_total_upper
*
base_target
)
else
:
constraint
.
set_constraints
(
name
,
lower_bound
=
risk_target
[
i
]
*
industry_lower
,
upper_bound
=
risk_target
[
i
]
*
industry_upper
)
factor_values
=
factor_processing
(
total_data
[
alpha_name
]
.
values
,
pre_process
=
[
winsorize_normal
,
standardize
],
risk_factors
=
risk_exp
,
post_process
=
[
winsorize_normal
,
standardize
])
# const linear model
er
=
const_model
.
predict
(
factor_values
)
codes
=
total_data
[
'code'
]
.
values
if
previous_pos
.
empty
:
current_position
=
None
turn_over_target
=
None
else
:
previous_pos
.
set_index
(
'code'
,
inplace
=
True
)
remained_pos
=
previous_pos
.
loc
[
codes
]
remained_pos
.
fillna
(
0.
,
inplace
=
True
)
turn_over_target
=
turn_over_target_base
current_position
=
remained_pos
.
weight
.
values
f_data
=
total_data
[
factors
]
try
:
pos
,
analysis
=
factor_analysis
(
f_data
,
factor_weights
,
industry
=
industry
,
d1returns
=
dx_return
,
risk_exp
=
risk_exp
,
benchmark
=
benchmark
,
is_tradable
=
total_data
.
isOpen
.
values
.
astype
(
bool
),
method
=
'risk_neutral'
,
constraints
=
constraint
,
use_rank
=
50
,
target_pos
,
_
=
er_portfolio_analysis
(
er
,
industry
,
None
,
constraint
,
False
,
benchmark_w
,
method
=
method
,
use_rank
=
use_rank
,
turn_over_target
=
turn_over_target
,
current_position
=
current_position
,
lbound
=
lbound
,
ubound
=
ubound
)
except
ValueError
:
alpha_logger
.
info
(
'{0} full re-balance'
.
format
(
date
))
target_pos
,
_
=
er_portfolio_analysis
(
er
,
industry
,
None
,
constraint
,
False
,
benchmark_w
,
method
=
method
,
use_rank
=
use_rank
,
lbound
=
lbound
,
ubound
=
ubound
)
except
Exception
as
e
:
print
(
e
)
rets
.
append
(
0.
)
else
:
rets
.
append
(
analysis
.
er
[
-
1
]
/
benchmark
.
sum
())
t
otal_data_dict
[
strategy
]
=
ret
s
t
arget_pos
[
'code'
]
=
total_data
[
'code'
]
.
value
s
ret_df
=
pd
.
DataFrame
(
total_data_dict
,
index
=
dates
)
ret_df
.
loc
[
advanceDateByCalendar
(
'china.sse'
,
dates
[
-
1
],
freq
)]
=
0.
ret_df
=
ret_df
.
shift
(
1
)
turn_over
,
executed_pos
=
executor
.
execute
(
target_pos
=
target_pos
)
executed_codes
=
executed_pos
.
code
.
tolist
()
dx_returns
=
engine
.
fetch_dx_return
(
date
,
executed_codes
,
horizon
=
horizon
,
offset
=
1
)
result
=
pd
.
merge
(
executed_pos
,
total_data
[[
'code'
,
'weight'
]],
on
=
[
'code'
],
how
=
'inner'
)
result
=
pd
.
merge
(
result
,
dx_returns
,
on
=
[
'code'
])
leverage
=
result
.
weight_x
.
abs
()
.
sum
()
ret
=
result
.
weight_x
.
values
@
(
np
.
exp
(
result
.
dx
.
values
)
-
1.
)
rets
.
append
(
np
.
log
(
1.
+
ret
))
executor
.
set_current
(
executed_pos
)
turn_overs
.
append
(
turn_over
)
leverags
.
append
(
leverage
)
previous_pos
=
executed_pos
alpha_logger
.
info
(
'{0} is finished'
.
format
(
date
))
ret_df
=
pd
.
DataFrame
({
'returns'
:
rets
,
'turn_over'
:
turn_overs
,
'leverage'
:
leverage
},
index
=
index_dates
)
# index return
index_return
=
engine
.
fetch_dx_return_index_range
(
benchmark_code
,
start_date
,
end_date
,
horizon
=
horizon
,
offset
=
1
)
.
set_index
(
'trade_date'
)
ret_df
[
'index'
]
=
index_return
[
'dx'
]
ret_df
.
loc
[
advanceDateByCalendar
(
'china.sse'
,
ref_dates
[
-
1
],
frequency
)]
=
0.
ret_df
=
ret_df
.
shift
(
1
)
ret_df
.
iloc
[
0
]
=
0.
ret_df
[
'tc_cost'
]
=
ret_df
.
turn_over
*
0.002
ret_df
[
'returns'
]
=
ret_df
[
'returns'
]
-
ret_df
[
'index'
]
*
ret_df
[
'leverage'
]
ret_df
[[
'returns'
,
'tc_cost'
]]
.
cumsum
()
.
plot
(
figsize
=
(
12
,
6
),
title
=
'Fixed frequency rebalanced: {0}'
.
format
(
frequency
),
secondary_y
=
'tc_cost'
)
ret_df
.
cumsum
()
.
plot
(
figsize
=
(
12
,
6
))
plt
.
savefig
(
"backtest_big_universe_20170814.png"
)
plt
.
show
()
scripts/create_view.sql
View file @
1dcc5b0d
...
...
@@ -26,12 +26,20 @@ SELECT array_to_string(ARRAY(SELECT 'r' || '.' || '"' || c.column_name || '"'
),
','
)
||
' FROM risk_exposure AS r'
As
sqlstmt5
;
create
MATERIALIZED
VIEW
full_factor_view
as
SELECT
m
.
"trade_date"
,
m
.
"code"
,
m
.
"secShortName"
,
m
.
"exchangeCD"
,
m
.
"preClosePrice"
,
m
.
"actPreClosePrice"
,
m
.
"openPrice"
,
m
.
"highestPrice"
,
m
.
"lowestPrice"
,
m
.
"closePrice"
,
m
.
"turnoverVol"
,
m
.
"turnoverValue"
,
m
.
"dealAmount"
,
m
.
"turnoverRate"
,
m
.
"accumAdjFactor"
,
m
.
"negMarketValue"
,
m
.
"marketValue"
,
m
.
"chgPct"
,
m
.
"isOpen"
,
m
.
"vwap"
,
SELECT
array_to_string
(
ARRAY
(
SELECT
'g'
||
'.'
||
'"'
||
c
.
column_name
||
'"'
FROM
information_schema
.
columns
As
c
WHERE
table_name
=
'gogoal'
AND
c
.
column_name
NOT
IN
(
'trade_date'
,
'code'
)
),
','
)
||
' FROM gogoal AS g'
As
sqlstmt6
;
create
table
full_factor
as
SELECT
m
.
"trade_date"
,
m
.
"code"
,
m
.
"secShortName"
,
m
.
"exchangeCD"
,
m
.
"preClosePrice"
,
m
.
"actPreClosePrice"
,
m
.
"openPrice"
,
m
.
"highestPrice"
,
m
.
"lowestPrice"
,
m
.
"closePrice"
,
m
.
"turnoverVol"
,
m
.
"turnoverValue"
,
m
.
"dealAmount"
,
m
.
"turnoverRate"
,
m
.
"accumAdjFactor"
,
m
.
"negMarketValue"
,
m
.
"marketValue"
,
m
.
"chgPct"
,
m
.
"isOpen"
,
m
.
"vwap"
,
u
.
"AccountsPayablesTDays"
,
u
.
"AccountsPayablesTRate"
,
u
.
"AdminiExpenseRate"
,
u
.
"ARTDays"
,
u
.
"ARTRate"
,
u
.
"ASSI"
,
u
.
"BLEV"
,
u
.
"BondsPayableToAsset"
,
u
.
"CashRateOfSales"
,
u
.
"CashToCurrentLiability"
,
u
.
"CMRA"
,
u
.
"CTOP"
,
u
.
"CTP5"
,
u
.
"CurrentAssetsRatio"
,
u
.
"CurrentAssetsTRate"
,
u
.
"CurrentRatio"
,
u
.
"DAVOL10"
,
u
.
"DAVOL20"
,
u
.
"DAVOL5"
,
u
.
"DDNBT"
,
u
.
"DDNCR"
,
u
.
"DDNSR"
,
u
.
"DebtEquityRatio"
,
u
.
"DebtsAssetRatio"
,
u
.
"DHILO"
,
u
.
"DilutedEPS"
,
u
.
"DVRAT"
,
u
.
"EBITToTOR"
,
u
.
"EGRO"
,
u
.
"EMA10"
,
u
.
"EMA120"
,
u
.
"EMA20"
,
u
.
"EMA5"
,
u
.
"EMA60"
,
u
.
"EPS"
,
u
.
"EquityFixedAssetRatio"
,
u
.
"EquityToAsset"
,
u
.
"EquityTRate"
,
u
.
"ETOP"
,
u
.
"ETP5"
,
u
.
"FinancialExpenseRate"
,
u
.
"FinancingCashGrowRate"
,
u
.
"FixAssetRatio"
,
u
.
"FixedAssetsTRate"
,
u
.
"GrossIncomeRatio"
,
u
.
"HBETA"
,
u
.
"HSIGMA"
,
u
.
"IntangibleAssetRatio"
,
u
.
"InventoryTDays"
,
u
.
"InventoryTRate"
,
u
.
"InvestCashGrowRate"
,
u
.
"LCAP"
,
u
.
"LFLO"
,
u
.
"LongDebtToAsset"
,
u
.
"LongDebtToWorkingCapital"
,
u
.
"LongTermDebtToAsset"
,
u
.
"MA10"
,
u
.
"MA120"
,
u
.
"MA20"
,
u
.
"MA5"
,
u
.
"MA60"
,
u
.
"MAWVAD"
,
u
.
"MFI"
,
u
.
"MLEV"
,
u
.
"NetAssetGrowRate"
,
u
.
"NetProfitGrowRate"
,
u
.
"NetProfitRatio"
,
u
.
"NOCFToOperatingNI"
,
u
.
"NonCurrentAssetsRatio"
,
u
.
"NPParentCompanyGrowRate"
,
u
.
"NPToTOR"
,
u
.
"OperatingExpenseRate"
,
u
.
"OperatingProfitGrowRate"
,
u
.
"OperatingProfitRatio"
,
u
.
"OperatingProfitToTOR"
,
u
.
"OperatingRevenueGrowRate"
,
u
.
"OperCashGrowRate"
,
u
.
"OperCashInToCurrentLiability"
,
u
.
"PB"
,
u
.
"PCF"
,
u
.
"PE"
,
u
.
"PS"
,
u
.
"PSY"
,
u
.
"QuickRatio"
,
u
.
"REVS10"
,
u
.
"REVS20"
,
u
.
"REVS5"
,
u
.
"ROA"
,
u
.
"ROA5"
,
u
.
"ROE"
,
u
.
"ROE5"
,
u
.
"RSI"
,
u
.
"RSTR12"
,
u
.
"RSTR24"
,
u
.
"SalesCostRatio"
,
u
.
"SaleServiceCashToOR"
,
u
.
"SUE"
,
u
.
"TaxRatio"
,
u
.
"TOBT"
,
u
.
"TotalAssetGrowRate"
,
u
.
"TotalAssetsTRate"
,
u
.
"TotalProfitCostRatio"
,
u
.
"TotalProfitGrowRate"
,
u
.
"VOL10"
,
u
.
"VOL120"
,
u
.
"VOL20"
,
u
.
"VOL240"
,
u
.
"VOL5"
,
u
.
"VOL60"
,
u
.
"WVAD"
,
u
.
"REC"
,
u
.
"DAREC"
,
u
.
"GREC"
,
u
.
"FY12P"
,
u
.
"DAREV"
,
u
.
"GREV"
,
u
.
"SFY12P"
,
u
.
"DASREV"
,
u
.
"GSREV"
,
u
.
"FEARNG"
,
u
.
"FSALESG"
,
u
.
"TA2EV"
,
u
.
"CFO2EV"
,
u
.
"ACCA"
,
u
.
"DEGM"
,
u
.
"SUOI"
,
u
.
"EARNMOM"
,
u
.
"FiftyTwoWeekHigh"
,
u
.
"Volatility"
,
u
.
"Skewness"
,
u
.
"ILLIQUIDITY"
,
u
.
"BackwardADJ"
,
u
.
"MACD"
,
u
.
"ADTM"
,
u
.
"ATR14"
,
u
.
"ATR6"
,
u
.
"BIAS10"
,
u
.
"BIAS20"
,
u
.
"BIAS5"
,
u
.
"BIAS60"
,
u
.
"BollDown"
,
u
.
"BollUp"
,
u
.
"CCI10"
,
u
.
"CCI20"
,
u
.
"CCI5"
,
u
.
"CCI88"
,
u
.
"KDJ_K"
,
u
.
"KDJ_D"
,
u
.
"KDJ_J"
,
u
.
"ROC6"
,
u
.
"ROC20"
,
u
.
"SBM"
,
u
.
"STM"
,
u
.
"UpRVI"
,
u
.
"DownRVI"
,
u
.
"RVI"
,
u
.
"SRMI"
,
u
.
"ChandeSD"
,
u
.
"ChandeSU"
,
u
.
"CMO"
,
u
.
"DBCD"
,
u
.
"ARC"
,
u
.
"OBV"
,
u
.
"OBV6"
,
u
.
"OBV20"
,
u
.
"TVMA20"
,
u
.
"TVMA6"
,
u
.
"TVSTD20"
,
u
.
"TVSTD6"
,
u
.
"VDEA"
,
u
.
"VDIFF"
,
u
.
"VEMA10"
,
u
.
"VEMA12"
,
u
.
"VEMA26"
,
u
.
"VEMA5"
,
u
.
"VMACD"
,
u
.
"VOSC"
,
u
.
"VR"
,
u
.
"VROC12"
,
u
.
"VROC6"
,
u
.
"VSTD10"
,
u
.
"VSTD20"
,
u
.
"KlingerOscillator"
,
u
.
"MoneyFlow20"
,
u
.
"AD"
,
u
.
"AD20"
,
u
.
"AD6"
,
u
.
"CoppockCurve"
,
u
.
"ASI"
,
u
.
"ChaikinOscillator"
,
u
.
"ChaikinVolatility"
,
u
.
"EMV14"
,
u
.
"EMV6"
,
u
.
"plusDI"
,
u
.
"minusDI"
,
u
.
"ADX"
,
u
.
"ADXR"
,
u
.
"Aroon"
,
u
.
"AroonDown"
,
u
.
"AroonUp"
,
u
.
"DEA"
,
u
.
"DIFF"
,
u
.
"DDI"
,
u
.
"DIZ"
,
u
.
"DIF"
,
u
.
"MTM"
,
u
.
"MTMMA"
,
u
.
"PVT"
,
u
.
"PVT6"
,
u
.
"PVT12"
,
u
.
"TRIX5"
,
u
.
"TRIX10"
,
u
.
"UOS"
,
u
.
"MA10RegressCoeff12"
,
u
.
"MA10RegressCoeff6"
,
u
.
"PLRC6"
,
u
.
"PLRC12"
,
u
.
"SwingIndex"
,
u
.
"Ulcer10"
,
u
.
"Ulcer5"
,
u
.
"Hurst"
,
u
.
"ACD6"
,
u
.
"ACD20"
,
u
.
"EMA12"
,
u
.
"EMA26"
,
u
.
"APBMA"
,
u
.
"BBI"
,
u
.
"BBIC"
,
u
.
"TEMA10"
,
u
.
"TEMA5"
,
u
.
"MA10Close"
,
u
.
"AR"
,
u
.
"BR"
,
u
.
"ARBR"
,
u
.
"CR20"
,
u
.
"MassIndex"
,
u
.
"BearPower"
,
u
.
"BullPower"
,
u
.
"Elder"
,
u
.
"NVI"
,
u
.
"PVI"
,
u
.
"RC12"
,
u
.
"RC24"
,
u
.
"JDQS20"
,
u
.
"Variance20"
,
u
.
"Variance60"
,
u
.
"Variance120"
,
u
.
"Kurtosis20"
,
u
.
"Kurtosis60"
,
u
.
"Kurtosis120"
,
u
.
"Alpha20"
,
u
.
"Alpha60"
,
u
.
"Alpha120"
,
u
.
"Beta20"
,
u
.
"Beta60"
,
u
.
"Beta120"
,
u
.
"SharpeRatio20"
,
u
.
"SharpeRatio60"
,
u
.
"SharpeRatio120"
,
u
.
"TreynorRatio20"
,
u
.
"TreynorRatio60"
,
u
.
"TreynorRatio120"
,
u
.
"InformationRatio20"
,
u
.
"InformationRatio60"
,
u
.
"InformationRatio120"
,
u
.
"GainVariance20"
,
u
.
"GainVariance60"
,
u
.
"GainVariance120"
,
u
.
"LossVariance20"
,
u
.
"LossVariance60"
,
u
.
"LossVariance120"
,
u
.
"GainLossVarianceRatio20"
,
u
.
"GainLossVarianceRatio60"
,
u
.
"GainLossVarianceRatio120"
,
u
.
"RealizedVolatility"
,
u
.
"REVS60"
,
u
.
"REVS120"
,
u
.
"REVS250"
,
u
.
"REVS750"
,
u
.
"REVS5m20"
,
u
.
"REVS5m60"
,
u
.
"REVS5Indu1"
,
u
.
"REVS20Indu1"
,
u
.
"Volumn1M"
,
u
.
"Volumn3M"
,
u
.
"Price1M"
,
u
.
"Price3M"
,
u
.
"Price1Y"
,
u
.
"Rank1M"
,
u
.
"CashDividendCover"
,
u
.
"DividendCover"
,
u
.
"DividendPaidRatio"
,
u
.
"RetainedEarningRatio"
,
u
.
"CashEquivalentPS"
,
u
.
"DividendPS"
,
u
.
"EPSTTM"
,
u
.
"NetAssetPS"
,
u
.
"TORPS"
,
u
.
"TORPSLatest"
,
u
.
"OperatingRevenuePS"
,
u
.
"OperatingRevenuePSLatest"
,
u
.
"OperatingProfitPS"
,
u
.
"OperatingProfitPSLatest"
,
u
.
"CapitalSurplusFundPS"
,
u
.
"SurplusReserveFundPS"
,
u
.
"UndividedProfitPS"
,
u
.
"RetainedEarningsPS"
,
u
.
"OperCashFlowPS"
,
u
.
"CashFlowPS"
,
u
.
"NetNonOIToTP"
,
u
.
"NetNonOIToTPLatest"
,
u
.
"PeriodCostsRate"
,
u
.
"InterestCover"
,
u
.
"NetProfitGrowRate3Y"
,
u
.
"NetProfitGrowRate5Y"
,
u
.
"OperatingRevenueGrowRate3Y"
,
u
.
"OperatingRevenueGrowRate5Y"
,
u
.
"NetCashFlowGrowRate"
,
u
.
"NetProfitCashCover"
,
u
.
"OperCashInToAsset"
,
u
.
"CashConversionCycle"
,
u
.
"OperatingCycle"
,
u
.
"PEG3Y"
,
u
.
"PEG5Y"
,
u
.
"PEIndu"
,
u
.
"PBIndu"
,
u
.
"PSIndu"
,
u
.
"PCFIndu"
,
u
.
"PEHist20"
,
u
.
"PEHist60"
,
u
.
"PEHist120"
,
u
.
"PEHist250"
,
u
.
"StaticPE"
,
u
.
"ForwardPE"
,
u
.
"EnterpriseFCFPS"
,
u
.
"ShareholderFCFPS"
,
u
.
"ROEDiluted"
,
u
.
"ROEAvg"
,
u
.
"ROEWeighted"
,
u
.
"ROECut"
,
u
.
"ROECutWeighted"
,
u
.
"ROIC"
,
u
.
"ROAEBIT"
,
u
.
"ROAEBITTTM"
,
u
.
"OperatingNIToTP"
,
u
.
"OperatingNIToTPLatest"
,
u
.
"InvestRAssociatesToTP"
,
u
.
"InvestRAssociatesToTPLatest"
,
u
.
"NPCutToNP"
,
u
.
"SuperQuickRatio"
,
u
.
"TSEPToInterestBearDebt"
,
u
.
"DebtTangibleEquityRatio"
,
u
.
"TangibleAToInteBearDebt"
,
u
.
"TangibleAToNetDebt"
,
u
.
"NOCFToTLiability"
,
u
.
"NOCFToInterestBearDebt"
,
u
.
"NOCFToNetDebt"
,
u
.
"TSEPToTotalCapital"
,
u
.
"InteBearDebtToTotalCapital"
,
u
.
"NPParentCompanyCutYOY"
,
u
.
"SalesServiceCashToORLatest"
,
u
.
"CashRateOfSalesLatest"
,
u
.
"NOCFToOperatingNILatest"
,
u
.
"TotalAssets"
,
u
.
"MktValue"
,
u
.
"NegMktValue"
,
u
.
"TEAP"
,
u
.
"NIAP"
,
u
.
"TotalFixedAssets"
,
u
.
"IntFreeCL"
,
u
.
"IntFreeNCL"
,
u
.
"IntCL"
,
u
.
"IntDebt"
,
u
.
"NetDebt"
,
u
.
"NetTangibleAssets"
,
u
.
"WorkingCapital"
,
u
.
"NetWorkingCapital"
,
u
.
"TotalPaidinCapital"
,
u
.
"RetainedEarnings"
,
u
.
"OperateNetIncome"
,
u
.
"ValueChgProfit"
,
u
.
"NetIntExpense"
,
u
.
"EBIT"
,
u
.
"EBITDA"
,
u
.
"EBIAT"
,
u
.
"NRProfitLoss"
,
u
.
"NIAPCut"
,
u
.
"FCFF"
,
u
.
"FCFE"
,
u
.
"DA"
,
u
.
"TRevenueTTM"
,
u
.
"TCostTTM"
,
u
.
"RevenueTTM"
,
u
.
"CostTTM"
,
u
.
"GrossProfitTTM"
,
u
.
"SalesExpenseTTM"
,
u
.
"AdminExpenseTTM"
,
u
.
"FinanExpenseTTM"
,
u
.
"AssetImpairLossTTM"
,
u
.
"NPFromOperatingTTM"
,
u
.
"NPFromValueChgTTM"
,
u
.
"OperateProfitTTM"
,
u
.
"NonOperatingNPTTM"
,
u
.
"TProfitTTM"
,
u
.
"NetProfitTTM"
,
u
.
"NetProfitAPTTM"
,
u
.
"SaleServiceRenderCashTTM"
,
u
.
"NetOperateCFTTM"
,
u
.
"NetInvestCFTTM"
,
u
.
"NetFinanceCFTTM"
,
u
.
"GrossProfit"
,
u
.
"Beta252"
,
u
.
"RSTR504"
,
u
.
"EPIBS"
,
u
.
"CETOP"
,
u
.
"DASTD"
,
u
.
"CmraCNE5"
,
u
.
"HsigmaCNE5"
,
u
.
"SGRO"
,
u
.
"EgibsLong"
,
u
.
"STOM"
,
u
.
"STOQ"
,
u
.
"STOA"
,
u
.
"NLSIZE"
,
l
.
"ROEAfterNonRecurring"
,
l
.
"EPSAfterNonRecurring"
,
l
.
"EODPrice"
,
l
.
"LogFloatCap"
,
l
.
"BPS"
,
l
.
"SPS"
,
l
.
"DebtToAsset"
,
l
.
"DROEAfterNonRecurring"
,
l
.
"LogTotalCap"
,
l
.
"BP"
,
l
.
"SP"
,
l
.
"EPAfterNonRecurring"
,
l
.
"DivToB"
,
l
.
"DivP"
,
l
.
"EBITToSales"
,
l
.
"EBITAToSales"
,
l
.
"EVToSales"
,
l
.
"EVToEBIT"
,
l
.
"EVToEBITDA"
,
l
.
"EVToNOPLAT"
,
l
.
"EVToIC"
,
l
.
"FCFFPS"
,
l
.
"FCFFToEarningAfterNonRecurring"
,
l
.
"FCFFP"
,
l
.
"ProfitToAsset"
,
l
.
"GrossProfitRatio"
,
l
.
"LATO"
,
l
.
"FATO"
,
l
.
"TATO"
,
l
.
"EquityTO"
,
l
.
"PayableTO"
,
l
.
"RecievableTO"
,
l
.
"RevenueGrowth"
,
l
.
"GrossProfitGrowth"
,
l
.
"NetProfitGrowth"
,
l
.
"GrossCFToRevenue"
,
l
.
"CFToRevenue"
,
l
.
"CFToProfit"
,
l
.
"CFToAsset"
,
l
.
"GrossCFGrowth"
,
l
.
"CFGrowth"
,
l
.
"ICFGrowth"
,
l
.
"AveAmount60"
,
l
.
"PeriodReturn60"
,
l
.
"AmountRatio60to250"
,
l
.
"CFPS"
,
l
.
"CFP"
,
l
.
"NetCFGrowth"
,
l
.
"NetCFGrowthP"
,
l
.
"NetCash"
,
l
.
"NetCashP"
,
l
.
"BVPSGrowth"
,
l
.
"EquityPSGrowth"
,
l
.
"WholeSales"
,
l
.
"WholeProfitAfterNonRecurring"
,
l
.
"ExpenseRatio"
,
l
.
"AcidTestRatio"
,
l
.
"TimeInterestEarnedRatio"
,
l
.
"DepositReceivedVsSale"
,
l
.
"DebtRatioExcemptDepRec"
,
l
.
"SNBARatio"
,
t
.
"CFinc1"
,
t
.
"BDTO"
,
t
.
"RVOL"
,
t
.
"CHV"
,
t
.
"VAL"
,
r
.
"BETA"
,
r
.
"MOMENTUM"
,
r
.
"SIZE"
,
r
.
"EARNYILD"
,
r
.
"RESVOL"
,
r
.
"GROWTH"
,
r
.
"BTOP"
,
r
.
"LEVERAGE"
,
r
.
"LIQUIDTY"
,
r
.
"SIZENL"
,
r
.
"Bank"
,
r
.
"RealEstate"
,
r
.
"Health"
,
r
.
"Transportation"
,
r
.
"Mining"
,
r
.
"NonFerMetal"
,
r
.
"HouseApp"
,
r
.
"LeiService"
,
r
.
"MachiEquip"
,
r
.
"BuildDeco"
,
r
.
"CommeTrade"
,
r
.
"CONMAT"
,
r
.
"Auto"
,
r
.
"Textile"
,
r
.
"FoodBever"
,
r
.
"Electronics"
,
r
.
"Computer"
,
r
.
"LightIndus"
,
r
.
"Utilities"
,
r
.
"Telecom"
,
r
.
"AgriForest"
,
r
.
"CHEM"
,
r
.
"Media"
,
r
.
"IronSteel"
,
r
.
"NonBankFinan"
,
r
.
"ELECEQP"
,
r
.
"AERODEF"
,
r
.
"Conglomerates"
,
r
.
"COUNTRY"
,
e
.
"DROE"
,
e
.
"IVR"
,
e
.
"xueqiu_hotness"
,
g
.
"con_eps"
,
g
.
"con_eps_rolling"
,
g
.
"con_na"
,
g
.
"con_na_rolling"
,
g
.
"con_np"
,
g
.
"con_npcgrate_1w"
,
g
.
"con_npcgrate_4w"
,
g
.
"con_npcgrate_13w"
,
g
.
"con_npcgrate_26w"
,
g
.
"con_npcgrate_52w"
,
g
.
"con_npcgrate_2y"
,
g
.
"con_np_rolling"
,
g
.
"con_np_yoy"
,
g
.
"con_pb"
,
g
.
"con_pb_order"
,
g
.
"con_pb_rolling"
,
g
.
"con_pb_rolling_order"
,
g
.
"con_or"
,
g
.
"con_pe"
,
g
.
"con_pe_order"
,
g
.
"con_pe_rolling"
,
g
.
"con_pe_rolling_order"
,
g
.
"con_peg"
,
g
.
"con_peg_order"
,
g
.
"con_peg_rolling"
,
g
.
"con_peg_rolling_order"
,
g
.
"con_roe"
,
g
.
"con_target_price"
,
g
.
"market_confidence_5d"
,
g
.
"market_confidence_10d"
,
g
.
"market_confidence_15d"
,
g
.
"market_confidence_25d"
,
g
.
"market_confidence_75d"
,
g
.
"mcap"
,
g
.
"optimism_confidence_5d"
,
g
.
"optimism_confidence_10d"
,
g
.
"optimism_confidence_15d"
,
g
.
"optimism_confidence_25d"
,
g
.
"optimism_confidence_75d"
,
g
.
"pessimism_confidence_5d"
,
g
.
"pessimism_confidence_10d"
,
g
.
"pessimism_confidence_15d"
,
g
.
"pessimism_confidence_25d"
,
g
.
"pessimism_confidence_75d"
,
g
.
"tcap"
,
s1
.
"SRISK"
as
d_srisk
,
s2
.
"SRISK"
as
s_srisk
,
s3
.
"SRISK"
as
l_srisk
FROM
market
AS
m
left
join
uqer
AS
u
on
m
.
trade_date
=
u
.
trade_date
and
m
.
code
=
u
.
code
inner
join
risk_exposure
AS
r
on
m
.
trade_date
=
r
.
trade_date
and
m
.
code
=
r
.
code
...
...
@@ -40,6 +48,7 @@ u."AccountsPayablesTDays",u."AccountsPayablesTRate",u."AdminiExpenseRate",u."ART
inner
join
specific_risk_long
as
s3
on
m
.
trade_date
=
s3
.
trade_date
and
m
.
code
=
s3
.
code
left
join
legacy_factor
as
l
on
m
.
trade_date
=
l
.
trade_date
and
m
.
code
=
l
.
code
left
join
tiny
as
t
on
m
.
trade_date
=
t
.
trade_date
and
m
.
code
=
t
.
code
left
join
experimental
as
e
on
m
.
trade_date
=
e
.
trade_date
and
m
.
code
=
e
.
code
;
left
join
experimental
as
e
on
m
.
trade_date
=
e
.
trade_date
and
m
.
code
=
e
.
code
left
join
gogoal
as
g
on
m
.
trade_date
=
g
.
trade_date
and
m
.
code
=
g
.
code
;
create
UNIQUE
index
on
full_factor_view
(
trade_date
,
code
);
\ No newline at end of file
create
UNIQUE
index
on
full_factor
(
trade_date
,
code
);
\ No newline at end of file
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