Commit f70bab43 authored by Dr.李's avatar Dr.李

made risk style available

parent 7f490ef6
......@@ -172,8 +172,16 @@ def factor_analysis(factors: pd.DataFrame,
if benchmark is not None and risk_exp is not None and method == 'risk_neutral':
# using linear programming portfolio builder
benchmark = benchmark.flatten()
lbound = 0.
ubound = 0.01 + benchmark
if 'lbound' in kwargs:
lbound = kwargs['lbound']
else:
lbound = 0.
if 'ubound' in kwargs:
ubound = kwargs['ubound']
else:
ubound = 0.01 + benchmark
if is_tradable is not None:
ubound[~is_tradable] = 0.
......
......@@ -143,13 +143,17 @@ class SqlEngine(object):
factor_str = mapping_factors(factors)
total_risk_factors = risk_styles + industry_styles
risk_str = ','.join('risk_exposure.' + f for f in total_risk_factors)
total_risk_factors = list(set(risk_styles + industry_styles).difference(factors))
if total_risk_factors:
risk_str = ',' + ','.join('risk_exposure.' + f for f in total_risk_factors)
else:
risk_str = ''
special_risk_table = 'specific_risk_' + risk_model
codes_str = ','.join(str(c) for c in codes)
sql = "select uqer.Code, {factors}, {risks}, market.isOpen, {risk_table}.SRISK" \
sql = "select uqer.Code, {factors} {risks}, market.isOpen, {risk_table}.SRISK" \
" from (uqer INNER JOIN" \
" risk_exposure on uqer.Date = risk_exposure.Date and uqer.Code = risk_exposure.Code)" \
" INNER JOIN market on uqer.Date = market.Date and uqer.Code = market.Code" \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment