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

update examples

parent 65c347f3
......@@ -50,8 +50,8 @@
"horizon = map_freq(frequency)\n",
"weight_gap = 0.01\n",
"benchmark_code = 905\n",
"universe_name = ['zz800']\n",
"universe = Universe('custom', universe_name)\n",
"universe_name = 'zz800'\n",
"universe = Universe(universe_name)\n",
"ref_dates = makeSchedule(start_date, end_date, frequency, 'china.sse')\n",
"\n",
"executor = NaiveExecutor()\n",
......@@ -279,13 +279,20 @@
"metadata": {},
"outputs": [],
"source": [
"with pd.ExcelWriter(f'{universe_name[0]}_{benchmark_code}.xlsx', engine='xlsxwriter') as writer:\n",
"with pd.ExcelWriter(f'{universe_name}_{benchmark_code}.xlsx', engine='xlsxwriter') as writer:\n",
" factor_df.to_excel(writer, sheet_name='ret')\n",
" ic_df.to_excel(writer, sheet_name='ic')\n",
" factor_res.to_excel(writer, sheet_name='ret_stat')\n",
" ic_res.to_excel(writer, sheet_name='ic_stat')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
......@@ -310,7 +317,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
"version": "3.6.5"
},
"varInspector": {
"cols": {
......
......@@ -42,7 +42,7 @@
"batch = 1\n",
"horizon = map_freq(freq)\n",
"weights_bandwidth = 0.01\n",
"universe = Universe(\"custom\", ['zz800'])\n",
"universe = Universe('zz800')\n",
"data_source = os.environ['DB_URI']\n",
"benchmark_code = 905\n",
"method = 'risk_neutral'"
......@@ -83,7 +83,7 @@
"# Constraintes settings\n",
"\n",
"industry_names = industry_list(industry_name, industry_level)\n",
"constraint_risk = ['SIZE', 'SIZENL', 'BETA'] + industry_names\n",
"constraint_risk = ['SIZE', 'SIZENL', 'BETA']\n",
"total_risk_names = constraint_risk + ['benchmark', 'total']\n",
"all_styles = risk_styles + industry_styles + macro_styles\n",
"\n",
......@@ -171,7 +171,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
"version": "3.6.5"
},
"varInspector": {
"cols": {
......
......@@ -40,10 +40,10 @@
"\"\"\"\n",
"\n",
"benchmark_code = 905\n",
"universe = Universe(\"zz800_cyb\", ['zz800', 'cyb'])\n",
"universe = Universe('zz800') + Universe('cyb')\n",
"\n",
"def create_scenario(weights_bandwidth=0.02, target_vol=0.01, method='risk_neutral'):\n",
" start_date = '2010-01-01'\n",
" start_date = '2017-01-01'\n",
" end_date = '2018-04-27'\n",
" freq = '10b'\n",
" neutralized_risk = None\n",
......@@ -69,7 +69,7 @@
" data_source=os.environ['DB_URI'])\n",
"\n",
" industry_names = industry_list('sw', 1)\n",
" constraint_risk = ['SIZE', 'SIZENL', 'BETA'] + industry_names\n",
" constraint_risk = ['SIZE', 'SIZENL', 'BETA']\n",
" total_risk_names = constraint_risk + ['benchmark', 'total']\n",
" all_styles = risk_styles + industry_styles + macro_styles\n",
"\n",
......@@ -152,7 +152,7 @@
"source": [
"weight_gaps = [0.005, 0.010, 0.015, 0.020]\n",
"\n",
"with pd.ExcelWriter(f'{universe.name}_{benchmark_code}_gap.xlsx', engine='xlsxwriter') as writer:\n",
"with pd.ExcelWriter(f'zz800_cyb_{benchmark_code}_gap.xlsx', engine='xlsxwriter') as writer:\n",
" for i, weight_gap in enumerate(weight_gaps):\n",
" ret_df = create_scenario(weight_gap, target_vol=0.01, method='risk_neutral')\n",
" res_df = create_report(ret_df, 25)\n",
......@@ -168,7 +168,7 @@
"source": [
"target_vols = [0.015, 0.030, 0.045, 0.060]\n",
"\n",
"with pd.ExcelWriter(f'{universe.name}_{benchmark_code}_tv.xlsx', engine='xlsxwriter') as writer:\n",
"with pd.ExcelWriter(f'zz800_cyb_{benchmark_code}_tv.xlsx', engine='xlsxwriter') as writer:\n",
" for i, target_vol in enumerate(target_vols):\n",
" ret_df = create_scenario(0.01, target_vol=target_vol, method='tv')\n",
" res_df = create_report(ret_df, 25)\n",
......
......@@ -48,7 +48,7 @@
"benchmark_total_upper = 1.0\n",
"batch = 1\n",
"horizon = map_freq(freq)\n",
"universe = Universe(\"custom\", ['zz800'])\n",
"universe = Universe('zz800')\n",
"data_source = os.environ['DB_URI']\n",
"benchmark_code = 905\n",
"weight_gap = 0.01\n",
......@@ -113,8 +113,7 @@
"Shared Data\n",
"\"\"\"\n",
"\n",
"industry_names = industry_list(industry_name, industry_level)\n",
"constraint_risk = ['SIZE', 'SIZENL', 'BETA'] + industry_names\n",
"constraint_risk = ['SIZE', 'SIZENL', 'BETA']\n",
"total_risk_names = constraint_risk + ['benchmark', 'total']\n",
"\n",
"b_type = []\n",
......@@ -262,7 +261,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
"version": "3.6.5"
},
"varInspector": {
"cols": {
......
......@@ -44,7 +44,7 @@
"category = 'sw'\n",
"level = 1\n",
"freq = '20b'\n",
"universe = Universe('custom', ['ashare_ex'])\n",
"universe = Universe('ashare_ex')\n",
"\n",
"horizon = map_freq(freq)\n",
"ref_dates = makeSchedule(start_date, end_date, freq, 'china.sse')"
......@@ -118,6 +118,13 @@
"df[['factor', 'abs t.']].groupby('factor').mean().sort_values('abs t.', ascending=False).head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
......@@ -142,7 +149,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
"version": "3.6.5"
},
"varInspector": {
"cols": {
......
......@@ -42,7 +42,7 @@
"source": [
"ref_date = '2018-01-08'\n",
"engine = SqlEngine(os.environ['DB_URI'])\n",
"universe = Universe('custom', ['zz800'])"
"universe = Universe('zz800')"
]
},
{
......@@ -148,7 +148,7 @@
"risk_model = 'short'\n",
"batch = 0\n",
"horizon = map_freq(freq)\n",
"universe = Universe(\"custom\", ['zz800'])\n",
"universe = Universe('zz800')\n",
"data_source = os.environ['DB_URI']\n",
"benchmark_code = 906\n",
"target_vol = 0.05\n",
......@@ -190,7 +190,7 @@
"Constraintes settings\n",
"\"\"\"\n",
"\n",
"constraint_risk = ['SIZE', 'SIZENL', 'BETA'] + industry_names\n",
"constraint_risk = ['SIZE', 'SIZENL', 'BETA']\n",
"total_risk_names = constraint_risk + ['benchmark', 'total']\n",
"\n",
"b_type = []\n",
......@@ -284,7 +284,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
"version": "3.6.5"
},
"varInspector": {
"cols": {
......
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