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

remove shared data

parent 2578387a
...@@ -88,42 +88,30 @@ ...@@ -88,42 +88,30 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true "collapsed": true
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"\"\"\"\n", "def factor_analysis(engine, factor_name, universe, benchmark_code, positive):\n",
"Shared data\n",
"\"\"\"\n",
"\n", "\n",
"index_return = engine.fetch_dx_return_index_range(benchmark_code, start_date, end_date, horizon=horizon,\n", " \"\"\"\n",
" Model phase: we need 1 constant linear model and one linear regression model\n",
" \"\"\"\n",
" \n",
" index_return = engine.fetch_dx_return_index_range(benchmark_code, start_date, end_date, horizon=horizon,\n",
" offset=1).set_index('trade_date')\n", " offset=1).set_index('trade_date')\n",
"\n", "\n",
"codes_return = engine.fetch_dx_return_range(universe,\n", " codes_return = engine.fetch_dx_return_range(universe,\n",
" dates=ref_dates,\n", " dates=ref_dates,\n",
" horizon=horizon,\n", " horizon=horizon,\n",
" offset=1)\n", " offset=1)\n",
"\n", "\n",
"return_groups = codes_return.groupby('trade_date')\n", " return_groups = codes_return.groupby('trade_date')\n",
"industry_total = engine.fetch_industry_matrix_range(universe, dates=ref_dates, category=industry_name, level=industry_level)\n", " industry_total = engine.fetch_industry_matrix_range(universe, dates=ref_dates, category=industry_name, level=industry_level)\n",
"industry_groups = industry_total.groupby('trade_date')" " industry_groups = industry_total.groupby('trade_date')\n",
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def factor_analysis(engine, factor_name, universe, benchmark_code, positive):\n",
"\n", "\n",
" \"\"\"\n",
" Model phase: we need 1 constant linear model and one linear regression model\n",
" \"\"\"\n",
" alpha_name = [str(factor_name) + '_' + ('pos' if positive else 'neg')]\n", " alpha_name = [str(factor_name) + '_' + ('pos' if positive else 'neg')]\n",
" simple_expression = LAST(factor_name) if positive else -LAST(factor_name)\n", " simple_expression = LAST(factor_name) if positive else -LAST(factor_name)\n",
"\n", "\n",
......
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