Commit e75c5c34 authored by Dr.李's avatar Dr.李

more notebooks

parent cc5d32ca
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "3604e08c-d849-4d0e-aa6d-384657b1b6c8",
"metadata": {},
"outputs": [],
"source": [
"import datetime as dt\n",
"from utility import (\n",
" read_sql,\n",
" fd_basicinfo,\n",
" fd_typeclass,\n",
" nearest_report_date\n",
")\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "35ca37b3-41d1-4c2d-a576-eef1cb9c1ec5",
"metadata": {},
"outputs": [],
"source": [
"# 获取回溯的报告日\n",
"\n",
"today = dt.datetime.today().strftime(\"%Y%m%d\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "96a3611d-8f1e-4420-9b08-7ca5dd6443cd",
"metadata": {},
"outputs": [],
"source": [
"# 获取所有目标股票型基金(清算结束日期晚于当前日)\n",
"\n",
"security_ids = read_sql(f\"\"\"\n",
"select SECURITYID from TQ_FD_TYPECLASS \n",
"WHERE\n",
" ISVALID = 1 AND\n",
" L1CODE = 1 AND\n",
" (ENDDATE>='{today}' or ENDDATE = '19000101') \n",
"ORDER BY SECURITYID;\n",
"\"\"\")[\"SECURITYID\"].unique().tolist()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "79115d35-0712-4432-a73c-29bd5262dda7",
"metadata": {},
"outputs": [],
"source": [
"basic_info = fd_basicinfo(security_ids)\n",
"type_info = fd_typeclass(security_ids)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "094c2bee-696b-4ebd-92ec-38d116e0acdb",
"metadata": {},
"outputs": [],
"source": [
"df = pd.merge(type_info, basic_info, on=\"SECURITYID\")"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "0c30cc50-a1c3-4774-84a8-5ab5faca8b67",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array(['标准指数股票型基金', '增强指数股票型基金', 'ETF联接基金', '其他行业股票型基金',\n",
" '偏股型基金(股票上下限60%-95%)', '标准股票型基金', '医药行业股票型基金', '偏债型基金',\n",
" '股票型分级子基金(优先份额)', '股票型分级子基金(进取份额)', '封闭式标准股票型基金'], dtype=object)"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.L3NAME.unique()"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "c99e0fe3-7193-449e-b5ee-6cbd0b003035",
"metadata": {},
"outputs": [],
"source": [
"# 分类\n",
"df.loc[(df[\"L3NAME\"].isin([\"其他行业股票型基金\", \"偏股型基金(股票上下限60%-95%)\", '标准股票型基金', '医药行业股票型基金', '封闭式标准股票型基金'])), \"股票型(子类)\"] = \"普通股票型基金\"\n",
"df.loc[(df[\"L3NAME\"].isin([\"标准指数股票型基金\"])), \"股票型(子类)\"] = \"被动指数型基金\"\n",
"df.loc[(df[\"L3NAME\"].isin([\"增强指数股票型基金\"])), \"股票型(子类)\"] = \"增强指数型基金\"\n",
"# df.loc[(df[\"FDNATURE\"] != \"ETF\"), \"货币型(子类)\"] = \"场外货币型基金\""
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "a42b357e-6b87-424b-9ca9-4ce60904b66b",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>SECURITYID</th>\n",
" <th>L1CODE</th>\n",
" <th>L1NAME</th>\n",
" <th>L2CODE</th>\n",
" <th>L2NAME</th>\n",
" <th>L3CODE</th>\n",
" <th>L3NAME</th>\n",
" <th>FDNAME</th>\n",
" <th>SNAMECOMP</th>\n",
" <th>FSYMBOL</th>\n",
" <th>FDNATURE</th>\n",
" <th>INVESTSTYLE</th>\n",
" </tr>\n",
" <tr>\n",
" <th>股票型(子类)</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>增强指数型基金</th>\n",
" <td>63</td>\n",
" <td>63</td>\n",
" <td>63</td>\n",
" <td>63</td>\n",
" <td>63</td>\n",
" <td>63</td>\n",
" <td>63</td>\n",
" <td>63</td>\n",
" <td>45</td>\n",
" <td>63</td>\n",
" <td>63</td>\n",
" <td>63</td>\n",
" </tr>\n",
" <tr>\n",
" <th>普通股票型基金</th>\n",
" <td>217</td>\n",
" <td>217</td>\n",
" <td>217</td>\n",
" <td>217</td>\n",
" <td>217</td>\n",
" <td>217</td>\n",
" <td>217</td>\n",
" <td>217</td>\n",
" <td>66</td>\n",
" <td>217</td>\n",
" <td>217</td>\n",
" <td>217</td>\n",
" </tr>\n",
" <tr>\n",
" <th>被动指数型基金</th>\n",
" <td>344</td>\n",
" <td>344</td>\n",
" <td>344</td>\n",
" <td>344</td>\n",
" <td>344</td>\n",
" <td>344</td>\n",
" <td>344</td>\n",
" <td>344</td>\n",
" <td>215</td>\n",
" <td>344</td>\n",
" <td>344</td>\n",
" <td>344</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" SECURITYID L1CODE L1NAME L2CODE L2NAME L3CODE L3NAME FDNAME \\\n",
"股票型(子类) \n",
"增强指数型基金 63 63 63 63 63 63 63 63 \n",
"普通股票型基金 217 217 217 217 217 217 217 217 \n",
"被动指数型基金 344 344 344 344 344 344 344 344 \n",
"\n",
" SNAMECOMP FSYMBOL FDNATURE INVESTSTYLE \n",
"股票型(子类) \n",
"增强指数型基金 45 63 63 63 \n",
"普通股票型基金 66 217 217 217 \n",
"被动指数型基金 215 344 344 344 "
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby(\"股票型(子类)\").count()"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "3a20a243-ebe0-4410-a3e8-3363e1e793e2",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>SECURITYID</th>\n",
" <th>L1CODE</th>\n",
" <th>L1NAME</th>\n",
" <th>L2CODE</th>\n",
" <th>L2NAME</th>\n",
" <th>L3CODE</th>\n",
" <th>L3NAME</th>\n",
" <th>FDNAME</th>\n",
" <th>SNAMECOMP</th>\n",
" <th>FSYMBOL</th>\n",
" <th>FDNATURE</th>\n",
" <th>INVESTSTYLE</th>\n",
" <th>股票型(子类)</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1030000030</td>\n",
" <td>1</td>\n",
" <td>股票基金</td>\n",
" <td>1.2</td>\n",
" <td>指数股票型基金</td>\n",
" <td>1.2.1</td>\n",
" <td>标准指数股票型基金</td>\n",
" <td>国泰沪深300指数证券投资基金</td>\n",
" <td>国泰沪深300指数</td>\n",
" <td>020011</td>\n",
" <td>证券投资基金</td>\n",
" <td>指数型</td>\n",
" <td>被动指数型基金</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1030000034</td>\n",
" <td>1</td>\n",
" <td>股票基金</td>\n",
" <td>1.2</td>\n",
" <td>指数股票型基金</td>\n",
" <td>1.2.2</td>\n",
" <td>增强指数股票型基金</td>\n",
" <td>华安MSCI中国A股指数增强型证券投资基金</td>\n",
" <td>None</td>\n",
" <td>040002</td>\n",
" <td>证券投资基金</td>\n",
" <td>指数型</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1030000045</td>\n",
" <td>1</td>\n",
" <td>股票基金</td>\n",
" <td>1.2</td>\n",
" <td>指数股票型基金</td>\n",
" <td>1.2.1</td>\n",
" <td>标准指数股票型基金</td>\n",
" <td>博时裕富沪深300指数证券投资基金</td>\n",
" <td>博时沪深300指数</td>\n",
" <td>050002</td>\n",
" <td>证券投资基金</td>\n",
" <td>指数型</td>\n",
" <td>被动指数型基金</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1030000045</td>\n",
" <td>1</td>\n",
" <td>股票基金</td>\n",
" <td>1.2</td>\n",
" <td>指数股票型基金</td>\n",
" <td>1.2.1</td>\n",
" <td>标准指数股票型基金</td>\n",
" <td>博时裕富沪深300指数证券投资基金</td>\n",
" <td>博时沪深300指数</td>\n",
" <td>050002</td>\n",
" <td>证券投资基金</td>\n",
" <td>指数型</td>\n",
" <td>被动指数型基金</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1030000096</td>\n",
" <td>1</td>\n",
" <td>股票基金</td>\n",
" <td>1.2</td>\n",
" <td>指数股票型基金</td>\n",
" <td>1.2.2</td>\n",
" <td>增强指数股票型基金</td>\n",
" <td>易方达上证50指数增强型证券投资基金</td>\n",
" <td>易方达上证50增强</td>\n",
" <td>110003</td>\n",
" <td>证券投资基金</td>\n",
" <td>指数型</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>933</th>\n",
" <td>1030005090</td>\n",
" <td>1</td>\n",
" <td>股票基金</td>\n",
" <td>1.2</td>\n",
" <td>指数股票型基金</td>\n",
" <td>1.2.1</td>\n",
" <td>标准指数股票型基金</td>\n",
" <td>富国中证煤炭指数分级证券投资基金</td>\n",
" <td>富国中证煤炭指数分级</td>\n",
" <td>161032</td>\n",
" <td>证券投资基金</td>\n",
" <td>指数型</td>\n",
" <td>被动指数型基金</td>\n",
" </tr>\n",
" <tr>\n",
" <th>934</th>\n",
" <td>1030005095</td>\n",
" <td>1</td>\n",
" <td>股票基金</td>\n",
" <td>1.2</td>\n",
" <td>指数股票型基金</td>\n",
" <td>1.2.1</td>\n",
" <td>标准指数股票型基金</td>\n",
" <td>信诚中证信息安全指数分级证券投资基金</td>\n",
" <td>信诚中证信息安全指数分级</td>\n",
" <td>165523</td>\n",
" <td>证券投资基金</td>\n",
" <td>指数型</td>\n",
" <td>被动指数型基金</td>\n",
" </tr>\n",
" <tr>\n",
" <th>935</th>\n",
" <td>1030005100</td>\n",
" <td>1</td>\n",
" <td>股票基金</td>\n",
" <td>1.2</td>\n",
" <td>指数股票型基金</td>\n",
" <td>1.2.1</td>\n",
" <td>标准指数股票型基金</td>\n",
" <td>信诚中证智能家居指数分级证券投资基金</td>\n",
" <td>信诚中证智能家居指数分级</td>\n",
" <td>165524</td>\n",
" <td>证券投资基金</td>\n",
" <td>指数型</td>\n",
" <td>被动指数型基金</td>\n",
" </tr>\n",
" <tr>\n",
" <th>936</th>\n",
" <td>1030005248</td>\n",
" <td>1</td>\n",
" <td>股票基金</td>\n",
" <td>1.2</td>\n",
" <td>指数股票型基金</td>\n",
" <td>1.2.1</td>\n",
" <td>标准指数股票型基金</td>\n",
" <td>华安创业板50指数分级证券投资基金</td>\n",
" <td>华安创业板50指数分级</td>\n",
" <td>160420</td>\n",
" <td>证券投资基金</td>\n",
" <td>指数型</td>\n",
" <td>被动指数型基金</td>\n",
" </tr>\n",
" <tr>\n",
" <th>937</th>\n",
" <td>1030005273</td>\n",
" <td>1</td>\n",
" <td>股票基金</td>\n",
" <td>1.2</td>\n",
" <td>指数股票型基金</td>\n",
" <td>1.2.1</td>\n",
" <td>标准指数股票型基金</td>\n",
" <td>方正富邦中证保险主题指数分级证券投资基金</td>\n",
" <td>方正富邦保险主题指数分级</td>\n",
" <td>167301</td>\n",
" <td>证券投资基金</td>\n",
" <td>指数型</td>\n",
" <td>被动指数型基金</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>938 rows × 13 columns</p>\n",
"</div>"
],
"text/plain": [
" SECURITYID L1CODE L1NAME L2CODE L2NAME L3CODE L3NAME \\\n",
"0 1030000030 1 股票基金 1.2 指数股票型基金 1.2.1 标准指数股票型基金 \n",
"1 1030000034 1 股票基金 1.2 指数股票型基金 1.2.2 增强指数股票型基金 \n",
"2 1030000045 1 股票基金 1.2 指数股票型基金 1.2.1 标准指数股票型基金 \n",
"3 1030000045 1 股票基金 1.2 指数股票型基金 1.2.1 标准指数股票型基金 \n",
"4 1030000096 1 股票基金 1.2 指数股票型基金 1.2.2 增强指数股票型基金 \n",
".. ... ... ... ... ... ... ... \n",
"933 1030005090 1 股票基金 1.2 指数股票型基金 1.2.1 标准指数股票型基金 \n",
"934 1030005095 1 股票基金 1.2 指数股票型基金 1.2.1 标准指数股票型基金 \n",
"935 1030005100 1 股票基金 1.2 指数股票型基金 1.2.1 标准指数股票型基金 \n",
"936 1030005248 1 股票基金 1.2 指数股票型基金 1.2.1 标准指数股票型基金 \n",
"937 1030005273 1 股票基金 1.2 指数股票型基金 1.2.1 标准指数股票型基金 \n",
"\n",
" FDNAME SNAMECOMP FSYMBOL FDNATURE INVESTSTYLE 股票型(子类) \n",
"0 国泰沪深300指数证券投资基金 国泰沪深300指数 020011 证券投资基金 指数型 被动指数型基金 \n",
"1 华安MSCI中国A股指数增强型证券投资基金 None 040002 证券投资基金 指数型 NaN \n",
"2 博时裕富沪深300指数证券投资基金 博时沪深300指数 050002 证券投资基金 指数型 被动指数型基金 \n",
"3 博时裕富沪深300指数证券投资基金 博时沪深300指数 050002 证券投资基金 指数型 被动指数型基金 \n",
"4 易方达上证50指数增强型证券投资基金 易方达上证50增强 110003 证券投资基金 指数型 NaN \n",
".. ... ... ... ... ... ... \n",
"933 富国中证煤炭指数分级证券投资基金 富国中证煤炭指数分级 161032 证券投资基金 指数型 被动指数型基金 \n",
"934 信诚中证信息安全指数分级证券投资基金 信诚中证信息安全指数分级 165523 证券投资基金 指数型 被动指数型基金 \n",
"935 信诚中证智能家居指数分级证券投资基金 信诚中证智能家居指数分级 165524 证券投资基金 指数型 被动指数型基金 \n",
"936 华安创业板50指数分级证券投资基金 华安创业板50指数分级 160420 证券投资基金 指数型 被动指数型基金 \n",
"937 方正富邦中证保险主题指数分级证券投资基金 方正富邦保险主题指数分级 167301 证券投资基金 指数型 被动指数型基金 \n",
"\n",
"[938 rows x 13 columns]"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "025f28d5-c059-44ff-9d58-c8bb15912b4a",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:root] *",
"language": "python",
"name": "conda-root-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
......@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 1,
"id": "25a5db3d-4c9d-46e8-bd5a-88cca84280ba",
"metadata": {},
"outputs": [],
......@@ -18,7 +18,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 2,
"id": "329e6a8c-4e60-43d7-8314-63cee4f9196a",
"metadata": {},
"outputs": [],
......@@ -33,7 +33,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 3,
"id": "74246462-2676-4817-8c89-3a024ed8e412",
"metadata": {},
"outputs": [],
......@@ -56,7 +56,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 4,
"id": "61270089-05d5-4396-829e-651118231b60",
"metadata": {},
"outputs": [],
......@@ -77,7 +77,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 5,
"id": "73250ba3-83f4-41fe-8e61-2869f7db8662",
"metadata": {},
"outputs": [],
......@@ -91,17 +91,17 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 7,
"id": "87566cc8-5684-4c03-b247-3fb9abf72cf6",
"metadata": {},
"outputs": [],
"source": [
"agg_port = pd.merge(agg_port, fd_basicinfo(agg_port.SECURITYID, current_date))"
"agg_port = pd.merge(agg_port, fd_basicinfo(agg_port.SECURITYID.tolist(), current_date))"
]
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 8,
"id": "89e23e81-3398-40ab-a410-584b659f5db1",
"metadata": {},
"outputs": [
......@@ -132,6 +132,8 @@
" <th>FDNAME</th>\n",
" <th>SNAMECOMP</th>\n",
" <th>FSYMBOL</th>\n",
" <th>FDNATURE</th>\n",
" <th>INVESTSTYLE</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
......@@ -143,6 +145,8 @@
" <td>大成财富管理2020生命周期证券投资基金</td>\n",
" <td>None</td>\n",
" <td>090006</td>\n",
" <td>证券投资基金</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>54</th>\n",
......@@ -152,6 +156,8 @@
" <td>国投瑞银融华债券型证券投资基金</td>\n",
" <td>None</td>\n",
" <td>121001</td>\n",
" <td>证券投资基金</td>\n",
" <td>收益型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>62</th>\n",
......@@ -161,6 +167,8 @@
" <td>银河收益证券投资基金</td>\n",
" <td>None</td>\n",
" <td>151002</td>\n",
" <td>证券投资基金</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>94</th>\n",
......@@ -170,6 +178,8 @@
" <td>南方宝元债券型基金</td>\n",
" <td>南方宝元债券</td>\n",
" <td>202101</td>\n",
" <td>证券投资基金</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>95</th>\n",
......@@ -179,6 +189,8 @@
" <td>鹏华弘泰灵活配置混合型证券投资基金</td>\n",
" <td>鹏华弘泰灵活配置混合</td>\n",
" <td>206001</td>\n",
" <td>证券投资基金</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
......@@ -188,6 +200,8 @@
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2067</th>\n",
......@@ -197,6 +211,8 @@
" <td>东方价值挖掘灵活配置混合型证券投资基金</td>\n",
" <td>东方价值挖掘灵活配置混合</td>\n",
" <td>004166</td>\n",
" <td>证券投资基金</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2070</th>\n",
......@@ -206,6 +222,8 @@
" <td>易方达瑞富灵活配置混合型证券投资基金</td>\n",
" <td>易方达瑞富混合</td>\n",
" <td>001745</td>\n",
" <td>证券投资基金</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2071</th>\n",
......@@ -215,6 +233,8 @@
" <td>易方达瑞富灵活配置混合型证券投资基金</td>\n",
" <td>易方达瑞富混合</td>\n",
" <td>001746</td>\n",
" <td>证券投资基金</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2072</th>\n",
......@@ -224,6 +244,8 @@
" <td>南方安康混合型证券投资基金</td>\n",
" <td>None</td>\n",
" <td>004517</td>\n",
" <td>证券投资基金</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2081</th>\n",
......@@ -233,10 +255,12 @@
" <td>易方达裕惠回报定期开放式混合型发起式证券投资基金</td>\n",
" <td>None</td>\n",
" <td>000436</td>\n",
" <td>证券投资基金</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>508 rows × 6 columns</p>\n",
"<p>508 rows × 8 columns</p>\n",
"</div>"
],
"text/plain": [
......@@ -253,23 +277,23 @@
"2072 1030009813 21.400833 低权益仓位混合型基金 南方安康混合型证券投资基金 \n",
"2081 1030013275 7.011667 低权益仓位混合型基金 易方达裕惠回报定期开放式混合型发起式证券投资基金 \n",
"\n",
" SNAMECOMP FSYMBOL \n",
"40 None 090006 \n",
"54 None 121001 \n",
"62 None 151002 \n",
"94 南方宝元债券 202101 \n",
"95 鹏华弘泰灵活配置混合 206001 \n",
"... ... ... \n",
"2067 东方价值挖掘灵活配置混合 004166 \n",
"2070 易方达瑞富混合 001745 \n",
"2071 易方达瑞富混合 001746 \n",
"2072 None 004517 \n",
"2081 None 000436 \n",
" SNAMECOMP FSYMBOL FDNATURE INVESTSTYLE \n",
"40 None 090006 证券投资基金 稳健成长型 \n",
"54 None 121001 证券投资基金 收益型 \n",
"62 None 151002 证券投资基金 稳健成长型 \n",
"94 南方宝元债券 202101 证券投资基金 稳健成长型 \n",
"95 鹏华弘泰灵活配置混合 206001 证券投资基金 稳健成长型 \n",
"... ... ... ... ... \n",
"2067 东方价值挖掘灵活配置混合 004166 证券投资基金 稳健成长型 \n",
"2070 易方达瑞富混合 001745 证券投资基金 稳健成长型 \n",
"2071 易方达瑞富混合 001746 证券投资基金 稳健成长型 \n",
"2072 None 004517 证券投资基金 稳健成长型 \n",
"2081 None 000436 证券投资基金 稳健成长型 \n",
"\n",
"[508 rows x 6 columns]"
"[508 rows x 8 columns]"
]
},
"execution_count": 13,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
......@@ -280,7 +304,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 9,
"id": "a27e2473-ddf5-4883-bb50-6fe46914d3da",
"metadata": {},
"outputs": [
......@@ -342,7 +366,7 @@
"高权益仓位混合型基金 1205"
]
},
"execution_count": 14,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
......
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"id": "51382765-24b4-4e5e-a118-077b276e0774",
"metadata": {},
"outputs": [],
"source": [
"import datetime as dt\n",
"from utility import (\n",
" read_sql,\n",
" fd_basicinfo,\n",
" fd_typeclass,\n",
" nearest_report_date\n",
")\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "47939edc-07d2-4c8e-b061-187806e124ea",
"metadata": {},
"outputs": [],
"source": [
"# 获取回溯的报告日\n",
"\n",
"today = dt.datetime.today().strftime(\"%Y%m%d\")"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "9a596482-dd98-49dc-b717-c17177f2cd64",
"metadata": {},
"outputs": [],
"source": [
"# 获取所有目标货币型基金(清算结束日期晚于当前日)\n",
"\n",
"security_ids = read_sql(f\"\"\"\n",
"select SECURITYID from TQ_FD_TYPECLASS \n",
"WHERE\n",
" ISVALID = 1 AND\n",
" L1CODE = 5 AND\n",
" (ENDDATE>='{today}' or ENDDATE = '19000101') \n",
"ORDER BY SECURITYID;\n",
"\"\"\")[\"SECURITYID\"].unique().tolist()"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "7e1a0517-e3de-4ea7-ae3c-9c2292c63260",
"metadata": {},
"outputs": [],
"source": [
"basic_info = fd_basicinfo(security_ids)\n",
"type_info = fd_typeclass(security_ids)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "b0d0d48b-708b-447a-922b-500fbfb97600",
"metadata": {},
"outputs": [],
"source": [
"df = pd.merge(type_info[[\"SECURITYID\"]], basic_info, on=\"SECURITYID\")"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "5ccf2dc7-fea9-4d52-b15d-e8ff55fac3dc",
"metadata": {},
"outputs": [],
"source": [
"# 分类\n",
"df.loc[(df[\"FDNATURE\"] == \"ETF\"), \"货币型(子类)\"] = \"场内货币型基金\"\n",
"df.loc[(df[\"FDNATURE\"] != \"ETF\"), \"货币型(子类)\"] = \"场外货币型基金\""
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "9d34507e-9efd-479a-8b25-a095de5a552c",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>SECURITYID</th>\n",
" <th>FDNAME</th>\n",
" <th>SNAMECOMP</th>\n",
" <th>FSYMBOL</th>\n",
" <th>FDNATURE</th>\n",
" </tr>\n",
" <tr>\n",
" <th>货币型(子类)</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>场内货币型基金</th>\n",
" <td>44</td>\n",
" <td>44</td>\n",
" <td>42</td>\n",
" <td>44</td>\n",
" <td>44</td>\n",
" </tr>\n",
" <tr>\n",
" <th>场外货币型基金</th>\n",
" <td>549</td>\n",
" <td>549</td>\n",
" <td>503</td>\n",
" <td>549</td>\n",
" <td>549</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" SECURITYID FDNAME SNAMECOMP FSYMBOL FDNATURE\n",
"货币型(子类) \n",
"场内货币型基金 44 44 42 44 44\n",
"场外货币型基金 549 549 503 549 549"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby(\"货币型(子类)\").count()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c46e44f3-62a7-4409-a276-e7493cbb98aa",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "7e30b869-ddb2-4b75-9918-6931b7c00b05",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:root] *",
"language": "python",
"name": "conda-root-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "76b46662-651d-4bcd-b554-f116051cf297",
"metadata": {},
"outputs": [],
"source": [
"import datetime as dt\n",
"from utility import (\n",
" read_sql,\n",
" fd_basicinfo,\n",
" fd_typeclass,\n",
" nearest_report_date\n",
")\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "f5d4b805-d5a3-4b4c-8429-7044e9bef831",
"metadata": {},
"outputs": [],
"source": [
"# 获取回溯的报告日\n",
"\n",
"today = dt.datetime.today().strftime(\"%Y%m%d\")"
]
},
{
"cell_type": "code",
"execution_count": 46,
"id": "72d3f785-aee7-44d9-a393-3abbdb4d60a4",
"metadata": {},
"outputs": [],
"source": [
"# 获取所有目标基金(清算结束日期晚于当前日)\n",
"\n",
"security_ids = read_sql(f\"\"\"\n",
"select SECURITYID from TQ_FD_TYPECLASS \n",
"WHERE\n",
" ISVALID = 1 AND\n",
" (ENDDATE>='{today}' or ENDDATE = '19000101') \n",
"ORDER BY SECURITYID;\n",
"\"\"\")[\"SECURITYID\"].unique().tolist()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "f5f5cc7d-c2d4-4c7f-b8a9-dd133407f9c6",
"metadata": {},
"outputs": [],
"source": [
"basic_info = fd_basicinfo(security_ids)\n",
"type_info = fd_typeclass(security_ids)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "52607b95-9d62-4f68-8256-984827dd0bea",
"metadata": {},
"outputs": [],
"source": [
"df = pd.merge(type_info, basic_info, on=\"SECURITYID\")"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "60fe66ee-a8d3-4a33-8c5a-555f68d9758c",
"metadata": {},
"outputs": [],
"source": [
"# 分类\n",
"df.loc[(df[\"INVESTSTYLE\"] == \"商品型\") & (df[\"L1CODE\"] != 6), \"另类投资型(子类)\"] = \"商品型基金\"\n",
"df.loc[(df[\"L3NAME\"] == \"对冲策略基金\"), \"另类投资型(子类)\"] = \"量化对冲基金\""
]
},
{
"cell_type": "code",
"execution_count": 45,
"id": "1bb62bc7-2515-415a-8eec-087d2d1787b6",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>SECURITYID</th>\n",
" <th>L1CODE</th>\n",
" <th>L1NAME</th>\n",
" <th>L2CODE</th>\n",
" <th>L2NAME</th>\n",
" <th>L3CODE</th>\n",
" <th>L3NAME</th>\n",
" <th>FDNAME</th>\n",
" <th>SNAMECOMP</th>\n",
" <th>FSYMBOL</th>\n",
" <th>FDNATURE</th>\n",
" <th>INVESTSTYLE</th>\n",
" </tr>\n",
" <tr>\n",
" <th>另类投资型(子类)</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>商品型基金</th>\n",
" <td>29</td>\n",
" <td>29</td>\n",
" <td>29</td>\n",
" <td>29</td>\n",
" <td>29</td>\n",
" <td>29</td>\n",
" <td>29</td>\n",
" <td>29</td>\n",
" <td>17</td>\n",
" <td>29</td>\n",
" <td>29</td>\n",
" <td>29</td>\n",
" </tr>\n",
" <tr>\n",
" <th>量化对冲基金</th>\n",
" <td>17</td>\n",
" <td>17</td>\n",
" <td>17</td>\n",
" <td>17</td>\n",
" <td>17</td>\n",
" <td>17</td>\n",
" <td>17</td>\n",
" <td>17</td>\n",
" <td>9</td>\n",
" <td>17</td>\n",
" <td>17</td>\n",
" <td>17</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" SECURITYID L1CODE L1NAME L2CODE L2NAME L3CODE L3NAME FDNAME \\\n",
"另类投资型(子类) \n",
"商品型基金 29 29 29 29 29 29 29 29 \n",
"量化对冲基金 17 17 17 17 17 17 17 17 \n",
"\n",
" SNAMECOMP FSYMBOL FDNATURE INVESTSTYLE \n",
"另类投资型(子类) \n",
"商品型基金 17 29 29 29 \n",
"量化对冲基金 9 17 17 17 "
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby(\"另类投资型(子类)\").count()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3ba8793e-d648-4dc0-99ef-731a8c97f50e",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:root] *",
"language": "python",
"name": "conda-root-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "b81e5b9e-b8f5-4198-b98c-2e26f025875c",
"metadata": {},
"outputs": [],
"source": [
"import datetime as dt\n",
"from utility import (\n",
" read_sql,\n",
" fd_basicinfo,\n",
" fd_typeclass,\n",
" nearest_report_date\n",
")\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "8bf4331c-c1db-47b4-b72d-10d5ccb72657",
"metadata": {},
"outputs": [],
"source": [
"# 获取回溯的报告日\n",
"\n",
"today = dt.datetime.today().strftime(\"%Y%m%d\")"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "d228ec88-a55b-4451-8a69-1a0e490b9161",
"metadata": {},
"outputs": [],
"source": [
"# 获取所有目标QDII基金(清算结束日期晚于当前日)\n",
"\n",
"security_ids = read_sql(f\"\"\"\n",
"select SECURITYID from TQ_FD_TYPECLASS \n",
"WHERE\n",
" ISVALID = 1 AND\n",
" L1CODE = 6 AND\n",
" (ENDDATE>='{today}' or ENDDATE = '19000101') \n",
"ORDER BY SECURITYID;\n",
"\"\"\")[\"SECURITYID\"].unique().tolist()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "7763ee34-dbba-4297-b2d8-16fc98be8a3b",
"metadata": {},
"outputs": [],
"source": [
"basic_info = fd_basicinfo(security_ids)\n",
"type_info = fd_typeclass(security_ids)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "e12d8f3b-0570-40db-9ec3-d6804b78c686",
"metadata": {},
"outputs": [],
"source": [
"df = pd.merge(type_info, basic_info, on=\"SECURITYID\")"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "b3f87023-d068-4014-975c-22db615c3273",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array(['QDII股票型基金', 'QDII混合基金', 'QDII全球股票型基金', 'QDII债券基金', 'QDII指数股票型基金',\n",
" 'QDII商品基金', 'QDII房地产信托基金', 'QDII分级子基金'], dtype=object)"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.L3NAME.unique()"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "0efd51eb-a03c-440b-b083-a36df52f9185",
"metadata": {},
"outputs": [],
"source": [
"# 分类\n",
"df.loc[(df[\"L3NAME\"].isin([\"QDII股票型基金\", \"QDII全球股票型基金\", \"QDII指数股票型基金\"])), \"QDII型(子类)\"] = \"QDII股票型基金\"\n",
"df.loc[df[\"L3NAME\"] == \"QDII债券基金\", \"QDII型(子类)\"] = \"QDII债券型基金\"\n",
"df.loc[(df[\"L3NAME\"].isin([\"QDII商品基金\", \"QDII房地产信托基金\"])), \"QDII型(子类)\"] = \"QDII另类投资基金\"\n",
"df.loc[(df[\"L3NAME\"].isin([\"QDII混合基金\", \"QDII分级子基金\"])), \"QDII型(子类)\"] = \"QDII混合型基金\""
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "850b9707-8849-48b5-9b39-9111ab78ccc1",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>SECURITYID</th>\n",
" <th>L1CODE</th>\n",
" <th>L1NAME</th>\n",
" <th>L2CODE</th>\n",
" <th>L2NAME</th>\n",
" <th>L3CODE</th>\n",
" <th>L3NAME</th>\n",
" <th>FDNAME</th>\n",
" <th>SNAMECOMP</th>\n",
" <th>FSYMBOL</th>\n",
" <th>FDNATURE</th>\n",
" <th>INVESTSTYLE</th>\n",
" </tr>\n",
" <tr>\n",
" <th>QDII型(子类)</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>QDII债券型基金</th>\n",
" <td>39</td>\n",
" <td>39</td>\n",
" <td>39</td>\n",
" <td>39</td>\n",
" <td>39</td>\n",
" <td>39</td>\n",
" <td>39</td>\n",
" <td>39</td>\n",
" <td>38</td>\n",
" <td>39</td>\n",
" <td>39</td>\n",
" <td>39</td>\n",
" </tr>\n",
" <tr>\n",
" <th>QDII另类投资基金</th>\n",
" <td>19</td>\n",
" <td>19</td>\n",
" <td>19</td>\n",
" <td>19</td>\n",
" <td>19</td>\n",
" <td>19</td>\n",
" <td>19</td>\n",
" <td>19</td>\n",
" <td>9</td>\n",
" <td>19</td>\n",
" <td>19</td>\n",
" <td>19</td>\n",
" </tr>\n",
" <tr>\n",
" <th>QDII混合型基金</th>\n",
" <td>31</td>\n",
" <td>31</td>\n",
" <td>31</td>\n",
" <td>31</td>\n",
" <td>31</td>\n",
" <td>31</td>\n",
" <td>31</td>\n",
" <td>31</td>\n",
" <td>13</td>\n",
" <td>31</td>\n",
" <td>31</td>\n",
" <td>31</td>\n",
" </tr>\n",
" <tr>\n",
" <th>QDII股票型基金</th>\n",
" <td>87</td>\n",
" <td>87</td>\n",
" <td>87</td>\n",
" <td>87</td>\n",
" <td>87</td>\n",
" <td>87</td>\n",
" <td>87</td>\n",
" <td>87</td>\n",
" <td>55</td>\n",
" <td>87</td>\n",
" <td>87</td>\n",
" <td>87</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" SECURITYID L1CODE L1NAME L2CODE L2NAME L3CODE L3NAME \\\n",
"QDII型(子类) \n",
"QDII债券型基金 39 39 39 39 39 39 39 \n",
"QDII另类投资基金 19 19 19 19 19 19 19 \n",
"QDII混合型基金 31 31 31 31 31 31 31 \n",
"QDII股票型基金 87 87 87 87 87 87 87 \n",
"\n",
" FDNAME SNAMECOMP FSYMBOL FDNATURE INVESTSTYLE \n",
"QDII型(子类) \n",
"QDII债券型基金 39 38 39 39 39 \n",
"QDII另类投资基金 19 9 19 19 19 \n",
"QDII混合型基金 31 13 31 31 31 \n",
"QDII股票型基金 87 55 87 87 87 "
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby(\"QDII型(子类)\").count()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0f3aec26-468c-4b17-b9c5-75119afcf005",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:root] *",
"language": "python",
"name": "conda-root-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "de082674-0285-4894-905a-52da1ab1727d",
"metadata": {},
"outputs": [],
"source": [
"import datetime as dt\n",
"from utility import (\n",
" read_sql,\n",
" fd_basicinfo,\n",
" fd_typeclass,\n",
" nearest_report_date\n",
")\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "11d2dbfe-b1c7-41b1-8df3-b6f40b096f83",
"metadata": {},
"outputs": [],
"source": [
"# 获取回溯的报告日\n",
"\n",
"today = dt.datetime.today().strftime(\"%Y%m%d\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "004a8f9f-4011-48c6-a5dd-327cce42de51",
"metadata": {},
"outputs": [],
"source": [
"# 获取所有目标债券型基金(清算结束日期晚于当前日)\n",
"\n",
"security_ids = read_sql(f\"\"\"\n",
"select SECURITYID from TQ_FD_TYPECLASS \n",
"WHERE\n",
" ISVALID = 1 AND\n",
" (ENDDATE>='{today}' or ENDDATE = '19000101') \n",
"ORDER BY SECURITYID;\n",
"\"\"\")[\"SECURITYID\"].unique().tolist()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "acf00858-6782-4ecb-8a87-9045810ce589",
"metadata": {},
"outputs": [],
"source": [
"basic_info = fd_basicinfo(security_ids)\n",
"type_info = fd_typeclass(security_ids)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "08bfc149-90e5-405d-a1f2-6ec750c26f9e",
"metadata": {},
"outputs": [],
"source": [
"df = pd.merge(type_info, basic_info, on=\"SECURITYID\")\n",
"# df = df[df.FDNATURE == 'FOF']"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "493e2114-8eaa-4c5c-bec4-2e297eaf3c99",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>SECURITYID</th>\n",
" <th>L1CODE</th>\n",
" <th>L1NAME</th>\n",
" <th>L2CODE</th>\n",
" <th>L2NAME</th>\n",
" <th>L3CODE</th>\n",
" <th>L3NAME</th>\n",
" <th>FDNAME</th>\n",
" <th>SNAMECOMP</th>\n",
" <th>FSYMBOL</th>\n",
" <th>FDNATURE</th>\n",
" <th>INVESTSTYLE</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
"Empty DataFrame\n",
"Columns: [SECURITYID, L1CODE, L1NAME, L2CODE, L2NAME, L3CODE, L3NAME, FDNAME, SNAMECOMP, FSYMBOL, FDNATURE, INVESTSTYLE]\n",
"Index: []"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[df.FSYMBOL == '013849']"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "fc897e0e-46f1-48a2-be9a-6381086c94bf",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['000001',\n",
" '000003',\n",
" '000004',\n",
" '000005',\n",
" '000008',\n",
" '000009',\n",
" '000010',\n",
" '000011',\n",
" '000013',\n",
" '000014',\n",
" '000015',\n",
" '000016',\n",
" '000017',\n",
" '000020',\n",
" '000021',\n",
" '000024',\n",
" '000025',\n",
" '000028',\n",
" '000029',\n",
" '000030',\n",
" '000031',\n",
" '000032',\n",
" '000033',\n",
" '000037',\n",
" '000038',\n",
" '000039',\n",
" '000041',\n",
" '000042',\n",
" '000043',\n",
" '000044',\n",
" '000045',\n",
" '000046',\n",
" '000047',\n",
" '000048',\n",
" '000049',\n",
" '000051',\n",
" '000053',\n",
" '000054',\n",
" '000055',\n",
" '000056',\n",
" '000057',\n",
" '000058',\n",
" '000059',\n",
" '000061',\n",
" '000063',\n",
" '000064',\n",
" '000065',\n",
" '000066',\n",
" '000067',\n",
" '000068',\n",
" '000069',\n",
" '000070',\n",
" '000071',\n",
" '000072',\n",
" '000073',\n",
" '000074',\n",
" '000075',\n",
" '000077',\n",
" '000078',\n",
" '000079',\n",
" '000080',\n",
" '000081',\n",
" '000082',\n",
" '000083',\n",
" '000084',\n",
" '000085',\n",
" '000086',\n",
" '000087',\n",
" '000088',\n",
" '000089',\n",
" '000090',\n",
" '000103',\n",
" '000104',\n",
" '000105',\n",
" '000106',\n",
" '000107',\n",
" '000109',\n",
" '000110',\n",
" '000111',\n",
" '000112',\n",
" '000116',\n",
" '000117',\n",
" '000118',\n",
" '000119',\n",
" '000120',\n",
" '000121',\n",
" '000122',\n",
" '000123',\n",
" '000124',\n",
" '000126',\n",
" '000127',\n",
" '000128',\n",
" '000129',\n",
" '000130',\n",
" '000131',\n",
" '000134',\n",
" '000135',\n",
" '000136',\n",
" '000137',\n",
" '000138',\n",
" '000139',\n",
" '000141',\n",
" '000142',\n",
" '000143',\n",
" '000147',\n",
" '000148',\n",
" '000149',\n",
" '000150',\n",
" '000152',\n",
" '000153',\n",
" '000165',\n",
" '000166',\n",
" '000167',\n",
" '000171',\n",
" '000172',\n",
" '000173',\n",
" '000174',\n",
" '000175',\n",
" '000176',\n",
" '000179',\n",
" '000180',\n",
" '000181',\n",
" '000182',\n",
" '000183',\n",
" '000184',\n",
" '000185',\n",
" '000186',\n",
" '000187',\n",
" '000188',\n",
" '000189',\n",
" '000190',\n",
" '000191',\n",
" '000192',\n",
" '000194',\n",
" '000195',\n",
" '000196',\n",
" '000197',\n",
" '000198',\n",
" '000199',\n",
" '000200',\n",
" '000201',\n",
" '000203',\n",
" '000204',\n",
" '000205',\n",
" '000206',\n",
" '000207',\n",
" '000208',\n",
" '000209',\n",
" '000210',\n",
" '000211',\n",
" '000212',\n",
" '000213',\n",
" '000214',\n",
" '000215',\n",
" '000216',\n",
" '000217',\n",
" '000218',\n",
" '000219',\n",
" '000220',\n",
" '000221',\n",
" '000222',\n",
" '000227',\n",
" '000235',\n",
" '000236',\n",
" '000239',\n",
" '000240',\n",
" '000241',\n",
" '000242',\n",
" '000244',\n",
" '000245',\n",
" '000246',\n",
" '000248',\n",
" '000251',\n",
" '000252',\n",
" '000253',\n",
" '000254',\n",
" '000255',\n",
" '000259',\n",
" '000263',\n",
" '000264',\n",
" '000265',\n",
" '000266',\n",
" '000267',\n",
" '000268',\n",
" '000270',\n",
" '000271',\n",
" '000272',\n",
" '000273',\n",
" '000274',\n",
" '000275',\n",
" '000277',\n",
" '000279',\n",
" '000286',\n",
" '000289',\n",
" '000290',\n",
" '000292',\n",
" '000293',\n",
" '000294',\n",
" '000295',\n",
" '000296',\n",
" '000297',\n",
" '000298',\n",
" '000299',\n",
" '000300',\n",
" '000301',\n",
" '000305',\n",
" '000306',\n",
" '000307',\n",
" '000308',\n",
" '000309',\n",
" '000310',\n",
" '000311',\n",
" '000312',\n",
" '000313',\n",
" '000314',\n",
" '000317',\n",
" '000318',\n",
" '000319',\n",
" '000320',\n",
" '000322',\n",
" '000323',\n",
" '000324',\n",
" '000325',\n",
" '000326',\n",
" '000327',\n",
" '000328',\n",
" '000329',\n",
" '000330',\n",
" '000331',\n",
" '000332',\n",
" '000333',\n",
" '000334',\n",
" '000335',\n",
" '000336',\n",
" '000338',\n",
" '000339',\n",
" '000341',\n",
" '000342',\n",
" '000343',\n",
" '000345',\n",
" '000346',\n",
" '000347',\n",
" '000351',\n",
" '000352',\n",
" '000354',\n",
" '000355',\n",
" '000356',\n",
" '000359',\n",
" '000362',\n",
" '000363',\n",
" '000366',\n",
" '000367',\n",
" '000368',\n",
" '000369',\n",
" '000370',\n",
" '000371',\n",
" '000372',\n",
" '000373',\n",
" '000376',\n",
" '000377',\n",
" '000378',\n",
" '000379',\n",
" '000380',\n",
" '000381',\n",
" '000385',\n",
" '000386',\n",
" '000389',\n",
" '000390',\n",
" '000394',\n",
" '000395',\n",
" '000396',\n",
" '000397',\n",
" '000398',\n",
" '000402',\n",
" '000403',\n",
" '000404',\n",
" '000406',\n",
" '000407',\n",
" '000408',\n",
" '000409',\n",
" '000410',\n",
" '000411',\n",
" '000412',\n",
" '000413',\n",
" '000414',\n",
" '000415',\n",
" '000416',\n",
" '000417',\n",
" '000418',\n",
" '000419',\n",
" '000420',\n",
" '000423',\n",
" '000424',\n",
" '000425',\n",
" '000431',\n",
" '000432',\n",
" '000433',\n",
" '000434',\n",
" '000436',\n",
" '000439',\n",
" '000452',\n",
" '000457',\n",
" '000458',\n",
" '000462',\n",
" '000463',\n",
" '000464',\n",
" '000465',\n",
" '000466',\n",
" '000469',\n",
" '000471',\n",
" '000475',\n",
" '000476',\n",
" '000477',\n",
" '000478',\n",
" '000480',\n",
" '000481',\n",
" '000483',\n",
" '000484',\n",
" '000487',\n",
" '000489',\n",
" '000490',\n",
" '000493',\n",
" '000494',\n",
" '000495',\n",
" '000496',\n",
" '000497',\n",
" '000500',\n",
" '000501',\n",
" '000502',\n",
" '000503',\n",
" '000504',\n",
" '000505',\n",
" '000506',\n",
" '000507',\n",
" '000508',\n",
" '000509',\n",
" '000511',\n",
" '000512',\n",
" '000513',\n",
" '000520',\n",
" '000522',\n",
" '000523',\n",
" '000524',\n",
" '000526',\n",
" '000527',\n",
" '000528',\n",
" '000529',\n",
" '000530',\n",
" '000531',\n",
" '000532',\n",
" '000533',\n",
" '000534',\n",
" '000535',\n",
" '000536',\n",
" '000538',\n",
" '000539',\n",
" '000540',\n",
" '000541',\n",
" '000542',\n",
" '000543',\n",
" '000545',\n",
" '000546',\n",
" '000547',\n",
" '000548',\n",
" '000549',\n",
" '000550',\n",
" '000551',\n",
" '000552',\n",
" '000553',\n",
" '000554',\n",
" '000556',\n",
" '000557',\n",
" '000559',\n",
" '000560',\n",
" '000561',\n",
" '000562',\n",
" '000563',\n",
" '000564',\n",
" '000566',\n",
" '000567',\n",
" '000569',\n",
" '000572',\n",
" '000573',\n",
" '000574',\n",
" '000575',\n",
" '000576',\n",
" '000577',\n",
" '000578',\n",
" '000579',\n",
" '000580',\n",
" '000581',\n",
" '000583',\n",
" '000584',\n",
" '000585',\n",
" '000586',\n",
" '000587',\n",
" '000588',\n",
" '000589',\n",
" '000590',\n",
" '000591',\n",
" '000592',\n",
" '000593',\n",
" '000594',\n",
" '000595',\n",
" '000596',\n",
" '000597',\n",
" '000598',\n",
" '000599',\n",
" '000600',\n",
" '000601',\n",
" '000602',\n",
" '000603',\n",
" '000604',\n",
" '000605',\n",
" '000607',\n",
" '000609',\n",
" '000612',\n",
" '000613',\n",
" '000614',\n",
" '000615',\n",
" '000618',\n",
" '000619',\n",
" '000620',\n",
" '000621',\n",
" '000622',\n",
" '000623',\n",
" '000624',\n",
" '000625',\n",
" '000626',\n",
" '000627',\n",
" '000628',\n",
" '000631',\n",
" '000632',\n",
" '000633',\n",
" '000634',\n",
" '000638',\n",
" '000639',\n",
" '000640',\n",
" '000641',\n",
" '000642',\n",
" '000644',\n",
" '000645',\n",
" '000646',\n",
" '000647',\n",
" '000648',\n",
" '000649',\n",
" '000650',\n",
" '000651',\n",
" '000652',\n",
" '000654',\n",
" '000655',\n",
" '000656',\n",
" '000657',\n",
" '000658',\n",
" '000659',\n",
" '000660',\n",
" '000661',\n",
" '000662',\n",
" '000663',\n",
" '000664',\n",
" '000665',\n",
" '000667',\n",
" '000668',\n",
" '000669',\n",
" '000672',\n",
" '000674',\n",
" '000675',\n",
" '000676',\n",
" '000677',\n",
" '000678',\n",
" '000679',\n",
" '000681',\n",
" '000682',\n",
" '000683',\n",
" '000684',\n",
" '000686',\n",
" '000687',\n",
" '000688',\n",
" '000689',\n",
" '000690',\n",
" '000692',\n",
" '000693',\n",
" '000694',\n",
" '000696',\n",
" '000697',\n",
" '000698',\n",
" '000699',\n",
" '000700',\n",
" '000701',\n",
" '000704',\n",
" '000705',\n",
" '000706',\n",
" '000707',\n",
" '000708',\n",
" '000709',\n",
" '000710',\n",
" '000711',\n",
" '000712',\n",
" '000713',\n",
" '000714',\n",
" '000715',\n",
" '000716',\n",
" '000717',\n",
" '000719',\n",
" '000720',\n",
" '000721',\n",
" '000722',\n",
" '000724',\n",
" '000725',\n",
" '000726',\n",
" '000727',\n",
" '000728',\n",
" '000729',\n",
" '000730',\n",
" '000734',\n",
" '000735',\n",
" '000736',\n",
" '000737',\n",
" '000739',\n",
" '000740',\n",
" '000741',\n",
" '000742',\n",
" '000743',\n",
" '000744',\n",
" '000745',\n",
" '000746',\n",
" '000747',\n",
" '000748',\n",
" '000750',\n",
" '000751',\n",
" '000753',\n",
" '000754',\n",
" '000755',\n",
" '000756',\n",
" '000757',\n",
" '000758',\n",
" '000759',\n",
" '000760',\n",
" '000761',\n",
" '000762',\n",
" '000763',\n",
" '000764',\n",
" '000767',\n",
" '000769',\n",
" '000770',\n",
" '000771',\n",
" '000772',\n",
" '000773',\n",
" '000778',\n",
" '000779',\n",
" '000780',\n",
" '000783',\n",
" '000784',\n",
" '000785',\n",
" '000786',\n",
" '000787',\n",
" '000788',\n",
" '000789',\n",
" '000790',\n",
" '000791',\n",
" '000792',\n",
" '000793',\n",
" '000794',\n",
" '000796',\n",
" '000797',\n",
" '000800',\n",
" '000801',\n",
" '000802',\n",
" '000803',\n",
" '000804',\n",
" '000805',\n",
" '000808',\n",
" '000809',\n",
" '000810',\n",
" '000812',\n",
" '000813',\n",
" '000814',\n",
" '000815',\n",
" '000816',\n",
" '000817',\n",
" '000818',\n",
" '000822',\n",
" '000823',\n",
" '000824',\n",
" '000825',\n",
" '000826',\n",
" '000827',\n",
" '000828',\n",
" '000829',\n",
" '000830',\n",
" '000831',\n",
" '000832',\n",
" '000833',\n",
" '000834',\n",
" '000835',\n",
" '000836',\n",
" '000837',\n",
" '000839',\n",
" '000840',\n",
" '000841',\n",
" '000843',\n",
" '000844',\n",
" '000845',\n",
" '000846',\n",
" '000847',\n",
" '000848',\n",
" '000849',\n",
" '000850',\n",
" '000854',\n",
" '000855',\n",
" '000856',\n",
" '000857',\n",
" '000859',\n",
" '000860',\n",
" '000861',\n",
" '000862',\n",
" '000863',\n",
" '000866',\n",
" '000867',\n",
" '000868',\n",
" '000869',\n",
" '000870',\n",
" '000871',\n",
" '000872',\n",
" '000873',\n",
" '000874',\n",
" '000875',\n",
" '000876',\n",
" '000877',\n",
" '000878',\n",
" '000879',\n",
" '000880',\n",
" '000882',\n",
" '000883',\n",
" '000884',\n",
" '000887',\n",
" '000891',\n",
" '000892',\n",
" '000893',\n",
" '000895',\n",
" '000896',\n",
" '000897',\n",
" '000898',\n",
" '000899',\n",
" '000903',\n",
" '000904',\n",
" '000905',\n",
" '000906',\n",
" '000907',\n",
" '000908',\n",
" '000910',\n",
" '000911',\n",
" '000912',\n",
" '000913',\n",
" '000914',\n",
" '000916',\n",
" '000917',\n",
" '000918',\n",
" '000919',\n",
" '000920',\n",
" '000921',\n",
" '000922',\n",
" '000923',\n",
" '000924',\n",
" '000925',\n",
" '000926',\n",
" '000927',\n",
" '000928',\n",
" '000929',\n",
" '000930',\n",
" '000931',\n",
" '000932',\n",
" '000933',\n",
" '000934',\n",
" '000935',\n",
" '000936',\n",
" '000939',\n",
" '000940',\n",
" '000942',\n",
" '000943',\n",
" '000944',\n",
" '000945',\n",
" '000946',\n",
" '000948',\n",
" '000950',\n",
" '000951',\n",
" '000952',\n",
" '000953',\n",
" '000954',\n",
" '000955',\n",
" '000958',\n",
" '000959',\n",
" '000960',\n",
" '000961',\n",
" '000962',\n",
" '000963',\n",
" '000965',\n",
" '000966',\n",
" '000967',\n",
" '000968',\n",
" '000969',\n",
" '000971',\n",
" '000972',\n",
" '000973',\n",
" '000974',\n",
" '000975',\n",
" '000976',\n",
" '000977',\n",
" '000978',\n",
" '000979',\n",
" '000980',\n",
" '000981',\n",
" '000982',\n",
" '000985',\n",
" '000986',\n",
" '000988',\n",
" '000989',\n",
" '000991',\n",
" '000992',\n",
" '000993',\n",
" '000994',\n",
" '000995',\n",
" '000996',\n",
" '000997',\n",
" '000998',\n",
" '001000',\n",
" '001001',\n",
" '001003',\n",
" '001004',\n",
" '001006',\n",
" '001007',\n",
" '001008',\n",
" '001009',\n",
" '001010',\n",
" '001011',\n",
" '001013',\n",
" '001015',\n",
" '001016',\n",
" '001017',\n",
" '001018',\n",
" '001019',\n",
" '001021',\n",
" '001023',\n",
" '001026',\n",
" '001027',\n",
" '001028',\n",
" '001030',\n",
" '001031',\n",
" '001033',\n",
" '001035',\n",
" '001036',\n",
" '001037',\n",
" '001038',\n",
" '001039',\n",
" '001040',\n",
" '001041',\n",
" '001042',\n",
" '001043',\n",
" '001044',\n",
" '001045',\n",
" '001046',\n",
" '001047',\n",
" '001048',\n",
" '001050',\n",
" '001051',\n",
" '001052',\n",
" '001053',\n",
" '001054',\n",
" '001056',\n",
" '001057',\n",
" '001058',\n",
" '001059',\n",
" '001060',\n",
" '001061',\n",
" '001063',\n",
" '001064',\n",
" '001065',\n",
" '001067',\n",
" '001068',\n",
" '001069',\n",
" '001070',\n",
" '001071',\n",
" '001072',\n",
" '001073',\n",
" '001074',\n",
" '001075',\n",
" '001076',\n",
" '001077',\n",
" '001078',\n",
" '001086',\n",
" '001087',\n",
" '001088',\n",
" '001092',\n",
" '001093',\n",
" '001094',\n",
" '001095',\n",
" '001096',\n",
" '001097',\n",
" '001101',\n",
" '001102',\n",
" '001103',\n",
" '001104',\n",
" '001105',\n",
" '001106',\n",
" '001110',\n",
" '001111',\n",
" '001112',\n",
" '001113',\n",
" '001115',\n",
" '001116',\n",
" '001117',\n",
" '001118',\n",
" '001120',\n",
" '001121',\n",
" '001122',\n",
" '001123',\n",
" '001124',\n",
" '001125',\n",
" '001126',\n",
" '001127',\n",
" '001128',\n",
" '001133',\n",
" '001134',\n",
" '001135',\n",
" '001136',\n",
" '001139',\n",
" '001140',\n",
" '001141',\n",
" '001142',\n",
" '001143',\n",
" '001144',\n",
" '001146',\n",
" '001147',\n",
" '001148',\n",
" '001149',\n",
" '001150',\n",
" '001152',\n",
" '001154',\n",
" '001156',\n",
" '001157',\n",
" '001158',\n",
" '001162',\n",
" '001163',\n",
" '001164',\n",
" '001165',\n",
" '001166',\n",
" '001167',\n",
" '001170',\n",
" '001171',\n",
" '001172',\n",
" '001173',\n",
" '001174',\n",
" '001175',\n",
" '001176',\n",
" '001177',\n",
" '001178',\n",
" '001179',\n",
" '001180',\n",
" '001181',\n",
" '001182',\n",
" '001183',\n",
" '001184',\n",
" '001185',\n",
" '001186',\n",
" '001188',\n",
" '001189',\n",
" '001190',\n",
" '001191',\n",
" '001192',\n",
" '001193',\n",
" '001194',\n",
" '001195',\n",
" '001196',\n",
" '001197',\n",
" '001198',\n",
" '001199',\n",
" '001200',\n",
" '001201',\n",
" '001202',\n",
" '001203',\n",
" '001204',\n",
" '001208',\n",
" '001209',\n",
" '001210',\n",
" '001211',\n",
" '001212',\n",
" '001213',\n",
" '001214',\n",
" '001215',\n",
" '001216',\n",
" '001217',\n",
" '001218',\n",
" '001219',\n",
" '001220',\n",
" '001222',\n",
" '001223',\n",
" '001224',\n",
" '001225',\n",
" '001226',\n",
" '001227',\n",
" '001228',\n",
" '001229',\n",
" '001230',\n",
" '001231',\n",
" '001232',\n",
" '001233',\n",
" '001234',\n",
" '001235',\n",
" '001236',\n",
" '001237',\n",
" '001239',\n",
" '001240',\n",
" '001241',\n",
" '001242',\n",
" '001243',\n",
" '001244',\n",
" '001245',\n",
" '001246',\n",
" '001247',\n",
" '001249',\n",
" '001250',\n",
" '001251',\n",
" '001252',\n",
" '001254',\n",
" '001255',\n",
" '001256',\n",
" '001257',\n",
" '001258',\n",
" '001260',\n",
" '001261',\n",
" '001264',\n",
" '001265',\n",
" '001266',\n",
" '001267',\n",
" '001268',\n",
" '001270',\n",
" '001271',\n",
" '001272',\n",
" '001273',\n",
" '001275',\n",
" '001276',\n",
" '001277',\n",
" '001278',\n",
" '001279',\n",
" '001280',\n",
" '001281',\n",
" '001282',\n",
" '001283',\n",
" '001284',\n",
" '001285',\n",
" '001286',\n",
" '001287',\n",
" '001289',\n",
" '001291',\n",
" '001294',\n",
" '001296',\n",
" '001297',\n",
" '001298',\n",
" '001299',\n",
" '001300',\n",
" '001301',\n",
" '001302',\n",
" '001303',\n",
" '001304',\n",
" '001305',\n",
" '001306',\n",
" '001307',\n",
" '001308',\n",
" '001309',\n",
" '001311',\n",
" '001312',\n",
" '001313',\n",
" '001314',\n",
" '001315',\n",
" '001316',\n",
" '001318',\n",
" '001319',\n",
" '001320',\n",
" '001322',\n",
" '001323',\n",
" '001324',\n",
" '001325',\n",
" '001326',\n",
" '001327',\n",
" '001328',\n",
" '001329',\n",
" '001330',\n",
" '001331',\n",
" '001332',\n",
" '001334',\n",
" '001335',\n",
" '001336',\n",
" '001337',\n",
" '001338',\n",
" '001339',\n",
" '001342',\n",
" '001343',\n",
" '001345',\n",
" '001347',\n",
" '001349',\n",
" ...]"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sorted(df.FSYMBOL.unique().tolist())"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e736945e-c4a8-46dd-bc92-114085c19f8f",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:root] *",
"language": "python",
"name": "conda-root-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
......@@ -24,25 +24,35 @@ def nearest_report_date(date):
return dt.date(last_year, q, last).strftime("%Y%m%d")
def fd_basicinfo(security_ids, trade_dt=None):
def fd_basicinfo(security_ids=None, trade_dt=None):
if not trade_dt:
trade_dt = dt.datetime.today().strftime("%Y%m%d")
else:
trade_dt = trade_dt.replace("-", "")
if isinstance(security_ids, str):
sec_id_strs = security_ids.split(",")
sec_id_strs = security_ids
elif not security_ids:
sec_id_strs = None
else:
sec_id_strs = ",".join(["'" + s + "'" for s in security_ids])
engine = sa.create_engine(CONN, connect_args={"charset": "GBK"})
if sec_id_strs:
query = f"""
select SECURITYID, FDNAME, SNAMECOMP, FSYMBOL from TQ_FD_BASICINFO
select SECURITYID, FDNAME, SNAMECOMP, FSYMBOL, FDNATURE, INVESTSTYLE from TQ_FD_BASICINFO
WHERE
ISVALID = 1 AND
SECURITYID in ({sec_id_strs}) AND
(LIQUENDDATE >= '{trade_dt}' or LIQUENDDATE = '19000101')
"""
else:
query = f"""
select SECURITYID, FDNAME, SNAMECOMP, FSYMBOL, FDNATURE, INVESTSTYLE from TQ_FD_BASICINFO
WHERE
ISVALID = 1 AND
(LIQUENDDATE >= '{trade_dt}' or LIQUENDDATE = '19000101')
"""
return pd.read_sql(query, con=engine)
......@@ -53,13 +63,13 @@ def fd_typeclass(security_ids, trade_dt=None):
trade_dt = trade_dt.replace("-", "")
if isinstance(security_ids, str):
sec_id_strs = security_ids.split(",")
sec_id_strs = security_ids
else:
sec_id_strs = ",".join(["'" + s + "'" for s in security_ids])
engine = sa.create_engine(CONN, connect_args={"charset": "GBK"})
query = f"""
select SECURITYID, L1CODE, L1NAME, L2CODE, L2NAME from TQ_FD_TYPECLASS
select SECURITYID, L1CODE, L1NAME, L2CODE, L2NAME, L3CODE, L3NAME from TQ_FD_TYPECLASS
WHERE
ISVALID = 1 AND
SECURITYID in ({sec_id_strs})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment