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

made risk_exp can be unused

parent 63610e55
...@@ -323,7 +323,7 @@ class SqlEngine(object): ...@@ -323,7 +323,7 @@ class SqlEngine(object):
query = select( query = select(
[FullFactor.trade_date, FullFactor.code, FullFactor.isOpen] + list(factor_cols.keys())) \ [FullFactor.trade_date, FullFactor.code, FullFactor.isOpen] + list(factor_cols.keys())) \
.select_from(big_table) .select_from(big_table).distinct()
df = pd.read_sql(query, self.engine).sort_values(['trade_date', 'code']) df = pd.read_sql(query, self.engine).sort_values(['trade_date', 'code'])
...@@ -387,7 +387,7 @@ class SqlEngine(object): ...@@ -387,7 +387,7 @@ class SqlEngine(object):
risk_exposure_cols = [FullFactor.__table__.columns[f] for f in total_risk_factors if f not in set(excluded)] risk_exposure_cols = [FullFactor.__table__.columns[f] for f in total_risk_factors if f not in set(excluded)]
query = select([FullFactor.code, special_risk_col] + risk_exposure_cols) \ query = select([FullFactor.code, special_risk_col] + risk_exposure_cols) \
.where(and_(FullFactor.trade_date == ref_date, FullFactor.code.in_(codes))) .where(and_(FullFactor.trade_date == ref_date, FullFactor.code.in_(codes))).distinct()
risk_exp = pd.read_sql(query, self.engine) risk_exp = pd.read_sql(query, self.engine)
...@@ -429,7 +429,7 @@ class SqlEngine(object): ...@@ -429,7 +429,7 @@ class SqlEngine(object):
query = select( query = select(
[FullFactor.trade_date, FullFactor.code, special_risk_col] + risk_exposure_cols) \ [FullFactor.trade_date, FullFactor.code, special_risk_col] + risk_exposure_cols) \
.select_from(big_table) .select_from(big_table).distinct()
risk_exp = pd.read_sql(query, self.engine) risk_exp = pd.read_sql(query, self.engine)
...@@ -450,7 +450,7 @@ class SqlEngine(object): ...@@ -450,7 +450,7 @@ class SqlEngine(object):
Industry.code.in_(codes), Industry.code.in_(codes),
Industry.industry == industry_category_name Industry.industry == industry_category_name
) )
) ).distinct()
return pd.read_sql(query, self.engine) return pd.read_sql(query, self.engine)
...@@ -481,7 +481,7 @@ class SqlEngine(object): ...@@ -481,7 +481,7 @@ class SqlEngine(object):
query = select([Industry.trade_date, query = select([Industry.trade_date,
Industry.code, Industry.code,
Industry.industryID1.label('industry_code'), Industry.industryID1.label('industry_code'),
Industry.industryName1.label('industry')]).select_from(big_table) Industry.industryName1.label('industry')]).select_from(big_table).distinct()
return pd.read_sql(query, self.engine) return pd.read_sql(query, self.engine)
def fetch_data(self, ref_date: str, def fetch_data(self, ref_date: str,
......
...@@ -17,11 +17,11 @@ plt.style.use('ggplot') ...@@ -17,11 +17,11 @@ plt.style.use('ggplot')
Back test parameter settings Back test parameter settings
""" """
start_date = '2012-01-01' start_date = '2017-01-01'
end_date = '2017-11-07' end_date = '2017-11-08'
benchmark_code = 300 benchmark_code = 300
universe_name = 'zz800' universe_name = ['zz500', 'hs300', 'sh50']
universe = Universe(universe_name, [universe_name]) universe = Universe(universe_name, universe_name)
frequency = '1w' frequency = '1w'
batch = 8 batch = 8
method = 'risk_neutral' method = 'risk_neutral'
...@@ -85,7 +85,6 @@ const_model_factor_data = engine.fetch_data_range(universe, ...@@ -85,7 +85,6 @@ const_model_factor_data = engine.fetch_data_range(universe,
total_features, total_features,
dates=ref_dates, dates=ref_dates,
benchmark=benchmark_code)['factor'] benchmark=benchmark_code)['factor']
""" """
Training phase Training phase
""" """
...@@ -101,7 +100,6 @@ for ref_date in ref_dates: ...@@ -101,7 +100,6 @@ for ref_date in ref_dates:
models_series.loc[ref_date] = model models_series.loc[ref_date] = model
alpha_logger.info('trade_date: {0} training finished'.format(ref_date)) alpha_logger.info('trade_date: {0} training finished'.format(ref_date))
""" """
Predicting and re-balance phase Predicting and re-balance phase
""" """
......
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