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

added update special tables

parent a6e9e0c8
...@@ -17,25 +17,24 @@ import datetime as dt ...@@ -17,25 +17,24 @@ import datetime as dt
start = dt.datetime.now() start = dt.datetime.now()
universe_name = 'zz500' universe = Universe('custom', ['zz800'])
factor_name = 'PE' simple_expression = CSRes(LAST('OperCashInToAsset'), 'roe_q')
expression = 1. / LAST(factor_name)
alpha_factor_name = '1/PE' alpha_factor_name = 'alpha_factor'
alpha_factor = {alpha_factor_name: expression} alpha_factor = {alpha_factor_name: simple_expression}
# end of formula definition # end of formula definition
engine = SqlEngine('postgresql+psycopg2://postgres:A12345678!@10.63.6.220/alpha') engine = SqlEngine('postgresql+psycopg2://postgres:A12345678!@10.63.6.220/alpha')
universe = Universe('custom', [universe_name])
neutralize_risk = ['SIZE'] + industry_styles neutralize_risk = ['SIZE', 'LEVERAGE'] + industry_styles
freq = '5b' freq = '10b'
n_bins = 5 n_bins = 5
horizon = map_freq(freq) horizon = map_freq(freq)
start_date = '2012-01-01' start_date = '2012-01-01'
end_date = '2017-11-21' end_date = '2018-01-05'
dates = makeSchedule(start_date, dates = makeSchedule(start_date,
end_date, end_date,
...@@ -93,10 +92,9 @@ df = df.cumsum().plot(ax=axes[0], title='Quantile Analysis for {0}'.format(alpha ...@@ -93,10 +92,9 @@ df = df.cumsum().plot(ax=axes[0], title='Quantile Analysis for {0}'.format(alpha
# =================================================================== # # =================================================================== #
factor_name = 'PE' factor_name = 'PE'
expression = DIFF(1./LAST(factor_name))
alpha_factor_name = '1/PE_1w_diff' alpha_factor_name = alpha_factor_name + '_1w_diff'
alpha_factor = {alpha_factor_name: expression} alpha_factor = {alpha_factor_name: DIFF(simple_expression)}
dates = makeSchedule(start_date, dates = makeSchedule(start_date,
end_date, end_date,
......
...@@ -24,7 +24,9 @@ ...@@ -24,7 +24,9 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": {}, "metadata": {
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [ "source": [
"\"\"\"\n", "\"\"\"\n",
...@@ -517,7 +519,7 @@ ...@@ -517,7 +519,7 @@
" risk = train_risk[ref_date][:, 1:]\n", " risk = train_risk[ref_date][:, 1:]\n",
" new_x = cross_product(x, risk)\n", " new_x = cross_product(x, risk)\n",
"\n", "\n",
" model = LinearRegression(features=linear_model_features_keys, fit_intercept=True) # n_jobs=8, min_samples_split=20)\n", " #model = LinearRegression(features=linear_model_features_keys, fit_intercept=True) # n_jobs=8, min_samples_split=20)\n",
" model = LassoRegression(alpha=0.01, features=linear_model_features_keys, fit_intercept=True) # n_jobs=8, min_samples_split=20)\n", " model = LassoRegression(alpha=0.01, features=linear_model_features_keys, fit_intercept=True) # n_jobs=8, min_samples_split=20)\n",
" model.fit(new_x, y)\n", " model.fit(new_x, y)\n",
" models_series.loc[ref_date] = model\n", " models_series.loc[ref_date] = model\n",
......
This diff is collapsed.
This diff is collapsed.
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