hikyuu2/hikyuu/examples/notebook/008-Pickle.ipynb

128 lines
56 KiB
C++
Raw Normal View History

{
"cells": [
{
"cell_type": "code",
2020-08-05 23:52:24 +08:00
"execution_count": 1,
"metadata": {},
"outputs": [
2024-08-20 16:03:50 +08:00
{
"name": "stderr",
"output_type": "stream",
"text": [
"2024-08-20 15:45:43,093 [INFO] hikyuu version: 2.1.1_202408182226_RELEASE_windows_x64 [<module>] (D:\\workspace\\hikyuu\\hikyuu\\__init__.py:97) [hikyuu::hku_info]\n"
]
},
2020-08-05 23:52:24 +08:00
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-08-20 16:03:50 +08:00
"2024-08-20 15:45:43.596 [HKU-I] - Using MYSQL BaseInfoDriver (BaseInfoDriver.cpp:58)\n",
"2024-08-20 15:45:43.615 [HKU-I] - Loading market information... (StockManager.cpp:481)\n",
"2024-08-20 15:45:43.621 [HKU-I] - Loading stock type information... (StockManager.cpp:494)\n",
"2024-08-20 15:45:43.628 [HKU-I] - Loading stock information... (StockManager.cpp:409)\n",
"2024-08-20 15:45:43.785 [HKU-I] - Loading stock weight... (StockManager.cpp:511)\n",
"2024-08-20 15:45:45.041 [HKU-I] - Loading KData... (StockManager.cpp:134)\n",
"2024-08-20 15:45:46.483 [HKU-I] - Preloading all day kdata to buffer! (StockManager.cpp:179)\n",
"2024-08-20 15:45:46.483 [HKU-I] - Preloading all week kdata to buffer! (StockManager.cpp:179)\n",
"2024-08-20 15:45:46.484 [HKU-I] - Preloading all month kdata to buffer! (StockManager.cpp:179)\n",
"2024-08-20 15:45:46.552 [HKU-I] - 1.51s Loaded Data. (StockManager.cpp:159)\n",
"CPU times: total: 516 ms\n",
"Wall time: 3.78 s\n"
2020-08-05 23:52:24 +08:00
]
}
],
"source": [
"%matplotlib inline\n",
2020-08-05 23:52:24 +08:00
"%time from hikyuu.interactive import *"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"k = get_kdata('sh000001', -100)"
]
},
{
"cell_type": "code",
2024-08-20 16:03:50 +08:00
"execution_count": 3,
2020-08-05 23:52:24 +08:00
"metadata": {},
2024-08-20 16:03:50 +08:00
"outputs": [],
2020-08-05 23:52:24 +08:00
"source": [
"import pickle\n",
"\n",
"with open(\"temp\", 'wb') as f:\n",
" pickle.dump(k, f)\n"
]
},
{
"cell_type": "code",
2024-08-20 16:03:50 +08:00
"execution_count": 4,
2020-08-05 23:52:24 +08:00
"metadata": {},
"outputs": [],
"source": [
"hku_save(k, \"temp\")"
]
},
{
"cell_type": "code",
2024-08-20 16:03:50 +08:00
"execution_count": 5,
2020-08-05 23:52:24 +08:00
"metadata": {},
"outputs": [],
"source": [
2024-08-20 16:03:50 +08:00
"k2 = hku_load(\"temp\")"
2020-08-05 23:52:24 +08:00
]
},
{
"cell_type": "code",
2024-08-20 16:03:50 +08:00
"execution_count": 6,
2020-08-05 23:52:24 +08:00
"metadata": {},
"outputs": [
{
"data": {
2024-08-20 16:03:50 +08:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA9MAAAMTCAYAAACi5UTxAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy81sbWrAAAACXBIWXMAAA9hAAAPYQGoP6dpAACdi0lEQVR4nOzdeXhU5eH28TsQyTASBmVcIHAAxYa4ICQCLggoLsCPqlhcG1HrgoFIDbYUcUFRoVTf4oJGsbgVxLVVSyuuKGrFJRHQGiMIOBCxMqITIA6Q5Lx/PJ0tmSyTbSbJ93Ndc5E5z5kzz5mNuefZkmzbtgUAAAAAAOqtQ7wrAAAAAABAa0OYBgAAAAAgRoRpAAAAAABiRJgGAAAAACBGhGkAAAAAAGJEmAYAAAAAIEaEaQAAAAAAYkSYBgAAzW7Pnj3au3dvvKsBAECTIUwDAJBAvv32W916663asGFDnfvu27dPTz75ZKPv8/vvv9c999wj27YlSR6PR3/605/qffs333xT5eXlkqRBgwYF67Rq1Spt3LhRkvTEE0+oX79+ja5rPGzZskV5eXny+XwR21977TVdf/31kqTPP/9cH374YTyqBwCIE8I0AAAJ5Ntvv9Vtt91WrzC9evVqXXHFFfrtb38rSdq6dauSkpLqdRk+fHjwOB6PR3l5eaqoqJAkbdy4UbNmzYq4ry1btuill17STTfdpDPOOEMZGRnas2eP9u3bp2uvvTYYKsvLy1VZWalNmzbpnHPO0T/+8Q9J0ocffqhTTjmlSR6jaPbs2aO7775bn332WcT2W2+9td6PSVJSkjZv3lzt2Pfcc49WrFihLl26RGz/+uuv9dRTT0mSPv30U51yyimaPXu2Kisrg/vs3r1bf/rTn7R+/fqmP2kAQFwRpgEAQatWrdKECRNkWZb2228/paamKisrKyJgjBo1Sn379q3xGHWV79u3T4ceeqimT58e3Pboo4/qmGOOkcPhUK9evTRr1qxqXYL9fr9mzZoly7KUkpKio446KmqrbElJiS6++GJ1795dTqdTI0aM0EcffVRtv3//+98aNWqUunTpogMOOEAXX3yxtm3bVm2/+tQt/L4vuugiXXbZZTWef1M6+eST9eijj+r+++/XDTfcoEMPPVRFRUXVLocccohuvfXWiG2BEFiTyspKXXHFFTr++OPlcrl04okn6pFHHlHHjh3129/+VgsXLtTOnTu13377aenSpXrxxRf1/fffB29/4403asKECfrtb38r27a1YsUKnX766c32WFx33XVaunSpfvGLX1QrO+SQQ6I+LuGXJ554Iupxf/jhBz3yyCO6/fbb1bFjx4gyp9OpPXv2SJIuueQSvfXWW1qyZImKi4uD++y///7yer2aMGGCysrKmvCMAQDxlhzvCgAAEsPDDz+sa665RsOHD9fs2bPVvXt3ffvtt/rHP/6hHTt21BqQY/HCCy/o+++/V05OjiTpvvvu029/+1tdeeWVuv322/Xuu+9q3rx52rFjhx566KHg7S6++GK98soruuWWW5Senq7Fixfr0ksvVadOnXThhRdKknw+n04++WRVVFRo/vz5cjgcuvPOOzV69GgVFhbqiCOOkCR99NFHOvXUUzVs2DA99thj+vbbb3XzzTfrs88+U2Fhofbbb7+Y6vbee+/pySef1JIlS/Tzzz/r0ksvbZLHqj4uueQSbd68WevWrVNSUpIGDBhQbZ/k5GQdcsgh1coef/xxXX755cHrgfP+61//qqSkJJ144om64oordOSRR6pbt24Rtz399NM1dOhQnX/++fr666/1xz/+UatWrVJpaak++eQTnXHGGerUqZO++OILeb1effvtt7riiit0xRVXRBzn/fff17Bhwxr1GLz11lt6+OGHtWbNGqWkpEQ9/2iPS7jvvvsu6vb58+crIyNDEydOlMfjkWVZwbL9999ffr9fknntpaam6t5779V7772n0tLS4HndeeedevHFFzV79mzdddddDT1NAECisQEAsG27Z8+edp8+fex9+/bVut/IkSPtPn36NLh8+PDh9plnnmnbtm2Xlpbaqamp9rnnnhuxz6RJk+wOHTrYHo/Htm3bXrlypS3Jvu+++4L77N271+7fv7/dv3//4LbZs2fbSUlJ9tq1a4Pb1q9fb3fo0MG+6qqrIurYu3dve/fu3cFtjz76qC3JXrp0aUx1s23bdrlc9jHHHGMvX77clmRfeumlNZ5/XT7++GNbkv3KK6/EdLvKysoay9LS0uz8/Pxq23/66Se7qKjIfv75521J9ueff24XFRXZb7zxhp2UlFTra6Fnz572U089ZT/44IP26NGj7dGjR9tHHnmkLck+8sgjg9ueeOIJ+9xzz7WHDx9ub9q0yd60aZP95ptv2pLsd955x/b7/TGdZzQjRoywJ0yYELVs9uzZdlpaWp3HCLzGNm3aFNy2ceNG2+Fw2O+99569e/duu2fPnvZVV11l33777fbVV19tDx061JZkp6am2pLsDh062D169LCHDRtmP/HEExHHX7x4se10Ou3//ve/jTpXAEDioJs3AECSGdvZ3NatW6f33ntPU6dOlWQmcNq5c6euvPLKiP0uueQSVVZW6rXXXpNkWrM7duwY0X16v/320wUXXKANGzbo66+/Du43ZMgQDRw4MLhf//79dcIJJ+iVV16RJHm9Xq1atUoXXXSRnE5ncL8LL7xQ++23X3C/+tZNkt5++22tW7dO//d//9fYhyho7NixUcf0OhwOSdKuXbt00003BS/hk2Oddtppuummm+q8D5fLpQEDBqhPnz6SpPT0dA0YMECWZcm2bT388MP67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JPPfWU7rjjDv3+97+P2PfQQw/Vc889F/U41157rX788cdq25944gmVl5dHtBwH1iYOhOuAQPAJbC8vL6+2T9X9ajpWrPuF32d96tZa3Hrrrbrgggu
2020-08-05 23:52:24 +08:00
"text/plain": [
"<Figure size 1000x800 with 1 Axes>"
2020-08-05 23:52:24 +08:00
]
},
"metadata": {},
2020-08-05 23:52:24 +08:00
"output_type": "display_data"
}
],
"source": [
"k2.plot()"
]
},
{
"cell_type": "code",
"execution_count": null,
2020-08-05 23:52:24 +08:00
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
2024-08-20 16:03:50 +08:00
"version": "3.11.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
}