From 3c403adb4c4e06881e86d15b5e008c09e88ef090 Mon Sep 17 00:00:00 2001 From: Guofu Li Date: Fri, 26 Aug 2022 15:32:16 +0800 Subject: [PATCH] 1. Make adjustments on `src/run.py` 2. Minor changes on `DDBPITLoader.py` --- ipynb/ddb.ipynb | 79 +++++++-- ipynb/ddb_pit.ipynb | 319 ++++++++++++++++++++++++++++++++++++- src/DDBBase.py | 2 +- src/loader/DDBPITLoader.py | 23 +-- src/run.py | 39 ++++- 5 files changed, 420 insertions(+), 42 deletions(-) diff --git a/ipynb/ddb.ipynb b/ipynb/ddb.ipynb index 4c0de16..9f8652a 100644 --- a/ipynb/ddb.ipynb +++ b/ipynb/ddb.ipynb @@ -1405,7 +1405,7 @@ }, { "cell_type": "code", - "execution_count": 100, + "execution_count": 108, "id": "4ba45027-bbb5-4b27-99da-3452cc8d2f1c", "metadata": {}, "outputs": [ @@ -1436,7 +1436,7 @@ " \n", " \n", " 0\n", - " 2227\n", + " 2287\n", " \n", " \n", "\n", @@ -1444,10 +1444,10 @@ ], "text/plain": [ " count\n", - "0 2227" + "0 2287" ] }, - "execution_count": 100, + "execution_count": 108, "metadata": {}, "output_type": "execute_result" } @@ -1455,14 +1455,14 @@ "source": [ "sess.run(\"\"\"\n", " select count(*) from (\n", - " select code, m_nDate, count(*) as cnt from tbl where code='002459.SZ' group by code, m_nDate map\n", + " select code, m_nDate, count(*) as cnt from tbl where code='002533.SZ' group by code, m_nDate map\n", " );\n", "\"\"\")" ] }, { "cell_type": "code", - "execution_count": 103, + "execution_count": 107, "id": "29ab8af5-e571-4064-b691-a186d9fb4d08", "metadata": {}, "outputs": [ @@ -1495,24 +1495,81 @@ " \n", " \n", " \n", + " \n", + " 2013-01-04\n", + " 2224\n", + " \n", + " \n", + " 2013-01-07\n", + " 2093\n", + " \n", + " \n", + " 2013-01-08\n", + " 3009\n", + " \n", + " \n", + " 2013-01-09\n", + " 2890\n", + " \n", + " \n", + " 2013-01-10\n", + " 2703\n", + " \n", + " \n", + " ...\n", + " ...\n", + " \n", + " \n", + " 2022-07-04\n", + " 3906\n", + " \n", + " \n", + " 2022-07-05\n", + " 4230\n", + " \n", + " \n", + " 2022-07-06\n", + " 4030\n", + " \n", + " \n", + " 2022-07-07\n", + " 4526\n", + " \n", + " \n", + " 2022-07-08\n", + " 4639\n", + " \n", " \n", "\n", + "

2287 rows × 1 columns

\n", "" ], "text/plain": [ - "Empty DataFrame\n", - "Columns: [count]\n", - "Index: []" + " count\n", + "m_nDate \n", + "2013-01-04 2224\n", + "2013-01-07 2093\n", + "2013-01-08 3009\n", + "2013-01-09 2890\n", + "2013-01-10 2703\n", + "... ...\n", + "2022-07-04 3906\n", + "2022-07-05 4230\n", + "2022-07-06 4030\n", + "2022-07-07 4526\n", + "2022-07-08 4639\n", + "\n", + "[2287 rows x 1 columns]" ] }, - "execution_count": 103, + "execution_count": 107, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = sess.run(\"\"\"\n", - " select m_nDate, count(*) from tbl where code='002458.SZ' group by m_nDate having count(*) > 5000 map;\n", + " select m_nDate, count(*) from tbl where code='002533.SZ' group by m_nDate map;\n", "\"\"\").set_index('m_nDate')\n", "df" ] diff --git a/ipynb/ddb_pit.ipynb b/ipynb/ddb_pit.ipynb index 5a8a333..f41e28c 100644 --- a/ipynb/ddb_pit.ipynb +++ b/ipynb/ddb_pit.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 3, + "execution_count": 214, "id": "139fd1cb-aedf-4186-8408-4d630ba69599", "metadata": {}, "outputs": [], @@ -13,6 +13,323 @@ "sess.login('admin', '123456')" ] }, + { + "cell_type": "code", + "execution_count": 216, + "id": "98ef95cf-0a7f-4e9d-8c7c-bc1d2a6268bd", + "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", + "
tableNamephysicalIndex
0dividentGws
1preliminary_earnings_estimateFyP
2is_common_oriDvA
3cfs_common_oriAUH
4bs_common_adjx2R
5earnings_preannouncementEOu
6cfs_common_adjzCC
7is_common_adjCdl
8bs_common_oriykc
\n", + "
" + ], + "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, diff --git a/src/DDBBase.py b/src/DDBBase.py index 6252454..368fb31 100644 --- a/src/DDBBase.py +++ b/src/DDBBase.py @@ -5,7 +5,7 @@ import dolphindb as ddb class DDBBase(object): ddb_config = { - 'host' : '192.168.1.7', + 'host' : '192.168.1.167', 'username' : 'admin', 'password' : '123456', } diff --git a/src/loader/DDBPITLoader.py b/src/loader/DDBPITLoader.py index 95575a6..01bb93c 100644 --- a/src/loader/DDBPITLoader.py +++ b/src/loader/DDBPITLoader.py @@ -31,8 +31,8 @@ class DDBPITLoader(DDBLoader): #'CCFS_BEFORE_ADJ' : 'cfs_common_ori', #'CIS_AFTER_ADJ' : 'is_common_adj', #'CIS_BEFORE_ADJ' : 'is_common_ori', - 'DIV_WIND' : 'divident', - #'EP_WIND' : 'earnings_preannouncement', + #'DIV_WIND' : 'divident', + 'EP_WIND' : 'earnings_preannouncement', #'PEE_WIND' : 'preliminary_earnings_estimate' } @@ -263,25 +263,6 @@ class DDBPITLoader(DDBLoader): self._dump_pit_to_ddb(mssql_table_name) -def main(): - - # TODO: - # 可以使用`Fire`库,对函数调用再做一次封装,就可以避免每次运行不同参数时候需要修改内部多处的代码。 - - # PIT基本面数据 - loader = DDBPITLoader() - loader.create_ddb_database() - #loader.create_ddb_partition_tables() - loader.dump_pit_to_ddb() - - # 日频行情数据 - #loader = DDBDailyLoader() - #loader.load_ddb_database() - #loader.dump_daily_kline_to_ddb() - - -if __name__ == '__main__': - main() diff --git a/src/run.py b/src/run.py index 602ee50..a7f1d2d 100644 --- a/src/run.py +++ b/src/run.py @@ -2,15 +2,8 @@ from loader.DDBHFTLoader import DDBHFTLoader from loader.DDBBasicInfoLoader import DDBBasicInfoLoader -def main(): - - # TODO: - # 可以使用`Fire`库,对函数调用再做一次封装,就可以避免每次运行不同参数时候需要修改内部多处的代码。 - - #loader = DDBBasicInfoLoader() - #loader.create_ddb_database() - #loader.create_ddb_partition_table() +def create_hft_data(): # 高频数据 loader = DDBHFTLoader() df_calendar = loader.make_calendar_df() @@ -25,6 +18,36 @@ def main(): print('Did finish init_table_data') +def create_basic_info_data(): + loader = DDBBasicInfoLoader() + loader.create_ddb_database() + loader.create_ddb_partition_table() + + +def create_pit_data(): + # PIT基本面数据 + loader = DDBPITLoader() + loader.create_ddb_database() + #loader.create_ddb_partition_tables() + loader.dump_pit_to_ddb() + + +def create_daily_kline_data(): + # 日频行情数据 + loader = DDBDailyLoader() + loader.load_ddb_database() + loader.dump_daily_kline_to_ddb() + + + +def main(): + + # TODO: + # 可以使用`Fire`库,对函数调用再做一次封装,就可以避免每次运行不同参数时候需要修改内部多处的代码。 + + # create_hft_data() + create_pit_data() + if __name__ == '__main__': main()