From 083c66abb1c7e165b2296828b1b77f0e6a8fbb41 Mon Sep 17 00:00:00 2001 From: Guofu Li Date: Wed, 28 Sep 2022 14:51:17 +0800 Subject: [PATCH] Dump daily one-hot concept data to dolphindb. --- ipynb/ddb.ipynb | 780 +++++++++++++++++++++++++++++-------- ipynb/ddb_pit.ipynb | 319 +-------------- ipynb/mssql.ipynb | 20 +- src/DDBBase.py | 7 +- src/loader/DDBHFTLoader.py | 14 - src/loader/DDBLoader.py | 15 +- src/run.py | 13 +- 7 files changed, 671 insertions(+), 497 deletions(-) diff --git a/ipynb/ddb.ipynb b/ipynb/ddb.ipynb index 9f8652a..f839689 100644 --- a/ipynb/ddb.ipynb +++ b/ipynb/ddb.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "id": "7246e0c8-61cd-4cbf-a978-aa0dc0172d6d", "metadata": {}, "outputs": [], @@ -35,28 +35,17 @@ }, { "cell_type": "code", - "execution_count": 60, + "execution_count": null, "id": "ed17fd0b-9b36-47e4-9ab6-11459a3621fb", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "115548" - ] - }, - "execution_count": 60, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "sess = ddb.session('192.168.1.7', 8848)\n", "sess.login('admin', '123456')\n", "\n", "# backup(backup_path, sql_obj, force, parallel)\n", "code = \"\"\"\n", - " backup('/data/dolphindb/backup/', , false, false)\n", "\"\"\"\n", "\n", "sess.run(code)" @@ -64,7 +53,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 127, "id": "c8d07fc8-d80c-490f-9220-0d3e8e4c72a4", "metadata": {}, "outputs": [ @@ -74,7 +63,7 @@ "50" ] }, - "execution_count": 32, + "execution_count": 127, "metadata": {}, "output_type": "execute_result" } @@ -104,7 +93,137 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 2, + "id": "45c4cbc3-08a1-4083-8117-44e8e3364375", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Failed to connect to host = localhost 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)", + "Input \u001b[0;32mIn [2]\u001b[0m, in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mdolphindb\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mddb\u001b[39;00m\n\u001b[1;32m 2\u001b[0m sess \u001b[38;5;241m=\u001b[39m ddb\u001b[38;5;241m.\u001b[39msession(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mlocalhost\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;241m8848\u001b[39m)\n\u001b[0;32m----> 3\u001b[0m \u001b[43msess\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlogin\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43madmin\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m123456\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 5\u001b[0m \u001b[38;5;66;03m# backup(backup_path, sql_obj, force, parallel)\u001b[39;00m\n\u001b[1;32m 6\u001b[0m sess\u001b[38;5;241m.\u001b[39mrun(\u001b[38;5;124m\"\"\"\u001b[39m\n\u001b[1;32m 7\u001b[0m \u001b[38;5;124m backup(\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m/data/dolphindb/backup/\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m, , false, false);\u001b[39m\n\u001b[1;32m 9\u001b[0m \u001b[38;5;124m backup(\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m/data/dolphindb/backup/\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m, , false, false);\n", + " backup('/data/dolphindb/backup/', , false, false);\n", + "\"\"\")" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "463a59a8-39cf-4406-9390-da5dfdc44fa7", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "50" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sess = ddb.session('192.168.1.7', 8848)\n", + "sess.login('admin', '123456')\n", + "\n", + "sess.run(\"\"\"\n", + " backup('/data/dolphindb/backup/', , true, false);\n", + " backup('/data/dolphindb/backup/',