diff --git a/dolphindb-read-data.ipynb b/dolphindb-read-data.ipynb index 096d444..b31fa38 100644 --- a/dolphindb-read-data.ipynb +++ b/dolphindb-read-data.ipynb @@ -1,35 +1,67 @@ { "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# dolphindb read data\n", + "\n", + "last update: 2022-12-13\n", + "\n", + "tick数据:2020到2022-11-24日左右,minute kline有2022到2022-11-10左右" + ] + }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Failed to connect to host = 192.168.1.7 port = 8848 with error code 111\n" + ] + }, + { + "ename": "RuntimeError", + "evalue": " in login: Couldn't send script/function to the remote host because the connection has been closed", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn [2], line 7\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mpandas\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39mpd\u001b[39;00m\n\u001b[1;32m 6\u001b[0m sess \u001b[39m=\u001b[39m ddb\u001b[39m.\u001b[39msession(\u001b[39m'\u001b[39m\u001b[39m192.168.1.7\u001b[39m\u001b[39m'\u001b[39m,\u001b[39m8848\u001b[39m)\n\u001b[0;32m----> 7\u001b[0m sess\u001b[39m.\u001b[39;49mlogin(\u001b[39m'\u001b[39;49m\u001b[39madmin\u001b[39;49m\u001b[39m'\u001b[39;49m,\u001b[39m'\u001b[39;49m\u001b[39m123456\u001b[39;49m\u001b[39m'\u001b[39;49m)\n", + "File \u001b[0;32m~/.local/lib/python3.9/site-packages/dolphindb/session.py:365\u001b[0m, in \u001b[0;36msession.login\u001b[0;34m(self, userid, password, enableEncryption)\u001b[0m\n\u001b[1;32m 363\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mpassword \u001b[39m=\u001b[39m password\n\u001b[1;32m 364\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39menableEncryption \u001b[39m=\u001b[39m enableEncryption\n\u001b[0;32m--> 365\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mcpp\u001b[39m.\u001b[39;49mlogin(userid, password, enableEncryption)\n\u001b[1;32m 366\u001b[0m \u001b[39mfinally\u001b[39;00m:\n\u001b[1;32m 367\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mmutex\u001b[39m.\u001b[39mrelease()\n", + "\u001b[0;31mRuntimeError\u001b[0m: in login: Couldn't send script/function to the remote host because the connection has been closed" + ] + } + ], "source": [ "import dolphindb as ddb\n", "import dolphindb.settings as keys\n", "import numpy as np\n", "import pandas as pd\n", "\n", - "\n", - "sess = ddb.session('192.168.1.7',8848)\n", - "sess.login('admin','123456')\n" + "# sess = ddb.session('192.168.1.7',8848)\n", + "sess = ddb.session('localhost',8848)\n", + "sess.login('admin','123456')" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'/hft_futuremarket_ts': 'TickPartitioned:3:0:TickPartitioned_3; MinKlinePartitioned:2:0:MinKlinePartitioned_2; ',\n", - " '/daily_stock_ts': 'idx_daily_kline:11:0:idx_daily_kline_11; idx_daily_concept:6:0:idx_daily_concept_6; hft_daily_factor:16:0:hft_daily_factor_16; daily_kline:2:0:daily_kline_2; ',\n", - " '/hft_stock_ts': 'Calendar:2:0:Calendar_2; KLinePartitioned:3:0:KLinePartitioned_3; OrderPartitioned:4:0:OrderPartitioned_4; TickPartitioned:5:0:TickPartitioned_5; TickQueuePartitioned:6:0:TickQueuePartitioned_6; TransePartitioned:7:0:TransePartitioned_7; '}" + "{'/hft_stock_ts': 'TransePartitioned:7:0:TransePartitioned_7; TickQueuePartitioned:6:0:TickQueuePartitioned_6; TickPartitioned:5:0:TickPartitioned_5; OrderPartitioned:4:0:OrderPartitioned_4; KLinePartitioned:3:0:KLinePartitioned_3; Calendar:2:0:Calendar_2; ',\n", + " '/daily_stock_ts': 'daily_kline:2:0:daily_kline_2; hft_daily_factor:16:0:hft_daily_factor_16; idx_daily_concept:6:0:idx_daily_concept_6; idx_daily_kline:11:0:idx_daily_kline_11; ',\n", + " '/hft_futuremarket_ts': 'MinKlinePartitioned:2:0:MinKlinePartitioned_2; TickPartitioned:3:0:TickPartitioned_3; DailyFutureInfoPartitioned:6:0:DailyFutureInfoPartitioned_6; '}" ] }, - "execution_count": 2, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -38,11 +70,156 @@ "sess.run('getAllDBs()')" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 读数据" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 读部分数据查看" + ] + }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 13, + "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", + "
code_domcode_initcode_contcode_cont1code_cont2code_cont3code_cont4m_nDate
0AP2105APAP2101AP2103AP2105AP2110AP21112021-01-01
1AP2105APAP2101AP2103AP2105AP2110AP21112021-01-02
2AP2105APAP2101AP2103AP2105AP2110AP21112021-01-03
3AP2105APAP2101AP2103AP2105AP2110AP21112021-01-04
\n", + "
" + ], + "text/plain": [ + " code_dom code_init code_cont code_cont1 code_cont2 code_cont3 code_cont4 \\\n", + "0 AP2105 AP AP2101 AP2103 AP2105 AP2110 AP2111 \n", + "1 AP2105 AP AP2101 AP2103 AP2105 AP2110 AP2111 \n", + "2 AP2105 AP AP2101 AP2103 AP2105 AP2110 AP2111 \n", + "3 AP2105 AP AP2101 AP2103 AP2105 AP2110 AP2111 \n", + "\n", + " m_nDate \n", + "0 2021-01-01 \n", + "1 2021-01-02 \n", + "2 2021-01-03 \n", + "3 2021-01-04 " + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df = sess.run(\"\"\"select top 4 * from loadTable(\"dfs://hft_futuremarket_ts\", \"DailyFutureInfoPartitioned\")\"\"\")\n", + "df" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 读少量数据" + ] + }, + { + "cell_type": "code", + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'sess' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn [1], line 4\u001b[0m\n\u001b[1;32m 2\u001b[0m tbName\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mTickPartitioned\u001b[39m\u001b[39m\"\u001b[39m \u001b[39m# MinKlinePartitioned\u001b[39;00m\n\u001b[1;32m 3\u001b[0m code_list\u001b[39m=\u001b[39m[\u001b[39m'\u001b[39m\u001b[39mAP2211\u001b[39m\u001b[39m'\u001b[39m]\n\u001b[0;32m----> 4\u001b[0m df \u001b[39m=\u001b[39m sess\u001b[39m.\u001b[39mrun(\u001b[39mf\u001b[39m\u001b[39m\"\"\"\u001b[39m\u001b[39mpt=loadTable(\u001b[39m\u001b[39m\"\u001b[39m\u001b[39m{\u001b[39;00mddb_hft_dbPath\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m\u001b[39m,\u001b[39m\u001b[39m\"\u001b[39m\u001b[39m{\u001b[39;00mtbName\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m\u001b[39m);\u001b[39m\n\u001b[1;32m 5\u001b[0m \u001b[39m select * from pt where m_nDatetime.date()=2022.06.01d and code in (\u001b[39m\u001b[39m{\u001b[39;00m\u001b[39m\"\u001b[39m\u001b[39m \u001b[39m\u001b[39m\"\u001b[39m\u001b[39m.\u001b[39mjoin([\u001b[39m\"\u001b[39m\u001b[39m`\u001b[39m\u001b[39m\"\u001b[39m\u001b[39m+\u001b[39mc \u001b[39mfor\u001b[39;00m c \u001b[39min\u001b[39;00m code_list])\u001b[39m}\u001b[39;00m\u001b[39m);\u001b[39m\n\u001b[1;32m 6\u001b[0m \u001b[39m \u001b[39m\u001b[39m\"\"\"\u001b[39m)\n", + "\u001b[0;31mNameError\u001b[0m: name 'sess' is not defined" + ] + } + ], "source": [ "ddb_hft_dbPath=\"dfs://hft_futuremarket_ts\"\n", "tbName=\"TickPartitioned\" # MinKlinePartitioned\n", @@ -54,9 +231,16 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": {}, "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(7687, 38)\n" + ] + }, { "data": { "text/html": [ @@ -266,308 +450,35 @@ "[5 rows x 38 columns]" ] }, - "execution_count": 7, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ + "print(df.shape)\n", "df.head()" ] }, { - "cell_type": "code", - "execution_count": 8, + "attachments": {}, + "cell_type": "markdown", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'partitionType': array([1, 1], dtype=int32),\n", - " 'partitionColumnName': array(['m_nDatetime', 'code_init'], dtype=object),\n", - " 'partitionTypeName': array(['VALUE', 'VALUE'], dtype=object),\n", - " 'partitionColumnIndex': array([ 1, 37], dtype=int32),\n", - " 'colDefs': name typeString typeInt comment\n", - " 0 code STRING 18 \n", - " 1 m_nDatetime NANOTIMESTAMP 14 \n", - " 2 m_nPrice DOUBLE 16 \n", - " 3 m_nOpen DOUBLE 16 \n", - " 4 m_nHigh DOUBLE 16 \n", - " 5 m_nLow DOUBLE 16 \n", - " 6 m_nClose DOUBLE 16 \n", - " 7 m_nAccHigh DOUBLE 16 \n", - " 8 m_nAccLow DOUBLE 16 \n", - " 9 m_iVolume SHORT 3 \n", - " 10 m_iAccVolume SHORT 3 \n", - " 11 m_nMatchItems SHORT 3 \n", - " 12 m_nAccMatchItems SHORT 3 \n", - " 13 m_iTurnover DOUBLE 16 \n", - " 14 m_iAccTurnover DOUBLE 16 \n", - " 15 m_nPreClose DOUBLE 16 \n", - " 16 m_nAccPreClose DOUBLE 16 \n", - " 17 m_nBidPrice DOUBLE 16 \n", - " 18 m_nBidVolume SHORT 3 \n", - " 19 m_nAskPrice DOUBLE 16 \n", - " 20 m_nAskVolume SHORT 3 \n", - " 21 m_iABFlag CHAR 2 \n", - " 22 m_nActBidVolume SHORT 3 \n", - " 23 m_nAccActBidVolume SHORT 3 \n", - " 24 m_nActBidTurnover DOUBLE 16 \n", - " 25 m_nAccActBidTurnover DOUBLE 16 \n", - " 26 m_nActAskVolume SHORT 3 \n", - " 27 m_nAccActAskVolume SHORT 3 \n", - " 28 m_nActAskTurnover DOUBLE 16 \n", - " 29 m_nAccActAskTurnover DOUBLE 16 \n", - " 30 m_nBidOrder DOUBLE 16 \n", - " 31 m_nAccBidOrder DOUBLE 16 \n", - " 32 m_nAskOrder DOUBLE 16 \n", - " 33 m_nAccAskOrder DOUBLE 16 \n", - " 34 m_nABOrderRate DOUBLE 16 \n", - " 35 m_nAccABOrderRate DOUBLE 16 \n", - " 36 m_nMItemsVolRate DOUBLE 16 \n", - " 37 code_init STRING 18 ,\n", - " 'chunkGranularity': 'TABLE',\n", - " 'engineType': 'TSDB',\n", - " 'keepDuplicates': 'ALL',\n", - " 'partitionSchema': [array(['2050-11', '2050-10', '2050-09', '2050-08', '2050-07', '2050-06',\n", - " '2050-05', '2050-04', '2050-03', '2050-02', '2050-01', '2049-12',\n", - " '2049-11', '2049-10', '2049-09', '2049-08', '2049-07', '2049-06',\n", - " '2049-05', '2049-04', '2049-03', '2049-02', '2049-01', '2048-12',\n", - " '2048-11', '2048-10', '2048-09', '2048-08', '2048-07', '2048-06',\n", - " '2048-05', '2048-04', '2048-03', '2048-02', '2048-01', '2047-12',\n", - " '2047-11', '2047-10', '2047-09', '2047-08', '2047-07', '2047-06',\n", - " '2047-05', '2047-04', '2047-03', '2047-02', '2047-01', '2046-12',\n", - " '2046-11', '2046-10', '2046-09', '2046-08', '2046-07', '2046-06',\n", - " '2046-05', '2046-04', '2046-03', '2046-02', '2046-01', '2045-12',\n", - " '2045-11', '2045-10', '2045-09', '2045-08', '2045-07', '2045-06',\n", - " '2045-05', '2045-04', '2045-03', '2045-02', '2045-01', '2044-12',\n", - " '2044-11', '2044-10', '2044-09', '2044-08', '2044-07', '2044-06',\n", - " '2044-05', '2044-04', '2044-03', '2044-02', '2044-01', '2043-12',\n", - " '2043-11', '2043-10', '2043-09', '2043-08', '2043-07', '2043-06',\n", - " '2043-05', '2043-04', '2043-03', '2043-02', '2043-01', '2042-12',\n", - " '2042-11', '2042-10', '2042-09', '2042-08', '2042-07', '2042-06',\n", - " '2042-05', '2042-04', '2042-03', '2042-02', '2042-01', '2041-12',\n", - " '2041-11', '2041-10', '2041-09', '2041-08', '2041-07', '2041-06',\n", - " '2041-05', '2041-04', '2041-03', '2041-02', '2041-01', '2040-12',\n", - " '2040-11', '2040-10', '2040-09', '2040-08', '2040-07', '2040-06',\n", - " '2040-05', '2040-04', '2040-03', '2040-02', '2040-01', '2039-12',\n", - " '2039-11', '2039-10', '2039-09', '2039-08', '2039-07', '2039-06',\n", - " '2039-05', '2039-04', '2039-03', '2039-02', '2039-01', '2038-12',\n", - " '2038-11', '2038-10', '2038-09', '2038-08', '2038-07', '2038-06',\n", - " '2038-05', '2038-04', '2038-03', '2038-02', '2038-01', '2037-12',\n", - " '2037-11', '2037-10', '2037-09', '2037-08', '2037-07', '2037-06',\n", - " '2037-05', '2037-04', '2037-03', '2037-02', '2037-01', '2036-12',\n", - " '2036-11', '2036-10', '2036-09', '2036-08', '2036-07', '2036-06',\n", - " '2036-05', '2036-04', '2036-03', '2036-02', '2036-01', '2035-12',\n", - " '2035-11', '2035-10', '2035-09', '2035-08', '2035-07', '2035-06',\n", - " '2035-05', '2035-04', '2035-03', '2035-02', '2035-01', '2034-12',\n", - " '2034-11', '2034-10', '2034-09', '2034-08', '2034-07', '2034-06',\n", - " '2034-05', '2034-04', '2034-03', '2034-02', '2034-01', '2033-12',\n", - " '2033-11', '2033-10', '2033-09', '2033-08', '2033-07', '2033-06',\n", - " '2033-05', '2033-04', '2033-03', '2033-02', '2033-01', '2032-12',\n", - " '2032-11', '2032-10', '2032-09', '2032-08', '2032-07', '2032-06',\n", - " '2032-05', '2032-04', '2032-03', '2032-02', '2032-01', '2031-12',\n", - " '2031-11', '2031-10', '2031-09', '2031-08', '2031-07', '2031-06',\n", - " '2031-05', '2031-04', '2031-03', '2031-02', '2031-01', '2030-12',\n", - " '2030-11', '2030-10', '2030-09', '2030-08', '2030-07', '2030-06',\n", - " '2030-05', '2030-04', '2030-03', '2030-02', '2030-01', '2029-12',\n", - " '2029-11', '2029-10', '2029-09', '2029-08', '2029-07', '2029-06',\n", - " '2029-05', '2029-04', '2029-03', '2029-02', '2029-01', '2028-12',\n", - " '2028-11', '2028-10', '2028-09', '2028-08', '2028-07', '2028-06',\n", - " '2028-05', '2028-04', '2028-03', '2028-02', '2028-01', '2027-12',\n", - " '2027-11', '2027-10', '2027-09', '2027-08', '2027-07', '2027-06',\n", - " '2027-05', '2027-04', '2027-03', '2027-02', '2027-01', '2026-12',\n", - " '2026-11', '2026-10', '2026-09', '2026-08', '2026-07', '2026-06',\n", - " '2026-05', '2026-04', '2026-03', '2026-02', '2026-01', '2025-12',\n", - " '2025-11', '2025-10', '2025-09', '2025-08', '2025-07', '2025-06',\n", - " '2025-05', '2025-04', '2025-03', '2025-02', '2025-01', '2024-12',\n", - " '2024-11', '2024-10', '2024-09', '2024-08', '2024-07', '2024-06',\n", - " '2024-05', '2024-04', '2024-03', '2024-02', '2024-01', '2023-12',\n", - " '2023-11', '2023-10', '2023-09', '2023-08', '2023-07', '2023-06',\n", - " '2023-05', '2023-04', '2023-03', '2023-02', '2023-01', '2022-12',\n", - " '2022-11', '2022-10', '2022-09', '2022-08', '2022-07', '2022-06',\n", - " '2022-05', '2022-04', '2022-03', '2022-02', '2022-01', '2021-12',\n", - " '2021-11', '2021-10', '2021-09', '2021-08', '2021-07', '2021-06',\n", - " '2021-05', '2021-04', '2021-03', '2021-02', '2021-01', '2020-12',\n", - " '2020-11', '2020-10', '2020-09', '2020-08', '2020-07', '2020-06',\n", - " '2020-05', '2020-04', '2020-03', '2020-02', '2020-01', '2019-12',\n", - " '2019-11', '2019-10', '2019-09', '2019-08', '2019-07', '2019-06',\n", - " '2019-05', '2019-04', '2019-03', '2019-02', '2019-01', '2018-12',\n", - " '2018-11', '2018-10', '2018-09', '2018-08', '2018-07', '2018-06',\n", - " '2018-05', '2018-04', '2018-03', '2018-02', '2018-01', '2017-12',\n", - " '2017-11', '2017-10', '2017-09', '2017-08', '2017-07', '2017-06',\n", - " '2017-05', '2017-04', '2017-03', '2017-02', '2017-01', '2016-12',\n", - " '2016-11', '2016-10', '2016-09', '2016-08', '2016-07', '2016-06',\n", - " '2016-05', '2016-04', '2016-03', '2016-02', '2016-01', '2015-12',\n", - " '2015-11', '2015-10', '2015-09', '2015-08', '2015-07', '2015-06',\n", - " '2015-05', '2015-04', '2015-03', '2015-02', '2015-01', '2014-12',\n", - " '2014-11', '2014-10', '2014-09', '2014-08', '2014-07', '2014-06',\n", - " '2014-05', '2014-04', '2014-03', '2014-02', '2014-01', '2013-12',\n", - " '2013-11', '2013-10', '2013-09', '2013-08', '2013-07', '2013-06',\n", - " '2013-05', '2013-04', '2013-03', '2013-02', '2013-01', '2012-12',\n", - " '2012-11', '2012-10', '2012-09', '2012-08', '2012-07', '2012-06',\n", - " '2012-05', '2012-04', '2012-03', '2012-02', '2012-01', '2011-12',\n", - " '2011-11', '2011-10', '2011-09', '2011-08', '2011-07', '2011-06',\n", - " '2011-05', '2011-04', '2011-03', '2011-02', '2011-01', '2010-12',\n", - " '2010-11', '2010-10', '2010-09', '2010-08', '2010-07', '2010-06',\n", - " '2010-05', '2010-04', '2010-03', '2010-02', '2010-01', '2009-12',\n", - " '2009-11', '2009-10', '2009-09', '2009-08', '2009-07', '2009-06',\n", - " '2009-05', '2009-04', '2009-03', '2009-02', '2009-01', '2008-12',\n", - " '2008-11', '2008-10', '2008-09', '2008-08', '2008-07', '2008-06',\n", - " '2008-05', '2008-04', '2008-03', '2008-02', '2008-01', '2007-12',\n", - " '2007-11', '2007-10', '2007-09', '2007-08', '2007-07', '2007-06',\n", - " '2007-05', '2007-04', '2007-03', '2007-02', '2007-01', '2006-12',\n", - " '2006-11', '2006-10', '2006-09', '2006-08', '2006-07', '2006-06',\n", - " '2006-05', '2006-04', '2006-03', '2006-02', '2006-01', '2005-12',\n", - " '2005-11', '2005-10', '2005-09', '2005-08', '2005-07', '2005-06',\n", - " '2005-05', '2005-04', '2005-03', '2005-02', '2005-01', '2004-12',\n", - " '2004-11', '2004-10', '2004-09', '2004-08', '2004-07', '2004-06',\n", - " '2004-05', '2004-04', '2004-03', '2004-02', '2004-01', '2003-12',\n", - " '2003-11', '2003-10', '2003-09', '2003-08', '2003-07', '2003-06',\n", - " '2003-05', '2003-04', '2003-03', '2003-02', '2003-01', '2002-12',\n", - " '2002-11', '2002-10', '2002-09', '2002-08', '2002-07', '2002-06',\n", - " '2002-05', '2002-04', '2002-03', '2002-02', '2002-01', '2001-12',\n", - " '2001-11', '2001-10', '2001-09', '2001-08', '2001-07', '2001-06',\n", - " '2001-05', '2001-04', '2001-03', '2001-02', '2001-01', '2000-12',\n", - " '2000-11', '2000-10', '2000-09', '2000-08', '2000-07', '2000-06',\n", - " '2000-05', '2000-04', '2000-03', '2000-02', '2000-01'],\n", - " dtype='datetime64[M]'),\n", - " array(['zn', 'y', 'wr', 'v', 'ss', 'sp', 'sn', 'sc', 'ru', 'rr', 'rb',\n", - " 'pp', 'pg', 'pb', 'p', 'nr', 'ni', 'm', 'lu', 'lh', 'l', 'jm',\n", - " 'jd', 'j', 'i', 'hc', 'fu', 'fb', 'eg', 'eb', 'cu', 'cs', 'c',\n", - " 'bu', 'bc', 'bb', 'b', 'au', 'al', 'ag', 'a', 'ZC', 'WH', 'UR',\n", - " 'TS', 'TF', 'TA', 'T', 'SR', 'SM', 'SF', 'SA', 'RS', 'RM', 'RI',\n", - " 'PM', 'PK', 'PF', 'OI', 'MA', 'LR', 'JR', 'IM', 'IH', 'IF', 'IC',\n", - " 'FG', 'CY', 'CJ', 'CF', 'AP'], dtype=object)],\n", - " 'partitionColumnType': array([ 7, 17], dtype=int32),\n", - " 'chunkPath': None,\n", - " 'sortColumns': array(['code', 'm_nDatetime'], dtype=object),\n", - " 'partitionSites': None}" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], "source": [ - "sess.run(f\"\"\"schema(pt)\"\"\")" + "### **🌟读较多数据**" ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ - "```python\n", - "def get_trade_tick(self, start_date, end_date, code_list):\n", - "\"\"\"\n", - "(source: 天软数据字典 ver 2022-05-25)\n", - "vol: 周期内的成交量。如果周期为分钟,则表示这分钟的成 交量,并非从开盘累计.\n", - " 对于期货,高频和日线的单位都是合约数量,如果要建立成交量和成交金额之间的关系,还需考虑合约乘数。\n", - "amount: 周期内的成交金额。如果周期为分钟,则表示这分钟的成交金额,并非从开盘累计。\n", - "cjbs: 对于期货/期权而言,是周期内的持仓的变动量,日线的话表示当日持仓量,单位为:手。\n", - "wb: 公式:委买/委卖(w_buy/w_sale)\n", - "lb: 由天软计算:\n", - " 1、对于交易明细:\n", - " 量比=现成交总手/[(过去 5 个交易日平均每分钟成交 量)×当日累计开市时间(分)]\n", - " 2、对于秒线/1 分钟线: 量比取周期内最后一条交易明细的数据。\n", - "\n", - "zmm: 对 tradetable 公式:按下面的前后逻辑优先判定\n", - " 没有成交 -> 0\n", - " 当前成交价>上一笔买一价 ->主买 1 \n", - " 当前成交价<上一笔卖一价 ->主卖 2 \n", - " 否则->3(一般是集合竞价、涨停、跌停) \n", - " 对于非交易明细(秒线或分钟线等):没有意义\n", - "buy_vol: 主动性买盘成交量:周期内买卖标识为 1 的成交量+买 卖标识为 3 的成交量/2\n", - "buy_amount: 主动性买盘成交金额:周期内买卖标识为 1 的成交金额 +买卖标识为 3 的成交金额/2\n", - "sale_vol: 主动性卖盘成交量:周期内买卖标识为 2 的成交量之和 +买卖标识为 3 的成交量/2\n", - "sale_amount: 主动性卖盘成交金额:周期内买卖标识为 2 的成交金额 +买卖标识为 3 的成交金额/2\n", - "w_buy: 一个周期内的委买量\n", - "sectional: 从开盘到当前时间的\n", - "sectional_yclose: 上一交易日(周期是日)的收盘价,与‘上次价’不一 样。‘上次价’表示前一个周期的收盘价。\n", - "sectional_vol: 从开盘到当前时间的成交量之和(主买+主卖)\n", - "sectional_amount: 从开盘到当前时间的成交金额之和(主买+主卖)\n", - "sectional_cjbs: 股指期货/期权:市场现有持仓量\n", - "sectional_wb: 当日累计委买/当日累计委卖\n", - "\n", - "['sectional_open'] as 'm_nAccOpen', //时点当日开盘, 没必要存, 取上日2059的即可\n", - "\n", - "\"\"\"\n", - "\n", - "code_list_input = ', '.join(['\\'%s\\'' % code_id for code_id in code_list])\n", - "scpt = \"\"\"\n", - " stock_list := Array({code_list_input});\n", - " r := select \n", - " ['StockID'] as 'code',\n", - " DateTimeToStr(['date']) as 'm_nDatetime',\n", - "\n", - " ['price'] as 'm_nPrice',\n", - " ['open'] as 'm_nOpen',\n", - " ['high'] as 'm_nHigh',\n", - " ['low'] as 'm_nLow',\n", - " ['close'] as 'm_nClose',\n", - "\n", - " ['sectional_high'] as 'm_nAccHigh',\n", - " ['sectional_low'] as 'm_nAccLow',\n", - "\n", - " ['vol'] as 'm_iVolume', //成交量\n", - " ['sectional_vol'] as 'm_iAccVolume', //时点当日累计成交量\n", - "\n", - " ['cjbs'] as 'm_nMatchItems', // 成交笔数 周期内的持仓的变动量\n", - " ['sectional_cjbs'] as 'm_nAccMatchItems',\n", - "\n", - " ['amount'] as 'm_iTurnover', //成交金额\n", - " ['sectional_amount'] as 'm_iAccTurnover', \n", - "\n", - " ['yclose'] as 'm_nPreClose', //上一周期的收盘价\n", - " ['sectional_yclose'] as 'm_nAccPreClose', // 前日收盘\n", - " \n", - " ['buy1'] as 'm_nBidPrice', //买一价?叫卖价?\n", - " ['bc1'] as 'm_nBidVolume', //买一量 当前以买一价出价的委买量\n", - " ['sale1'] as 'm_nAskPrice', \n", - " ['sc1'] as 'm_nAskVolume', \n", - "\n", - " ['zmm'] as 'm_iABFlag', //买卖标识\n", - "\n", - " ['buy_vol'] as 'm_nActBidVolume', //主买量\n", - " ['sectional_buy_vol'] as 'm_nAccActBidVolume', //时点当日累计主买量\n", - " ['buy_amount'] as 'm_nActBidTurnover', //主买金额\n", - " ['sectional_buy_amount'] as 'm_nAccActBidTurnover', \n", - "\n", - " ['sale_vol'] as 'm_nActAskVolume', \n", - " ['sectional_sale_vol'] as 'm_nAccActAskVolume', \n", - " ['sale_amount'] as 'm_nActAskTurnover',\n", - " ['sectional_sale_amount'] as 'm_nAccActAskTurnover', \n", - "\n", - " ['w_buy'] as 'm_nBidOrder', //委买\n", - " ['sectional_w_buy'] as 'm_nAccBidOrder', \n", - " ['w_sale'] as 'm_nAskOrder',\n", - " ['sectional_w_sale'] as 'm_nAccAskOrder',\n", - "\n", - " ['wb'] as 'm_nABOrderRate', //委比\n", - " ['sectional_wb'] as 'm_nAccABOrderRate', //时点当日累计委比\n", - " ['lb'] as 'm_nMItemsVolRate'//量比\n", - "\n", - " from tradetable\n", - " datekey {start_date}T to {end_date}T+0.999 \n", - " of stock_list\n", - " end;\n", - " \n", - " return r; \n", - "\"\"\".format(\n", - " code_list_input=code_list_input,\n", - " start_date=start_date,\n", - " end_date=end_date\n", - ")\n", - "logger.debug(scpt)\n", - "r = self.c.exec(scpt,timeout=self.timeout_default)\n", - "return r\n", - "```" + "#### 读主力" ] }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -591,1207 +502,446 @@ " \n", " \n", " \n", - " code\n", - " m_nDatetime\n", - " m_nPrice\n", - " m_nOpen\n", - " m_nHigh\n", - " m_nLow\n", - " m_nClose\n", - " m_nAccHigh\n", - " m_nAccLow\n", - " m_iVolume\n", - " ...\n", - " m_nActAskTurnover\n", - " m_nAccActAskTurnover\n", - " m_nBidOrder\n", - " m_nAccBidOrder\n", - " m_nAskOrder\n", - " m_nAccAskOrder\n", - " m_nABOrderRate\n", - " m_nAccABOrderRate\n", - " m_nMItemsVolRate\n", + " code_dom\n", " code_init\n", + " code_cont\n", + " code_cont1\n", + " code_cont2\n", + " code_cont3\n", + " code_cont4\n", + " m_nDate\n", " \n", " \n", " \n", " \n", " 0\n", - " AP2211\n", - " 2022-02-11 08:55:00\n", - " 7776.0\n", - " 7776.0\n", - " 7776.0\n", - " 7776.0\n", - " 7776.0\n", - " 0.0\n", - " 0.0\n", - " 0\n", - " ...\n", - " 0.0\n", - " 0.0\n", - " 0.0\n", - " 0.0\n", - " 0.0\n", - " 0.0\n", - " 0.0\n", - " 0.000000\n", - " 0.0\n", - " AP\n", + " IC2206\n", + " IC\n", + " IC2205\n", + " IC2206\n", + " IC2209\n", + " IC2212\n", + " \n", + " 2022-05-01\n", " \n", " \n", " 1\n", - " AP2211\n", - " 2022-02-11 08:59:00\n", - " 7761.0\n", - " 7761.0\n", - " 7761.0\n", - " 7761.0\n", - " 7761.0\n", - " 7761.0\n", - " 7761.0\n", - " 2705\n", - " ...\n", - " 10496752.5\n", - " 10496752.5\n", - " 1.0\n", - " 1.0\n", - " 1.0\n", - " 1.0\n", - " 1.0\n", - " 1.000000\n", - " 0.0\n", - " AP\n", + " IC2206\n", + " IC\n", + " IC2205\n", + " IC2206\n", + " IC2209\n", + " IC2212\n", + " \n", + " 2022-05-02\n", " \n", " \n", " 2\n", - " AP2211\n", - " 2022-02-11 09:00:00\n", - " 7761.0\n", - " 7761.0\n", - " 7761.0\n", - " 7761.0\n", - " 7761.0\n", - " 7761.0\n", - " 7761.0\n", - " 0\n", - " ...\n", - " 0.0\n", - " 10496752.5\n", - " 1.0\n", - " 2.0\n", - " 1.0\n", - " 2.0\n", - " 1.0\n", - " 1.000000\n", - " 0.0\n", - " AP\n", + " IC2206\n", + " IC\n", + " IC2205\n", + " IC2206\n", + " IC2209\n", + " IC2212\n", + " \n", + " 2022-05-03\n", " \n", " \n", " 3\n", - " AP2211\n", - " 2022-02-11 09:00:00\n", - " 7759.0\n", - " 7759.0\n", - " 7759.0\n", - " 7759.0\n", - " 7759.0\n", - " 7761.0\n", - " 7759.0\n", - " 1\n", - " ...\n", - " 7761.0\n", - " 10504513.5\n", - " 1.0\n", - " 3.0\n", - " 1.0\n", - " 3.0\n", - " 1.0\n", - " 1.000000\n", - " 0.0\n", - " AP\n", + " IC2206\n", + " IC\n", + " IC2205\n", + " IC2206\n", + " IC2209\n", + " IC2212\n", + " \n", + " 2022-05-04\n", " \n", " \n", " 4\n", - " AP2211\n", - " 2022-02-11 09:00:01\n", - " 7759.0\n", - " 7759.0\n", - " 7759.0\n", - " 7759.0\n", - " 7759.0\n", - " 7761.0\n", - " 7759.0\n", - " 0\n", - " ...\n", - " 0.0\n", - " 10504513.5\n", - " 1.0\n", - " 4.0\n", - " 1.0\n", - " 4.0\n", - " 1.0\n", - " 1.000000\n", - " 0.0\n", - " AP\n", + " IC2206\n", + " IC\n", + " IC2205\n", + " IC2206\n", + " IC2209\n", + " IC2212\n", + " \n", + " 2022-05-05\n", " \n", " \n", - " 5\n", - " AP2211\n", - " 2022-02-11 09:00:02\n", - " 7759.0\n", - " 7759.0\n", - " 7759.0\n", - " 7759.0\n", - " 7759.0\n", - " 7761.0\n", - " 7759.0\n", - " 0\n", + " ...\n", + " ...\n", " ...\n", - " 0.0\n", - " 10504513.5\n", - " 1.0\n", - " 5.0\n", - " 1.0\n", - " 5.0\n", - " 1.0\n", - " 1.000000\n", - " 0.0\n", - " AP\n", - " \n", - " \n", - " 6\n", - " AP2211\n", - " 2022-02-11 09:00:03\n", - " 7759.0\n", - " 7759.0\n", - " 7759.0\n", - " 7759.0\n", - " 7759.0\n", - " 7761.0\n", - " 7759.0\n", - " 0\n", " ...\n", - " 0.0\n", - " 10504513.5\n", - " 1.0\n", - " 6.0\n", - " 1.0\n", - " 6.0\n", - " 1.0\n", - " 1.000000\n", - " 0.0\n", - " AP\n", - " \n", - " \n", - " 7\n", - " AP2211\n", - " 2022-02-11 09:00:04\n", - " 7759.0\n", - " 7759.0\n", - " 7759.0\n", - " 7759.0\n", - " 7759.0\n", - " 7761.0\n", - " 7759.0\n", - " 1\n", " ...\n", - " 7761.0\n", - " 10512274.5\n", - " 1.0\n", - " 7.0\n", - " 1.0\n", - " 7.0\n", - " 1.0\n", - " 1.000000\n", - " 0.0\n", - " AP\n", - " \n", - " \n", - " 8\n", - " AP2211\n", - " 2022-02-11 09:00:05\n", - " 7759.0\n", - " 7759.0\n", - " 7759.0\n", - " 7759.0\n", - " 7759.0\n", - " 7761.0\n", - " 7759.0\n", - " 0\n", " ...\n", - " 0.0\n", - " 10512274.5\n", - " 1.0\n", - " 8.0\n", - " 1.0\n", - " 8.0\n", - " 1.0\n", - " 1.000000\n", - " 0.0\n", - " AP\n", - " \n", - " \n", - " 9\n", - " AP2211\n", - " 2022-02-11 09:00:05\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7761.0\n", - " 7757.0\n", - " 1\n", " ...\n", - " 7761.0\n", - " 10520035.5\n", - " 1.0\n", - " 9.0\n", - " 1.0\n", - " 9.0\n", - " 1.0\n", - " 1.000000\n", - " 0.0\n", - " AP\n", - " \n", - " \n", - " 10\n", - " AP2211\n", - " 2022-02-11 09:00:07\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7761.0\n", - " 7757.0\n", - " 0\n", " ...\n", - " 0.0\n", - " 10520035.5\n", - " 1.0\n", - " 10.0\n", - " 1.0\n", - " 10.0\n", - " 1.0\n", - " 1.000000\n", - " 0.0\n", - " AP\n", - " \n", - " \n", - " 11\n", - " AP2211\n", - " 2022-02-11 09:00:08\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7761.0\n", - " 7757.0\n", - " 0\n", " ...\n", - " 0.0\n", - " 10520035.5\n", - " 1.0\n", - " 11.0\n", - " 1.0\n", - " 11.0\n", - " 1.0\n", - " 1.000000\n", - " 0.0\n", - " AP\n", " \n", " \n", - " 12\n", - " AP2211\n", - " 2022-02-11 09:00:09\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7761.0\n", - " 7757.0\n", - " 0\n", - " ...\n", - " 0.0\n", - " 10520035.5\n", - " 1.0\n", - " 12.0\n", - " 1.0\n", - " 12.0\n", - " 1.0\n", - " 1.000000\n", - " 0.0\n", - " AP\n", + " 204\n", + " IC2212\n", + " IC\n", + " IC2211\n", + " IC2212\n", + " IC2303\n", + " IC2306\n", + " \n", + " 2022-11-20\n", " \n", " \n", - " 13\n", - " AP2211\n", - " 2022-02-11 09:00:10\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7761.0\n", - " 7757.0\n", - " 0\n", - " ...\n", - " 0.0\n", - " 10520035.5\n", - " 1.0\n", - " 13.0\n", - " 1.0\n", - " 13.0\n", - " 1.0\n", - " 1.000000\n", - " 0.0\n", - " AP\n", + " 205\n", + " IC2212\n", + " IC\n", + " IC2212\n", + " IC2301\n", + " IC2303\n", + " IC2306\n", + " \n", + " 2022-11-21\n", " \n", " \n", - " 14\n", - " AP2211\n", - " 2022-02-11 09:00:12\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7761.0\n", - " 7757.0\n", - " 0\n", - " ...\n", - " 0.0\n", - " 10520035.5\n", - " 1.0\n", - " 14.0\n", - " 1.0\n", - " 14.0\n", - " 1.0\n", - " 1.000000\n", - " 0.0\n", - " AP\n", + " 206\n", + " IC2212\n", + " IC\n", + " IC2212\n", + " IC2301\n", + " IC2303\n", + " IC2306\n", + " \n", + " 2022-11-22\n", " \n", " \n", - " 15\n", - " AP2211\n", - " 2022-02-11 09:00:13\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7757.0\n", - " 7761.0\n", - " 7757.0\n", - " 0\n", - " ...\n", - " 0.0\n", - " 10520035.5\n", - " 1.0\n", - " 15.0\n", - " 1.0\n", - " 15.0\n", - " 1.0\n", - " 1.000000\n", - " 0.0\n", - " AP\n", + " 207\n", + " IC2212\n", + " IC\n", + " IC2212\n", + " IC2301\n", + " IC2303\n", + " IC2306\n", + " \n", + " 2022-11-23\n", " \n", " \n", - " 16\n", - " AP2211\n", - " 2022-02-11 09:00:13\n", - " 7751.0\n", - " 7751.0\n", - " 7751.0\n", - " 7751.0\n", - " 7751.0\n", - " 7761.0\n", - " 7751.0\n", - " 1\n", - " ...\n", - " 7761.0\n", - " 10527796.5\n", - " 1.0\n", - " 16.0\n", - " 1.0\n", - " 16.0\n", - " 1.0\n", - " 1.000000\n", - " 0.0\n", - " AP\n", + " 208\n", + " IC2212\n", + " IC\n", + " IC2212\n", + " IC2301\n", + " IC2303\n", + " IC2306\n", + " \n", + " 2022-11-24\n", " \n", - " \n", - " 17\n", - " AP2211\n", - " 2022-02-11 09:00:14\n", - " 7751.0\n", - " 7751.0\n", - " 7751.0\n", - " 7751.0\n", - " 7751.0\n", - " 7761.0\n", - " 7751.0\n", - " 0\n", - " ...\n", - " 0.0\n", - " 10527796.5\n", - " 1.0\n", - " 17.0\n", - " 1.0\n", - " 17.0\n", - " 1.0\n", - " 1.000000\n", - " 0.0\n", - " AP\n", + " \n", + "\n", + "

209 rows × 8 columns

\n", + "" + ], + "text/plain": [ + " code_dom code_init code_cont code_cont1 code_cont2 code_cont3 code_cont4 \\\n", + "0 IC2206 IC IC2205 IC2206 IC2209 IC2212 \n", + "1 IC2206 IC IC2205 IC2206 IC2209 IC2212 \n", + "2 IC2206 IC IC2205 IC2206 IC2209 IC2212 \n", + "3 IC2206 IC IC2205 IC2206 IC2209 IC2212 \n", + "4 IC2206 IC IC2205 IC2206 IC2209 IC2212 \n", + ".. ... ... ... ... ... ... ... \n", + "204 IC2212 IC IC2211 IC2212 IC2303 IC2306 \n", + "205 IC2212 IC IC2212 IC2301 IC2303 IC2306 \n", + "206 IC2212 IC IC2212 IC2301 IC2303 IC2306 \n", + "207 IC2212 IC IC2212 IC2301 IC2303 IC2306 \n", + "208 IC2212 IC IC2212 IC2301 IC2303 IC2306 \n", + "\n", + " m_nDate \n", + "0 2022-05-01 \n", + "1 2022-05-02 \n", + "2 2022-05-03 \n", + "3 2022-05-04 \n", + "4 2022-05-05 \n", + ".. ... \n", + "204 2022-11-20 \n", + "205 2022-11-21 \n", + "206 2022-11-22 \n", + "207 2022-11-23 \n", + "208 2022-11-24 \n", + "\n", + "[209 rows x 8 columns]" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "st_d = '2022.05.01'\n", + "en_d = '2022.11.24'\n", + "code_init = 'IC'\n", + "\n", + "spt=\"\"\"select * from loadTable(\"dfs://hft_futuremarket_ts\", \"DailyFutureInfoPartitioned\") where m_nDate.date()>={st_d}d and m_nDate.date()<={en_d}d and code_init=`{code_init}\n", + "\"\"\".format(st_d=st_d,en_d=en_d,code_init=code_init)\n", + "\n", + "block= sess.run(spt, fetchSize = 8192)\n", + "\n", + "total = []\n", + "while block.hasNext():\n", + " tem = block.read()\n", + " total.append(tem)\n", + "\n", + "import pandas as pd\n", + "df_dom=pd.concat(total)\n", + "df_dom" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 读tick数据" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "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", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \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_nDatetimem_nPricem_iVolumem_iAccVolumem_nMatchItemsm_nAccMatchItemsm_nBidPricem_nBidVolumem_nAskPricem_nAskVolume
18AP22112022-02-11 09:00:157751.07751.07751.07751.07751.07761.07751.00...0.010527796.52.019.01.018.02.01.0555560.0AP0IC22102022-10-10 09:29:005730.2109109.0-76-29454.05730.0115730.21
19AP22112022-02-11 09:00:167751.07751.07751.07751.07751.07761.07751.00...0.010527796.510.029.01.019.010.01.5263160.0AP1IC22102022-10-10 09:30:005730.025134.0-16-29470.05730.015732.010
20AP22112022-02-11 09:00:167738.07738.07738.07738.07738.07761.07738.02IC22102022-10-10 09:30:005730.030164.0-20-29490.05730.21...7761.010535557.59.038.01.020.09.01.9000000.0AP5730.82
21AP22112022-02-11 09:00:177730.07730.07730.07730.07730.07761.07730.011...85371.010620928.51.039.01.021.01.01.8571430.0AP3IC22102022-10-10 09:30:015730.626190.0-17-29507.05730.225732.07
22AP22112022-02-11 09:00:187730.07730.07730.07730.07730.07761.07730.00...0.010620928.51.040.01.022.01.01.8181820.0AP4IC22102022-10-10 09:30:015730.229219.0-19-29526.05730.215731.41
23AP22112022-02-11 09:00:197730.07730.07730.07730.07730.07761.07730.00............0.010620928.51.041.01.023.01.01.7826090.0AP
24AP22112022-02-11 09:00:207730.07730.07730.07730.07730.07761.07730.00...0.010620928.51.042.01.024.01.01.7500000.0AP
25AP22112022-02-11 09:00:217731.07731.07731.07731.07731.07761.07730.01...7761.010628689.51.043.01.025.01.01.7200000.0AP
26AP22112022-02-11 09:00:227731.07731.07731.07731.07731.07761.07730.00...0.010628689.51.044.01.026.01.01.6923080.0AP
27AP22112022-02-11 09:00:227725.07725.07725.07725.07725.07761.07725.01...7761.010636450.51.045.01.027.01.01.6666670.0AP
28AP22112022-02-11 09:00:237725.07725.07725.07725.07725.07761.07725.00...0.010636450.51.046.01.028.01.01.6428570.0AP
29AP22112022-02-11 09:00:247725.07725.07725.07725.07725.07761.07725.00...0.010636450.51.047.01.029.01.01.6206900.0AP
30AP22112022-02-11 09:00:257725.07725.07725.07725.07725.07761.07725.00...0.010636450.51.048.01.030.01.01.6000000.0AP
31AP22112022-02-11 09:00:267725.07725.07725.07725.07725.07761.07725.00...0.010636450.51.049.01.031.01.01.5806450.0AP
32AP22112022-02-11 09:00:277725.07725.07725.07725.07725.07761.07725.05833IC23062022-11-23 14:59:576026.016468.00...0.010636450.51.050.01.032.01.01.5625000.0AP-23469.06019.016026.09
33AP22112022-02-11 09:00:297725.07725.07725.07725.07725.07761.07725.05834IC23062022-11-23 14:59:586026.00...0.010636450.51.051.01.033.01.01.5454550.0AP6468.00-23469.06019.216026.09
34AP22112022-02-11 09:00:307725.07725.07725.07725.07725.07761.07725.05835IC23062022-11-23 14:59:596026.056473.00...0.010636450.51.052.01.034.01.01.5294120.0AP-23469.06019.216026.04
35AP22112022-02-11 09:00:317725.07725.07725.07725.07725.07761.07725.05836IC23062022-11-23 15:00:006019.216474.00...0.010636450.51.053.01.035.01.01.5142860.0AP-23469.06019.016019.29
36AP22112022-02-11 09:00:327725.07725.07725.07725.07725.07761.07725.05837IC23062022-11-23 15:25:246019.20...0.010636450.51.054.01.036.01.01.5000000.0AP
37AP22112022-02-11 09:00:337725.07725.07725.07725.07725.07761.07725.00...0.010636450.51.055.01.037.01.01.4864860.0AP
38AP22112022-02-11 09:00:347725.07725.07725.07725.07725.07761.07725.06474.00...0.010636450.51.056.01.038.01.01.4736840.0AP
39AP22112022-02-11 09:00:357725.07725.07725.07725.07725.07761.07725.00...0.010636450.51.057.01.039.01.01.4615380.0AP-23469.06019.016019.29
\n", - "

40 rows × 38 columns

\n", + "

2881230 rows × 11 columns

\n", "
" ], "text/plain": [ - " code m_nDatetime m_nPrice m_nOpen m_nHigh m_nLow m_nClose \\\n", - "0 AP2211 2022-02-11 08:55:00 7776.0 7776.0 7776.0 7776.0 7776.0 \n", - "1 AP2211 2022-02-11 08:59:00 7761.0 7761.0 7761.0 7761.0 7761.0 \n", - "2 AP2211 2022-02-11 09:00:00 7761.0 7761.0 7761.0 7761.0 7761.0 \n", - "3 AP2211 2022-02-11 09:00:00 7759.0 7759.0 7759.0 7759.0 7759.0 \n", - "4 AP2211 2022-02-11 09:00:01 7759.0 7759.0 7759.0 7759.0 7759.0 \n", - "5 AP2211 2022-02-11 09:00:02 7759.0 7759.0 7759.0 7759.0 7759.0 \n", - "6 AP2211 2022-02-11 09:00:03 7759.0 7759.0 7759.0 7759.0 7759.0 \n", - "7 AP2211 2022-02-11 09:00:04 7759.0 7759.0 7759.0 7759.0 7759.0 \n", - "8 AP2211 2022-02-11 09:00:05 7759.0 7759.0 7759.0 7759.0 7759.0 \n", - "9 AP2211 2022-02-11 09:00:05 7757.0 7757.0 7757.0 7757.0 7757.0 \n", - "10 AP2211 2022-02-11 09:00:07 7757.0 7757.0 7757.0 7757.0 7757.0 \n", - "11 AP2211 2022-02-11 09:00:08 7757.0 7757.0 7757.0 7757.0 7757.0 \n", - "12 AP2211 2022-02-11 09:00:09 7757.0 7757.0 7757.0 7757.0 7757.0 \n", - "13 AP2211 2022-02-11 09:00:10 7757.0 7757.0 7757.0 7757.0 7757.0 \n", - "14 AP2211 2022-02-11 09:00:12 7757.0 7757.0 7757.0 7757.0 7757.0 \n", - "15 AP2211 2022-02-11 09:00:13 7757.0 7757.0 7757.0 7757.0 7757.0 \n", - "16 AP2211 2022-02-11 09:00:13 7751.0 7751.0 7751.0 7751.0 7751.0 \n", - "17 AP2211 2022-02-11 09:00:14 7751.0 7751.0 7751.0 7751.0 7751.0 \n", - "18 AP2211 2022-02-11 09:00:15 7751.0 7751.0 7751.0 7751.0 7751.0 \n", - "19 AP2211 2022-02-11 09:00:16 7751.0 7751.0 7751.0 7751.0 7751.0 \n", - "20 AP2211 2022-02-11 09:00:16 7738.0 7738.0 7738.0 7738.0 7738.0 \n", - "21 AP2211 2022-02-11 09:00:17 7730.0 7730.0 7730.0 7730.0 7730.0 \n", - "22 AP2211 2022-02-11 09:00:18 7730.0 7730.0 7730.0 7730.0 7730.0 \n", - "23 AP2211 2022-02-11 09:00:19 7730.0 7730.0 7730.0 7730.0 7730.0 \n", - "24 AP2211 2022-02-11 09:00:20 7730.0 7730.0 7730.0 7730.0 7730.0 \n", - "25 AP2211 2022-02-11 09:00:21 7731.0 7731.0 7731.0 7731.0 7731.0 \n", - "26 AP2211 2022-02-11 09:00:22 7731.0 7731.0 7731.0 7731.0 7731.0 \n", - "27 AP2211 2022-02-11 09:00:22 7725.0 7725.0 7725.0 7725.0 7725.0 \n", - "28 AP2211 2022-02-11 09:00:23 7725.0 7725.0 7725.0 7725.0 7725.0 \n", - "29 AP2211 2022-02-11 09:00:24 7725.0 7725.0 7725.0 7725.0 7725.0 \n", - "30 AP2211 2022-02-11 09:00:25 7725.0 7725.0 7725.0 7725.0 7725.0 \n", - "31 AP2211 2022-02-11 09:00:26 7725.0 7725.0 7725.0 7725.0 7725.0 \n", - "32 AP2211 2022-02-11 09:00:27 7725.0 7725.0 7725.0 7725.0 7725.0 \n", - "33 AP2211 2022-02-11 09:00:29 7725.0 7725.0 7725.0 7725.0 7725.0 \n", - "34 AP2211 2022-02-11 09:00:30 7725.0 7725.0 7725.0 7725.0 7725.0 \n", - "35 AP2211 2022-02-11 09:00:31 7725.0 7725.0 7725.0 7725.0 7725.0 \n", - "36 AP2211 2022-02-11 09:00:32 7725.0 7725.0 7725.0 7725.0 7725.0 \n", - "37 AP2211 2022-02-11 09:00:33 7725.0 7725.0 7725.0 7725.0 7725.0 \n", - "38 AP2211 2022-02-11 09:00:34 7725.0 7725.0 7725.0 7725.0 7725.0 \n", - "39 AP2211 2022-02-11 09:00:35 7725.0 7725.0 7725.0 7725.0 7725.0 \n", - "\n", - " m_nAccHigh m_nAccLow m_iVolume ... m_nActAskTurnover \\\n", - "0 0.0 0.0 0 ... 0.0 \n", - "1 7761.0 7761.0 2705 ... 10496752.5 \n", - "2 7761.0 7761.0 0 ... 0.0 \n", - "3 7761.0 7759.0 1 ... 7761.0 \n", - "4 7761.0 7759.0 0 ... 0.0 \n", - "5 7761.0 7759.0 0 ... 0.0 \n", - "6 7761.0 7759.0 0 ... 0.0 \n", - "7 7761.0 7759.0 1 ... 7761.0 \n", - "8 7761.0 7759.0 0 ... 0.0 \n", - "9 7761.0 7757.0 1 ... 7761.0 \n", - "10 7761.0 7757.0 0 ... 0.0 \n", - "11 7761.0 7757.0 0 ... 0.0 \n", - "12 7761.0 7757.0 0 ... 0.0 \n", - "13 7761.0 7757.0 0 ... 0.0 \n", - "14 7761.0 7757.0 0 ... 0.0 \n", - "15 7761.0 7757.0 0 ... 0.0 \n", - "16 7761.0 7751.0 1 ... 7761.0 \n", - "17 7761.0 7751.0 0 ... 0.0 \n", - "18 7761.0 7751.0 0 ... 0.0 \n", - "19 7761.0 7751.0 0 ... 0.0 \n", - "20 7761.0 7738.0 1 ... 7761.0 \n", - "21 7761.0 7730.0 11 ... 85371.0 \n", - "22 7761.0 7730.0 0 ... 0.0 \n", - "23 7761.0 7730.0 0 ... 0.0 \n", - "24 7761.0 7730.0 0 ... 0.0 \n", - "25 7761.0 7730.0 1 ... 7761.0 \n", - "26 7761.0 7730.0 0 ... 0.0 \n", - "27 7761.0 7725.0 1 ... 7761.0 \n", - "28 7761.0 7725.0 0 ... 0.0 \n", - "29 7761.0 7725.0 0 ... 0.0 \n", - "30 7761.0 7725.0 0 ... 0.0 \n", - "31 7761.0 7725.0 0 ... 0.0 \n", - "32 7761.0 7725.0 0 ... 0.0 \n", - "33 7761.0 7725.0 0 ... 0.0 \n", - "34 7761.0 7725.0 0 ... 0.0 \n", - "35 7761.0 7725.0 0 ... 0.0 \n", - "36 7761.0 7725.0 0 ... 0.0 \n", - "37 7761.0 7725.0 0 ... 0.0 \n", - "38 7761.0 7725.0 0 ... 0.0 \n", - "39 7761.0 7725.0 0 ... 0.0 \n", - "\n", - " m_nAccActAskTurnover m_nBidOrder m_nAccBidOrder m_nAskOrder \\\n", - "0 0.0 0.0 0.0 0.0 \n", - "1 10496752.5 1.0 1.0 1.0 \n", - "2 10496752.5 1.0 2.0 1.0 \n", - "3 10504513.5 1.0 3.0 1.0 \n", - "4 10504513.5 1.0 4.0 1.0 \n", - "5 10504513.5 1.0 5.0 1.0 \n", - "6 10504513.5 1.0 6.0 1.0 \n", - "7 10512274.5 1.0 7.0 1.0 \n", - "8 10512274.5 1.0 8.0 1.0 \n", - "9 10520035.5 1.0 9.0 1.0 \n", - "10 10520035.5 1.0 10.0 1.0 \n", - "11 10520035.5 1.0 11.0 1.0 \n", - "12 10520035.5 1.0 12.0 1.0 \n", - "13 10520035.5 1.0 13.0 1.0 \n", - "14 10520035.5 1.0 14.0 1.0 \n", - "15 10520035.5 1.0 15.0 1.0 \n", - "16 10527796.5 1.0 16.0 1.0 \n", - "17 10527796.5 1.0 17.0 1.0 \n", - "18 10527796.5 2.0 19.0 1.0 \n", - "19 10527796.5 10.0 29.0 1.0 \n", - "20 10535557.5 9.0 38.0 1.0 \n", - "21 10620928.5 1.0 39.0 1.0 \n", - "22 10620928.5 1.0 40.0 1.0 \n", - "23 10620928.5 1.0 41.0 1.0 \n", - "24 10620928.5 1.0 42.0 1.0 \n", - "25 10628689.5 1.0 43.0 1.0 \n", - "26 10628689.5 1.0 44.0 1.0 \n", - "27 10636450.5 1.0 45.0 1.0 \n", - "28 10636450.5 1.0 46.0 1.0 \n", - "29 10636450.5 1.0 47.0 1.0 \n", - "30 10636450.5 1.0 48.0 1.0 \n", - "31 10636450.5 1.0 49.0 1.0 \n", - "32 10636450.5 1.0 50.0 1.0 \n", - "33 10636450.5 1.0 51.0 1.0 \n", - "34 10636450.5 1.0 52.0 1.0 \n", - "35 10636450.5 1.0 53.0 1.0 \n", - "36 10636450.5 1.0 54.0 1.0 \n", - "37 10636450.5 1.0 55.0 1.0 \n", - "38 10636450.5 1.0 56.0 1.0 \n", - "39 10636450.5 1.0 57.0 1.0 \n", + " code m_nDatetime m_nPrice m_iVolume m_iAccVolume \\\n", + "0 IC2210 2022-10-10 09:29:00 5730.2 109 109.0 \n", + "1 IC2210 2022-10-10 09:30:00 5730.0 25 134.0 \n", + "2 IC2210 2022-10-10 09:30:00 5730.0 30 164.0 \n", + "3 IC2210 2022-10-10 09:30:01 5730.6 26 190.0 \n", + "4 IC2210 2022-10-10 09:30:01 5730.2 29 219.0 \n", + "... ... ... ... ... ... \n", + "5833 IC2306 2022-11-23 14:59:57 6026.0 1 6468.0 \n", + "5834 IC2306 2022-11-23 14:59:58 6026.0 0 6468.0 \n", + "5835 IC2306 2022-11-23 14:59:59 6026.0 5 6473.0 \n", + "5836 IC2306 2022-11-23 15:00:00 6019.2 1 6474.0 \n", + "5837 IC2306 2022-11-23 15:25:24 6019.2 0 6474.0 \n", "\n", - " m_nAccAskOrder m_nABOrderRate m_nAccABOrderRate m_nMItemsVolRate \\\n", - "0 0.0 0.0 0.000000 0.0 \n", - "1 1.0 1.0 1.000000 0.0 \n", - "2 2.0 1.0 1.000000 0.0 \n", - "3 3.0 1.0 1.000000 0.0 \n", - "4 4.0 1.0 1.000000 0.0 \n", - "5 5.0 1.0 1.000000 0.0 \n", - "6 6.0 1.0 1.000000 0.0 \n", - "7 7.0 1.0 1.000000 0.0 \n", - "8 8.0 1.0 1.000000 0.0 \n", - "9 9.0 1.0 1.000000 0.0 \n", - "10 10.0 1.0 1.000000 0.0 \n", - "11 11.0 1.0 1.000000 0.0 \n", - "12 12.0 1.0 1.000000 0.0 \n", - "13 13.0 1.0 1.000000 0.0 \n", - "14 14.0 1.0 1.000000 0.0 \n", - "15 15.0 1.0 1.000000 0.0 \n", - "16 16.0 1.0 1.000000 0.0 \n", - "17 17.0 1.0 1.000000 0.0 \n", - "18 18.0 2.0 1.055556 0.0 \n", - "19 19.0 10.0 1.526316 0.0 \n", - "20 20.0 9.0 1.900000 0.0 \n", - "21 21.0 1.0 1.857143 0.0 \n", - "22 22.0 1.0 1.818182 0.0 \n", - "23 23.0 1.0 1.782609 0.0 \n", - "24 24.0 1.0 1.750000 0.0 \n", - "25 25.0 1.0 1.720000 0.0 \n", - "26 26.0 1.0 1.692308 0.0 \n", - "27 27.0 1.0 1.666667 0.0 \n", - "28 28.0 1.0 1.642857 0.0 \n", - "29 29.0 1.0 1.620690 0.0 \n", - "30 30.0 1.0 1.600000 0.0 \n", - "31 31.0 1.0 1.580645 0.0 \n", - "32 32.0 1.0 1.562500 0.0 \n", - "33 33.0 1.0 1.545455 0.0 \n", - "34 34.0 1.0 1.529412 0.0 \n", - "35 35.0 1.0 1.514286 0.0 \n", - "36 36.0 1.0 1.500000 0.0 \n", - "37 37.0 1.0 1.486486 0.0 \n", - "38 38.0 1.0 1.473684 0.0 \n", - "39 39.0 1.0 1.461538 0.0 \n", + " m_nMatchItems m_nAccMatchItems m_nBidPrice m_nBidVolume m_nAskPrice \\\n", + "0 -76 -29454.0 5730.0 11 5730.2 \n", + "1 -16 -29470.0 5730.0 1 5732.0 \n", + "2 -20 -29490.0 5730.2 1 5730.8 \n", + "3 -17 -29507.0 5730.2 2 5732.0 \n", + "4 -19 -29526.0 5730.2 1 5731.4 \n", + "... ... ... ... ... ... \n", + "5833 0 -23469.0 6019.0 1 6026.0 \n", + "5834 0 -23469.0 6019.2 1 6026.0 \n", + "5835 0 -23469.0 6019.2 1 6026.0 \n", + "5836 0 -23469.0 6019.0 1 6019.2 \n", + "5837 0 -23469.0 6019.0 1 6019.2 \n", "\n", - " code_init \n", - "0 AP \n", - "1 AP \n", - "2 AP \n", - "3 AP \n", - "4 AP \n", - "5 AP \n", - "6 AP \n", - "7 AP \n", - "8 AP \n", - "9 AP \n", - "10 AP \n", - "11 AP \n", - "12 AP \n", - "13 AP \n", - "14 AP \n", - "15 AP \n", - "16 AP \n", - "17 AP \n", - "18 AP \n", - "19 AP \n", - "20 AP \n", - "21 AP \n", - "22 AP \n", - "23 AP \n", - "24 AP \n", - "25 AP \n", - "26 AP \n", - "27 AP \n", - "28 AP \n", - "29 AP \n", - "30 AP \n", - "31 AP \n", - "32 AP \n", - "33 AP \n", - "34 AP \n", - "35 AP \n", - "36 AP \n", - "37 AP \n", - "38 AP \n", - "39 AP \n", + " m_nAskVolume \n", + "0 1 \n", + "1 10 \n", + "2 2 \n", + "3 7 \n", + "4 1 \n", + "... ... \n", + "5833 9 \n", + "5834 9 \n", + "5835 4 \n", + "5836 9 \n", + "5837 9 \n", "\n", - "[40 rows x 38 columns]" + "[2881230 rows x 11 columns]" ] }, "execution_count": 10, @@ -1800,8 +950,679 @@ } ], "source": [ - "df = sess.run(\"\"\"select top 40 * from pt\"\"\")\n", - "df" + "st_d = '2022.10.01'\n", + "en_d = '2022.11.24'\n", + "code_init = 'IC'\n", + "\n", + "spt=\"\"\"pt=loadTable(\"dfs://hft_futuremarket_ts\",\"TickPartitioned\")\n", + "select code,m_nDatetime,m_nPrice,m_iVolume,m_iAccVolume,m_nMatchItems,m_nAccMatchItems,m_nBidPrice,m_nBidVolume,m_nAskPrice,m_nAskVolume from pt where m_nDatetime.date()>={st_d}d and m_nDatetime.date()<={en_d}d and code_init=`{code_init}\n", + "\"\"\".format(st_d=st_d,en_d=en_d,code_init=code_init)\n", + "\n", + "block= sess.run(spt, fetchSize = 8192)\n", + "\n", + "total = []\n", + "while block.hasNext():\n", + " tem = block.read()\n", + " total.append(tem)\n", + "\n", + "import pandas as pd\n", + "df_ddb=pd.concat(total)\n", + "df_ddb" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 表结构和字段解释\n", + "\n", + "### DailyFutureInfoPartitioned\n" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'partitionType': array([1, 1], dtype=int32),\n", + " 'partitionColumnType': array([ 7, 17], dtype=int32),\n", + " 'partitionColumnIndex': array([7, 1], dtype=int32),\n", + " 'chunkPath': None,\n", + " 'colDefs': name typeString typeInt comment\n", + " 0 code_dom STRING 18 \n", + " 1 code_init STRING 18 \n", + " 2 code_cont STRING 18 \n", + " 3 code_cont1 STRING 18 \n", + " 4 code_cont2 STRING 18 \n", + " 5 code_cont3 STRING 18 \n", + " 6 code_cont4 STRING 18 \n", + " 7 m_nDate NANOTIMESTAMP 14 ,\n", + " 'chunkGranularity': 'TABLE',\n", + " 'partitionTypeName': array(['VALUE', 'VALUE'], dtype=object),\n", + " 'keepDuplicates': 'ALL',\n", + " 'engineType': 'TSDB',\n", + " 'partitionColumnName': array(['m_nDate', 'code_init'], dtype=object),\n", + " 'partitionSchema': [array(['2050-11', '2050-10', '2050-09', '2050-08', '2050-07', '2050-06',\n", + " '2050-05', '2050-04', '2050-03', '2050-02', '2050-01', '2049-12',\n", + " '2049-11', '2049-10', '2049-09', '2049-08', '2049-07', '2049-06',\n", + " '2049-05', '2049-04', '2049-03', '2049-02', '2049-01', '2048-12',\n", + " '2048-11', '2048-10', '2048-09', '2048-08', '2048-07', '2048-06',\n", + " '2048-05', '2048-04', '2048-03', '2048-02', '2048-01', '2047-12',\n", + " '2047-11', '2047-10', '2047-09', '2047-08', '2047-07', '2047-06',\n", + " '2047-05', '2047-04', '2047-03', '2047-02', '2047-01', '2046-12',\n", + " '2046-11', '2046-10', '2046-09', '2046-08', '2046-07', '2046-06',\n", + " '2046-05', '2046-04', '2046-03', '2046-02', '2046-01', '2045-12',\n", + " '2045-11', '2045-10', '2045-09', '2045-08', '2045-07', '2045-06',\n", + " '2045-05', '2045-04', '2045-03', '2045-02', '2045-01', '2044-12',\n", + " '2044-11', '2044-10', '2044-09', '2044-08', '2044-07', '2044-06',\n", + " '2044-05', '2044-04', '2044-03', '2044-02', '2044-01', '2043-12',\n", + " '2043-11', '2043-10', '2043-09', '2043-08', '2043-07', '2043-06',\n", + " '2043-05', '2043-04', '2043-03', '2043-02', '2043-01', '2042-12',\n", + " '2042-11', '2042-10', '2042-09', '2042-08', '2042-07', '2042-06',\n", + " '2042-05', '2042-04', '2042-03', '2042-02', '2042-01', '2041-12',\n", + " '2041-11', '2041-10', '2041-09', '2041-08', '2041-07', '2041-06',\n", + " '2041-05', '2041-04', '2041-03', '2041-02', '2041-01', '2040-12',\n", + " '2040-11', '2040-10', '2040-09', '2040-08', '2040-07', '2040-06',\n", + " '2040-05', '2040-04', '2040-03', '2040-02', '2040-01', '2039-12',\n", + " '2039-11', '2039-10', '2039-09', '2039-08', '2039-07', '2039-06',\n", + " '2039-05', '2039-04', '2039-03', '2039-02', '2039-01', '2038-12',\n", + " '2038-11', '2038-10', '2038-09', '2038-08', '2038-07', '2038-06',\n", + " '2038-05', '2038-04', '2038-03', '2038-02', '2038-01', '2037-12',\n", + " '2037-11', '2037-10', '2037-09', '2037-08', '2037-07', '2037-06',\n", + " '2037-05', '2037-04', '2037-03', '2037-01', '2036-12', '2036-11',\n", + " '2036-10', '2036-09', '2036-08', '2036-07', '2036-06', '2036-05',\n", + " '2036-04', '2036-03', '2036-02', '2036-01', '2035-12', '2035-11',\n", + " '2035-10', '2035-09', '2035-08', '2035-07', '2035-06', '2035-05',\n", + " '2035-04', '2035-03', '2035-02', '2035-01', '2034-12', '2034-11',\n", + " '2034-10', '2034-09', '2034-08', '2034-07', '2034-06', '2034-05',\n", + " '2034-04', '2034-03', '2034-02', '2034-01', '2033-12', '2033-11',\n", + " '2033-10', '2033-09', '2033-08', '2033-07', '2033-06', '2033-05',\n", + " '2033-04', '2033-03', '2033-02', '2033-01', '2032-12', '2032-11',\n", + " '2032-10', '2032-09', '2032-08', '2032-07', '2032-06', '2032-05',\n", + " '2032-04', '2032-03', '2032-02', '2032-01', '2031-12', '2031-11',\n", + " '2031-10', '2031-09', '2031-08', '2031-07', '2031-06', '2031-05',\n", + " '2031-04', '2031-03', '2031-02', '2031-01', '2030-12', '2030-11',\n", + " '2030-10', '2030-09', '2030-08', '2030-07', '2030-06', '2030-05',\n", + " '2030-04', '2030-03', '2030-02', '2030-01', '2029-12', '2029-11',\n", + " '2029-10', '2029-09', '2029-08', '2029-07', '2029-06', '2029-05',\n", + " '2029-04', '2029-03', '2029-02', '2029-01', '2028-12', '2028-11',\n", + " '2028-10', '2028-09', '2028-08', '2028-07', '2028-06', '2028-05',\n", + " '2028-04', '2028-03', '2028-02', '2028-01', '2027-12', '2027-11',\n", + " '2027-10', '2027-09', '2027-08', '2027-07', '2027-06', '2027-05',\n", + " '2027-04', '2027-03', '2027-02', '2027-01', '2026-12', '2026-11',\n", + " '2026-10', '2026-09', '2026-08', '2026-07', '2026-06', '2026-05',\n", + " '2026-04', '2026-03', '2026-02', '2026-01', '2025-12', '2025-11',\n", + " '2025-10', '2025-09', '2025-08', '2025-07', '2025-06', '2025-05',\n", + " '2025-04', '2025-03', '2025-02', '2025-01', '2024-12', '2024-11',\n", + " '2024-10', '2024-09', '2024-08', '2024-07', '2024-06', '2024-05',\n", + " '2024-04', '2024-03', '2024-02', '2024-01', '2023-12', '2023-11',\n", + " '2023-10', '2023-09', '2023-08', '2023-07', '2023-06', '2023-05',\n", + " '2023-04', '2023-03', '2023-02', '2023-01', '2022-12', '2022-11',\n", + " '2022-10', '2022-09', '2022-08', '2022-07', '2022-06', '2022-05',\n", + " '2022-04', '2022-03', '2022-02', '2022-01', '2021-12', '2021-11',\n", + " '2021-10', '2021-09', '2021-08', '2021-07', '2021-06', '2021-05',\n", + " '2021-04', '2021-03', '2021-02', '2021-01', '2020-12', '2020-11',\n", + " '2020-10', '2020-09', '2020-08', '2020-07', '2020-06', '2020-05',\n", + " '2020-04', '2020-03', '2020-02', '2020-01', '2019-12', '2019-11',\n", + " '2019-10', '2019-09', '2019-08', '2019-07', '2019-06', '2019-05',\n", + " '2019-04', '2019-03', '2019-02', '2019-01', '2018-12', '2018-11',\n", + " '2018-10', '2018-09', '2018-08', '2018-07', '2018-06', '2018-05',\n", + " '2018-04', '2018-03', '2018-02', '2018-01', '2017-12', '2017-11',\n", + " '2017-10', '2017-09', '2017-08', '2017-07', '2017-06', '2017-05',\n", + " '2017-04', '2017-03', '2017-02', '2017-01', '2016-12', '2016-11',\n", + " '2016-10', '2016-09', '2016-08', '2016-07', '2016-06', '2016-05',\n", + " '2016-04', '2016-03', '2016-02', '2016-01', '2015-12', '2015-11',\n", + " '2015-10', '2015-09', '2015-08', '2015-07', '2015-06', '2015-05',\n", + " '2015-04', '2015-03', '2015-02', '2015-01', '2014-12', '2014-11',\n", + " '2014-10', '2014-09', '2014-08', '2014-07', '2014-06', '2014-05',\n", + " '2014-04', '2014-03', '2014-02', '2014-01', '2013-12', '2013-11',\n", + " '2013-10', '2013-09', '2013-08', '2013-07', '2013-06', '2013-05',\n", + " '2013-04', '2013-03', '2013-02', '2013-01', '2012-12', '2012-11',\n", + " '2012-10', '2012-09', '2012-08', '2012-07', '2012-06', '2012-05',\n", + " '2012-04', '2012-03', '2012-02', '2012-01', '2011-12', '2011-11',\n", + " '2011-10', '2011-09', '2011-08', '2011-07', '2011-06', '2011-05',\n", + " '2011-04', '2011-03', '2011-02', '2011-01', '2010-12', '2010-11',\n", + " '2010-10', '2010-09', '2010-08', '2010-07', '2010-06', '2010-05',\n", + " '2010-04', '2010-03', '2010-02', '2010-01', '2009-12', '2009-11',\n", + " '2009-10', '2009-09', '2009-08', '2009-07', '2009-06', '2009-05',\n", + " '2009-04', '2009-03', '2009-02', '2009-01', '2008-12', '2008-11',\n", + " '2008-10', '2008-09', '2008-08', '2008-07', '2008-06', '2008-05',\n", + " '2008-04', '2008-03', '2008-02', '2008-01', '2007-12', '2007-11',\n", + " '2007-10', '2007-09', '2007-08', '2007-07', '2007-06', '2007-05',\n", + " '2007-04', '2007-03', '2007-02', '2007-01', '2006-12', '2006-11',\n", + " '2006-10', '2006-09', '2006-08', '2006-07', '2006-06', '2006-05',\n", + " '2006-04', '2006-03', '2006-02', '2006-01', '2005-12', '2005-11',\n", + " '2005-10', '2005-09', '2005-08', '2005-07', '2005-06', '2005-05',\n", + " '2005-04', '2005-03', '2005-02', '2005-01', '2004-12', '2004-11',\n", + " '2004-10', '2004-09', '2004-08', '2004-07', '2004-06', '2004-05',\n", + " '2004-04', '2004-03', '2004-02', '2004-01', '2003-12', '2003-11',\n", + " '2003-10', '2003-09', '2003-08', '2003-07', '2003-06', '2003-05',\n", + " '2003-04', '2003-03', '2003-02', '2003-01', '2002-12', '2002-11',\n", + " '2002-10', '2002-09', '2002-08', '2002-07', '2002-06', '2002-05',\n", + " '2002-04', '2002-03', '2002-02', '2002-01', '2001-12', '2001-11',\n", + " '2001-10', '2001-09', '2001-08', '2001-07', '2001-06', '2001-05',\n", + " '2001-04', '2001-03', '2001-02', '2001-01', '2000-12', '2000-11',\n", + " '2000-10', '2000-09', '2000-08', '2000-07', '2000-06', '2000-05',\n", + " '2000-04', '2000-03', '2000-02', '2000-01', '2037-02', '1899-12'],\n", + " dtype='datetime64[M]'),\n", + " array(['zn', 'y', 'wr', 'v', 'ss', 'sp', 'sn', 'sc', 'ru', 'rr', 'rb',\n", + " 'pp', 'pg', 'pb', 'p', 'nr', 'ni', 'm', 'lu', 'lh', 'l', 'jm',\n", + " 'jd', 'j', 'i', 'hc', 'fu', 'fb', 'eg', 'eb', 'cu', 'cs', 'c',\n", + " 'bu', 'bc', 'bb', 'b', 'au', 'al', 'ag', 'a', 'ZC', 'WH', 'UR',\n", + " 'TS', 'TF', 'TA', 'T', 'SR', 'SM', 'SF', 'SA', 'RS', 'RM', 'RI',\n", + " 'PM', 'PK', 'PF', 'OI', 'MA', 'LR', 'JR', 'IM', 'IH', 'IF', 'IC',\n", + " 'FG', 'CY', 'CJ', 'CF', 'AP'], dtype=object)],\n", + " 'sortColumns': array(['code_init', 'm_nDate'], dtype=object),\n", + " 'partitionSites': None}" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sess.run('loadTable(\"dfs://hft_futuremarket_ts\",\"DailyFutureInfoPartitioned\").schema()')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### MinKlinePartitioned" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'partitionType': array([1, 1], dtype=int32),\n", + " 'partitionColumnType': array([ 7, 17], dtype=int32),\n", + " 'partitionColumnIndex': array([ 1, 37], dtype=int32),\n", + " 'chunkPath': None,\n", + " 'colDefs': name typeString typeInt comment\n", + " 0 code STRING 18 \n", + " 1 m_nDatetime NANOTIMESTAMP 14 \n", + " 2 m_nPrice DOUBLE 16 \n", + " 3 m_nOpen DOUBLE 16 \n", + " 4 m_nHigh DOUBLE 16 \n", + " 5 m_nLow DOUBLE 16 \n", + " 6 m_nClose DOUBLE 16 \n", + " 7 m_nAccHigh DOUBLE 16 \n", + " 8 m_nAccLow DOUBLE 16 \n", + " 9 m_iVolume SHORT 3 \n", + " 10 m_iAccVolume SHORT 3 \n", + " 11 m_nMatchItems SHORT 3 \n", + " 12 m_nAccMatchItems SHORT 3 \n", + " 13 m_iTurnover DOUBLE 16 \n", + " 14 m_iAccTurnover DOUBLE 16 \n", + " 15 m_nPreClose DOUBLE 16 \n", + " 16 m_nAccPreClose DOUBLE 16 \n", + " 17 m_nBidPrice DOUBLE 16 \n", + " 18 m_nBidVolume SHORT 3 \n", + " 19 m_nAskPrice DOUBLE 16 \n", + " 20 m_nAskVolume SHORT 3 \n", + " 21 m_iABFlag CHAR 2 \n", + " 22 m_nActBidVolume SHORT 3 \n", + " 23 m_nAccActBidVolume SHORT 3 \n", + " 24 m_nActBidTurnover DOUBLE 16 \n", + " 25 m_nAccActBidTurnover DOUBLE 16 \n", + " 26 m_nActAskVolume SHORT 3 \n", + " 27 m_nAccActAskVolume SHORT 3 \n", + " 28 m_nActAskTurnover DOUBLE 16 \n", + " 29 m_nAccActAskTurnover DOUBLE 16 \n", + " 30 m_nBidOrder DOUBLE 16 \n", + " 31 m_nAccBidOrder DOUBLE 16 \n", + " 32 m_nAskOrder DOUBLE 16 \n", + " 33 m_nAccAskOrder DOUBLE 16 \n", + " 34 m_nABOrderRate DOUBLE 16 \n", + " 35 m_nAccABOrderRate DOUBLE 16 \n", + " 36 m_nMItemsVolRate DOUBLE 16 \n", + " 37 code_init STRING 18 ,\n", + " 'chunkGranularity': 'TABLE',\n", + " 'partitionTypeName': array(['VALUE', 'VALUE'], dtype=object),\n", + " 'keepDuplicates': 'ALL',\n", + " 'engineType': 'TSDB',\n", + " 'partitionColumnName': array(['m_nDatetime', 'code_init'], dtype=object),\n", + " 'partitionSchema': [array(['2050-11', '2050-10', '2050-09', '2050-08', '2050-07', '2050-06',\n", + " '2050-05', '2050-04', '2050-03', '2050-02', '2050-01', '2049-12',\n", + " '2049-11', '2049-10', '2049-09', '2049-08', '2049-07', '2049-06',\n", + " '2049-05', '2049-04', '2049-03', '2049-02', '2049-01', '2048-12',\n", + " '2048-11', '2048-10', '2048-09', '2048-08', '2048-07', '2048-06',\n", + " '2048-05', '2048-04', '2048-03', '2048-02', '2048-01', '2047-12',\n", + " '2047-11', '2047-10', '2047-09', '2047-08', '2047-07', '2047-06',\n", + " '2047-05', '2047-04', '2047-03', '2047-02', '2047-01', '2046-12',\n", + " '2046-11', '2046-10', '2046-09', '2046-08', '2046-07', '2046-06',\n", + " '2046-05', '2046-04', '2046-03', '2046-02', '2046-01', '2045-12',\n", + " '2045-11', '2045-10', '2045-09', '2045-08', '2045-07', '2045-06',\n", + " '2045-05', '2045-04', '2045-03', '2045-02', '2045-01', '2044-12',\n", + " '2044-11', '2044-10', '2044-09', '2044-08', '2044-07', '2044-06',\n", + " '2044-05', '2044-04', '2044-03', '2044-02', '2044-01', '2043-12',\n", + " '2043-11', '2043-10', '2043-09', '2043-08', '2043-07', '2043-06',\n", + " '2043-05', '2043-04', '2043-03', '2043-02', '2043-01', '2042-12',\n", + " '2042-11', '2042-10', '2042-09', '2042-08', '2042-07', '2042-06',\n", + " '2042-05', '2042-04', '2042-03', '2042-02', '2042-01', '2041-12',\n", + " '2041-11', '2041-10', '2041-09', '2041-08', '2041-07', '2041-06',\n", + " '2041-05', '2041-04', '2041-03', '2041-02', '2041-01', '2040-12',\n", + " '2040-11', '2040-10', '2040-09', '2040-08', '2040-07', '2040-06',\n", + " '2040-05', '2040-04', '2040-03', '2040-02', '2040-01', '2039-12',\n", + " '2039-11', '2039-10', '2039-09', '2039-08', '2039-07', '2039-06',\n", + " '2039-05', '2039-04', '2039-03', '2039-02', '2039-01', '2038-12',\n", + " '2038-11', '2038-10', '2038-09', '2038-08', '2038-07', '2038-06',\n", + " '2038-05', '2038-04', '2038-03', '2038-02', '2038-01', '2037-12',\n", + " '2037-11', '2037-10', '2037-09', '2037-08', '2037-07', '2037-06',\n", + " '2037-05', '2037-04', '2037-03', '2037-01', '2036-12', '2036-11',\n", + " '2036-10', '2036-09', '2036-08', '2036-07', '2036-06', '2036-05',\n", + " '2036-04', '2036-03', '2036-02', '2036-01', '2035-12', '2035-11',\n", + " '2035-10', '2035-09', '2035-08', '2035-07', '2035-06', '2035-05',\n", + " '2035-04', '2035-03', '2035-02', '2035-01', '2034-12', '2034-11',\n", + " '2034-10', '2034-09', '2034-08', '2034-07', '2034-06', '2034-05',\n", + " '2034-04', '2034-03', '2034-02', '2034-01', '2033-12', '2033-11',\n", + " '2033-10', '2033-09', '2033-08', '2033-07', '2033-06', '2033-05',\n", + " '2033-04', '2033-03', '2033-02', '2033-01', '2032-12', '2032-11',\n", + " '2032-10', '2032-09', '2032-08', '2032-07', '2032-06', '2032-05',\n", + " '2032-04', '2032-03', '2032-02', '2032-01', '2031-12', '2031-11',\n", + " '2031-10', '2031-09', '2031-08', '2031-07', '2031-06', '2031-05',\n", + " '2031-04', '2031-03', '2031-02', '2031-01', '2030-12', '2030-11',\n", + " '2030-10', '2030-09', '2030-08', '2030-07', '2030-06', '2030-05',\n", + " '2030-04', '2030-03', '2030-02', '2030-01', '2029-12', '2029-11',\n", + " '2029-10', '2029-09', '2029-08', '2029-07', '2029-06', '2029-05',\n", + " '2029-04', '2029-03', '2029-02', '2029-01', '2028-12', '2028-11',\n", + " '2028-10', '2028-09', '2028-08', '2028-07', '2028-06', '2028-05',\n", + " '2028-04', '2028-03', '2028-02', '2028-01', '2027-12', '2027-11',\n", + " '2027-10', '2027-09', '2027-08', '2027-07', '2027-06', '2027-05',\n", + " '2027-04', '2027-03', '2027-02', '2027-01', '2026-12', '2026-11',\n", + " '2026-10', '2026-09', '2026-08', '2026-07', '2026-06', '2026-05',\n", + " '2026-04', '2026-03', '2026-02', '2026-01', '2025-12', '2025-11',\n", + " '2025-10', '2025-09', '2025-08', '2025-07', '2025-06', '2025-05',\n", + " '2025-04', '2025-03', '2025-02', '2025-01', '2024-12', '2024-11',\n", + " '2024-10', '2024-09', '2024-08', '2024-07', '2024-06', '2024-05',\n", + " '2024-04', '2024-03', '2024-02', '2024-01', '2023-12', '2023-11',\n", + " '2023-10', '2023-09', '2023-08', '2023-07', '2023-06', '2023-05',\n", + " '2023-04', '2023-03', '2023-02', '2023-01', '2022-12', '2022-11',\n", + " '2022-10', '2022-09', '2022-08', '2022-07', '2022-06', '2022-05',\n", + " '2022-04', '2022-03', '2022-02', '2022-01', '2021-12', '2021-11',\n", + " '2021-10', '2021-09', '2021-08', '2021-07', '2021-06', '2021-05',\n", + " '2021-04', '2021-03', '2021-02', '2021-01', '2020-12', '2020-11',\n", + " '2020-10', '2020-09', '2020-08', '2020-07', '2020-06', '2020-05',\n", + " '2020-04', '2020-03', '2020-02', '2020-01', '2019-12', '2019-11',\n", + " '2019-10', '2019-09', '2019-08', '2019-07', '2019-06', '2019-05',\n", + " '2019-04', '2019-03', '2019-02', '2019-01', '2018-12', '2018-11',\n", + " '2018-10', '2018-09', '2018-08', '2018-07', '2018-06', '2018-05',\n", + " '2018-04', '2018-03', '2018-02', '2018-01', '2017-12', '2017-11',\n", + " '2017-10', '2017-09', '2017-08', '2017-07', '2017-06', '2017-05',\n", + " '2017-04', '2017-03', '2017-02', '2017-01', '2016-12', '2016-11',\n", + " '2016-10', '2016-09', '2016-08', '2016-07', '2016-06', '2016-05',\n", + " '2016-04', '2016-03', '2016-02', '2016-01', '2015-12', '2015-11',\n", + " '2015-10', '2015-09', '2015-08', '2015-07', '2015-06', '2015-05',\n", + " '2015-04', '2015-03', '2015-02', '2015-01', '2014-12', '2014-11',\n", + " '2014-10', '2014-09', '2014-08', '2014-07', '2014-06', '2014-05',\n", + " '2014-04', '2014-03', '2014-02', '2014-01', '2013-12', '2013-11',\n", + " '2013-10', '2013-09', '2013-08', '2013-07', '2013-06', '2013-05',\n", + " '2013-04', '2013-03', '2013-02', '2013-01', '2012-12', '2012-11',\n", + " '2012-10', '2012-09', '2012-08', '2012-07', '2012-06', '2012-05',\n", + " '2012-04', '2012-03', '2012-02', '2012-01', '2011-12', '2011-11',\n", + " '2011-10', '2011-09', '2011-08', '2011-07', '2011-06', '2011-05',\n", + " '2011-04', '2011-03', '2011-02', '2011-01', '2010-12', '2010-11',\n", + " '2010-10', '2010-09', '2010-08', '2010-07', '2010-06', '2010-05',\n", + " '2010-04', '2010-03', '2010-02', '2010-01', '2009-12', '2009-11',\n", + " '2009-10', '2009-09', '2009-08', '2009-07', '2009-06', '2009-05',\n", + " '2009-04', '2009-03', '2009-02', '2009-01', '2008-12', '2008-11',\n", + " '2008-10', '2008-09', '2008-08', '2008-07', '2008-06', '2008-05',\n", + " '2008-04', '2008-03', '2008-02', '2008-01', '2007-12', '2007-11',\n", + " '2007-10', '2007-09', '2007-08', '2007-07', '2007-06', '2007-05',\n", + " '2007-04', '2007-03', '2007-02', '2007-01', '2006-12', '2006-11',\n", + " '2006-10', '2006-09', '2006-08', '2006-07', '2006-06', '2006-05',\n", + " '2006-04', '2006-03', '2006-02', '2006-01', '2005-12', '2005-11',\n", + " '2005-10', '2005-09', '2005-08', '2005-07', '2005-06', '2005-05',\n", + " '2005-04', '2005-03', '2005-02', '2005-01', '2004-12', '2004-11',\n", + " '2004-10', '2004-09', '2004-08', '2004-07', '2004-06', '2004-05',\n", + " '2004-04', '2004-03', '2004-02', '2004-01', '2003-12', '2003-11',\n", + " '2003-10', '2003-09', '2003-08', '2003-07', '2003-06', '2003-05',\n", + " '2003-04', '2003-03', '2003-02', '2003-01', '2002-12', '2002-11',\n", + " '2002-10', '2002-09', '2002-08', '2002-07', '2002-06', '2002-05',\n", + " '2002-04', '2002-03', '2002-02', '2002-01', '2001-12', '2001-11',\n", + " '2001-10', '2001-09', '2001-08', '2001-07', '2001-06', '2001-05',\n", + " '2001-04', '2001-03', '2001-02', '2001-01', '2000-12', '2000-11',\n", + " '2000-10', '2000-09', '2000-08', '2000-07', '2000-06', '2000-05',\n", + " '2000-04', '2000-03', '2000-02', '2000-01', '2037-02', '1899-12'],\n", + " dtype='datetime64[M]'),\n", + " array(['zn', 'y', 'wr', 'v', 'ss', 'sp', 'sn', 'sc', 'ru', 'rr', 'rb',\n", + " 'pp', 'pg', 'pb', 'p', 'nr', 'ni', 'm', 'lu', 'lh', 'l', 'jm',\n", + " 'jd', 'j', 'i', 'hc', 'fu', 'fb', 'eg', 'eb', 'cu', 'cs', 'c',\n", + " 'bu', 'bc', 'bb', 'b', 'au', 'al', 'ag', 'a', 'ZC', 'WH', 'UR',\n", + " 'TS', 'TF', 'TA', 'T', 'SR', 'SM', 'SF', 'SA', 'RS', 'RM', 'RI',\n", + " 'PM', 'PK', 'PF', 'OI', 'MA', 'LR', 'JR', 'IM', 'IH', 'IF', 'IC',\n", + " 'FG', 'CY', 'CJ', 'CF', 'AP'], dtype=object)],\n", + " 'sortColumns': array(['code', 'm_nDatetime'], dtype=object),\n", + " 'partitionSites': None}" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sess.run('loadTable(\"dfs://hft_futuremarket_ts\",\"MinKlinePartitioned\").schema()')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### TickPartitioned" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'partitionType': array([1, 1], dtype=int32),\n", + " 'partitionColumnType': array([ 7, 17], dtype=int32),\n", + " 'partitionColumnIndex': array([ 1, 37], dtype=int32),\n", + " 'chunkPath': None,\n", + " 'colDefs': name typeString typeInt comment\n", + " 0 code STRING 18 \n", + " 1 m_nDatetime NANOTIMESTAMP 14 \n", + " 2 m_nPrice DOUBLE 16 \n", + " 3 m_nOpen DOUBLE 16 \n", + " 4 m_nHigh DOUBLE 16 \n", + " 5 m_nLow DOUBLE 16 \n", + " 6 m_nClose DOUBLE 16 \n", + " 7 m_nAccHigh DOUBLE 16 \n", + " 8 m_nAccLow DOUBLE 16 \n", + " 9 m_iVolume SHORT 3 \n", + " 10 m_iAccVolume SHORT 3 \n", + " 11 m_nMatchItems SHORT 3 \n", + " 12 m_nAccMatchItems SHORT 3 \n", + " 13 m_iTurnover DOUBLE 16 \n", + " 14 m_iAccTurnover DOUBLE 16 \n", + " 15 m_nPreClose DOUBLE 16 \n", + " 16 m_nAccPreClose DOUBLE 16 \n", + " 17 m_nBidPrice DOUBLE 16 \n", + " 18 m_nBidVolume SHORT 3 \n", + " 19 m_nAskPrice DOUBLE 16 \n", + " 20 m_nAskVolume SHORT 3 \n", + " 21 m_iABFlag CHAR 2 \n", + " 22 m_nActBidVolume SHORT 3 \n", + " 23 m_nAccActBidVolume SHORT 3 \n", + " 24 m_nActBidTurnover DOUBLE 16 \n", + " 25 m_nAccActBidTurnover DOUBLE 16 \n", + " 26 m_nActAskVolume SHORT 3 \n", + " 27 m_nAccActAskVolume SHORT 3 \n", + " 28 m_nActAskTurnover DOUBLE 16 \n", + " 29 m_nAccActAskTurnover DOUBLE 16 \n", + " 30 m_nBidOrder DOUBLE 16 \n", + " 31 m_nAccBidOrder DOUBLE 16 \n", + " 32 m_nAskOrder DOUBLE 16 \n", + " 33 m_nAccAskOrder DOUBLE 16 \n", + " 34 m_nABOrderRate DOUBLE 16 \n", + " 35 m_nAccABOrderRate DOUBLE 16 \n", + " 36 m_nMItemsVolRate DOUBLE 16 \n", + " 37 code_init STRING 18 ,\n", + " 'chunkGranularity': 'TABLE',\n", + " 'partitionTypeName': array(['VALUE', 'VALUE'], dtype=object),\n", + " 'keepDuplicates': 'ALL',\n", + " 'engineType': 'TSDB',\n", + " 'partitionColumnName': array(['m_nDatetime', 'code_init'], dtype=object),\n", + " 'partitionSchema': [array(['2050-11', '2050-10', '2050-09', '2050-08', '2050-07', '2050-06',\n", + " '2050-05', '2050-04', '2050-03', '2050-02', '2050-01', '2049-12',\n", + " '2049-11', '2049-10', '2049-09', '2049-08', '2049-07', '2049-06',\n", + " '2049-05', '2049-04', '2049-03', '2049-02', '2049-01', '2048-12',\n", + " '2048-11', '2048-10', '2048-09', '2048-08', '2048-07', '2048-06',\n", + " '2048-05', '2048-04', '2048-03', '2048-02', '2048-01', '2047-12',\n", + " '2047-11', '2047-10', '2047-09', '2047-08', '2047-07', '2047-06',\n", + " '2047-05', '2047-04', '2047-03', '2047-02', '2047-01', '2046-12',\n", + " '2046-11', '2046-10', '2046-09', '2046-08', '2046-07', '2046-06',\n", + " '2046-05', '2046-04', '2046-03', '2046-02', '2046-01', '2045-12',\n", + " '2045-11', '2045-10', '2045-09', '2045-08', '2045-07', '2045-06',\n", + " '2045-05', '2045-04', '2045-03', '2045-02', '2045-01', '2044-12',\n", + " '2044-11', '2044-10', '2044-09', '2044-08', '2044-07', '2044-06',\n", + " '2044-05', '2044-04', '2044-03', '2044-02', '2044-01', '2043-12',\n", + " '2043-11', '2043-10', '2043-09', '2043-08', '2043-07', '2043-06',\n", + " '2043-05', '2043-04', '2043-03', '2043-02', '2043-01', '2042-12',\n", + " '2042-11', '2042-10', '2042-09', '2042-08', '2042-07', '2042-06',\n", + " '2042-05', '2042-04', '2042-03', '2042-02', '2042-01', '2041-12',\n", + " '2041-11', '2041-10', '2041-09', '2041-08', '2041-07', '2041-06',\n", + " '2041-05', '2041-04', '2041-03', '2041-02', '2041-01', '2040-12',\n", + " '2040-11', '2040-10', '2040-09', '2040-08', '2040-07', '2040-06',\n", + " '2040-05', '2040-04', '2040-03', '2040-02', '2040-01', '2039-12',\n", + " '2039-11', '2039-10', '2039-09', '2039-08', '2039-07', '2039-06',\n", + " '2039-05', '2039-04', '2039-03', '2039-02', '2039-01', '2038-12',\n", + " '2038-11', '2038-10', '2038-09', '2038-08', '2038-07', '2038-06',\n", + " '2038-05', '2038-04', '2038-03', '2038-02', '2038-01', '2037-12',\n", + " '2037-11', '2037-10', '2037-09', '2037-08', '2037-07', '2037-06',\n", + " '2037-05', '2037-04', '2037-03', '2037-01', '2036-12', '2036-11',\n", + " '2036-10', '2036-09', '2036-08', '2036-07', '2036-06', '2036-05',\n", + " '2036-04', '2036-03', '2036-02', '2036-01', '2035-12', '2035-11',\n", + " '2035-10', '2035-09', '2035-08', '2035-07', '2035-06', '2035-05',\n", + " '2035-04', '2035-03', '2035-02', '2035-01', '2034-12', '2034-11',\n", + " '2034-10', '2034-09', '2034-08', '2034-07', '2034-06', '2034-05',\n", + " '2034-04', '2034-03', '2034-02', '2034-01', '2033-12', '2033-11',\n", + " '2033-10', '2033-09', '2033-08', '2033-07', '2033-06', '2033-05',\n", + " '2033-04', '2033-03', '2033-02', '2033-01', '2032-12', '2032-11',\n", + " '2032-10', '2032-09', '2032-08', '2032-07', '2032-06', '2032-05',\n", + " '2032-04', '2032-03', '2032-02', '2032-01', '2031-12', '2031-11',\n", + " '2031-10', '2031-09', '2031-08', '2031-07', '2031-06', '2031-05',\n", + " '2031-04', '2031-03', '2031-02', '2031-01', '2030-12', '2030-11',\n", + " '2030-10', '2030-09', '2030-08', '2030-07', '2030-06', '2030-05',\n", + " '2030-04', '2030-03', '2030-02', '2030-01', '2029-12', '2029-11',\n", + " '2029-10', '2029-09', '2029-08', '2029-07', '2029-06', '2029-05',\n", + " '2029-04', '2029-03', '2029-02', '2029-01', '2028-12', '2028-11',\n", + " '2028-10', '2028-09', '2028-08', '2028-07', '2028-06', '2028-05',\n", + " '2028-04', '2028-03', '2028-02', '2028-01', '2027-12', '2027-11',\n", + " '2027-10', '2027-09', '2027-08', '2027-07', '2027-06', '2027-05',\n", + " '2027-04', '2027-03', '2027-02', '2027-01', '2026-12', '2026-11',\n", + " '2026-10', '2026-09', '2026-08', '2026-07', '2026-06', '2026-05',\n", + " '2026-04', '2026-03', '2026-02', '2026-01', '2025-12', '2025-11',\n", + " '2025-10', '2025-09', '2025-08', '2025-07', '2025-06', '2025-05',\n", + " '2025-04', '2025-03', '2025-02', '2025-01', '2024-12', '2024-11',\n", + " '2024-10', '2024-09', '2024-08', '2024-07', '2024-06', '2024-05',\n", + " '2024-04', '2024-03', '2024-02', '2024-01', '2023-12', '2023-11',\n", + " '2023-10', '2023-09', '2023-08', '2023-07', '2023-06', '2023-05',\n", + " '2023-04', '2023-03', '2023-02', '2023-01', '2022-12', '2022-11',\n", + " '2022-10', '2022-09', '2022-08', '2022-07', '2022-06', '2022-05',\n", + " '2022-04', '2022-03', '2022-02', '2022-01', '2021-12', '2021-11',\n", + " '2021-10', '2021-09', '2021-08', '2021-07', '2021-06', '2021-05',\n", + " '2021-04', '2021-03', '2021-02', '2021-01', '2020-12', '2020-11',\n", + " '2020-10', '2020-09', '2020-08', '2020-07', '2020-06', '2020-05',\n", + " '2020-04', '2020-03', '2020-02', '2020-01', '2019-12', '2019-11',\n", + " '2019-10', '2019-09', '2019-08', '2019-07', '2019-06', '2019-05',\n", + " '2019-04', '2019-03', '2019-02', '2019-01', '2018-12', '2018-11',\n", + " '2018-10', '2018-09', '2018-08', '2018-07', '2018-06', '2018-05',\n", + " '2018-04', '2018-03', '2018-02', '2018-01', '2017-12', '2017-11',\n", + " '2017-10', '2017-09', '2017-08', '2017-07', '2017-06', '2017-05',\n", + " '2017-04', '2017-03', '2017-02', '2017-01', '2016-12', '2016-11',\n", + " '2016-10', '2016-09', '2016-08', '2016-07', '2016-06', '2016-05',\n", + " '2016-04', '2016-03', '2016-02', '2016-01', '2015-12', '2015-11',\n", + " '2015-10', '2015-09', '2015-08', '2015-07', '2015-06', '2015-05',\n", + " '2015-04', '2015-03', '2015-02', '2015-01', '2014-12', '2014-11',\n", + " '2014-10', '2014-09', '2014-08', '2014-07', '2014-06', '2014-05',\n", + " '2014-04', '2014-03', '2014-02', '2014-01', '2013-12', '2013-11',\n", + " '2013-10', '2013-09', '2013-08', '2013-07', '2013-06', '2013-05',\n", + " '2013-04', '2013-03', '2013-02', '2013-01', '2012-12', '2012-11',\n", + " '2012-10', '2012-09', '2012-08', '2012-07', '2012-06', '2012-05',\n", + " '2012-04', '2012-03', '2012-02', '2012-01', '2011-12', '2011-11',\n", + " '2011-10', '2011-09', '2011-08', '2011-07', '2011-06', '2011-05',\n", + " '2011-04', '2011-03', '2011-02', '2011-01', '2010-12', '2010-11',\n", + " '2010-10', '2010-09', '2010-08', '2010-07', '2010-06', '2010-05',\n", + " '2010-04', '2010-03', '2010-02', '2010-01', '2009-12', '2009-11',\n", + " '2009-10', '2009-09', '2009-08', '2009-07', '2009-06', '2009-05',\n", + " '2009-04', '2009-03', '2009-02', '2009-01', '2008-12', '2008-11',\n", + " '2008-10', '2008-09', '2008-08', '2008-07', '2008-06', '2008-05',\n", + " '2008-04', '2008-03', '2008-02', '2008-01', '2007-12', '2007-11',\n", + " '2007-10', '2007-09', '2007-08', '2007-07', '2007-06', '2007-05',\n", + " '2007-04', '2007-03', '2007-02', '2007-01', '2006-12', '2006-11',\n", + " '2006-10', '2006-09', '2006-08', '2006-07', '2006-06', '2006-05',\n", + " '2006-04', '2006-03', '2006-02', '2006-01', '2005-12', '2005-11',\n", + " '2005-10', '2005-09', '2005-08', '2005-07', '2005-06', '2005-05',\n", + " '2005-04', '2005-03', '2005-02', '2005-01', '2004-12', '2004-11',\n", + " '2004-10', '2004-09', '2004-08', '2004-07', '2004-06', '2004-05',\n", + " '2004-04', '2004-03', '2004-02', '2004-01', '2003-12', '2003-11',\n", + " '2003-10', '2003-09', '2003-08', '2003-07', '2003-06', '2003-05',\n", + " '2003-04', '2003-03', '2003-02', '2003-01', '2002-12', '2002-11',\n", + " '2002-10', '2002-09', '2002-08', '2002-07', '2002-06', '2002-05',\n", + " '2002-04', '2002-03', '2002-02', '2002-01', '2001-12', '2001-11',\n", + " '2001-10', '2001-09', '2001-08', '2001-07', '2001-06', '2001-05',\n", + " '2001-04', '2001-03', '2001-02', '2001-01', '2000-12', '2000-11',\n", + " '2000-10', '2000-09', '2000-08', '2000-07', '2000-06', '2000-05',\n", + " '2000-04', '2000-03', '2000-02', '2000-01', '2037-02', '1899-12'],\n", + " dtype='datetime64[M]'),\n", + " array(['zn', 'y', 'wr', 'v', 'ss', 'sp', 'sn', 'sc', 'ru', 'rr', 'rb',\n", + " 'pp', 'pg', 'pb', 'p', 'nr', 'ni', 'm', 'lu', 'lh', 'l', 'jm',\n", + " 'jd', 'j', 'i', 'hc', 'fu', 'fb', 'eg', 'eb', 'cu', 'cs', 'c',\n", + " 'bu', 'bc', 'bb', 'b', 'au', 'al', 'ag', 'a', 'ZC', 'WH', 'UR',\n", + " 'TS', 'TF', 'TA', 'T', 'SR', 'SM', 'SF', 'SA', 'RS', 'RM', 'RI',\n", + " 'PM', 'PK', 'PF', 'OI', 'MA', 'LR', 'JR', 'IM', 'IH', 'IF', 'IC',\n", + " 'FG', 'CY', 'CJ', 'CF', 'AP'], dtype=object)],\n", + " 'sortColumns': array(['code', 'm_nDatetime'], dtype=object),\n", + " 'partitionSites': None}" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sess.run('loadTable(\"dfs://hft_futuremarket_ts\",\"TickPartitioned\").schema()')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 字段解释" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```python\n", + "# def get_trade_tick(self, start_date, end_date, code_list):\n", + "\n", + "# code_list_input = ', '.join(['\\'%s\\'' % code_id for code_id in code_list])\n", + "scpt = \"\"\"\n", + " stock_list := Array({code_list_input});\n", + " r := select \n", + " ['StockID'] as 'code',\n", + " DateTimeToStr(['date']) as 'm_nDatetime',\n", + "\n", + " ['price'] as 'm_nPrice',\n", + " ['open'] as 'm_nOpen',\n", + " ['high'] as 'm_nHigh',\n", + " ['low'] as 'm_nLow',\n", + " ['close'] as 'm_nClose',\n", + "\n", + " ['sectional_high'] as 'm_nAccHigh',\n", + " ['sectional_low'] as 'm_nAccLow',\n", + "\n", + " ['vol'] as 'm_iVolume', //成交量\n", + " ['sectional_vol'] as 'm_iAccVolume', //时点当日累计成交量\n", + "\n", + " ['cjbs'] as 'm_nMatchItems', // 成交笔数 周期内的持仓的变动量\n", + " ['sectional_cjbs'] as 'm_nAccMatchItems',\n", + "\n", + " ['amount'] as 'm_iTurnover', //成交金额\n", + " ['sectional_amount'] as 'm_iAccTurnover', \n", + "\n", + " ['yclose'] as 'm_nPreClose', //上一周期的收盘价\n", + " ['sectional_yclose'] as 'm_nAccPreClose', // 前日收盘\n", + " \n", + " ['buy1'] as 'm_nBidPrice', //买一价?叫卖价?\n", + " ['bc1'] as 'm_nBidVolume', //买一量 当前以买一价出价的委买量\n", + " ['sale1'] as 'm_nAskPrice', \n", + " ['sc1'] as 'm_nAskVolume', \n", + "\n", + " ['zmm'] as 'm_iABFlag', //买卖标识\n", + "\n", + " ['buy_vol'] as 'm_nActBidVolume', //主买量\n", + " ['sectional_buy_vol'] as 'm_nAccActBidVolume', //时点当日累计主买量\n", + " ['buy_amount'] as 'm_nActBidTurnover', //主买金额\n", + " ['sectional_buy_amount'] as 'm_nAccActBidTurnover', \n", + "\n", + " ['sale_vol'] as 'm_nActAskVolume', \n", + " ['sectional_sale_vol'] as 'm_nAccActAskVolume', \n", + " ['sale_amount'] as 'm_nActAskTurnover',\n", + " ['sectional_sale_amount'] as 'm_nAccActAskTurnover', \n", + "\n", + " ['w_buy'] as 'm_nBidOrder', //委买\n", + " ['sectional_w_buy'] as 'm_nAccBidOrder', \n", + " ['w_sale'] as 'm_nAskOrder',\n", + " ['sectional_w_sale'] as 'm_nAccAskOrder',\n", + "\n", + " ['wb'] as 'm_nABOrderRate', //委比\n", + " ['sectional_wb'] as 'm_nAccABOrderRate', //时点当日累计委比\n", + " ['lb'] as 'm_nMItemsVolRate'//量比\n", + "\n", + " from tradetable\n", + " datekey {start_date}T to {end_date}T+0.999 \n", + " of stock_list\n", + " end;\n", + " \n", + " return r; \n", + "\"\"\".format(\n", + " code_list_input=code_list_input,\n", + " start_date=start_date,\n", + " end_date=end_date\n", + ")\n", + "# logger.debug(scpt)\n", + "# r = self.c.exec(scpt,timeout=self.timeout_default)\n", + "# return r\n", + "\n", + "\"\"\"\n", + "(source: 天软数据字典 ver 2022-05-25)\n", + "vol: 周期内的成交量。如果周期为分钟,则表示这分钟的成 交量,并非从开盘累计.\n", + " 对于期货,高频和日线的单位都是合约数量,如果要建立成交量和成交金额之间的关系,还需考虑合约乘数。\n", + "amount: 周期内的成交金额。如果周期为分钟,则表示这分钟的成交金额,并非从开盘累计。\n", + "cjbs: 对于期货/期权而言,是周期内的持仓的变动量,日线的话表示当日持仓量,单位为:手。\n", + "wb: 公式:委买/委卖(w_buy/w_sale)\n", + "lb: 由天软计算:\n", + " 1、对于交易明细:\n", + " 量比=现成交总手/[(过去 5 个交易日平均每分钟成交 量)×当日累计开市时间(分)]\n", + " 2、对于秒线/1 分钟线: 量比取周期内最后一条交易明细的数据。\n", + "\n", + "zmm: 对 tradetable 公式:按下面的前后逻辑优先判定\n", + " 没有成交 -> 0\n", + " 当前成交价>上一笔买一价 ->主买 1 \n", + " 当前成交价<上一笔卖一价 ->主卖 2 \n", + " 否则->3(一般是集合竞价、涨停、跌停) \n", + " 对于非交易明细(秒线或分钟线等):没有意义\n", + "buy_vol: 主动性买盘成交量:周期内买卖标识为 1 的成交量+买 卖标识为 3 的成交量/2\n", + "buy_amount: 主动性买盘成交金额:周期内买卖标识为 1 的成交金额 +买卖标识为 3 的成交金额/2\n", + "sale_vol: 主动性卖盘成交量:周期内买卖标识为 2 的成交量之和 +买卖标识为 3 的成交量/2\n", + "sale_amount: 主动性卖盘成交金额:周期内买卖标识为 2 的成交金额 +买卖标识为 3 的成交金额/2\n", + "w_buy: 一个周期内的委买量\n", + "sectional: 从开盘到当前时间的\n", + "sectional_yclose: 上一交易日(周期是日)的收盘价,与‘上次价’不一 样。‘上次价’表示前一个周期的收盘价。\n", + "sectional_vol: 从开盘到当前时间的成交量之和(主买+主卖)\n", + "sectional_amount: 从开盘到当前时间的成交金额之和(主买+主卖)\n", + "sectional_cjbs: 股指期货/期权:市场现有持仓量\n", + "sectional_wb: 当日累计委买/当日累计委卖\n", + "\n", + "['sectional_open'] as 'm_nAccOpen', //时点当日开盘, 没必要存, 取上日2059的即可\n", + "\n", + "\"\"\"\n", + "\n", + "```" ] } ], @@ -1821,7 +1642,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.6" + "version": "3.9.2" }, "orig_nbformat": 4, "vscode": { diff --git a/dolphindb-test-clean.ipynb b/dolphindb-test-clean.ipynb index 72474f9..7c6b208 100644 --- a/dolphindb-test-clean.ipynb +++ b/dolphindb-test-clean.ipynb @@ -477,12 +477,92 @@ "len(all_init)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "WS\n", + "RO\n", + "WT\n", + "ER\n", + "TC\n", + "ME\n" + ] + } + ], + "source": [ + "for ci in ci_all:\n", + " if ci not in all_init:\n", + " print(ci)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "import code_list_all_pkl" + ] + }, + { + "cell_type": "code", + "execution_count": 12, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "from src.code_list_all_pkl import code_list as code_list_pickel_from_file\n", + "ci_all = set([c[:-4] for c in code_list_pickel_from_file])" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "77" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(ci_all)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'LR', 'TF', 'cu', 'nr', 'zn', 'zn2310 on 20200323 in TickPartiti'}" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cl=\"LR2003+LR2005+LR2007+LR2011+LR2101+LR2103+LR2105+LR2107+LR2109+LR2111+LR2201+LR2203+LR2205+LR2207+LR2209+LR2211+LR2301+LR2303+LR2305+LR2307+LR2309+LR2311+TF2003+TF2006+TF2009+TF2012+TF2103+TF2106+TF2109+TF2112+TF2203+TF2206+TF2209+TF2212+TF2303+TF2306+cu2002+cu2003+cu2004+cu2005+cu2006+cu2007+cu2008+cu2009+cu2010+cu2011+cu2012+cu2101+cu2102+cu2103+cu2104+cu2105+cu2106+cu2107+cu2108+cu2109+cu2110+cu2111+cu2112+cu2201+cu2202+cu2203+cu2204+cu2205+cu2206+cu2207+cu2208+cu2209+cu2210+cu2211+cu2212+cu2301+cu2302+cu2303+cu2304+cu2305+cu2306+cu2307+cu2308+cu2309+cu2310+nr2002+nr2003+nr2004+nr2005+nr2006+nr2007+nr2008+nr2009+nr2010+nr2011+nr2012+nr2101+nr2102+nr2103+nr2104+nr2105+nr2106+nr2107+nr2108+nr2109+nr2110+nr2111+nr2112+nr2201+nr2202+nr2203+nr2204+nr2205+nr2206+nr2207+nr2208+nr2209+nr2210+nr2211+nr2212+nr2301+nr2302+nr2303+nr2304+nr2305+nr2306+nr2307+nr2308+nr2309+nr2310+zn2002+zn2003+zn2004+zn2005+zn2006+zn2007+zn2008+zn2009+zn2010+zn2011+zn2012+zn2101+zn2102+zn2103+zn2104+zn2105+zn2106+zn2107+zn2108+zn2109+zn2110+zn2111+zn2112+zn2201+zn2202+zn2203+zn2204+zn2205+zn2206+zn2207+zn2208+zn2209+zn2210+zn2211+zn2212+zn2301+zn2302+zn2303+zn2304+zn2305+zn2306+zn2307+zn2308+zn2309+zn2310 on 20200323 in TickPartitioned\"\n", + "set([c[:-4] for c in cl.split(\"+\")])\n" + ] }, { "cell_type": "code", @@ -3018,7 +3098,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.6" + "version": "3.9.2" }, "orig_nbformat": 4, "vscode": { diff --git a/src/data_loader.py b/src/data_loader.py index b0495d8..9950c8f 100644 --- a/src/data_loader.py +++ b/src/data_loader.py @@ -143,9 +143,15 @@ def run(): run_add_1day_code_init_minKline(date, code_list) -def run_pool_dates_by_code_init_n_group(typ='mink', code_gp_amt=10, date_gp_amt=10, start_date='20220101', end_date='20221031', if_check=1, code_dict_by='init'): +def run_pool_dates_by_code_init_n_group(typ='mink', code_gp_amt=10, date_gp_amt=10, start_date='20220101', end_date='20221031', if_check=1, code_dict_by='init',keep_code_init_list=[]): logger.info("Running run_pool_dates_by_group") - code_list_pickel=code_list_pickel_from_file + code_list_pickel_raw=code_list_pickel_from_file + code_list_pickel=code_list_pickel_raw + if len(keep_code_init_list)>0: + code_list_pickel = [] + for i in code_list_pickel_raw: + if i[:2] in keep_code_init_list: + code_list_pickel.append(i) code_list_pickel=sorted(list(set(code_list_pickel))) all_code_dict_by_init = {} for c in code_list_pickel: @@ -223,22 +229,24 @@ if __name__ == '__main__': if_check=int(if_check) split_code_into_howmany_groups_no = int(split_code_into_howmany_groups_no) split_date_into_howmany_groups=int(split_date_into_howmany_groups) + keep_code_init_list=[] else: typ = 'tick' - st_d = '20211201' - en_d = '20211231' + st_d = '20200401' + en_d = '20200531' if_check = 1 - split_code_into_howmany_groups_no = 20 - split_date_into_howmany_groups = 5 + split_code_into_howmany_groups_no = 15 + split_date_into_howmany_groups = 15 + keep_code_init_list = ['PF', 'WH', 'fb', 'pg'] logger.add(ROOT_DIR+"/logs/{time:YYYYMMDD-HHmmss}"+f"_{running_which_env}_{typ}_{st_d}_{en_d}_{if_check}_{split_code_into_howmany_groups_no}_{split_date_into_howmany_groups}.log", rotation="10 MB", compression="zip", level="INFO") logger.warning( - f"Going to run *{typ}* from {st_d} to {en_d} with if_check dupliactes={if_check} in *{running_which_env}*, plz check if this info is correct.\n\n\n\n") + f"Going to run {'+'.join(keep_code_init_list)} *{typ}* from {st_d} to {en_d} with if_check dupliactes={if_check} in *{running_which_env}*, plz check if this info is correct.\n\n\n\n") run_pool_dates_by_code_init_n_group(typ=typ, code_gp_amt=split_code_into_howmany_groups_no, - date_gp_amt=split_date_into_howmany_groups, start_date=st_d, end_date=en_d, if_check=if_check, code_dict_by='group') + date_gp_amt=split_date_into_howmany_groups, start_date=st_d, end_date=en_d, if_check=if_check, code_dict_by='group',keep_code_init_list=keep_code_init_list) # run_pool_dates_by_code_init_n_group(typ='mink',group_amount=5) toc = time.perf_counter()