{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "139fd1cb-aedf-4186-8408-4d630ba69599", "metadata": {}, "outputs": [], "source": [ "import dolphindb as ddb\n", "\n", "sess = ddb.session(\"192.168.1.167\", 8848)\n", "sess.login('admin', '123456')" ] }, { "cell_type": "code", "execution_count": 42, "id": "86d6ce04-b5ae-410b-af8d-9d9b5d87a959", "metadata": {}, "outputs": [], "source": [ "sess.run(\"\"\"\n", " dropFunctionView('pit_at_date')\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 43, "id": "5482fa63-23e7-48e7-9636-5628faef7b73", "metadata": {}, "outputs": [], "source": [ "sess.run(\"\"\"\n", "def pit_at_date(table_name, date, report_period_list, code_partition_id) {\n", "\tsource_table = loadTable(\"dfs://pit_stock_ts\", table_name);\n", "\t\n", "\tm_nDate = take(date, size(report_period_list));\n", "\treport_period = report_period_list;\n", "\t\n", "\tquery_table = table(report_period, m_nDate);\n", "\tquery_table_exp = select * from cj(query_table, select code from source_table where partition(code, code_partition_id) group by code map);\n", "\t\n", "\tsource_table_part = select source_table.* from ej(source_table, query_table_exp, `code`report_period) where partition(code, code_partition_id);\n", "\t\n", "\treturn select source_table_part.* from aj(query_table_exp, source_table_part, `code`report_period`m_nDate, `code`report_period`appear_at_date) where not isNull(source_table_part.code)\n", "}\n", "\n", "addFunctionView(pit_at_date)\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 44, "id": "4e0eaa4d-80c9-4925-8496-a7d133fc0fda", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | \n", " | \n", " | appear_in_period | \n", "TOT_OPER_REV | \n", "OPER_REV | \n", "INT_INC | \n", "INSUR_PREM_UNEARNED | \n", "HANDLING_CHRG_COMM_INC | \n", "NET_INC_OTHER_OPS | \n", "PLUS_NET_INC_OTHER_BUS | \n", "PLUS_NET_GAIN_CHG_FV | \n", "PLUS_NET_INVEST_INC | \n", "... | \n", "OTHER_INCOME | \n", "MEMO | \n", "ASSET_DISPOSAL_INCOME | \n", "CONTINUED_NET_PROFIT | \n", "END_NET_PROFIT | \n", "CREDIT_IMPAIRMENT_LOSS | \n", "RD_EXPENSE | \n", "STMNOTE_FINEXP | \n", "FIN_EXP_INT_INC | \n", "TOT_OPER_COST2 | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
code | \n", "report_period | \n", "appear_at_date | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
000400.SZ | \n", "2018-12-31 | \n", "2019-03-29 | \n", "2018-12-31 | \n", "8.216559e+09 | \n", "8.216559e+09 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "73932.94 | \n", "0.0 | \n", "0.0 | \n", "73932.94 | \n", "... | \n", "72773000.86 | \n", "nan | \n", "0.00 | \n", "2.737097e+08 | \n", "0.0 | \n", "0.0 | \n", "3.350267e+08 | \n", "45075829.77 | \n", "0.0 | \n", "7.967406e+09 | \n", "
000558.SZ | \n", "2018-12-31 | \n", "2019-04-26 | \n", "2018-12-31 | \n", "7.024741e+08 | \n", "7.024741e+08 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "23984753.52 | \n", "0.0 | \n", "0.0 | \n", "23984753.52 | \n", "... | \n", "10174473.66 | \n", "nan | \n", "-12902036.23 | \n", "-5.424955e+07 | \n", "0.0 | \n", "0.0 | \n", "0.000000e+00 | \n", "39309311.59 | \n", "0.0 | \n", "6.444387e+08 | \n", "
000677.SZ | \n", "2018-12-31 | \n", "2019-03-29 | \n", "2018-12-31 | \n", "7.068198e+08 | \n", "7.068198e+08 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "220497.76 | \n", "0.0 | \n", "0.0 | \n", "220497.76 | \n", "... | \n", "1157100.00 | \n", "nan | \n", "-1852690.97 | \n", "6.403690e+06 | \n", "0.0 | \n", "0.0 | \n", "3.514984e+05 | \n", "5234360.37 | \n", "0.0 | \n", "6.821367e+08 | \n", "
000731.SZ | \n", "2018-12-31 | \n", "2019-04-16 | \n", "2018-12-31 | \n", "2.639920e+09 | \n", "2.639920e+09 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "4467512.66 | \n", "0.0 | \n", "0.0 | \n", "4467512.66 | \n", "... | \n", "3477372.43 | \n", "nan | \n", "1992627.87 | \n", "2.228619e+08 | \n", "0.0 | \n", "0.0 | \n", "1.653546e+06 | \n", "46581902.65 | \n", "0.0 | \n", "2.367904e+09 | \n", "
000752.SZ | \n", "2018-12-31 | \n", "2019-05-16 | \n", "2018-12-31 | \n", "3.231171e+08 | \n", "3.231171e+08 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "-43852162.57 | \n", "0.0 | \n", "0.0 | \n", "-43852162.57 | \n", "... | \n", "136549.44 | \n", "nan | \n", "0.00 | \n", "-3.830619e+08 | \n", "0.0 | \n", "0.0 | \n", "0.000000e+00 | \n", "0.00 | \n", "0.0 | \n", "3.135966e+08 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
688039.SH | \n", "2018-12-31 | \n", "2019-11-22 | \n", "2018-12-31 | \n", "2.035519e+08 | \n", "2.035519e+08 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "156599.67 | \n", "0.0 | \n", "0.0 | \n", "156599.67 | \n", "... | \n", "15702563.93 | \n", "nan | \n", "0.00 | \n", "6.389806e+07 | \n", "0.0 | \n", "0.0 | \n", "3.660990e+07 | \n", "0.00 | \n", "0.0 | \n", "1.511902e+08 | \n", "
688368.SH | \n", "2018-12-31 | \n", "2019-09-17 | \n", "2018-12-31 | \n", "7.665912e+08 | \n", "7.665912e+08 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "972435.31 | \n", "0.0 | \n", "0.0 | \n", "972435.31 | \n", "... | \n", "6568742.64 | \n", "nan | \n", "0.00 | \n", "0.000000e+00 | \n", "0.0 | \n", "0.0 | \n", "6.081719e+07 | \n", "0.00 | \n", "0.0 | \n", "6.890894e+08 | \n", "
688396.SH | \n", "2018-12-31 | \n", "2020-01-31 | \n", "2018-12-31 | \n", "6.270797e+09 | \n", "6.270797e+09 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "10592096.66 | \n", "0.0 | \n", "0.0 | \n", "10592096.66 | \n", "... | \n", "91086261.29 | \n", "nan | \n", "9434573.46 | \n", "0.000000e+00 | \n", "0.0 | \n", "0.0 | \n", "4.497610e+08 | \n", "0.00 | \n", "0.0 | \n", "5.796301e+09 | \n", "
831010.NE | \n", "2018-12-31 | \n", "2020-07-01 | \n", "2018-12-31 | \n", "2.936331e+08 | \n", "2.936331e+08 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "262112.16 | \n", "0.0 | \n", "0.0 | \n", "262112.16 | \n", "... | \n", "380000.00 | \n", "nan | \n", "-258845.78 | \n", "4.129632e+07 | \n", "0.0 | \n", "0.0 | \n", "5.236440e+05 | \n", "254556.29 | \n", "0.0 | \n", "2.437095e+08 | \n", "
833874.NE | \n", "2018-12-31 | \n", "2020-06-29 | \n", "2018-12-31 | \n", "1.974978e+08 | \n", "1.974978e+08 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "5841180.61 | \n", "0.0 | \n", "0.0 | \n", "5841180.61 | \n", "... | \n", "882100.00 | \n", "nan | \n", "9554.96 | \n", "9.051358e+07 | \n", "0.0 | \n", "0.0 | \n", "1.092805e+07 | \n", "0.00 | \n", "0.0 | \n", "1.021658e+08 | \n", "
91 rows × 66 columns
\n", "\n", " | \n", " | \n", " | TOT_OPER_REV | \n", "
---|---|---|---|
code | \n", "report_period | \n", "appear_at_date | \n", "\n", " |
000400.SZ | \n", "2019-09-30 | \n", "2020-10-29 | \n", "5.658881e+09 | \n", "
000558.SZ | \n", "2019-09-30 | \n", "2020-10-29 | \n", "8.322244e+07 | \n", "
000677.SZ | \n", "2019-09-30 | \n", "2020-10-21 | \n", "6.020088e+08 | \n", "
000731.SZ | \n", "2019-09-30 | \n", "2020-10-27 | \n", "2.311672e+09 | \n", "
000752.SZ | \n", "2019-09-30 | \n", "2020-10-29 | \n", "2.330136e+08 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "
688039.SH | \n", "2019-09-30 | \n", "2020-10-28 | \n", "1.185143e+08 | \n", "
688368.SH | \n", "2019-09-30 | \n", "2020-10-28 | \n", "6.139719e+08 | \n", "
688396.SH | \n", "2019-09-30 | \n", "2020-10-20 | \n", "4.131915e+09 | \n", "
831010.NE | \n", "2019-09-30 | \n", "2020-10-29 | \n", "2.276040e+08 | \n", "
833874.NE | \n", "2019-09-30 | \n", "2020-10-26 | \n", "1.303494e+08 | \n", "
91 rows × 1 columns
\n", "\n", " | code | \n", "report_period | \n", "appear_in_period | \n", "appear_at_date | \n", "TOT_OPER_REV | \n", "
---|---|---|---|---|---|
0 | \n", "000400.SZ | \n", "2019-12-31 | \n", "2019-12-31 | \n", "2020-04-10 | \n", "1.015608e+10 | \n", "
1 | \n", "000558.SZ | \n", "2019-12-31 | \n", "2019-12-31 | \n", "2020-04-27 | \n", "1.378479e+08 | \n", "
2 | \n", "000558.SZ | \n", "2019-12-31 | \n", "2019-12-31 | \n", "2020-08-25 | \n", "1.378479e+08 | \n", "
3 | \n", "000677.SZ | \n", "2019-12-31 | \n", "2019-12-31 | \n", "2020-04-25 | \n", "7.906742e+08 | \n", "
4 | \n", "000731.SZ | \n", "2019-12-31 | \n", "2019-12-31 | \n", "2020-04-24 | \n", "2.929131e+09 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
109 | \n", "688396.SH | \n", "2019-12-31 | \n", "2019-12-31 | \n", "2020-04-23 | \n", "5.742784e+09 | \n", "
110 | \n", "831010.NE | \n", "2019-12-31 | \n", "2019-12-31 | \n", "2020-04-13 | \n", "3.552313e+08 | \n", "
111 | \n", "831010.NE | \n", "2019-12-31 | \n", "2019-12-31 | \n", "2020-07-01 | \n", "3.552313e+08 | \n", "
112 | \n", "833874.NE | \n", "2019-12-31 | \n", "2019-12-31 | \n", "2020-03-18 | \n", "1.785113e+08 | \n", "
113 | \n", "833874.NE | \n", "2019-12-31 | \n", "2019-12-31 | \n", "2020-06-29 | \n", "1.785113e+08 | \n", "
114 rows × 5 columns
\n", "