Commit 2efc48ff authored by Dr.李's avatar Dr.李

update category

parent aaac4c26
This diff is collapsed.
This diff is collapsed.
......@@ -21,7 +21,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 2,
"id": "47939edc-07d2-4c8e-b061-187806e124ea",
"metadata": {},
"outputs": [],
......@@ -33,7 +33,43 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 3,
"id": "80dec4d7-8fec-4eee-8008-7bbf60494751",
"metadata": {},
"outputs": [],
"source": [
"hard_coded_etf = [\"511990.OF\",\n",
" \"511980.OF\",\n",
" \"511970.OF\",\n",
" \"511960.OF\",\n",
" \"511950.OF\",\n",
" \"511930.OF\",\n",
" \"511920.OF\",\n",
" \"511910.OF\",\n",
" \"511900.OF\",\n",
" \"511880.OF\",\n",
" \"511860.OF\",\n",
" \"511850.OF\",\n",
" \"511830.OF\",\n",
" \"511820.OF\",\n",
" \"511810.OF\",\n",
" \"511800.OF\",\n",
" \"511770.OF\",\n",
" \"511700.OF\",\n",
" \"511690.OF\",\n",
" \"511670.OF\",\n",
" \"511660.OF\",\n",
" \"511650.OF\",\n",
" \"511620.OF\",\n",
" \"511600.OF\",\n",
" \"159005.OF\",\n",
" \"159003.OF\",\n",
" \"159001.OF\"]"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "9a596482-dd98-49dc-b717-c17177f2cd64",
"metadata": {},
"outputs": [],
......@@ -41,23 +77,26 @@
"# 获取所有目标货币型基金(清算结束日期晚于当前日)\n",
"\n",
"security_info = fd_alive_funds(today, 2205)\n",
"security_ids = security_info.SECURITYID.unique().tolist()"
"security_ids = security_info.SECURITYID.unique().tolist()\n",
"basic_info = fd_basicinfo(security_ids)\n",
"etf_security_codes = basic_info[basic_info.FSYMBOL.isin([c.split(\".\")[0] for c in hard_coded_etf])].SECURITYID.unique()"
]
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 5,
"id": "5ccf2dc7-fea9-4d52-b15d-e8ff55fac3dc",
"metadata": {},
"outputs": [],
"source": [
"# 分类\n",
"security_info[\"货币型(子类)\"] = \"货币型基金\""
"security_info.loc[security_info.SECURITYID.isin(etf_security_codes), \"货币型(子类)\"] = \"场内货币型基金\"\n",
"security_info.loc[pd.isnull(security_info[\"货币型(子类)\"]), \"货币型(子类)\"] = \"普通货币型基金\""
]
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 6,
"id": "9d34507e-9efd-479a-8b25-a095de5a552c",
"metadata": {},
"outputs": [
......@@ -97,11 +136,18 @@
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>货币型基金</th>\n",
" <td>711</td>\n",
" <td>711</td>\n",
" <td>711</td>\n",
" <td>711</td>\n",
" <th>场内货币型基金</th>\n",
" <td>27</td>\n",
" <td>27</td>\n",
" <td>27</td>\n",
" <td>27</td>\n",
" </tr>\n",
" <tr>\n",
" <th>普通货币型基金</th>\n",
" <td>683</td>\n",
" <td>683</td>\n",
" <td>683</td>\n",
" <td>683</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
......@@ -110,10 +156,11 @@
"text/plain": [
" SECURITYID BEGINDATE ENDDATE CLASSCODE\n",
"货币型(子类) \n",
"货币型基金 711 711 711 711"
"场内货币型基金 27 27 27 27\n",
"普通货币型基金 683 683 683 683"
]
},
"execution_count": 16,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
......@@ -125,7 +172,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "7e30b869-ddb2-4b75-9918-6931b7c00b05",
"id": "23a36fd2-cb27-4b06-b706-6a7528d6c056",
"metadata": {},
"outputs": [],
"source": []
......
......@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 10,
"id": "de082674-0285-4894-905a-52da1ab1727d",
"metadata": {},
"outputs": [],
......@@ -21,7 +21,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 11,
"id": "11d2dbfe-b1c7-41b1-8df3-b6f40b096f83",
"metadata": {},
"outputs": [],
......@@ -33,7 +33,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 12,
"id": "004a8f9f-4011-48c6-a5dd-327cce42de51",
"metadata": {},
"outputs": [
......@@ -43,7 +43,7 @@
"351"
]
},
"execution_count": 3,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
......@@ -58,7 +58,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 13,
"id": "fc897e0e-46f1-48a2-be9a-6381086c94bf",
"metadata": {},
"outputs": [],
......@@ -68,19 +68,20 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 14,
"id": "c3e8441c-d3c5-48f7-aa98-0b3aa7794767",
"metadata": {},
"outputs": [],
"source": [
"df.loc[df.CLASSCODE.str.startswith(\"221001\"), \"FOF型(子类)\"] = \"偏股混合型FOF基金\"\n",
"df.loc[df.CLASSCODE.str.startswith(\"221002\"), \"FOF型(子类)\"] = \"平衡混合型FOF基金\"\n",
"df.loc[df.CLASSCODE.str.startswith(\"221003\"), \"FOF型(子类)\"] = \"偏债混合型FOF基金\""
"df.loc[df.CLASSCODE.str.startswith(\"221003\"), \"FOF型(子类)\"] = \"偏债混合型FOF基金\"\n",
"df.loc[df.CLASSCODE.str.startswith(\"221004\"), \"FOF型(子类)\"] = \"养老型FOF基金\""
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 15,
"id": "2f43d675-50a9-4eb7-ae94-13cb235d93d7",
"metadata": {},
"outputs": [
......@@ -152,7 +153,7 @@
"平衡混合型FOF基金 338 338 338 338"
]
},
"execution_count": 9,
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
......@@ -164,7 +165,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "2234dfb1-5b08-44d4-91bf-e52a43bf4076",
"id": "af92574c-fee9-47f1-9645-898ac73c559f",
"metadata": {},
"outputs": [],
"source": []
......
This diff is collapsed.
......@@ -231,22 +231,22 @@ def fd_assetportfolio(security_ids, report_dates_begin, report_dates_end=None):
sec_id_strs = ",".join(["'" + s + "'" for s in security_ids])
if report_dates_end:
query = f"""
SELECT SECODE as SECURITYID, REPORTDATE, BDRTO, CONVBDRTO, EQUITYINVERTO FROM TQ_FD_ASSETPORTFOLIO
SELECT security_id as SECURITYID, report_date as REPORTDATE, bd_rto as BDRTO, conv_bd_rto as CONVBDRTO, equity_inve_rto as EQUITYINVERTO, st_fin_bd_rto as STFINBDRTO, deposit_rto as DEPOSITRTO FROM fd_portfolio
WHERE
REPORTDATE >= '{_to_yyyymmdd(report_dates_begin)}' AND
REPORTDATE <= '{_to_yyyymmdd(report_dates_end)}' AND
ISVALID = 1 AND
SECODE in ({sec_id_strs})
report_date >= '{_to_yyyy_mm_dd(report_dates_begin)}' AND
report_date <= '{_to_yyyy_mm_dd(report_dates_end)}' AND
is_valid = 1 AND
security_id in ({sec_id_strs})
"""
else:
query = f"""
SELECT SECODE as SECURITYID, REPORTDATE, BDRTO, CONVBDRTO, EQUITYINVERTO FROM TQ_FD_ASSETPORTFOLIO
SELECT security_id as SECURITYID, report_date as REPORTDATE, bd_rto as BDRTO, conv_bd_rto as CONVBDRTO, equity_inve_rto as EQUITYINVERTO, st_fin_bd_rto as STFINBDRTO, deposit_rto as DEPOSITRTO FROM fd_portfolio
WHERE
REPORTDATE >= '{report_dates_begin}' AND
ISVALID = 1 AND
SECODE in ({sec_id_strs})
report_date >= '{_to_yyyy_mm_dd(report_dates_begin)}' AND
is_valid = 1 AND
security_id in ({sec_id_strs})
"""
return read_sql(query).sort_values("SECURITYID").reset_index(drop=True)
return read_sql(query, source="mysql").sort_values("SECURITYID").reset_index(drop=True)
def fd_qtfdnav(security_ids, trade_dt):
......
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