{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from sqlalchemy import create_engine\n", "import pandas as pd\n", "from datetime import timedelta\n", "import jqdatasdk as jq\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# load existing portfolio" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# check if database need update\n", "def fetch_data_for_table():\n", " '''\n", " return None if no update needed\n", " else return (starttime, endtime, frequency)\n", " '''\n", " pass" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Need to fetch stock price periodically from jqdatasdk, also need to check if portfolio updated, but this case can be handled seperately \n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# fetch stock price from api\n", "def fetch_stock_price():\n", " pass" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "auth success \n" ] } ], "source": [ "# TODO auth, remove later\n", "user_name = \"13126862272\"\n", "password = \"862272\"\n", "jq.auth(user_name, password)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | open | \n", "close | \n", "high | \n", "low | \n", "volume | \n", "money | \n", "
---|---|---|---|---|---|---|
2021-01-05 09:31:00 | \n", "32.54 | \n", "31.73 | \n", "32.54 | \n", "31.72 | \n", "1205715.0 | \n", "38788451.0 | \n", "
2021-01-05 09:32:00 | \n", "31.68 | \n", "32.00 | \n", "32.00 | \n", "31.39 | \n", "1084879.0 | \n", "34358448.0 | \n", "
2021-01-05 09:33:00 | \n", "31.91 | \n", "31.62 | \n", "31.91 | \n", "31.61 | \n", "811350.0 | \n", "25785154.0 | \n", "
2021-01-05 09:34:00 | \n", "31.62 | \n", "32.07 | \n", "32.07 | \n", "31.62 | \n", "760611.0 | \n", "24135183.0 | \n", "
2021-01-05 09:35:00 | \n", "32.11 | \n", "31.98 | \n", "32.16 | \n", "31.98 | \n", "655989.0 | \n", "21046238.0 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
2021-01-05 11:26:00 | \n", "32.25 | \n", "32.29 | \n", "32.29 | \n", "32.20 | \n", "118071.0 | \n", "3807211.0 | \n", "
2021-01-05 11:27:00 | \n", "32.29 | \n", "32.30 | \n", "32.30 | \n", "32.21 | \n", "114251.0 | \n", "3686602.0 | \n", "
2021-01-05 11:28:00 | \n", "32.26 | \n", "32.24 | \n", "32.30 | \n", "32.21 | \n", "60077.0 | \n", "1938244.0 | \n", "
2021-01-05 11:29:00 | \n", "32.25 | \n", "32.28 | \n", "32.30 | \n", "32.22 | \n", "65634.0 | \n", "2117204.0 | \n", "
2021-01-05 11:30:00 | \n", "32.23 | \n", "32.30 | \n", "32.30 | \n", "32.23 | \n", "49052.0 | \n", "1582947.0 | \n", "
120 rows × 6 columns
\n", "\n", " | time | \n", "code | \n", "open | \n", "close | \n", "high | \n", "low | \n", "volume | \n", "money | \n", "
---|---|---|---|---|---|---|---|---|
0 | \n", "2021-01-05 09:31:00 | \n", "600409.XSHG | \n", "9.23 | \n", "9.16 | \n", "9.23 | \n", "9.08 | \n", "1417593.0 | \n", "13000397.0 | \n", "
1 | \n", "2021-01-05 09:32:00 | \n", "600409.XSHG | \n", "9.17 | \n", "9.17 | \n", "9.17 | \n", "9.15 | \n", "394595.0 | \n", "3613283.0 | \n", "
2 | \n", "2021-01-05 09:33:00 | \n", "600409.XSHG | \n", "9.16 | \n", "9.15 | \n", "9.16 | \n", "9.13 | \n", "492224.0 | \n", "4501667.0 | \n", "
3 | \n", "2021-01-05 09:34:00 | \n", "600409.XSHG | \n", "9.14 | \n", "9.21 | \n", "9.22 | \n", "9.14 | \n", "451578.0 | \n", "4152355.0 | \n", "
4 | \n", "2021-01-05 09:35:00 | \n", "600409.XSHG | \n", "9.20 | \n", "9.20 | \n", "9.22 | \n", "9.20 | \n", "503040.0 | \n", "4631781.0 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
715 | \n", "2021-01-05 11:26:00 | \n", "600415.XSHG | \n", "5.87 | \n", "5.87 | \n", "5.87 | \n", "5.87 | \n", "279118.0 | \n", "1639550.0 | \n", "
716 | \n", "2021-01-05 11:27:00 | \n", "600415.XSHG | \n", "5.87 | \n", "5.87 | \n", "5.87 | \n", "5.87 | \n", "253667.0 | \n", "1490048.0 | \n", "
717 | \n", "2021-01-05 11:28:00 | \n", "600415.XSHG | \n", "5.87 | \n", "5.87 | \n", "5.87 | \n", "5.87 | \n", "137293.0 | \n", "806465.0 | \n", "
718 | \n", "2021-01-05 11:29:00 | \n", "600415.XSHG | \n", "5.87 | \n", "5.87 | \n", "5.87 | \n", "5.87 | \n", "218351.0 | \n", "1282600.0 | \n", "
719 | \n", "2021-01-05 11:30:00 | \n", "600415.XSHG | \n", "5.87 | \n", "5.87 | \n", "5.87 | \n", "5.87 | \n", "248941.0 | \n", "1462285.0 | \n", "
720 rows × 8 columns
\n", "\n", " | date | \n", "weight | \n", "display_name | \n", "
---|---|---|---|
000008.XSHE | \n", "2020-12-31 | \n", "0.088 | \n", "神州高铁 | \n", "
000009.XSHE | \n", "2020-12-31 | \n", "0.344 | \n", "中国宝安 | \n", "
000012.XSHE | \n", "2020-12-31 | \n", "0.180 | \n", "南玻A | \n", "
000021.XSHE | \n", "2020-12-31 | \n", "0.297 | \n", "深科技 | \n", "
001872.XSHE | \n", "2020-12-31 | \n", "0.030 | \n", "招商港口 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "
688002.XSHG | \n", "2020-12-31 | \n", "0.438 | \n", "睿创微纳 | \n", "
688099.XSHG | \n", "2020-12-31 | \n", "0.287 | \n", "晶晨股份 | \n", "
688088.XSHG | \n", "2020-12-31 | \n", "0.252 | \n", "虹软科技 | \n", "
688321.XSHG | \n", "2020-12-31 | \n", "0.134 | \n", "微芯生物 | \n", "
688029.XSHG | \n", "2020-12-31 | \n", "0.130 | \n", "南微医学 | \n", "
500 rows × 3 columns
\n", "\n", " | display_name | \n", "name | \n", "start_date | \n", "end_date | \n", "type | \n", "
---|---|---|---|---|---|
000001.XSHE | \n", "平安银行 | \n", "PAYH | \n", "1991-04-03 | \n", "2200-01-01 | \n", "stock | \n", "
000002.XSHE | \n", "万科A | \n", "WKA | \n", "1991-01-29 | \n", "2200-01-01 | \n", "stock | \n", "
000004.XSHE | \n", "国华网安 | \n", "GHWA | \n", "1990-12-01 | \n", "2200-01-01 | \n", "stock | \n", "
000005.XSHE | \n", "ST星源 | \n", "STXY | \n", "1990-12-10 | \n", "2200-01-01 | \n", "stock | \n", "
000006.XSHE | \n", "深振业A | \n", "SZYA | \n", "1992-04-27 | \n", "2200-01-01 | \n", "stock | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
688799.XSHG | \n", "华纳药厂 | \n", "HNYC | \n", "2021-07-13 | \n", "2200-01-01 | \n", "stock | \n", "
688800.XSHG | \n", "瑞可达 | \n", "RKD | \n", "2021-07-22 | \n", "2200-01-01 | \n", "stock | \n", "
688819.XSHG | \n", "天能股份 | \n", "TNGF | \n", "2021-01-18 | \n", "2200-01-01 | \n", "stock | \n", "
688981.XSHG | \n", "中芯国际 | \n", "ZXGJ | \n", "2020-07-16 | \n", "2200-01-01 | \n", "stock | \n", "
689009.XSHG | \n", "九号公司 | \n", "JHGS | \n", "2020-10-29 | \n", "2200-01-01 | \n", "stock | \n", "
5248 rows × 5 columns
\n", "