{ "cells": [ { "cell_type": "code", "execution_count": 2, "id": "a4915372-8508-45ce-ba31-8aef7c5b0ef1", "metadata": {}, "outputs": [], "source": [ "import dolphindb as ddb\n", "\n", "sess = ddb.session('localhost', 8848)\n", "sess.login('admin', '123456')" ] }, { "cell_type": "code", "execution_count": 108, "id": "ebd3b848-e0ce-4d0f-94f7-78a687040e80", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
codem_nDatedowmoy
0000400.SZ2006-01-0421
1000400.SZ2006-01-0531
2000400.SZ2006-01-0641
3000400.SZ2006-01-0901
4000400.SZ2006-01-1011
...............
95000400.SZ2011-01-2511
96000400.SZ2011-01-2621
97000400.SZ2011-01-2731
98000400.SZ2011-01-2841
99000400.SZ2011-01-3101
\n", "

100 rows × 4 columns

\n", "
" ], "text/plain": [ " code m_nDate dow moy\n", "0 000400.SZ 2006-01-04 2 1\n", "1 000400.SZ 2006-01-05 3 1\n", "2 000400.SZ 2006-01-06 4 1\n", "3 000400.SZ 2006-01-09 0 1\n", "4 000400.SZ 2006-01-10 1 1\n", ".. ... ... ... ...\n", "95 000400.SZ 2011-01-25 1 1\n", "96 000400.SZ 2011-01-26 2 1\n", "97 000400.SZ 2011-01-27 3 1\n", "98 000400.SZ 2011-01-28 4 1\n", "99 000400.SZ 2011-01-31 0 1\n", "\n", "[100 rows x 4 columns]" ] }, "execution_count": 108, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sess.run(\"\"\"\n", " select top 100 code, m_nDate, dayOfWeek(m_nDate) as dow, monthOfYear(m_nDate) as moy \n", " from loadTable(\"dfs://daily_stock_ts\", \"daily_kline\")\n", " where monthOfYear(m_nDate) = 1\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 92, "id": "ae07f021-409d-4b8b-8676-ff2a0f54bb34", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
codem_nDatevol_20
2776841600000.SH2006-01-04NaN
2776842600000.SH2006-01-05NaN
2776843600000.SH2006-01-06NaN
2776844600000.SH2006-01-09NaN
2776845600000.SH2006-01-10NaN
............
2780773600000.SH2022-08-040.291758
2780774600000.SH2022-08-050.289024
2780775600000.SH2022-08-080.283952
2780776600000.SH2022-08-090.270085
2780777600000.SH2022-08-100.256963
\n", "

3937 rows × 3 columns

\n", "
" ], "text/plain": [ " code m_nDate vol_20\n", "2776841 600000.SH 2006-01-04 NaN\n", "2776842 600000.SH 2006-01-05 NaN\n", "2776843 600000.SH 2006-01-06 NaN\n", "2776844 600000.SH 2006-01-09 NaN\n", "2776845 600000.SH 2006-01-10 NaN\n", "... ... ... ...\n", "2780773 600000.SH 2022-08-04 0.291758\n", "2780774 600000.SH 2022-08-05 0.289024\n", "2780775 600000.SH 2022-08-08 0.283952\n", "2780776 600000.SH 2022-08-09 0.270085\n", "2780777 600000.SH 2022-08-10 0.256963\n", "\n", "[3937 rows x 3 columns]" ] }, "execution_count": 92, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = sess.run(\"\"\"\n", " vol_20 = select code, m_nDate, mstdp(close, 20, 9) as vol_20\n", " from loadTable(\"dfs://daily_stock_ts\", \"daily_kline\")\n", " context by code;\n", " vol_20\n", "\"\"\")\n", "df[df['code'] == '600000.SH']" ] }, { "cell_type": "code", "execution_count": 79, "id": "cffabf93-81d3-4075-b80a-1c761ccd95b6", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
codem_nDaterank_vol_20
0000400.SZ2006-01-04NaN
1000515.SZ2006-01-04NaN
2000558.SZ2006-01-04NaN
3000602.SZ2006-01-04NaN
4000731.SZ2006-01-04NaN
............
10403520688272.SH2022-08-100.901734
10403521688320.SH2022-08-100.985756
10403522688739.SH2022-08-100.707267
10403523688777.SH2022-08-100.960776
10403524830964.NE2022-08-100.021263
\n", "

10403525 rows × 3 columns

\n", "
" ], "text/plain": [ " code m_nDate rank_vol_20\n", "0 000400.SZ 2006-01-04 NaN\n", "1 000515.SZ 2006-01-04 NaN\n", "2 000558.SZ 2006-01-04 NaN\n", "3 000602.SZ 2006-01-04 NaN\n", "4 000731.SZ 2006-01-04 NaN\n", "... ... ... ...\n", "10403520 688272.SH 2022-08-10 0.901734\n", "10403521 688320.SH 2022-08-10 0.985756\n", "10403522 688739.SH 2022-08-10 0.707267\n", "10403523 688777.SH 2022-08-10 0.960776\n", "10403524 830964.NE 2022-08-10 0.021263\n", "\n", "[10403525 rows x 3 columns]" ] }, "execution_count": 79, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = sess.run(\"\"\"\n", " rank_vol_20 = select code, m_nDate, rank(vol_20, tiesMethod='average', percent=true)\n", " from vol_20 context by m_nDate;\n", " rank_vol_20\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 80, "id": "f10dd713-e516-48bc-a232-f1570eef03ff", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
codem_nDaterank_vol_20
2295890000400.SZ2012-01-050.932731
2295891000558.SZ2012-01-050.191422
2295892000602.SZ2012-01-050.367946
2295893000731.SZ2012-01-050.252370
2295894000752.SZ2012-01-050.734537
............
2298104600586.SH2012-01-050.126862
2298105600660.SH2012-01-050.031603
2298106601299.SH2012-01-050.127765
2298107601788.SH2012-01-050.419413
2298108601988.SH2012-01-050.000451
\n", "

2219 rows × 3 columns

\n", "
" ], "text/plain": [ " code m_nDate rank_vol_20\n", "2295890 000400.SZ 2012-01-05 0.932731\n", "2295891 000558.SZ 2012-01-05 0.191422\n", "2295892 000602.SZ 2012-01-05 0.367946\n", "2295893 000731.SZ 2012-01-05 0.252370\n", "2295894 000752.SZ 2012-01-05 0.734537\n", "... ... ... ...\n", "2298104 600586.SH 2012-01-05 0.126862\n", "2298105 600660.SH 2012-01-05 0.031603\n", "2298106 601299.SH 2012-01-05 0.127765\n", "2298107 601788.SH 2012-01-05 0.419413\n", "2298108 601988.SH 2012-01-05 0.000451\n", "\n", "[2219 rows x 3 columns]" ] }, "execution_count": 80, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[df['m_nDate'] == '2012-01-05']" ] }, { "cell_type": "code", "execution_count": 84, "id": "972934f5-35c7-4874-b990-4ce0f9d58965", "metadata": {}, "outputs": [], "source": [ "df = sess.run(\"\"\"\n", " corr_5 = select code, m_nDate, mcorr(high, vol, 5) as corr_5\n", " from loadTable(\"dfs://daily_stock_ts\", \"daily_kline\")\n", " context by code;\n", " corr_5\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 91, "id": "d3442f93-3beb-40c1-92c1-7f2d2d0e8ec3", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
codem_nDatedelta_corr_5
5873882600000.SH2006-01-11NaN
5873883600000.SH2006-01-12NaN
5873884600000.SH2006-01-13NaN
5873885600000.SH2006-01-160.111578
5873886600000.SH2006-01-170.053048
5873887600000.SH2006-01-180.680933
5873888600000.SH2006-01-19-0.530191
5873889600000.SH2006-01-20-0.283952
5873890600000.SH2006-01-23-0.295373
5873891600000.SH2006-01-24-0.105135
\n", "
" ], "text/plain": [ " code m_nDate delta_corr_5\n", "5873882 600000.SH 2006-01-11 NaN\n", "5873883 600000.SH 2006-01-12 NaN\n", "5873884 600000.SH 2006-01-13 NaN\n", "5873885 600000.SH 2006-01-16 0.111578\n", "5873886 600000.SH 2006-01-17 0.053048\n", "5873887 600000.SH 2006-01-18 0.680933\n", "5873888 600000.SH 2006-01-19 -0.530191\n", "5873889 600000.SH 2006-01-20 -0.283952\n", "5873890 600000.SH 2006-01-23 -0.295373\n", "5873891 600000.SH 2006-01-24 -0.105135" ] }, "execution_count": 91, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = sess.run(\"\"\"\n", " delta_corr_5 = select code, m_nDate, mfirst(corr_5, 5) - corr_5 as delta_corr_5\n", " from corr_5 context by code;\n", " delta_corr_5\n", "\"\"\")\n", "df[df['code'] == '600000.SH'].iloc[5:15]" ] }, { "cell_type": "code", "execution_count": 93, "id": "b70d0329-0f82-4fef-a6e1-faf2068e85f4", "metadata": {}, "outputs": [], "source": [ "df = sess.run(\"\"\"\n", " alpha101_22 = select code, m_nDate, delta_corr_5 * rank_vol_20 as alpha101_22\n", " from ej(rank_vol_20, delta_corr_5, `code`m_nDate);\n", " alpha101_22\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 94, "id": "4fbb58eb-58fa-40d9-a0e8-32e9b4868629", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
codem_nDatealpha101_22
0000400.SZ2006-01-04NaN
1000515.SZ2006-01-04NaN
2000558.SZ2006-01-04NaN
3000602.SZ2006-01-04NaN
4000731.SZ2006-01-04NaN
............
10403520688272.SH2022-08-100.280800
10403521688320.SH2022-08-100.464768
10403522688739.SH2022-08-100.054898
10403523688777.SH2022-08-100.427098
10403524830964.NE2022-08-10-0.016451
\n", "

10403525 rows × 3 columns

\n", "
" ], "text/plain": [ " code m_nDate alpha101_22\n", "0 000400.SZ 2006-01-04 NaN\n", "1 000515.SZ 2006-01-04 NaN\n", "2 000558.SZ 2006-01-04 NaN\n", "3 000602.SZ 2006-01-04 NaN\n", "4 000731.SZ 2006-01-04 NaN\n", "... ... ... ...\n", "10403520 688272.SH 2022-08-10 0.280800\n", "10403521 688320.SH 2022-08-10 0.464768\n", "10403522 688739.SH 2022-08-10 0.054898\n", "10403523 688777.SH 2022-08-10 0.427098\n", "10403524 830964.NE 2022-08-10 -0.016451\n", "\n", "[10403525 rows x 3 columns]" ] }, "execution_count": 94, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df" ] }, { "cell_type": "code", "execution_count": 10, "id": "f211d667-4932-457e-9051-667607f8a105", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
codem_nDatemonth_of_year
0000400.SZ2006-01-041
1000400.SZ2006-01-051
2000400.SZ2006-01-061
3000400.SZ2006-01-091
4000400.SZ2006-01-101
............
95000400.SZ2006-06-066
96000400.SZ2006-06-076
97000400.SZ2006-06-086
98000400.SZ2006-06-096
99000400.SZ2006-06-126
\n", "

100 rows × 3 columns

\n", "
" ], "text/plain": [ " code m_nDate month_of_year\n", "0 000400.SZ 2006-01-04 1\n", "1 000400.SZ 2006-01-05 1\n", "2 000400.SZ 2006-01-06 1\n", "3 000400.SZ 2006-01-09 1\n", "4 000400.SZ 2006-01-10 1\n", ".. ... ... ...\n", "95 000400.SZ 2006-06-06 6\n", "96 000400.SZ 2006-06-07 6\n", "97 000400.SZ 2006-06-08 6\n", "98 000400.SZ 2006-06-09 6\n", "99 000400.SZ 2006-06-12 6\n", "\n", "[100 rows x 3 columns]" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sess.run(\"\"\"\n", " select top 100 code, m_nDate, monthOfYear(m_nDate) as month_of_year \n", " from loadTable(\"dfs://daily_stock_ts\", \"daily_kline\")\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 97, "id": "fc62191a-94f6-4172-a2a2-39907d94e6b5", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
codem_nDatetrend_with_turnovertrend_with_amountabs_trend_with_turnoverabs_trend_with_amountalpha101_22
0000400.SZ2006-01-04NaN0.0821850.1019430.0821850.101943
1000400.SZ2006-01-05NaN0.0062550.0248390.0062550.024839
2000400.SZ2006-01-06NaN-0.004377-0.0111940.0043770.011194
3000400.SZ2006-01-09NaN0.0295490.0661960.0295490.066196
4000400.SZ2006-01-10NaN0.0117160.0132020.0117160.013202
........................
95000400.SZ2006-06-060.1210660.021408-0.019479-0.0214080.019479
96000400.SZ2006-06-070.0910730.099845-0.084317-0.0998450.084317
97000400.SZ2006-06-08-0.3368590.007474-0.006340-0.0074740.006340
98000400.SZ2006-06-09-0.453049-0.0050570.002774-0.0050570.002774
99000400.SZ2006-06-12-0.244429-0.0073220.006228-0.0073220.006228
\n", "

100 rows × 7 columns

\n", "
" ], "text/plain": [ " code m_nDate trend_with_turnover trend_with_amount \\\n", "0 000400.SZ 2006-01-04 NaN 0.082185 \n", "1 000400.SZ 2006-01-05 NaN 0.006255 \n", "2 000400.SZ 2006-01-06 NaN -0.004377 \n", "3 000400.SZ 2006-01-09 NaN 0.029549 \n", "4 000400.SZ 2006-01-10 NaN 0.011716 \n", ".. ... ... ... ... \n", "95 000400.SZ 2006-06-06 0.121066 0.021408 \n", "96 000400.SZ 2006-06-07 0.091073 0.099845 \n", "97 000400.SZ 2006-06-08 -0.336859 0.007474 \n", "98 000400.SZ 2006-06-09 -0.453049 -0.005057 \n", "99 000400.SZ 2006-06-12 -0.244429 -0.007322 \n", "\n", " abs_trend_with_turnover abs_trend_with_amount alpha101_22 \n", "0 0.101943 0.082185 0.101943 \n", "1 0.024839 0.006255 0.024839 \n", "2 -0.011194 0.004377 0.011194 \n", "3 0.066196 0.029549 0.066196 \n", "4 0.013202 0.011716 0.013202 \n", ".. ... ... ... \n", "95 -0.019479 -0.021408 0.019479 \n", "96 -0.084317 -0.099845 0.084317 \n", "97 -0.006340 -0.007474 0.006340 \n", "98 0.002774 -0.005057 0.002774 \n", "99 0.006228 -0.007322 0.006228 \n", "\n", "[100 rows x 7 columns]" ] }, "execution_count": 97, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sess.run(\"\"\"\n", " select top 100 * \n", " from loadTable(\"dfs://daily_stock_ts\", \"daily_factor\")\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 8, "id": "081d51c7-f9d5-4493-bc16-a03945d1e4c2", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
codem_nDateopenhighlowcloseIsZtIsT
0000622.SZ2018-10-103.173.203.113.130False
1000622.SZ2018-10-113.023.112.822.830False
2000622.SZ2018-10-122.852.862.622.770False
3000622.SZ2018-10-152.802.872.732.730False
4000622.SZ2018-10-162.732.812.602.670False
5000622.SZ2018-10-172.712.742.572.660False
6000622.SZ2018-10-182.672.672.462.500False
7000622.SZ2018-10-192.422.592.422.580False
8000622.SZ2018-10-222.842.842.842.841False
9000622.SZ2018-10-233.123.122.843.121True
10000622.SZ2018-10-243.133.433.023.431True
11000622.SZ2018-10-253.703.773.613.771True
12000622.SZ2018-10-264.154.154.154.151False
13000622.SZ2018-10-294.304.574.254.571True
14000622.SZ2018-10-304.585.034.465.031True
15000622.SZ2018-11-055.535.535.535.531False
16000622.SZ2018-11-066.086.086.086.081False
17000622.SZ2018-11-076.456.696.336.691True
18000622.SZ2018-11-087.257.366.987.361True
19000622.SZ2018-11-097.388.107.267.900False
\n", "
" ], "text/plain": [ " code m_nDate open high low close IsZt IsT\n", "0 000622.SZ 2018-10-10 3.17 3.20 3.11 3.13 0 False\n", "1 000622.SZ 2018-10-11 3.02 3.11 2.82 2.83 0 False\n", "2 000622.SZ 2018-10-12 2.85 2.86 2.62 2.77 0 False\n", "3 000622.SZ 2018-10-15 2.80 2.87 2.73 2.73 0 False\n", "4 000622.SZ 2018-10-16 2.73 2.81 2.60 2.67 0 False\n", "5 000622.SZ 2018-10-17 2.71 2.74 2.57 2.66 0 False\n", "6 000622.SZ 2018-10-18 2.67 2.67 2.46 2.50 0 False\n", "7 000622.SZ 2018-10-19 2.42 2.59 2.42 2.58 0 False\n", "8 000622.SZ 2018-10-22 2.84 2.84 2.84 2.84 1 False\n", "9 000622.SZ 2018-10-23 3.12 3.12 2.84 3.12 1 True\n", "10 000622.SZ 2018-10-24 3.13 3.43 3.02 3.43 1 True\n", "11 000622.SZ 2018-10-25 3.70 3.77 3.61 3.77 1 True\n", "12 000622.SZ 2018-10-26 4.15 4.15 4.15 4.15 1 False\n", "13 000622.SZ 2018-10-29 4.30 4.57 4.25 4.57 1 True\n", "14 000622.SZ 2018-10-30 4.58 5.03 4.46 5.03 1 True\n", "15 000622.SZ 2018-11-05 5.53 5.53 5.53 5.53 1 False\n", "16 000622.SZ 2018-11-06 6.08 6.08 6.08 6.08 1 False\n", "17 000622.SZ 2018-11-07 6.45 6.69 6.33 6.69 1 True\n", "18 000622.SZ 2018-11-08 7.25 7.36 6.98 7.36 1 True\n", "19 000622.SZ 2018-11-09 7.38 8.10 7.26 7.90 0 False" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sess.run(\"\"\"\n", " select code, m_nDate, open, high, low, close, IsZt, \\\n", " (IsZt and high=close and low!=close) as IsT \\\n", " from loadTable(\"dfs://daily_stock_ts\", \"daily_kline\") \n", " where code='000622.SZ' and m_nDate>=2018.10.10 and m_nDate<=2018.11.10\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 18, "id": "14c51fe0-3791-4f5b-8ccc-bfd43f0f5be9", "metadata": {}, "outputs": [], "source": [ "sess.run(\"\"\"\n", " t1 = select code, m_nDate, amount/vol as vwap from loadTable(\"dfs://daily_stock_ts\", \"daily_kline\") \n", " where code='000400.SZ' and m_nDate>=2014.01.04 and m_nDate<=2014.02.04;\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 20, "id": "29bc4089-4df1-4bea-800f-d01e893d08bd", "metadata": {}, "outputs": [], "source": [ "sess.run(\"\"\"\n", " t2 = select code, m_nDate, vwap from loadTable(\"dfs://daily_stock_ts\", \"hft_daily_factor\")\n", " where code='000400.SZ' and m_nDate>=2014.01.04 and m_nDate<=2014.02.04\n", "\"\"\") " ] }, { "cell_type": "code", "execution_count": null, "id": "b98b12d4-1068-4c98-8374-bbc1adce01a3", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
codem_nDatevwapt2_vwapvwap_sub
0000400.SZ2014-01-0630.62853330.982086-0.353552
1000400.SZ2014-01-0733.00400032.6129760.391024
2000400.SZ2014-01-0832.90872432.6109450.297780
3000400.SZ2014-01-0933.56331533.736282-0.172967
4000400.SZ2014-01-1032.01233932.273132-0.260793
5000400.SZ2014-01-1332.30144032.1131600.188280
6000400.SZ2014-01-1432.49557132.781237-0.285666
7000400.SZ2014-01-1533.79142733.7507420.040686
8000400.SZ2014-01-1634.69570834.871143-0.175435
9000400.SZ2014-01-1733.91033033.978306-0.067975
10000400.SZ2014-01-2033.70738933.731507-0.024118
11000400.SZ2014-01-2133.33821033.663293-0.325083
12000400.SZ2014-01-2234.04644033.6571110.389329
13000400.SZ2014-01-2334.02809334.028356-0.000263
14000400.SZ2014-01-2433.91991633.8790260.040890
15000400.SZ2014-01-2734.10455633.9498440.154712
16000400.SZ2014-01-2833.92630234.179352-0.253050
17000400.SZ2014-01-2934.04629333.9170530.129240
18000400.SZ2014-01-3034.04107034.464937-0.423867
\n", "
" ], "text/plain": [ " code m_nDate vwap t2_vwap vwap_sub\n", "0 000400.SZ 2014-01-06 30.628533 30.982086 -0.353552\n", "1 000400.SZ 2014-01-07 33.004000 32.612976 0.391024\n", "2 000400.SZ 2014-01-08 32.908724 32.610945 0.297780\n", "3 000400.SZ 2014-01-09 33.563315 33.736282 -0.172967\n", "4 000400.SZ 2014-01-10 32.012339 32.273132 -0.260793\n", "5 000400.SZ 2014-01-13 32.301440 32.113160 0.188280\n", "6 000400.SZ 2014-01-14 32.495571 32.781237 -0.285666\n", "7 000400.SZ 2014-01-15 33.791427 33.750742 0.040686\n", "8 000400.SZ 2014-01-16 34.695708 34.871143 -0.175435\n", "9 000400.SZ 2014-01-17 33.910330 33.978306 -0.067975\n", "10 000400.SZ 2014-01-20 33.707389 33.731507 -0.024118\n", "11 000400.SZ 2014-01-21 33.338210 33.663293 -0.325083\n", "12 000400.SZ 2014-01-22 34.046440 33.657111 0.389329\n", "13 000400.SZ 2014-01-23 34.028093 34.028356 -0.000263\n", "14 000400.SZ 2014-01-24 33.919916 33.879026 0.040890\n", "15 000400.SZ 2014-01-27 34.104556 33.949844 0.154712\n", "16 000400.SZ 2014-01-28 33.926302 34.179352 -0.253050\n", "17 000400.SZ 2014-01-29 34.046293 33.917053 0.129240\n", "18 000400.SZ 2014-01-30 34.041070 34.464937 -0.423867" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sess.run(\"\"\"\n", " select *, t1.vwap-t2.vwap from ej(t1, t2, `code`m_nDate)\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 51, "id": "b0543222-4201-4ca7-8a38-2f561adecd76", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
winsorize
00.191026
10.082927
20.143954
3-0.060634
40.014164
......
39320.014144
39330.042313
3934-0.020979
39350.000000
3936-0.021067
\n", "

3937 rows × 1 columns

\n", "
" ], "text/plain": [ " winsorize\n", "0 0.191026\n", "1 0.082927\n", "2 0.143954\n", "3 -0.060634\n", "4 0.014164\n", "... ...\n", "3932 0.014144\n", "3933 0.042313\n", "3934 -0.020979\n", "3935 0.000000\n", "3936 -0.021067\n", "\n", "[3937 rows x 1 columns]" ] }, "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sess.run(\"\"\"\n", " t1 = select winsorize(PctChg/20, 0.05) from loadTable(\"dfs://daily_stock_ts\", \"daily_kline\") where code=\"600000.SH\";\n", " t1;\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 11, "id": "4d0ac236-d2b3-4724-9f89-040d85e95221", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
codem_nDateamountamount_rankamount_with_trend
0000400.SZ2006-01-043.265679e+070.4103210.661152
1000515.SZ2006-01-049.116335e+060.1776650.462941
2000558.SZ2006-01-042.417575e+06-0.2318100.209710
3000602.SZ2006-01-041.767682e+070.3147210.705630
4000731.SZ2006-01-041.402217e+070.2724200.675770
..................
10403520688272.SH2022-08-107.012509e+07-0.0147270.271909
10403521688320.SH2022-08-101.067048e+080.1014420.561355
10403522688739.SH2022-08-101.035707e+07-0.4421220.030941
10403523688777.SH2022-08-104.529292e+080.3943360.751877
10403524830964.NE2022-08-105.583561e+05-0.4934090.002081
\n", "

10403525 rows × 5 columns

\n", "
" ], "text/plain": [ " code m_nDate amount amount_rank amount_with_trend\n", "0 000400.SZ 2006-01-04 3.265679e+07 0.410321 0.661152\n", "1 000515.SZ 2006-01-04 9.116335e+06 0.177665 0.462941\n", "2 000558.SZ 2006-01-04 2.417575e+06 -0.231810 0.209710\n", "3 000602.SZ 2006-01-04 1.767682e+07 0.314721 0.705630\n", "4 000731.SZ 2006-01-04 1.402217e+07 0.272420 0.675770\n", "... ... ... ... ... ...\n", "10403520 688272.SH 2022-08-10 7.012509e+07 -0.014727 0.271909\n", "10403521 688320.SH 2022-08-10 1.067048e+08 0.101442 0.561355\n", "10403522 688739.SH 2022-08-10 1.035707e+07 -0.442122 0.030941\n", "10403523 688777.SH 2022-08-10 4.529292e+08 0.394336 0.751877\n", "10403524 830964.NE 2022-08-10 5.583561e+05 -0.493409 0.002081\n", "\n", "[10403525 rows x 5 columns]" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = sess.run(\"\"\"\n", " select \n", " code, m_nDate, \n", " amount, \n", " rank(amount,tiesMethod='average', percent=true)-0.5 as amount_rank,\n", " rank(amount,tiesMethod='average', percent=true)-0.5 * winsorize(abs(PctChg)/10, 0.02) as amount_with_trend\n", " from loadTable(\"dfs://daily_stock_ts\", \"daily_kline\")\n", " context by m_nDate\n", "\"\"\")\n", "df" ] }, { "cell_type": "code", "execution_count": 88, "id": "b0d7d22f-6d80-45ed-b685-0cbc0daccd13", "metadata": {}, "outputs": [], "source": [ "df = sess.run(\"\"\"\n", " tableInsert(\n", " loadTable(\"dfs://daily_stock_ts\", \"daily_factor\"),\n", " select \n", " code, m_nDate, \n", " rank(amount,tiesMethod='average', percent=true)-0.5 * winsorize(abs(PctChg), 0.02) \n", " from loadTable(\"dfs://daily_stock_ts\", \"daily_kline\")\n", " context by m_nDate\n", " )\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 118, "id": "a72d9b1f-a84a-463f-87b8-1841d51afd5e", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
codem_nDatetrend_with_amount
0000400.SZ2006-01-040.101943
1000400.SZ2006-01-050.024839
2000400.SZ2006-01-06-0.011194
3000400.SZ2006-01-090.066196
4000400.SZ2006-01-100.013202
............
95000400.SZ2006-06-06-0.019479
96000400.SZ2006-06-07-0.084317
97000400.SZ2006-06-08-0.006340
98000400.SZ2006-06-090.002774
99000400.SZ2006-06-120.006228
\n", "

100 rows × 3 columns

\n", "
" ], "text/plain": [ " code m_nDate trend_with_amount\n", "0 000400.SZ 2006-01-04 0.101943\n", "1 000400.SZ 2006-01-05 0.024839\n", "2 000400.SZ 2006-01-06 -0.011194\n", "3 000400.SZ 2006-01-09 0.066196\n", "4 000400.SZ 2006-01-10 0.013202\n", ".. ... ... ...\n", "95 000400.SZ 2006-06-06 -0.019479\n", "96 000400.SZ 2006-06-07 -0.084317\n", "97 000400.SZ 2006-06-08 -0.006340\n", "98 000400.SZ 2006-06-09 0.002774\n", "99 000400.SZ 2006-06-12 0.006228\n", "\n", "[100 rows x 3 columns]" ] }, "execution_count": 118, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sess.run(\"\"\"\n", " select top 100 * from loadTable(\"dfs://daily_stock_ts\", \"daily_factor\")\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 87, "id": "bbf2d32b-db27-4f3d-820e-8d53ff936b2d", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
codem_nDateamountrank_amount_sub
0000400.SZ2006-01-043.265679e+070.410321
1182000400.SZ2006-01-052.582027e+070.338525
2402000400.SZ2006-01-063.477456e+070.361201
3634000400.SZ2006-01-093.356378e+070.374590
4854000400.SZ2006-01-105.437912e+070.438322
...............
10379267000400.SZ2022-08-041.660664e+090.487822
10384112000400.SZ2022-08-051.430263e+090.480821
10388961000400.SZ2022-08-089.427016e+080.464359
10393815000400.SZ2022-08-099.085981e+080.464985
10398670000400.SZ2022-08-101.074877e+090.471164
\n", "

3786 rows × 4 columns

\n", "
" ], "text/plain": [ " code m_nDate amount rank_amount_sub\n", "0 000400.SZ 2006-01-04 3.265679e+07 0.410321\n", "1182 000400.SZ 2006-01-05 2.582027e+07 0.338525\n", "2402 000400.SZ 2006-01-06 3.477456e+07 0.361201\n", "3634 000400.SZ 2006-01-09 3.356378e+07 0.374590\n", "4854 000400.SZ 2006-01-10 5.437912e+07 0.438322\n", "... ... ... ... ...\n", "10379267 000400.SZ 2022-08-04 1.660664e+09 0.487822\n", "10384112 000400.SZ 2022-08-05 1.430263e+09 0.480821\n", "10388961 000400.SZ 2022-08-08 9.427016e+08 0.464359\n", "10393815 000400.SZ 2022-08-09 9.085981e+08 0.464985\n", "10398670 000400.SZ 2022-08-10 1.074877e+09 0.471164\n", "\n", "[3786 rows x 4 columns]" ] }, "execution_count": 87, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[df['code'] == '000400.SZ']" ] }, { "cell_type": "code", "execution_count": 47, "id": "0548beb0-9cc7-4c27-9383-2519e72b62a6", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
codem_nDatetrend_with_amounttrend_with_turnover
0000400.SZ2006-01-042.4619291.984772
1000515.SZ2006-01-040.7629781.693085
2000558.SZ2006-01-04-0.2711230.042549
3000602.SZ2006-01-040.6866640.895247
4000731.SZ2006-01-040.5265840.304176
...............
10403520688272.SH2022-08-10-0.0628452.001800
10403521688320.SH2022-08-100.0813300.256045
10403522688739.SH2022-08-10-0.238192-0.179157
10403523688777.SH2022-08-101.1235320.242664
10403524830964.NE2022-08-10-0.000000-0.000000
\n", "

10403525 rows × 4 columns

\n", "
" ], "text/plain": [ " code m_nDate trend_with_amount trend_with_turnover\n", "0 000400.SZ 2006-01-04 2.461929 1.984772\n", "1 000515.SZ 2006-01-04 0.762978 1.693085\n", "2 000558.SZ 2006-01-04 -0.271123 0.042549\n", "3 000602.SZ 2006-01-04 0.686664 0.895247\n", "4 000731.SZ 2006-01-04 0.526584 0.304176\n", "... ... ... ... ...\n", "10403520 688272.SH 2022-08-10 -0.062845 2.001800\n", "10403521 688320.SH 2022-08-10 0.081330 0.256045\n", "10403522 688739.SH 2022-08-10 -0.238192 -0.179157\n", "10403523 688777.SH 2022-08-10 1.123532 0.242664\n", "10403524 830964.NE 2022-08-10 -0.000000 -0.000000\n", "\n", "[10403525 rows x 4 columns]" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sess.run(\"\"\"\n", " f = select \n", " code, m_nDate, \n", " (rank(amount, tiesMethod='average', percent=true) - 0.5) * abs(winsorize(PctChg, 0.01)) as trend_with_amount,\n", " (rank((amount/MarketValues), tiesMethod='average', percent=true) - 0.5) * abs(winsorize(PctChg, 0.01)) as trend_with_turnover\n", " from loadTable(\"dfs://daily_stock_ts\", \"daily_kline\")\n", " context by m_nDate\n", " f;\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 14, "id": "b604dd48-2869-41d8-a001-275ab0b49594", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
codem_nDaterank_PctChg_sub
0000400.SZ2006-01-030.461697
1000400.SZ2006-01-040.241123
2000400.SZ2006-01-05-0.124425
3000400.SZ2006-01-080.399528
4000400.SZ2006-01-090.108267
............
10403520830964.NE2022-08-03-0.027355
10403521830964.NE2022-08-04-0.070112
10403522830964.NE2022-08-070.050077
10403523830964.NE2022-08-08-0.027355
10403524830964.NE2022-08-09-0.027355
\n", "

10403525 rows × 3 columns

\n", "
" ], "text/plain": [ " code m_nDate rank_PctChg_sub\n", "0 000400.SZ 2006-01-03 0.461697\n", "1 000400.SZ 2006-01-04 0.241123\n", "2 000400.SZ 2006-01-05 -0.124425\n", "3 000400.SZ 2006-01-08 0.399528\n", "4 000400.SZ 2006-01-09 0.108267\n", "... ... ... ...\n", "10403520 830964.NE 2022-08-03 -0.027355\n", "10403521 830964.NE 2022-08-04 -0.070112\n", "10403522 830964.NE 2022-08-07 0.050077\n", "10403523 830964.NE 2022-08-08 -0.027355\n", "10403524 830964.NE 2022-08-09 -0.027355\n", "\n", "[10403525 rows x 3 columns]" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sess.run(\"\"\"\n", " r = select \n", " code, m_nDate-1 as m_nDate, \n", " rank(PctChg, percent=true)-0.5 \n", " from loadTable(\"dfs://daily_stock_ts\", \"daily_kline\");\n", " r;\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 95, "id": "daab613f-9e6b-4f75-bfbe-80a2293912c3", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
codem_nDaterank_PctChg_subalpha101_22_m_nDatealpha101_22
0000400.SZ2006-01-030.461697NaTNaN
1000400.SZ2006-01-040.2411232006-01-04NaN
2000400.SZ2006-01-05-0.1244252006-01-05NaN
3000400.SZ2006-01-080.3995282006-01-06NaN
4000400.SZ2006-01-090.1082672006-01-09NaN
..................
10403520830964.NE2022-08-03-0.0273552022-08-030.008355
10403521830964.NE2022-08-04-0.0701122022-08-040.015653
10403522830964.NE2022-08-070.0500772022-08-050.014966
10403523830964.NE2022-08-08-0.0273552022-08-08-0.034349
10403524830964.NE2022-08-09-0.0273552022-08-09-0.021269
\n", "

10403525 rows × 5 columns

\n", "
" ], "text/plain": [ " code m_nDate rank_PctChg_sub alpha101_22_m_nDate \\\n", "0 000400.SZ 2006-01-03 0.461697 NaT \n", "1 000400.SZ 2006-01-04 0.241123 2006-01-04 \n", "2 000400.SZ 2006-01-05 -0.124425 2006-01-05 \n", "3 000400.SZ 2006-01-08 0.399528 2006-01-06 \n", "4 000400.SZ 2006-01-09 0.108267 2006-01-09 \n", "... ... ... ... ... \n", "10403520 830964.NE 2022-08-03 -0.027355 2022-08-03 \n", "10403521 830964.NE 2022-08-04 -0.070112 2022-08-04 \n", "10403522 830964.NE 2022-08-07 0.050077 2022-08-05 \n", "10403523 830964.NE 2022-08-08 -0.027355 2022-08-08 \n", "10403524 830964.NE 2022-08-09 -0.027355 2022-08-09 \n", "\n", " alpha101_22 \n", "0 NaN \n", "1 NaN \n", "2 NaN \n", "3 NaN \n", "4 NaN \n", "... ... \n", "10403520 0.008355 \n", "10403521 0.015653 \n", "10403522 0.014966 \n", "10403523 -0.034349 \n", "10403524 -0.021269 \n", "\n", "[10403525 rows x 5 columns]" ] }, "execution_count": 95, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = sess.run(\"\"\"\n", " select * from aj(r, alpha101_22, `code`m_nDate)\n", "\"\"\")\n", "df" ] }, { "cell_type": "code", "execution_count": 96, "id": "ea2c353c-2e74-46f1-86c9-48322e9f9296", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
rank_PctChg_subalpha101_22
rank_PctChg_sub1.000000-0.006789
alpha101_22-0.0067891.000000
\n", "
" ], "text/plain": [ " rank_PctChg_sub alpha101_22\n", "rank_PctChg_sub 1.000000 -0.006789\n", "alpha101_22 -0.006789 1.000000" ] }, "execution_count": 96, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[[\"rank_PctChg_sub\", \"alpha101_22\"]].dropna().corr()" ] }, { "cell_type": "code", "execution_count": 54, "id": "aac33fb2-d06b-4456-81a2-cf8476a13d4d", "metadata": {}, "outputs": [], "source": [ "df = df.set_index([\"m_nDate\"])[['rank_PctChg_sub', 'trend_with_amount', 'trend_with_turnover']].dropna()" ] }, { "cell_type": "code", "execution_count": 55, "id": "bc7447a7-be59-481b-b15a-d2ff59355135", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
rank_PctChg_subtrend_with_amounttrend_with_turnover
rank_PctChg_sub1.000000-0.041950-0.032851
trend_with_amount-0.0419501.0000000.622215
trend_with_turnover-0.0328510.6222151.000000
\n", "
" ], "text/plain": [ " rank_PctChg_sub trend_with_amount trend_with_turnover\n", "rank_PctChg_sub 1.000000 -0.041950 -0.032851\n", "trend_with_amount -0.041950 1.000000 0.622215\n", "trend_with_turnover -0.032851 0.622215 1.000000" ] }, "execution_count": 55, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.corr(method=\"pearson\")" ] }, { "cell_type": "code", "execution_count": 60, "id": "259aad61-545d-48b2-80d1-7588e2b1b95e", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-0.0417603527848196" ] }, "execution_count": 60, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from scipy.spatial import distance\n", "1 - distance.cosine(df['rank_PctChg_sub'], df['trend_with_amount'])" ] }, { "cell_type": "code", "execution_count": 62, "id": "84a31edf-a9cd-47bb-9f2b-384a45479c2d", "metadata": {}, "outputs": [], "source": [ "s_corr = df[[\"rank_PctChg_sub\", \"trend_with_amount\"]]\\\n", " .groupby(\"m_nDate\").apply(lambda _df : 1 - distance.cosine(_df['rank_PctChg_sub'], _df['trend_with_amount']))" ] }, { "cell_type": "code", "execution_count": 65, "id": "0574a132-0744-412d-a2b3-e7d5b78c3d7a", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.3412639405204461" ] }, "execution_count": 65, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sum(s_corr > 0) / len(s_corr)" ] }, { "cell_type": "code", "execution_count": 131, "id": "faac8d09-0e8c-409e-85e9-0cb2d567e7b6", "metadata": {}, "outputs": [ { "ename": "RuntimeError", "evalue": " in run: Server response: 'select code as symbol,m_nDate as date,open,close,high,low,vol as volume,amount,cjbs,yclose,PctChg,amount / vol as vwap,FloatShares,MarketValues,trend_with_turnover,trend_with_amount,k_skew,k_advrev,k_tail30trade,k_vpcorr,k_largeorder_ret,factor from lj(lj(loadTable(\"dfs://daily_stock_ts\", \"daily_kline\"),loadTable(\"dfs://daily_stock_ts\", \"daily_factor\"),[\"code\",\"m_nDate\"]),loadTable(\"dfs://daily_stock_ts\", \"hft_daily_factor\"),[\"code\",\"m_nDate\"]) where partition(code, 0) order by m_nDate asc => Multiple-table join does not support partitioned table except the first table!' script: '\n select code as symbol, m_nDate as date, open, close, high, low, vol as volume, amount, cjbs, yclose, PctChg, amount/vol as vwap, FloatShares, MarketValues, trend_with_turnover, trend_with_amount, k_skew, k_advrev, k_tail30trade, k_vpcorr, k_largeorder_ret, factor as factor\n from lj(lj(loadTable('dfs://daily_stock_ts', 'daily_kline'), loadTable('dfs://daily_stock_ts', 'daily_factor'), `code`m_nDate), loadTable('dfs://daily_stock_ts', 'hft_daily_factor'), `code`m_nDate) where partition(code, 0)\n order by m_nDate asc;\n'", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)", "Input \u001b[0;32mIn [131]\u001b[0m, in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43msess\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\"\"\u001b[39;49m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;124;43m select code as symbol, m_nDate as date, open, close, high, low, vol as volume, amount, cjbs, yclose, PctChg, amount/vol as vwap, FloatShares, MarketValues, trend_with_turnover, trend_with_amount, k_skew, k_advrev, k_tail30trade, k_vpcorr, k_largeorder_ret, factor as factor\u001b[39;49m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;124;43m from lj(lj(loadTable(\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mdfs://daily_stock_ts\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m, \u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mdaily_kline\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m), loadTable(\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mdfs://daily_stock_ts\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m, \u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mdaily_factor\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m), `code`m_nDate), loadTable(\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mdfs://daily_stock_ts\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m, \u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mhft_daily_factor\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m), `code`m_nDate) where partition(code, 0)\u001b[39;49m\n\u001b[1;32m 4\u001b[0m \u001b[38;5;124;43m order by m_nDate asc;\u001b[39;49m\n\u001b[1;32m 5\u001b[0m \u001b[38;5;124;43m\"\"\"\u001b[39;49m\u001b[43m)\u001b[49m\n", "File \u001b[0;32m~/.venv/tinysoft/lib/python3.8/site-packages/dolphindb/session.py:161\u001b[0m, in \u001b[0;36msession.run\u001b[0;34m(self, script, *args, **kwargs)\u001b[0m\n\u001b[1;32m 159\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mfetchSize\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m kwargs\u001b[38;5;241m.\u001b[39mkeys():\n\u001b[1;32m 160\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m BlockReader(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcpp\u001b[38;5;241m.\u001b[39mrunBlock(script, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs))\n\u001b[0;32m--> 161\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcpp\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[43mscript\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", "\u001b[0;31mRuntimeError\u001b[0m: in run: Server response: 'select code as symbol,m_nDate as date,open,close,high,low,vol as volume,amount,cjbs,yclose,PctChg,amount / vol as vwap,FloatShares,MarketValues,trend_with_turnover,trend_with_amount,k_skew,k_advrev,k_tail30trade,k_vpcorr,k_largeorder_ret,factor from lj(lj(loadTable(\"dfs://daily_stock_ts\", \"daily_kline\"),loadTable(\"dfs://daily_stock_ts\", \"daily_factor\"),[\"code\",\"m_nDate\"]),loadTable(\"dfs://daily_stock_ts\", \"hft_daily_factor\"),[\"code\",\"m_nDate\"]) where partition(code, 0) order by m_nDate asc => Multiple-table join does not support partitioned table except the first table!' script: '\n select code as symbol, m_nDate as date, open, close, high, low, vol as volume, amount, cjbs, yclose, PctChg, amount/vol as vwap, FloatShares, MarketValues, trend_with_turnover, trend_with_amount, k_skew, k_advrev, k_tail30trade, k_vpcorr, k_largeorder_ret, factor as factor\n from lj(lj(loadTable('dfs://daily_stock_ts', 'daily_kline'), loadTable('dfs://daily_stock_ts', 'daily_factor'), `code`m_nDate), loadTable('dfs://daily_stock_ts', 'hft_daily_factor'), `code`m_nDate) where partition(code, 0)\n order by m_nDate asc;\n'" ] } ], "source": [ "sess.run(\"\"\"\n", " select code as symbol, m_nDate as date, open, close, high, low, vol as volume, amount, cjbs, yclose, PctChg, amount/vol as vwap, FloatShares, MarketValues, trend_with_turnover, trend_with_amount, k_skew, k_advrev, k_tail30trade, k_vpcorr, k_largeorder_ret, factor as factor\n", " from lj(lj(loadTable('dfs://daily_stock_ts', 'daily_kline'), loadTable('dfs://daily_stock_ts', 'daily_factor'), `code`m_nDate), loadTable('dfs://daily_stock_ts', 'hft_daily_factor'), `code`m_nDate) where partition(code, 0)\n", " order by m_nDate asc;\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 39, "id": "7f05d056-4369-4f30-9f3e-47505799532e", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
abs
01.491228
13.027605
20.388937
39.987086
41.056751
......
90538610.000000
90538620.298507
90538630.299401
90538640.000000
90538650.000000
\n", "

9053866 rows × 1 columns

\n", "
" ], "text/plain": [ " abs\n", "0 1.491228\n", "1 3.027605\n", "2 0.388937\n", "3 9.987086\n", "4 1.056751\n", "... ...\n", "9053861 0.000000\n", "9053862 0.298507\n", "9053863 0.299401\n", "9053864 0.000000\n", "9053865 0.000000\n", "\n", "[9053866 rows x 1 columns]" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = sess.run(\"\"\"\n", "select abs(winsorize(PctChg, 0.01)) from lj(loadTable('dfs://daily_stock_ts', 'daily_kline'), loadTable('dfs://daily_stock_ts', 'daily_factor'), `code`m_nDate) \n", "where m_nDate > 2010.01.01\n", "\"\"\")\n", "df" ] }, { "cell_type": "code", "execution_count": 40, "id": "90805827-5fe0-416c-9c6f-58473cbad48b", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[]], dtype=object)" ] }, "execution_count": 40, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAEICAYAAABPgw/pAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAUEElEQVR4nO3df5Bd5X3f8ffHSLWJNoYmcjdE4IgpxKkrxrG1BRqmmZWpZ2Tjgf7AKa5rWx5SpR4T/yhuDf4DTz3TKZkWJza4ZlQg4ERFOJgWFWhcD2aLydTUEiEWEiaRMQ4SGBlkhJdQHJVv/9jjzmZnpXt3dXev9tn3a+bOnh/POef7iN0Pzz577rmpKiRJS9+rhl2AJGkwDHRJaoSBLkmNMNAlqREGuiQ1wkCXpEYY6FInyaYkDwy7Dmm+DHRJaoSBLkmNMNC17CS5Isl3kvwoyZ4k//Cv7s51SQ4l+XaS86ft2JTk8e647yZ5zxDKl45oxbALkIbgO8DfA74PvAv4/SRndPvOAW4HVgP/CLgjyenAy8DngL9TVY8lOQX4mUWvXDqKoY7Qk9yU5ECSR/ps/2vdiGp3kv+80PWpTVX1B1X1VFW9UlW3AX8GnN3tPgD8TlX9ZbfvMeCCbt8rwLokJ1bV01W1e/Grl45s2FMuNwMb+2mY5EzgSuC8qvrbwEcXriy1LMn7kjyc5PkkzwPrmBqRA+yvv/rEuu8BP19VLwL/BPgX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oTZLTktyXZE+S3Uk+MuyaFkOSE5L8cZK7hl3LYklycpLbk3w7yaNJ/u6wa1pIST7WfU8/kuTWJK8Zdk2DluSmJAe69+r8ZNvPJPlqkj/rvv71QV1vSQV6n48haM1h4PKqeiNwLvChZdBngI8Ajw67iEX2WeAPq+qXgDfRcP+TrAE+DIxV1TqmbrhY6JsphuFmYOOMbVcA91bVmcC93fpALKlAp7/HEDSlqp6uqoe65R8x9UO+ZrhVLawkpwIXADcMu5bFkuQk4FeZumOMqvpxVT0/1KIW3grgxO69Kz8FPDXkegauqu5n6s6/6aY/KuUW4B8M6npLLdDXAE9OW99H4+E2XfcUyzcDDw65lIX2O8C/Bl4Zch2L6XTgB8DvdlNNNyRp9pMfqmo/8B+APweeBg5V1f8YblWLZrSqnu6Wvw+MDurESy3Ql60kI8CXgY9W1QvDrmehJHkncKCqdg67lkW2AngL8IWqejPwIgP8Vfx4080bX8TU/8h+HliV5J8Nt6rF170Bc2D3ji+1QO/nMQTNSbKSqTDfWlV3DLueBXYecGGSJ5iaUntrkt8fbkmLYh+wr6p+8tvX7UwFfKv+PvDdqvpBVf0lcAfwK0OuabE8k+QUgO7rgUGdeKkFej+PIWhK9xjiG4FHq+ozw65noVXVlVV1alWtZeq/79eqqvmRW1V9H3gyyRu6TecDe4ZY0kL7c+DcJD/VfY+fT8N/BJ5h+qNS3g/cOagTL6mPoDvSYwiGXNZCOw94L7ArycPdtk9W1T3DK0kL5DeBrd1g5XHgA0OuZ8FU1YNJbgceYupOrj+mwUcAJLkVGAdWJ9kHfAq4GvhSkkuB7wG/NrDr+dZ/SWrDUptykSQdgYEuSY0w0CWpEQa6JDXCQJekRhjoktQIA12SGvH/AKGbw22Jq4pIAAAAAElFTkSuQmCC\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "df.hist()" ] }, { "cell_type": "code", "execution_count": null, "id": "e5869db1-4134-426a-a8a0-782cc27ff198", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.13" } }, "nbformat": 4, "nbformat_minor": 5 }