You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2185 lines
88 KiB

{
"cells": [
{
"cell_type": "code",
"execution_count": 214,
"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": 216,
"id": "98ef95cf-0a7f-4e9d-8c7c-bc1d2a6268bd",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>tableName</th>\n",
" <th>physicalIndex</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>divident</td>\n",
" <td>Gws</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>preliminary_earnings_estimate</td>\n",
" <td>FyP</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>is_common_ori</td>\n",
" <td>DvA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>cfs_common_ori</td>\n",
" <td>AUH</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>bs_common_adj</td>\n",
" <td>x2R</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>earnings_preannouncement</td>\n",
" <td>EOu</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>cfs_common_adj</td>\n",
" <td>zCC</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>is_common_adj</td>\n",
" <td>Cdl</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>bs_common_ori</td>\n",
" <td>ykc</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" tableName physicalIndex\n",
"0 divident Gws\n",
"1 preliminary_earnings_estimate FyP\n",
"2 is_common_ori DvA\n",
"3 cfs_common_ori AUH\n",
"4 bs_common_adj x2R\n",
"5 earnings_preannouncement EOu\n",
"6 cfs_common_adj zCC\n",
"7 is_common_adj Cdl\n",
"8 bs_common_ori ykc"
]
},
"execution_count": 216,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sess.run(\"listTables('dfs://pit_stock_ts')\")"
]
},
{
"cell_type": "code",
"execution_count": 217,
"id": "12d5328e-ee57-4cf6-adeb-863649cbb19d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'partitionType': 5,\n",
" 'partitionColumnType': 17,\n",
" 'partitionColumnIndex': 0,\n",
" 'chunkPath': None,\n",
" 'colDefs': name typeString typeInt comment\n",
" 0 code SYMBOL 17 \n",
" 1 report_period DATE 6 \n",
" 2 appear_at_date DATE 6 \n",
" 3 S_PROFITNOTICE_STYLE STRING 18 \n",
" 4 S_PROFITNOTICE_CHANGEMIN DOUBLE 16 \n",
" 5 S_PROFITNOTICE_CHANGEMAX DOUBLE 16 \n",
" 6 S_PROFITNOTICE_NETPROFITMIN DOUBLE 16 \n",
" 7 S_PROFITNOTICE_NETPROFITMAX DOUBLE 16 \n",
" 8 S_PROFITNOTICE_REASON STRING 18 ,\n",
" 'chunkGranularity': 'TABLE',\n",
" 'partitionTypeName': 'HASH',\n",
" 'keepDuplicates': 'ALL',\n",
" 'engineType': 'TSDB',\n",
" 'partitionColumnName': 'code',\n",
" 'partitionSchema': 50,\n",
" 'sortColumns': array(['code', 'report_period', 'appear_at_date'], dtype=object),\n",
" 'partitionSites': None}"
]
},
"execution_count": 217,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sess.run(\"\"\"\n",
" schema(loadTable(\"dfs://pit_stock_ts\", \"earnings_preannouncement\"))\n",
"\"\"\")"
]
},
{
"cell_type": "code",
"execution_count": 218,
"id": "46547093-9ee6-46ed-a821-73f3237b3c5e",
"metadata": {},
"outputs": [],
"source": [
"import sqlalchemy as sa\n",
"engine = sa.create_engine(\n",
" 'mssql+pyodbc://sa:xn.123@192.168.1.91/tr_statement?driver=ODBC+Driver+18+for+SQL+Server',\n",
" connect_args = {\n",
" \"TrustServerCertificate\": \"yes\"\n",
" }, echo=False)"
]
},
{
"cell_type": "code",
"execution_count": 224,
"id": "26b5701e-17e5-439e-8921-e7523384eee7",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[('tr_statement', 'dbo', 'SRC_TS_DIVIDEND_ANNOUNCEMENT', 'BASE TABLE'),\n",
" ('tr_statement', 'dbo', 'SRC_TS_EARNINGS_PREANNOUNCEMENT', 'BASE TABLE'),\n",
" ('tr_statement', 'dbo', 'SRC_TS_PRELIMINARY_EARNING_EST', 'BASE TABLE'),\n",
" ('tr_statement', 'dbo', 'SRC_TS_FINCOMP_CASHFLOWSTATEMENT', 'BASE TABLE'),\n",
" ('tr_statement', 'dbo', 'SRC_TS_FINCOMP_INCOMESTATEMENT', 'BASE TABLE'),\n",
" ('tr_statement', 'dbo', 'SRC_TS_FINCOMP_BALANCESHEET', 'BASE TABLE'),\n",
" ('tr_statement', 'dbo', 'SRC_TS_CONSOLIDATED_CASHFLOWSTATEMENT', 'BASE TABLE'),\n",
" ('tr_statement', 'dbo', 'SRC_TS_CONSOLIDATED_INCOMESTATEMENT', 'BASE TABLE'),\n",
" ('tr_statement', 'dbo', 'SRC_TS_CONSOLIDATED_BALANCESHEET', 'BASE TABLE'),\n",
" ('tr_statement', 'dbo', 'CBS_META', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'CBS_BEFORE_ADJ', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'CBS_AFTER_ADJ', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'CIS_META', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'CIS_BEFORE_ADJ', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'CIS_AFTER_ADJ', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'CCFS_META', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'CCFS_BEFORE_ADJ', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'CCFS_AFTER_ADJ', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'FBS_META', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'FBS_BEFORE_ADJ', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'FBS_AFTER_ADJ', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'FIS_META', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'FIS_BEFORE_ADJ', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'FIS_AFTER_ADJ', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'FCFS_META', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'FCFS_BEFORE_ADJ', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'FCFS_AFTER_ADJ', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'PEE_META', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'PEE_WIND', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'EP_META', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'EP_WIND', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'DIV_META', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'DIV_WIND', 'VIEW'),\n",
" ('tr_statement', 'dbo', 'SRC_TS_NON_RECURRING_PNL', 'BASE TABLE')]\n"
]
}
],
"source": [
"from pprint import pprint \n",
"\n",
"with engine.connect() as conn:\n",
" rs = conn.execute(\"\"\"\n",
"SELECT\n",
" *\n",
"FROM\n",
" tr_statement.INFORMATION_SCHEMA.TABLES;\n",
"\"\"\").fetchall()\n",
"\n",
"pprint(rs)"
]
},
{
"cell_type": "code",
"execution_count": 231,
"id": "2dcd793a-2442-4b4e-b261-b2cead090efc",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[('tr_statement', 'dbo', 'SRC_TS_EARNINGS_PREANNOUNCEMENT', 'StockID', 1, 'char', 8, 8, None, None, 0, None, None, 1, None, 8, 1, 'NO', 47),\n",
" ('tr_statement', 'dbo', 'SRC_TS_EARNINGS_PREANNOUNCEMENT', 'StockName', 12, 'varchar', 20, 20, None, None, 1, None, None, 12, None, 20, 2, 'YES', 39),\n",
" ('tr_statement', 'dbo', 'SRC_TS_EARNINGS_PREANNOUNCEMENT', 'ReportPeriod', 4, 'int', 10, 4, 0, 10, 0, None, None, 4, None, None, 3, 'NO', 56),\n",
" ('tr_statement', 'dbo', 'SRC_TS_EARNINGS_PREANNOUNCEMENT', 'AppearAtDate', 4, 'int', 10, 4, 0, 10, 0, None, None, 4, None, None, 4, 'NO', 56),\n",
" ('tr_statement', 'dbo', 'SRC_TS_EARNINGS_PREANNOUNCEMENT', 'S_PROFITNOTICE_CONTENT', -1, 'text', 2147483647, 2147483647, None, None, 1, None, None, -1, None, 2147483647, 5, 'YES', 35),\n",
" ('tr_statement', 'dbo', 'SRC_TS_EARNINGS_PREANNOUNCEMENT', 'S_PROFITNOTICE_STYLE', 12, 'varchar', 20, 20, None, None, 1, None, None, 12, None, 20, 6, 'YES', 39),\n",
" ('tr_statement', 'dbo', 'SRC_TS_EARNINGS_PREANNOUNCEMENT', 'S_PROFITNOTICE_CHANG_SOURCE', 12, 'varchar', 20, 20, None, None, 1, None, None, 12, None, 20, 7, 'YES', 39),\n",
" ('tr_statement', 'dbo', 'SRC_TS_EARNINGS_PREANNOUNCEMENT', 'S_PROFITNOTICE_REASON', -1, 'text', 2147483647, 2147483647, None, None, 1, None, None, -1, None, 2147483647, 8, 'YES', 35),\n",
" ('tr_statement', 'dbo', 'SRC_TS_EARNINGS_PREANNOUNCEMENT', 'REMARK', -1, 'text', 2147483647, 2147483647, None, None, 1, None, None, -1, None, 2147483647, 9, 'YES', 35),\n",
" ('tr_statement', 'dbo', 'SRC_TS_EARNINGS_PREANNOUNCEMENT', 'S_PROFITNOTICE_NETPROFITMAX', 6, 'float', 15, 8, None, 10, 1, None, None, 6, None, None, 10, 'YES', 109),\n",
" ('tr_statement', 'dbo', 'SRC_TS_EARNINGS_PREANNOUNCEMENT', 'S_PROFITNOTICE_NETPROFITUNIT', 12, 'varchar', 20, 20, None, None, 1, None, None, 12, None, 20, 11, 'YES', 39),\n",
" ('tr_statement', 'dbo', 'SRC_TS_EARNINGS_PREANNOUNCEMENT', 'S_PROFITNOTICE_NETPROFITMIN', 6, 'float', 15, 8, None, 10, 1, None, None, 6, None, None, 12, 'YES', 109),\n",
" ('tr_statement', 'dbo', 'SRC_TS_EARNINGS_PREANNOUNCEMENT', 'S_PROFITNOTICE_CHANGEMIN', 6, 'float', 15, 8, None, 10, 1, None, None, 6, None, None, 13, 'YES', 109),\n",
" ('tr_statement', 'dbo', 'SRC_TS_EARNINGS_PREANNOUNCEMENT', 'S_PROFITNOTICE_CHANGEMAX', 6, 'float', 15, 8, None, 10, 1, None, None, 6, None, None, 14, 'YES', 109)]\n"
]
}
],
"source": [
"with engine.connect() as conn:\n",
" rs = conn.execute(\"EXEC sp_columns SRC_TS_EARNINGS_PREANNOUNCEMENT\").fetchall()\n",
"\n",
"pprint(rs)"
]
},
{
"cell_type": "code",
"execution_count": 230,
"id": "e5904cbf-4405-4d2e-bc5b-88706273f5d0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[('NE430047', '诺思兰德', 20211231, 20220225, '净利润亏损5174.6万元', '增亏', '天软计算', '本报告期内,公司经营业绩较去年亏损增加。主要原因为:1、报告期内公司研发费用、管理费用较上年度有所增加2、报告期内毛利率较高的技术转让收入减少导致本报告期亏损增加。', 'nan', -5174.6, '万元', -5174.6, -104.1182, -104.1182),\n",
" ('NE430489', '佳先股份', 20211231, 20220228, '净利润盈利6193.94万元比上年同期增长125.26%', '预增', '公告中公布', '本报告期归属于上市公司股东的净利润预计增长125.26%的主要原因如下:\\r\\n1、报告期内公司新厂区生产经营稳定产能逐步放大为公司满足旺盛\\r\\n的市场需求提供了重要保障公司通过不断地拓展销售渠道销售业务实现较好\\r\\n增长同时因疫情、海运费上涨以及原料价格上涨、供求关系紧张等影响 ... (254 characters truncated) ... 和盈利水平得到进一步提升。\\r\\n3、报告期内公司将控股子公司安徽沙丰新材料有限公司全年数据纳入合\\r\\n并报表而上年同期由于收购日为2020年12月8日合并报表中仅合并了安\\r\\n徽沙丰新材料有限公司12月份数据。上述合并范围的差异也导致了公司报告期\\r\\n营业收入、利润较去年同期增长。', 'nan', 6193.94, '万元', 6193.94, 125.26, 125.26),\n",
" ('NE430510', '丰光精密', 20211231, 20220121, '净利润盈利4800万元-5100万元比上年同期增长43.62%-52.6%', '预增', '公告中公布', '(1)报告期内公司下游行业需求旺盛,同时公司市场拓展取得较好效果,公司半导体装备制造类产品和工业自动化类产品营业收入较上年同期增加;(2)公司汽车类产品营业收入较上年同期增加;(3)公司前期开发的新客户、新项目逐步实现量产,相关产品营业收入相应增加。\\r\\n', 'nan', 5100.0, '万元', 4800.0, 43.62, 52.6),\n",
" ('NE430564', '天润科技', 20220331, 20220525, '净利润盈利250万元-320万元比上年同期增长74.14%-122.9%', '预增', '公告中公布', '2022年1月份受西安疫情的影响公司在陕西省内的部分项目完工及验收时间有所推迟公司2022年第一季度收入较上年同期有所下降但由于2021年第一季度确认收入占比84.87%的汕头市中心城区(金平、龙湖区)农村地籍调查服务采购项目毛利率较低导致2022年第一季度公司预计收入规模虽较去年同期有所下降但净利润却较同期有所增长。', 'nan', 320.0, '万元', 250.0, 74.14, 122.9),\n",
" ('NE831370', '新安洁 ', 20211231, 20220225, '净利润盈利4159万元比上年同期下降55.38%', '预减', '公告中公布', '1、公司本报告期增值税及社保支出较上年同期有增长\\r\\n2、公司因应收账款账龄和金额发生变化本报告期的信用减值损失增加\\r\\n3、本报告期公司因部分项目撤场等原因导致资产处置损失增加。\\r\\n', 'nan', 4159.0, '万元', 4159.0, -55.38, -55.38),\n",
" ('NE831689', '克莱特 ', 20211231, 20220321, '净利润盈利4577.19万元比上年同期增长80.24%', '预增', '公告中公布', '公司归属于母公司所有者净利润上升,主要系受行业政策等因素影响,风电\\r\\n新能源装备等下游行业景气度不断提升对公司产品需求增长较快使得公司订\\r\\n单不断增长公司盈利能力进一步提升。\\r\\n受益于国家产业政策的支持国内海上风力发电行业进入快速发展阶段。公\\r\\n司顺势而为积极拓展海上风力 ... (34 characters truncated) ... 合作关系,如空空冷却器、水冷系统等海上风力发电产品。\\r\\n受到上述因素的影响公司新能源装备领域的收入出现了大幅的增长带动公司\\r\\n收入从2020年的28,491.97万元上升至2021年的39,156.58万元,同时带动公司\\r\\n的净利润从2,539.48万元上升至4,577.19万元。', 'nan', 4577.19, '万元', 4577.19, 80.24, 80.24),\n",
" ('NE831689', '克莱特 ', 20220331, 20220302, '净利润盈利900万元-950万元比上年同期增长6.57%-12.49%', '预增', '公告中公布', 'nan', 'nan', 950.0, '万元', 900.0, 6.57, 12.49),\n",
" ('NE831832', '科达自控', 20211231, 20220124, '净利润盈利3600万元-4000万元比上年同期增长23.88%-37.64%', '预增', '公告中公布', '报告期内公司省内外市场拓展取得较好效果,营业收入与上年同期相比有所提升净利润相应增加。', 'nan', 4000.0, '万元', 3600.0, 23.88, 37.64),\n",
" ('NE832145', '恒合股份', 20211231, 20220228, '净利润盈利1670.1万元比上年同期下降45.6%', '预减', '公告中公布', '1、公司油气回收在线监测收入的下降是导致营业收入和净利润降低的主要因素。该业务受疫情等因素的影响下游客户暂停或延缓招标加之疫情的反复\\r\\n使得已经开始的项目有所放缓致使公司油气回收在线监测系统总体收入有所降\\r\\n低进而影响了公司的营收和净利润。\\r\\n2、同时液位量测系统已过政策大力推动期公司液位量测业务量有所下\\r\\n降导致2021年营业收入也随之降低。\\r\\n3、公司预计归属于上市公司股东的扣除非经常性损益后的净利润变动幅度\\r\\n较大主要系公司在2021年度收到计入非经常性损益的上市补助及重大贡献奖\\r\\n励所致。', 'nan', 1670.1, '万元', 1670.1, -45.6, -45.6),\n",
" ('NE832419', '路斯股份', 20211231, 20220223, '净利润盈利2900万元-3500万元比上年同期下降9.72%-25.19%', '预减', '公告中公布', 'nan', 'nan', 3500.0, '万元', 2900.0, -25.19, -9.72)]\n"
]
}
],
"source": [
"with engine.connect() as conn:\n",
" rs = conn.execute(\"select top 10 * from SRC_TS_EARNINGS_PREANNOUNCEMENT\").fetchall()\n",
"\n",
"pprint(rs)"
]
},
{
"cell_type": "code",
"execution_count": 229,
"id": "f6e2ef1d-2e68-49c1-8c57-a0b937037831",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[('tr_statement', 'dbo', 'EP_WIND', 'WIND_CODE', 12, 'varchar', 13, 13, None, None, 1, None, None, 12, None, 13, 1, 'YES', 39),\n",
" ('tr_statement', 'dbo', 'EP_WIND', 'IntCode', 4, 'int', 10, 4, 0, 10, 1, None, None, 4, None, None, 2, 'YES', 38),\n",
" ('tr_statement', 'dbo', 'EP_WIND', 'ReportPeriod', 4, 'int', 10, 4, 0, 10, 0, None, None, 4, None, None, 3, 'NO', 56),\n",
" ('tr_statement', 'dbo', 'EP_WIND', 'AppearAtDate', 4, 'int', 10, 4, 0, 10, 0, None, None, 4, None, None, 4, 'NO', 56),\n",
" ('tr_statement', 'dbo', 'EP_WIND', 'S_PROFITNOTICE_STYLE', 12, 'varchar', 20, 20, None, None, 1, None, None, 12, None, 20, 5, 'YES', 39),\n",
" ('tr_statement', 'dbo', 'EP_WIND', 'S_PROFITNOTICE_CHANGEMIN', 6, 'float', 15, 8, None, 10, 1, None, None, 6, None, None, 6, 'YES', 109),\n",
" ('tr_statement', 'dbo', 'EP_WIND', 'S_PROFITNOTICE_CHANGEMAX', 6, 'float', 15, 8, None, 10, 1, None, None, 6, None, None, 7, 'YES', 109),\n",
" ('tr_statement', 'dbo', 'EP_WIND', 'S_PROFITNOTICE_NETPROFITMIN', 6, 'float', 15, 8, None, 10, 1, None, None, 6, None, None, 8, 'YES', 109),\n",
" ('tr_statement', 'dbo', 'EP_WIND', 'S_PROFITNOTICE_NETPROFITMAX', 6, 'float', 15, 8, None, 10, 1, None, None, 6, None, None, 9, 'YES', 109),\n",
" ('tr_statement', 'dbo', 'EP_WIND', 'S_PROFITNOTICE_REASON', -1, 'text', 2147483647, 2147483647, None, None, 1, None, None, -1, None, 2147483647, 10, 'YES', 35)]\n"
]
}
],
"source": [
"with engine.connect() as conn:\n",
" rs = conn.execute(\"EXEC sp_columns EP_WIND\").fetchall()\n",
"\n",
"pprint(rs)"
]
},
{
"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": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th>appear_in_period</th>\n",
" <th>TOT_OPER_REV</th>\n",
" <th>OPER_REV</th>\n",
" <th>INT_INC</th>\n",
" <th>INSUR_PREM_UNEARNED</th>\n",
" <th>HANDLING_CHRG_COMM_INC</th>\n",
" <th>NET_INC_OTHER_OPS</th>\n",
" <th>PLUS_NET_INC_OTHER_BUS</th>\n",
" <th>PLUS_NET_GAIN_CHG_FV</th>\n",
" <th>PLUS_NET_INVEST_INC</th>\n",
" <th>...</th>\n",
" <th>OTHER_INCOME</th>\n",
" <th>MEMO</th>\n",
" <th>ASSET_DISPOSAL_INCOME</th>\n",
" <th>CONTINUED_NET_PROFIT</th>\n",
" <th>END_NET_PROFIT</th>\n",
" <th>CREDIT_IMPAIRMENT_LOSS</th>\n",
" <th>RD_EXPENSE</th>\n",
" <th>STMNOTE_FINEXP</th>\n",
" <th>FIN_EXP_INT_INC</th>\n",
" <th>TOT_OPER_COST2</th>\n",
" </tr>\n",
" <tr>\n",
" <th>code</th>\n",
" <th>report_period</th>\n",
" <th>appear_at_date</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>000400.SZ</th>\n",
" <th>2018-12-31</th>\n",
" <th>2019-03-29</th>\n",
" <td>2018-12-31</td>\n",
" <td>8.216559e+09</td>\n",
" <td>8.216559e+09</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>73932.94</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>73932.94</td>\n",
" <td>...</td>\n",
" <td>72773000.86</td>\n",
" <td>nan</td>\n",
" <td>0.00</td>\n",
" <td>2.737097e+08</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>3.350267e+08</td>\n",
" <td>45075829.77</td>\n",
" <td>0.0</td>\n",
" <td>7.967406e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>000558.SZ</th>\n",
" <th>2018-12-31</th>\n",
" <th>2019-04-26</th>\n",
" <td>2018-12-31</td>\n",
" <td>7.024741e+08</td>\n",
" <td>7.024741e+08</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>23984753.52</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>23984753.52</td>\n",
" <td>...</td>\n",
" <td>10174473.66</td>\n",
" <td>nan</td>\n",
" <td>-12902036.23</td>\n",
" <td>-5.424955e+07</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.000000e+00</td>\n",
" <td>39309311.59</td>\n",
" <td>0.0</td>\n",
" <td>6.444387e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>000677.SZ</th>\n",
" <th>2018-12-31</th>\n",
" <th>2019-03-29</th>\n",
" <td>2018-12-31</td>\n",
" <td>7.068198e+08</td>\n",
" <td>7.068198e+08</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>220497.76</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>220497.76</td>\n",
" <td>...</td>\n",
" <td>1157100.00</td>\n",
" <td>nan</td>\n",
" <td>-1852690.97</td>\n",
" <td>6.403690e+06</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>3.514984e+05</td>\n",
" <td>5234360.37</td>\n",
" <td>0.0</td>\n",
" <td>6.821367e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>000731.SZ</th>\n",
" <th>2018-12-31</th>\n",
" <th>2019-04-16</th>\n",
" <td>2018-12-31</td>\n",
" <td>2.639920e+09</td>\n",
" <td>2.639920e+09</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>4467512.66</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>4467512.66</td>\n",
" <td>...</td>\n",
" <td>3477372.43</td>\n",
" <td>nan</td>\n",
" <td>1992627.87</td>\n",
" <td>2.228619e+08</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.653546e+06</td>\n",
" <td>46581902.65</td>\n",
" <td>0.0</td>\n",
" <td>2.367904e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>000752.SZ</th>\n",
" <th>2018-12-31</th>\n",
" <th>2019-05-16</th>\n",
" <td>2018-12-31</td>\n",
" <td>3.231171e+08</td>\n",
" <td>3.231171e+08</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>-43852162.57</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>-43852162.57</td>\n",
" <td>...</td>\n",
" <td>136549.44</td>\n",
" <td>nan</td>\n",
" <td>0.00</td>\n",
" <td>-3.830619e+08</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.000000e+00</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>3.135966e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <th>...</th>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>688039.SH</th>\n",
" <th>2018-12-31</th>\n",
" <th>2019-11-22</th>\n",
" <td>2018-12-31</td>\n",
" <td>2.035519e+08</td>\n",
" <td>2.035519e+08</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>156599.67</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>156599.67</td>\n",
" <td>...</td>\n",
" <td>15702563.93</td>\n",
" <td>nan</td>\n",
" <td>0.00</td>\n",
" <td>6.389806e+07</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>3.660990e+07</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>1.511902e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>688368.SH</th>\n",
" <th>2018-12-31</th>\n",
" <th>2019-09-17</th>\n",
" <td>2018-12-31</td>\n",
" <td>7.665912e+08</td>\n",
" <td>7.665912e+08</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>972435.31</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>972435.31</td>\n",
" <td>...</td>\n",
" <td>6568742.64</td>\n",
" <td>nan</td>\n",
" <td>0.00</td>\n",
" <td>0.000000e+00</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>6.081719e+07</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>6.890894e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>688396.SH</th>\n",
" <th>2018-12-31</th>\n",
" <th>2020-01-31</th>\n",
" <td>2018-12-31</td>\n",
" <td>6.270797e+09</td>\n",
" <td>6.270797e+09</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>10592096.66</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>10592096.66</td>\n",
" <td>...</td>\n",
" <td>91086261.29</td>\n",
" <td>nan</td>\n",
" <td>9434573.46</td>\n",
" <td>0.000000e+00</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>4.497610e+08</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>5.796301e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>831010.NE</th>\n",
" <th>2018-12-31</th>\n",
" <th>2020-07-01</th>\n",
" <td>2018-12-31</td>\n",
" <td>2.936331e+08</td>\n",
" <td>2.936331e+08</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>262112.16</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>262112.16</td>\n",
" <td>...</td>\n",
" <td>380000.00</td>\n",
" <td>nan</td>\n",
" <td>-258845.78</td>\n",
" <td>4.129632e+07</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>5.236440e+05</td>\n",
" <td>254556.29</td>\n",
" <td>0.0</td>\n",
" <td>2.437095e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>833874.NE</th>\n",
" <th>2018-12-31</th>\n",
" <th>2020-06-29</th>\n",
" <td>2018-12-31</td>\n",
" <td>1.974978e+08</td>\n",
" <td>1.974978e+08</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>5841180.61</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>5841180.61</td>\n",
" <td>...</td>\n",
" <td>882100.00</td>\n",
" <td>nan</td>\n",
" <td>9554.96</td>\n",
" <td>9.051358e+07</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.092805e+07</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>1.021658e+08</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>91 rows × 66 columns</p>\n",
"</div>"
],
"text/plain": [
" appear_in_period TOT_OPER_REV \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 2018-12-31 8.216559e+09 \n",
"000558.SZ 2018-12-31 2019-04-26 2018-12-31 7.024741e+08 \n",
"000677.SZ 2018-12-31 2019-03-29 2018-12-31 7.068198e+08 \n",
"000731.SZ 2018-12-31 2019-04-16 2018-12-31 2.639920e+09 \n",
"000752.SZ 2018-12-31 2019-05-16 2018-12-31 3.231171e+08 \n",
"... ... ... \n",
"688039.SH 2018-12-31 2019-11-22 2018-12-31 2.035519e+08 \n",
"688368.SH 2018-12-31 2019-09-17 2018-12-31 7.665912e+08 \n",
"688396.SH 2018-12-31 2020-01-31 2018-12-31 6.270797e+09 \n",
"831010.NE 2018-12-31 2020-07-01 2018-12-31 2.936331e+08 \n",
"833874.NE 2018-12-31 2020-06-29 2018-12-31 1.974978e+08 \n",
"\n",
" OPER_REV INT_INC \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 8.216559e+09 0.0 \n",
"000558.SZ 2018-12-31 2019-04-26 7.024741e+08 0.0 \n",
"000677.SZ 2018-12-31 2019-03-29 7.068198e+08 0.0 \n",
"000731.SZ 2018-12-31 2019-04-16 2.639920e+09 0.0 \n",
"000752.SZ 2018-12-31 2019-05-16 3.231171e+08 0.0 \n",
"... ... ... \n",
"688039.SH 2018-12-31 2019-11-22 2.035519e+08 0.0 \n",
"688368.SH 2018-12-31 2019-09-17 7.665912e+08 0.0 \n",
"688396.SH 2018-12-31 2020-01-31 6.270797e+09 0.0 \n",
"831010.NE 2018-12-31 2020-07-01 2.936331e+08 0.0 \n",
"833874.NE 2018-12-31 2020-06-29 1.974978e+08 0.0 \n",
"\n",
" INSUR_PREM_UNEARNED \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 0.0 \n",
"000558.SZ 2018-12-31 2019-04-26 0.0 \n",
"000677.SZ 2018-12-31 2019-03-29 0.0 \n",
"000731.SZ 2018-12-31 2019-04-16 0.0 \n",
"000752.SZ 2018-12-31 2019-05-16 0.0 \n",
"... ... \n",
"688039.SH 2018-12-31 2019-11-22 0.0 \n",
"688368.SH 2018-12-31 2019-09-17 0.0 \n",
"688396.SH 2018-12-31 2020-01-31 0.0 \n",
"831010.NE 2018-12-31 2020-07-01 0.0 \n",
"833874.NE 2018-12-31 2020-06-29 0.0 \n",
"\n",
" HANDLING_CHRG_COMM_INC \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 0.0 \n",
"000558.SZ 2018-12-31 2019-04-26 0.0 \n",
"000677.SZ 2018-12-31 2019-03-29 0.0 \n",
"000731.SZ 2018-12-31 2019-04-16 0.0 \n",
"000752.SZ 2018-12-31 2019-05-16 0.0 \n",
"... ... \n",
"688039.SH 2018-12-31 2019-11-22 0.0 \n",
"688368.SH 2018-12-31 2019-09-17 0.0 \n",
"688396.SH 2018-12-31 2020-01-31 0.0 \n",
"831010.NE 2018-12-31 2020-07-01 0.0 \n",
"833874.NE 2018-12-31 2020-06-29 0.0 \n",
"\n",
" NET_INC_OTHER_OPS \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 73932.94 \n",
"000558.SZ 2018-12-31 2019-04-26 23984753.52 \n",
"000677.SZ 2018-12-31 2019-03-29 220497.76 \n",
"000731.SZ 2018-12-31 2019-04-16 4467512.66 \n",
"000752.SZ 2018-12-31 2019-05-16 -43852162.57 \n",
"... ... \n",
"688039.SH 2018-12-31 2019-11-22 156599.67 \n",
"688368.SH 2018-12-31 2019-09-17 972435.31 \n",
"688396.SH 2018-12-31 2020-01-31 10592096.66 \n",
"831010.NE 2018-12-31 2020-07-01 262112.16 \n",
"833874.NE 2018-12-31 2020-06-29 5841180.61 \n",
"\n",
" PLUS_NET_INC_OTHER_BUS \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 0.0 \n",
"000558.SZ 2018-12-31 2019-04-26 0.0 \n",
"000677.SZ 2018-12-31 2019-03-29 0.0 \n",
"000731.SZ 2018-12-31 2019-04-16 0.0 \n",
"000752.SZ 2018-12-31 2019-05-16 0.0 \n",
"... ... \n",
"688039.SH 2018-12-31 2019-11-22 0.0 \n",
"688368.SH 2018-12-31 2019-09-17 0.0 \n",
"688396.SH 2018-12-31 2020-01-31 0.0 \n",
"831010.NE 2018-12-31 2020-07-01 0.0 \n",
"833874.NE 2018-12-31 2020-06-29 0.0 \n",
"\n",
" PLUS_NET_GAIN_CHG_FV \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 0.0 \n",
"000558.SZ 2018-12-31 2019-04-26 0.0 \n",
"000677.SZ 2018-12-31 2019-03-29 0.0 \n",
"000731.SZ 2018-12-31 2019-04-16 0.0 \n",
"000752.SZ 2018-12-31 2019-05-16 0.0 \n",
"... ... \n",
"688039.SH 2018-12-31 2019-11-22 0.0 \n",
"688368.SH 2018-12-31 2019-09-17 0.0 \n",
"688396.SH 2018-12-31 2020-01-31 0.0 \n",
"831010.NE 2018-12-31 2020-07-01 0.0 \n",
"833874.NE 2018-12-31 2020-06-29 0.0 \n",
"\n",
" PLUS_NET_INVEST_INC ... \\\n",
"code report_period appear_at_date ... \n",
"000400.SZ 2018-12-31 2019-03-29 73932.94 ... \n",
"000558.SZ 2018-12-31 2019-04-26 23984753.52 ... \n",
"000677.SZ 2018-12-31 2019-03-29 220497.76 ... \n",
"000731.SZ 2018-12-31 2019-04-16 4467512.66 ... \n",
"000752.SZ 2018-12-31 2019-05-16 -43852162.57 ... \n",
"... ... ... \n",
"688039.SH 2018-12-31 2019-11-22 156599.67 ... \n",
"688368.SH 2018-12-31 2019-09-17 972435.31 ... \n",
"688396.SH 2018-12-31 2020-01-31 10592096.66 ... \n",
"831010.NE 2018-12-31 2020-07-01 262112.16 ... \n",
"833874.NE 2018-12-31 2020-06-29 5841180.61 ... \n",
"\n",
" OTHER_INCOME MEMO \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 72773000.86 nan \n",
"000558.SZ 2018-12-31 2019-04-26 10174473.66 nan \n",
"000677.SZ 2018-12-31 2019-03-29 1157100.00 nan \n",
"000731.SZ 2018-12-31 2019-04-16 3477372.43 nan \n",
"000752.SZ 2018-12-31 2019-05-16 136549.44 nan \n",
"... ... ... \n",
"688039.SH 2018-12-31 2019-11-22 15702563.93 nan \n",
"688368.SH 2018-12-31 2019-09-17 6568742.64 nan \n",
"688396.SH 2018-12-31 2020-01-31 91086261.29 nan \n",
"831010.NE 2018-12-31 2020-07-01 380000.00 nan \n",
"833874.NE 2018-12-31 2020-06-29 882100.00 nan \n",
"\n",
" ASSET_DISPOSAL_INCOME \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 0.00 \n",
"000558.SZ 2018-12-31 2019-04-26 -12902036.23 \n",
"000677.SZ 2018-12-31 2019-03-29 -1852690.97 \n",
"000731.SZ 2018-12-31 2019-04-16 1992627.87 \n",
"000752.SZ 2018-12-31 2019-05-16 0.00 \n",
"... ... \n",
"688039.SH 2018-12-31 2019-11-22 0.00 \n",
"688368.SH 2018-12-31 2019-09-17 0.00 \n",
"688396.SH 2018-12-31 2020-01-31 9434573.46 \n",
"831010.NE 2018-12-31 2020-07-01 -258845.78 \n",
"833874.NE 2018-12-31 2020-06-29 9554.96 \n",
"\n",
" CONTINUED_NET_PROFIT END_NET_PROFIT \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 2.737097e+08 0.0 \n",
"000558.SZ 2018-12-31 2019-04-26 -5.424955e+07 0.0 \n",
"000677.SZ 2018-12-31 2019-03-29 6.403690e+06 0.0 \n",
"000731.SZ 2018-12-31 2019-04-16 2.228619e+08 0.0 \n",
"000752.SZ 2018-12-31 2019-05-16 -3.830619e+08 0.0 \n",
"... ... ... \n",
"688039.SH 2018-12-31 2019-11-22 6.389806e+07 0.0 \n",
"688368.SH 2018-12-31 2019-09-17 0.000000e+00 0.0 \n",
"688396.SH 2018-12-31 2020-01-31 0.000000e+00 0.0 \n",
"831010.NE 2018-12-31 2020-07-01 4.129632e+07 0.0 \n",
"833874.NE 2018-12-31 2020-06-29 9.051358e+07 0.0 \n",
"\n",
" CREDIT_IMPAIRMENT_LOSS RD_EXPENSE \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 0.0 3.350267e+08 \n",
"000558.SZ 2018-12-31 2019-04-26 0.0 0.000000e+00 \n",
"000677.SZ 2018-12-31 2019-03-29 0.0 3.514984e+05 \n",
"000731.SZ 2018-12-31 2019-04-16 0.0 1.653546e+06 \n",
"000752.SZ 2018-12-31 2019-05-16 0.0 0.000000e+00 \n",
"... ... ... \n",
"688039.SH 2018-12-31 2019-11-22 0.0 3.660990e+07 \n",
"688368.SH 2018-12-31 2019-09-17 0.0 6.081719e+07 \n",
"688396.SH 2018-12-31 2020-01-31 0.0 4.497610e+08 \n",
"831010.NE 2018-12-31 2020-07-01 0.0 5.236440e+05 \n",
"833874.NE 2018-12-31 2020-06-29 0.0 1.092805e+07 \n",
"\n",
" STMNOTE_FINEXP FIN_EXP_INT_INC \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 45075829.77 0.0 \n",
"000558.SZ 2018-12-31 2019-04-26 39309311.59 0.0 \n",
"000677.SZ 2018-12-31 2019-03-29 5234360.37 0.0 \n",
"000731.SZ 2018-12-31 2019-04-16 46581902.65 0.0 \n",
"000752.SZ 2018-12-31 2019-05-16 0.00 0.0 \n",
"... ... ... \n",
"688039.SH 2018-12-31 2019-11-22 0.00 0.0 \n",
"688368.SH 2018-12-31 2019-09-17 0.00 0.0 \n",
"688396.SH 2018-12-31 2020-01-31 0.00 0.0 \n",
"831010.NE 2018-12-31 2020-07-01 254556.29 0.0 \n",
"833874.NE 2018-12-31 2020-06-29 0.00 0.0 \n",
"\n",
" TOT_OPER_COST2 \n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 7.967406e+09 \n",
"000558.SZ 2018-12-31 2019-04-26 6.444387e+08 \n",
"000677.SZ 2018-12-31 2019-03-29 6.821367e+08 \n",
"000731.SZ 2018-12-31 2019-04-16 2.367904e+09 \n",
"000752.SZ 2018-12-31 2019-05-16 3.135966e+08 \n",
"... ... \n",
"688039.SH 2018-12-31 2019-11-22 1.511902e+08 \n",
"688368.SH 2018-12-31 2019-09-17 6.890894e+08 \n",
"688396.SH 2018-12-31 2020-01-31 5.796301e+09 \n",
"831010.NE 2018-12-31 2020-07-01 2.437095e+08 \n",
"833874.NE 2018-12-31 2020-06-29 1.021658e+08 \n",
"\n",
"[91 rows x 66 columns]"
]
},
"execution_count": 44,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#sess.run(\"\"\"\n",
"# is_common_ori = loadTable(\"dfs://pit_stock_ts\", \"is_common_ori\")\n",
"#\"\"\")\n",
"\n",
"# pit_report_period_at_date(table_name, date, report_period_list, code_partition_id)\n",
"sess.run(\"\"\"\n",
" select * from pit_at_date(\"is_common_ori\", 2021.03.14, [2018.12.31], 0) order by code\n",
"\"\"\").set_index(['code', 'report_period', 'appear_at_date'])"
]
},
{
"cell_type": "code",
"execution_count": 70,
"id": "4cd4cd6e-f34e-43a8-98de-c468a54d8081",
"metadata": {},
"outputs": [],
"source": [
"sess.run(\"\"\"\n",
" dropFunctionView('pit_col_at_date');\n",
"\"\"\")\n",
"\n",
"sess.run(\"\"\"\n",
"def pit_col_at_date(table_name, col_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(\n",
" query_table, \n",
" select code from source_table where partition(code, code_partition_id\n",
" ) group by code map);\n",
"\t\n",
"\tcol_list = sqlCol(['code', 'report_period', 'appear_at_date', col_name]);\n",
" from_tbl = <ej(source_table, query_table_exp, `code`report_period)>;\n",
" where_conditions = [<partition(code, code_partition_id)>];\n",
" source_table_part = sql(select=col_list, from=from_tbl, where=where_conditions).eval();\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_col_at_date);\n",
"\"\"\")"
]
},
{
"cell_type": "code",
"execution_count": 71,
"id": "943b760a-ab39-4291-8a93-81b3e38a70b7",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th>TOT_OPER_REV</th>\n",
" </tr>\n",
" <tr>\n",
" <th>code</th>\n",
" <th>report_period</th>\n",
" <th>appear_at_date</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>000400.SZ</th>\n",
" <th>2019-09-30</th>\n",
" <th>2020-10-29</th>\n",
" <td>5.658881e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>000558.SZ</th>\n",
" <th>2019-09-30</th>\n",
" <th>2020-10-29</th>\n",
" <td>8.322244e+07</td>\n",
" </tr>\n",
" <tr>\n",
" <th>000677.SZ</th>\n",
" <th>2019-09-30</th>\n",
" <th>2020-10-21</th>\n",
" <td>6.020088e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>000731.SZ</th>\n",
" <th>2019-09-30</th>\n",
" <th>2020-10-27</th>\n",
" <td>2.311672e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>000752.SZ</th>\n",
" <th>2019-09-30</th>\n",
" <th>2020-10-29</th>\n",
" <td>2.330136e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <th>...</th>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>688039.SH</th>\n",
" <th>2019-09-30</th>\n",
" <th>2020-10-28</th>\n",
" <td>1.185143e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>688368.SH</th>\n",
" <th>2019-09-30</th>\n",
" <th>2020-10-28</th>\n",
" <td>6.139719e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>688396.SH</th>\n",
" <th>2019-09-30</th>\n",
" <th>2020-10-20</th>\n",
" <td>4.131915e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>831010.NE</th>\n",
" <th>2019-09-30</th>\n",
" <th>2020-10-29</th>\n",
" <td>2.276040e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>833874.NE</th>\n",
" <th>2019-09-30</th>\n",
" <th>2020-10-26</th>\n",
" <td>1.303494e+08</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>91 rows × 1 columns</p>\n",
"</div>"
],
"text/plain": [
" TOT_OPER_REV\n",
"code report_period appear_at_date \n",
"000400.SZ 2019-09-30 2020-10-29 5.658881e+09\n",
"000558.SZ 2019-09-30 2020-10-29 8.322244e+07\n",
"000677.SZ 2019-09-30 2020-10-21 6.020088e+08\n",
"000731.SZ 2019-09-30 2020-10-27 2.311672e+09\n",
"000752.SZ 2019-09-30 2020-10-29 2.330136e+08\n",
"... ...\n",
"688039.SH 2019-09-30 2020-10-28 1.185143e+08\n",
"688368.SH 2019-09-30 2020-10-28 6.139719e+08\n",
"688396.SH 2019-09-30 2020-10-20 4.131915e+09\n",
"831010.NE 2019-09-30 2020-10-29 2.276040e+08\n",
"833874.NE 2019-09-30 2020-10-26 1.303494e+08\n",
"\n",
"[91 rows x 1 columns]"
]
},
"execution_count": 71,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sess.run(\"\"\"\n",
" select * from pit_col_at_date(\"is_common_adj\", \"TOT_OPER_REV\", 2021.03.14, [2019.09.30], 0) order by code\n",
"\"\"\").set_index(['code', 'report_period', 'appear_at_date'])"
]
},
{
"cell_type": "code",
"execution_count": 59,
"id": "2fea0f1e-5105-4d28-9c36-c5542a5389ba",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>code</th>\n",
" <th>report_period</th>\n",
" <th>appear_in_period</th>\n",
" <th>appear_at_date</th>\n",
" <th>TOT_OPER_REV</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>000400.SZ</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-04-10</td>\n",
" <td>1.015608e+10</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>000558.SZ</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-04-27</td>\n",
" <td>1.378479e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>000558.SZ</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-08-25</td>\n",
" <td>1.378479e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>000677.SZ</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-04-25</td>\n",
" <td>7.906742e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>000731.SZ</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-04-24</td>\n",
" <td>2.929131e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>109</th>\n",
" <td>688396.SH</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-04-23</td>\n",
" <td>5.742784e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>110</th>\n",
" <td>831010.NE</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-04-13</td>\n",
" <td>3.552313e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>111</th>\n",
" <td>831010.NE</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-07-01</td>\n",
" <td>3.552313e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>112</th>\n",
" <td>833874.NE</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-03-18</td>\n",
" <td>1.785113e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>113</th>\n",
" <td>833874.NE</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-06-29</td>\n",
" <td>1.785113e+08</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>114 rows × 5 columns</p>\n",
"</div>"
],
"text/plain": [
" code report_period appear_in_period appear_at_date TOT_OPER_REV\n",
"0 000400.SZ 2019-12-31 2019-12-31 2020-04-10 1.015608e+10\n",
"1 000558.SZ 2019-12-31 2019-12-31 2020-04-27 1.378479e+08\n",
"2 000558.SZ 2019-12-31 2019-12-31 2020-08-25 1.378479e+08\n",
"3 000677.SZ 2019-12-31 2019-12-31 2020-04-25 7.906742e+08\n",
"4 000731.SZ 2019-12-31 2019-12-31 2020-04-24 2.929131e+09\n",
".. ... ... ... ... ...\n",
"109 688396.SH 2019-12-31 2019-12-31 2020-04-23 5.742784e+09\n",
"110 831010.NE 2019-12-31 2019-12-31 2020-04-13 3.552313e+08\n",
"111 831010.NE 2019-12-31 2019-12-31 2020-07-01 3.552313e+08\n",
"112 833874.NE 2019-12-31 2019-12-31 2020-03-18 1.785113e+08\n",
"113 833874.NE 2019-12-31 2019-12-31 2020-06-29 1.785113e+08\n",
"\n",
"[114 rows x 5 columns]"
]
},
"execution_count": 59,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sess.run(\"\"\"\n",
" source_table = loadTable(\"dfs://pit_stock_ts\", \"is_common_ori\");\n",
" m_nDate = [2022.03.04]\n",
" report_period = [2019.12.31]\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, 0) group by code map);\n",
"\t\n",
" \n",
" col_list = sqlCol(['code', 'report_period', 'appear_in_period', 'appear_at_date', 'TOT_OPER_REV']);\n",
" from_tbl = <ej(source_table, query_table_exp, `code`report_period)>;\n",
" where_conditions = [<partition(code, 0)>];\n",
" source_table_part = sql(select=col_list, from=from_tbl, where=where_conditions).eval();\n",
"\tsource_table_part\n",
"\"\"\")"
]
},
{
"cell_type": "code",
"execution_count": 181,
"id": "3c246940-1ad6-414f-b461-2d8ca7cd87f1",
"metadata": {},
"outputs": [],
"source": [
"sess.run(\"\"\"\n",
" def single_quarter(table_name, col_list) {\n",
" \n",
" sel_col = array(ANY, 4 + size(col_list));\n",
" sel_col[0] = sqlCol('code');\n",
" sel_col[2] = sqlColAlias(<year(report_period)>, 'year');\n",
" \n",
" for (i in 0..(size(col_list) - 1)) {\n",
" sel_col[i + 4] = sqlCol(col_list[i]);\n",
" }\n",
"\n",
" // 当季累计数据,作为下一季基准\n",
" sel_col[1] = sqlColAlias(sqlCol('report_period'), 'base_report_period');\n",
" sel_col[3] = sqlColAlias(<quarterOfYear(report_period) + 1>, 'quarter_of_year');\n",
" tbl_quarter_accum_base = sql(\n",
" select = sel_col,\n",
" from = table_name,\n",
" where = <quarterOfYear(report_period) < 4>\n",
" ).eval();\n",
"\n",
" // 从第二季开始,需要去匹配前一季累计基数\n",
" sel_col[1] = sqlColAlias(sqlCol('report_period'), 'current_report_period');\n",
" sel_col[3] = sqlColAlias(<quarterOfYear(report_period)>, 'quarter_of_year');\n",
" tbl_quarter_accum = sql(\n",
" select = sel_col,\n",
" from = table_name,\n",
" where = <quarterOfYear(report_period) > 1>\n",
" ).eval();\n",
"\n",
" // 单季流量,把非第一季的季报都要扣除前一季度的基数\n",
" sel_col[1] = sqlColAlias(sqlCol('current_report_period'), 'report_period');\n",
" sel_col[2] = sqlCol('year');\n",
" sel_col[3] = sqlCol('quarter_of_year');\n",
" for (i in 0..(size(col_list) - 1)) {\n",
" sel_col[i + 4] = sqlColAlias(\n",
" expr(\n",
" sqlCol('tbl_quarter_accum_' + col_list[i]),\n",
" -,\n",
" sqlCol(col_list[i])\n",
" )\n",
" , col_list[i] + '_flux');\n",
" }\n",
" from_obj = ej(\n",
" tbl_quarter_accum_base, \n",
" tbl_quarter_accum, \n",
" `code`year`quarter_of_year, \n",
" `code`year`quarter_of_year);\n",
" tbl_quarter_flux = sql(\n",
" select = sel_col, \n",
" from = from_obj\n",
" ).eval();\n",
"\n",
" // 每年第一个季度\n",
" sel_col[1] = sqlCol('report_period');\n",
" sel_col[2] = sqlColAlias(<year(report_period)>, 'year');\n",
" sel_col[3] = sqlColAlias(<quarterOfYear(report_period)>, 'quarter_of_year');\n",
" for (i in 0..(size(col_list) - 1)) {\n",
" sel_col[i + 4] = sqlColAlias(sqlCol(col_list[i]), col_list[i] + '_flux');\n",
" }\n",
" tbl_quarter1 = sql(\n",
" select = sel_col,\n",
" from = table_name,\n",
" where = <quarterOfYear(report_period) == 1>\n",
" ).eval();\n",
" \n",
" // 再拼接回第一季度(无需扣除基数的数据)\n",
" tbl_quarter_flux = unionAll(\n",
" tbl_quarter1, \n",
" tbl_quarter_flux\n",
" );\n",
" \n",
" return tbl_quarter_flux;\n",
" }\n",
"\"\"\")"
]
},
{
"cell_type": "code",
"execution_count": 182,
"id": "981c8b85-a750-4d6b-bed9-c2567a95b2a3",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>code</th>\n",
" <th>report_period</th>\n",
" <th>year</th>\n",
" <th>quarter_of_year</th>\n",
" <th>TOT_OPER_REV_flux</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>000400.SZ</td>\n",
" <td>2019-03-31</td>\n",
" <td>2019</td>\n",
" <td>1</td>\n",
" <td>1.032565e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>82</th>\n",
" <td>000400.SZ</td>\n",
" <td>2019-06-30</td>\n",
" <td>2019</td>\n",
" <td>2</td>\n",
" <td>2.021923e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>81</th>\n",
" <td>000400.SZ</td>\n",
" <td>2019-09-30</td>\n",
" <td>2019</td>\n",
" <td>3</td>\n",
" <td>2.183729e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>80</th>\n",
" <td>000400.SZ</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019</td>\n",
" <td>4</td>\n",
" <td>4.917866e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>000558.SZ</td>\n",
" <td>2019-03-31</td>\n",
" <td>2019</td>\n",
" <td>1</td>\n",
" <td>2.361816e+07</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>321</th>\n",
" <td>688396.SH</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019</td>\n",
" <td>4</td>\n",
" <td>1.610869e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>79</th>\n",
" <td>833874.NE</td>\n",
" <td>2019-03-31</td>\n",
" <td>2019</td>\n",
" <td>1</td>\n",
" <td>3.720237e+07</td>\n",
" </tr>\n",
" <tr>\n",
" <th>325</th>\n",
" <td>833874.NE</td>\n",
" <td>2019-06-30</td>\n",
" <td>2019</td>\n",
" <td>2</td>\n",
" <td>4.538674e+07</td>\n",
" </tr>\n",
" <tr>\n",
" <th>324</th>\n",
" <td>833874.NE</td>\n",
" <td>2019-09-30</td>\n",
" <td>2019</td>\n",
" <td>3</td>\n",
" <td>4.776034e+07</td>\n",
" </tr>\n",
" <tr>\n",
" <th>323</th>\n",
" <td>833874.NE</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019</td>\n",
" <td>4</td>\n",
" <td>4.816188e+07</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>326 rows × 5 columns</p>\n",
"</div>"
],
"text/plain": [
" code report_period year quarter_of_year TOT_OPER_REV_flux\n",
"0 000400.SZ 2019-03-31 2019 1 1.032565e+09\n",
"82 000400.SZ 2019-06-30 2019 2 2.021923e+09\n",
"81 000400.SZ 2019-09-30 2019 3 2.183729e+09\n",
"80 000400.SZ 2019-12-31 2019 4 4.917866e+09\n",
"1 000558.SZ 2019-03-31 2019 1 2.361816e+07\n",
".. ... ... ... ... ...\n",
"321 688396.SH 2019-12-31 2019 4 1.610869e+09\n",
"79 833874.NE 2019-03-31 2019 1 3.720237e+07\n",
"325 833874.NE 2019-06-30 2019 2 4.538674e+07\n",
"324 833874.NE 2019-09-30 2019 3 4.776034e+07\n",
"323 833874.NE 2019-12-31 2019 4 4.816188e+07\n",
"\n",
"[326 rows x 5 columns]"
]
},
"execution_count": 182,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sess.run(\"single_quarter(tmp_table, ['TOT_OPER_REV'])\").sort_values(['code', 'report_period'])"
]
},
{
"cell_type": "code",
"execution_count": 144,
"id": "1ceea0a7-7218-4aa7-be8a-ebb655dcbc93",
"metadata": {},
"outputs": [],
"source": [
"sess.run(\"\"\"\n",
" tmp_table = select * from pit_col_at_date(\n",
" \"is_common_ori\", \n",
" \"TOT_OPER_REV\", \n",
" 2021.03.14, \n",
" [2019.12.31, 2019.09.30, 2019.06.30, 2019.03.31], \n",
" 0) order by code\n",
"\"\"\")"
]
},
{
"cell_type": "code",
"execution_count": 145,
"id": "d01d6fc2-15ed-4e40-9181-0f3e3a96d2cb",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>code</th>\n",
" <th>report_period</th>\n",
" <th>appear_at_date</th>\n",
" <th>TOT_OPER_REV</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>000400.SZ</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-04-10</td>\n",
" <td>1.015608e+10</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>000400.SZ</td>\n",
" <td>2019-09-30</td>\n",
" <td>2019-10-12</td>\n",
" <td>5.238217e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>000400.SZ</td>\n",
" <td>2019-06-30</td>\n",
" <td>2019-08-24</td>\n",
" <td>3.054488e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>000400.SZ</td>\n",
" <td>2019-03-31</td>\n",
" <td>2019-04-26</td>\n",
" <td>1.032565e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>000558.SZ</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-08-25</td>\n",
" <td>1.378479e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>333</th>\n",
" <td>831010.NE</td>\n",
" <td>2019-06-30</td>\n",
" <td>2019-08-09</td>\n",
" <td>1.970813e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>334</th>\n",
" <td>833874.NE</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-06-29</td>\n",
" <td>1.785113e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>335</th>\n",
" <td>833874.NE</td>\n",
" <td>2019-09-30</td>\n",
" <td>2019-10-22</td>\n",
" <td>1.303494e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>336</th>\n",
" <td>833874.NE</td>\n",
" <td>2019-06-30</td>\n",
" <td>2019-08-16</td>\n",
" <td>8.258911e+07</td>\n",
" </tr>\n",
" <tr>\n",
" <th>337</th>\n",
" <td>833874.NE</td>\n",
" <td>2019-03-31</td>\n",
" <td>2019-04-30</td>\n",
" <td>3.720237e+07</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>338 rows × 4 columns</p>\n",
"</div>"
],
"text/plain": [
" code report_period appear_at_date TOT_OPER_REV\n",
"0 000400.SZ 2019-12-31 2020-04-10 1.015608e+10\n",
"1 000400.SZ 2019-09-30 2019-10-12 5.238217e+09\n",
"2 000400.SZ 2019-06-30 2019-08-24 3.054488e+09\n",
"3 000400.SZ 2019-03-31 2019-04-26 1.032565e+09\n",
"4 000558.SZ 2019-12-31 2020-08-25 1.378479e+08\n",
".. ... ... ... ...\n",
"333 831010.NE 2019-06-30 2019-08-09 1.970813e+08\n",
"334 833874.NE 2019-12-31 2020-06-29 1.785113e+08\n",
"335 833874.NE 2019-09-30 2019-10-22 1.303494e+08\n",
"336 833874.NE 2019-06-30 2019-08-16 8.258911e+07\n",
"337 833874.NE 2019-03-31 2019-04-30 3.720237e+07\n",
"\n",
"[338 rows x 4 columns]"
]
},
"execution_count": 145,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sess.run(\"tmp_table\")"
]
},
{
"cell_type": "code",
"execution_count": 50,
"id": "5ac22809-9ba9-4a01-b76a-591558c4cc52",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'< select symbol,date,cumsum(volume) as cumVol from tmp_tablef0e858a3837f0000 >'"
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sess.run(\"\"\"\n",
"sql(select=sqlCol(['symbol', 'date', 'cumsum(volume) as cumVol']), from = tmp_table)\n",
"\"\"\")"
]
},
{
"cell_type": "code",
"execution_count": 51,
"id": "dc36ca56-07e0-4912-b5d2-da192a1c3c62",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'< select symbol,date,cumsum(volume) as cumVol from tmp_tablef0e858a3837f0000 >'"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sess.run(\"\"\"\n",
"sql(select=(sqlCol(`symbol),sqlCol(`date),sqlColAlias(<cumsum(volume)>, `cumVol)), from=tmp_table)\n",
"\"\"\")"
]
},
{
"cell_type": "code",
"execution_count": 211,
"id": "c3be05b5-c9b9-4df5-8481-b3092c25125e",
"metadata": {},
"outputs": [],
"source": [
"sess.run(\"\"\"\n",
" def yoy(table_name, col_list) {\n",
" sel_col = array(ANY, 4 + size(col_list));\n",
" sel_col[0] = sqlCol('code');\n",
" sel_col[3] = sqlColAlias(<quarterOfYear(report_period)>, 'quarter_of_year');\n",
" \n",
" // 上一年数据\n",
" for (i in 0..(size(col_list) - 1)) {\n",
" sel_col[i + 4] = sqlColAlias(sqlCol(col_list[i]), col_list[i] + '_base');\n",
" }\n",
" sel_col[1] = sqlColAlias(sqlCol('report_period'), 'report_period_last_year');\n",
" sel_col[2] = sqlColAlias(<year(report_period) + 1>, 'year');\n",
" tbl_last_year = sql(\n",
" select = sel_col,\n",
" from = table_name\n",
" ).eval();\n",
"\n",
" // 本年度数据\n",
" for (i in 0..(size(col_list) - 1)) {\n",
" sel_col[i + 4] = sqlCol(col_list[i]);\n",
" }\n",
" sel_col[1] = sqlColAlias(sqlCol('report_period'), 'report_period_current_year');\n",
" sel_col[2] = sqlColAlias(<year(report_period)>, 'year');\n",
" tbl_this_year = sql(\n",
" select = sel_col,\n",
" from = table_name\n",
" ).eval();\n",
" \n",
" // 计算同比增长率\n",
" sel_col = array(ANY, 4 + (3 * size(col_list)));\n",
"\n",
" sel_col[0] = sqlCol('code');\n",
" sel_col[1] = sqlColAlias(sqlCol('report_period_current_year'), 'report_period');\n",
" sel_col[2] = sqlCol('year');\n",
" sel_col[3] = sqlCol('quarter_of_year');\n",
" \n",
" for (i in 0..(size(col_list) - 1)) {\n",
" sel_col[3 * i + 4] = sqlCol(col_list[i] + '_base');\n",
" sel_col[3 * i + 5] = sqlCol(col_list[i]);\n",
" sel_col[3 * i + 6] = sqlColAlias(\n",
" expr(expr(sqlCol(col_list[i]), -, sqlCol(col_list[i] + '_base')), /, expr(abs, sqlCol(col_list[i] + '_base'))), \n",
" col_list[i] + '_yoy');\n",
" }\n",
" from_obj = ej(\n",
" tbl_last_year, \n",
" tbl_this_year, \n",
" `code`year`quarter_of_year, \n",
" `code`year`quarter_of_year);\n",
" \n",
" return sql(\n",
" select = sel_col,\n",
" from = from_obj).eval();\n",
" }\n",
"\"\"\")"
]
},
{
"cell_type": "code",
"execution_count": 212,
"id": "63492d0c-c348-4e8b-a08b-5feb279cee5e",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>code</th>\n",
" <th>report_period</th>\n",
" <th>year</th>\n",
" <th>quarter_of_year</th>\n",
" <th>TOT_OPER_REV_base</th>\n",
" <th>TOT_OPER_REV</th>\n",
" <th>TOT_OPER_REV_yoy</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>000400.SZ</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019</td>\n",
" <td>4</td>\n",
" <td>8.216559e+09</td>\n",
" <td>1.015608e+10</td>\n",
" <td>0.236051</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>000400.SZ</td>\n",
" <td>2018-12-31</td>\n",
" <td>2018</td>\n",
" <td>4</td>\n",
" <td>1.033072e+10</td>\n",
" <td>8.216559e+09</td>\n",
" <td>-0.204648</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>000558.SZ</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019</td>\n",
" <td>4</td>\n",
" <td>7.024741e+08</td>\n",
" <td>1.378479e+08</td>\n",
" <td>-0.803768</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>000558.SZ</td>\n",
" <td>2018-12-31</td>\n",
" <td>2018</td>\n",
" <td>4</td>\n",
" <td>1.324249e+09</td>\n",
" <td>7.024741e+08</td>\n",
" <td>-0.469530</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>000677.SZ</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019</td>\n",
" <td>4</td>\n",
" <td>7.068198e+08</td>\n",
" <td>7.906742e+08</td>\n",
" <td>0.118636</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>177</th>\n",
" <td>688396.SH</td>\n",
" <td>2018-12-31</td>\n",
" <td>2018</td>\n",
" <td>4</td>\n",
" <td>5.875590e+09</td>\n",
" <td>6.270797e+09</td>\n",
" <td>0.067262</td>\n",
" </tr>\n",
" <tr>\n",
" <th>178</th>\n",
" <td>831010.NE</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019</td>\n",
" <td>4</td>\n",
" <td>2.936331e+08</td>\n",
" <td>3.552313e+08</td>\n",
" <td>0.209780</td>\n",
" </tr>\n",
" <tr>\n",
" <th>179</th>\n",
" <td>831010.NE</td>\n",
" <td>2018-12-31</td>\n",
" <td>2018</td>\n",
" <td>4</td>\n",
" <td>2.209252e+08</td>\n",
" <td>2.936331e+08</td>\n",
" <td>0.329106</td>\n",
" </tr>\n",
" <tr>\n",
" <th>180</th>\n",
" <td>833874.NE</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019</td>\n",
" <td>4</td>\n",
" <td>1.974978e+08</td>\n",
" <td>1.785113e+08</td>\n",
" <td>-0.096135</td>\n",
" </tr>\n",
" <tr>\n",
" <th>181</th>\n",
" <td>833874.NE</td>\n",
" <td>2018-12-31</td>\n",
" <td>2018</td>\n",
" <td>4</td>\n",
" <td>1.986075e+08</td>\n",
" <td>1.974978e+08</td>\n",
" <td>-0.005588</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>182 rows × 7 columns</p>\n",
"</div>"
],
"text/plain": [
" code report_period year quarter_of_year TOT_OPER_REV_base \\\n",
"0 000400.SZ 2019-12-31 2019 4 8.216559e+09 \n",
"1 000400.SZ 2018-12-31 2018 4 1.033072e+10 \n",
"2 000558.SZ 2019-12-31 2019 4 7.024741e+08 \n",
"3 000558.SZ 2018-12-31 2018 4 1.324249e+09 \n",
"4 000677.SZ 2019-12-31 2019 4 7.068198e+08 \n",
".. ... ... ... ... ... \n",
"177 688396.SH 2018-12-31 2018 4 5.875590e+09 \n",
"178 831010.NE 2019-12-31 2019 4 2.936331e+08 \n",
"179 831010.NE 2018-12-31 2018 4 2.209252e+08 \n",
"180 833874.NE 2019-12-31 2019 4 1.974978e+08 \n",
"181 833874.NE 2018-12-31 2018 4 1.986075e+08 \n",
"\n",
" TOT_OPER_REV TOT_OPER_REV_yoy \n",
"0 1.015608e+10 0.236051 \n",
"1 8.216559e+09 -0.204648 \n",
"2 1.378479e+08 -0.803768 \n",
"3 7.024741e+08 -0.469530 \n",
"4 7.906742e+08 0.118636 \n",
".. ... ... \n",
"177 6.270797e+09 0.067262 \n",
"178 3.552313e+08 0.209780 \n",
"179 2.936331e+08 0.329106 \n",
"180 1.785113e+08 -0.096135 \n",
"181 1.974978e+08 -0.005588 \n",
"\n",
"[182 rows x 7 columns]"
]
},
"execution_count": 212,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sess.run(\"yoy(tmp_table, ['TOT_OPER_REV'])\")"
]
},
{
"cell_type": "code",
"execution_count": 183,
"id": "5273ebfc-25bd-4b38-9605-d3109cf2280f",
"metadata": {},
"outputs": [],
"source": [
"sess.run(\"\"\"\n",
" tmp_table = select * from pit_col_at_date(\n",
" \"is_common_ori\", \n",
" \"TOT_OPER_REV\", \n",
" 2021.03.14, \n",
" [2019.12.31, 2018.12.31, 2017.12.31], \n",
" 0) order by code\n",
"\"\"\")"
]
},
{
"cell_type": "code",
"execution_count": 184,
"id": "99af13cd-5918-4d21-9067-d3da86d19c15",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>code</th>\n",
" <th>report_period</th>\n",
" <th>appear_at_date</th>\n",
" <th>TOT_OPER_REV</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>000400.SZ</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-04-10</td>\n",
" <td>1.015608e+10</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>000400.SZ</td>\n",
" <td>2018-12-31</td>\n",
" <td>2019-03-29</td>\n",
" <td>8.216559e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>000400.SZ</td>\n",
" <td>2017-12-31</td>\n",
" <td>2018-03-24</td>\n",
" <td>1.033072e+10</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>000558.SZ</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-08-25</td>\n",
" <td>1.378479e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>000558.SZ</td>\n",
" <td>2018-12-31</td>\n",
" <td>2019-04-26</td>\n",
" <td>7.024741e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>268</th>\n",
" <td>831010.NE</td>\n",
" <td>2018-12-31</td>\n",
" <td>2020-07-01</td>\n",
" <td>2.936331e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>269</th>\n",
" <td>831010.NE</td>\n",
" <td>2017-12-31</td>\n",
" <td>2020-07-01</td>\n",
" <td>2.209252e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>270</th>\n",
" <td>833874.NE</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-06-29</td>\n",
" <td>1.785113e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>271</th>\n",
" <td>833874.NE</td>\n",
" <td>2018-12-31</td>\n",
" <td>2020-06-29</td>\n",
" <td>1.974978e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>272</th>\n",
" <td>833874.NE</td>\n",
" <td>2017-12-31</td>\n",
" <td>2020-06-29</td>\n",
" <td>1.986075e+08</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>273 rows × 4 columns</p>\n",
"</div>"
],
"text/plain": [
" code report_period appear_at_date TOT_OPER_REV\n",
"0 000400.SZ 2019-12-31 2020-04-10 1.015608e+10\n",
"1 000400.SZ 2018-12-31 2019-03-29 8.216559e+09\n",
"2 000400.SZ 2017-12-31 2018-03-24 1.033072e+10\n",
"3 000558.SZ 2019-12-31 2020-08-25 1.378479e+08\n",
"4 000558.SZ 2018-12-31 2019-04-26 7.024741e+08\n",
".. ... ... ... ...\n",
"268 831010.NE 2018-12-31 2020-07-01 2.936331e+08\n",
"269 831010.NE 2017-12-31 2020-07-01 2.209252e+08\n",
"270 833874.NE 2019-12-31 2020-06-29 1.785113e+08\n",
"271 833874.NE 2018-12-31 2020-06-29 1.974978e+08\n",
"272 833874.NE 2017-12-31 2020-06-29 1.986075e+08\n",
"\n",
"[273 rows x 4 columns]"
]
},
"execution_count": 184,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sess.run(\"tmp_table\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "87820a2a-1ddf-4950-b0d4-a3e7d4a61b16",
"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
}