Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
F
fof
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dr.李
fof
Commits
041faa29
Commit
041faa29
authored
Feb 12, 2022
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change category codes
parent
382ae34b
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
75 additions
and
272 deletions
+75
-272
010 股票型基金.ipynb
category/010 股票型基金.ipynb
+0
-0
020 混合型基金.ipynb
category/020 混合型基金.ipynb
+0
-0
030 债券型基金.ipynb
category/030 债券型基金.ipynb
+0
-0
040 货币基金.ipynb
category/040 货币基金.ipynb
+26
-62
050 另类投资基金.ipynb
category/050 另类投资基金.ipynb
+0
-0
060 QDII基金.ipynb
category/060 QDII基金.ipynb
+0
-0
070 FOF基金.ipynb
category/070 FOF基金.ipynb
+33
-205
utility.py
fof/utility.py
+16
-5
No files found.
category/010 股票型基金.ipynb
View file @
041faa29
This diff is collapsed.
Click to expand it.
category/020 混合型基金.ipynb
View file @
041faa29
This diff is collapsed.
Click to expand it.
category/030 债券型基金.ipynb
View file @
041faa29
This diff is collapsed.
Click to expand it.
category/040 货币基金.ipynb
View file @
041faa29
...
...
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count":
8
,
"execution_count":
2
,
"id": "51382765-24b4-4e5e-a118-077b276e0774",
"metadata": {},
"outputs": [],
...
...
@@ -21,7 +21,7 @@
},
{
"cell_type": "code",
"execution_count":
9
,
"execution_count":
3
,
"id": "47939edc-07d2-4c8e-b061-187806e124ea",
"metadata": {},
"outputs": [],
...
...
@@ -33,52 +33,32 @@
},
{
"cell_type": "code",
"execution_count":
10
,
"execution_count":
4
,
"id": "9a596482-dd98-49dc-b717-c17177f2cd64",
"metadata": {},
"outputs": [],
"source": [
"# 获取所有目标货币型基金(清算结束日期晚于当前日)\n",
"\n",
"security_ids = fd_alive_funds(today, 204)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "7e1a0517-e3de-4ea7-ae3c-9c2292c63260",
"metadata": {},
"outputs": [],
"source": [
"basic_info = fd_basicinfo(security_ids)\n",
"type_info = fd_typeclass(security_ids)"
"security_info = fd_alive_funds(today, 2205)\n",
"security_ids = security_info.SECURITYID.unique().tolist()"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "b0d0d48b-708b-447a-922b-500fbfb97600",
"metadata": {},
"outputs": [],
"source": [
"df = pd.merge(type_info[[\"SECURITYID\"]], basic_info, on=\"SECURITYID\")"
]
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 9,
"id": "5ccf2dc7-fea9-4d52-b15d-e8ff55fac3dc",
"metadata": {},
"outputs": [],
"source": [
"# 分类\n",
"
df.loc[(df[\"FDNATURE\"] == \"ETF\"
), \"货币型(子类)\"] = \"场内货币型基金\"\n",
"
df.loc[(df[\"FDNATURE\"] != \"ETF\"
), \"货币型(子类)\"] = \"场外货币型基金\""
"
security_info.loc[(security_info.CLASSCODE.str.startswith(\"220502\")
), \"货币型(子类)\"] = \"场内货币型基金\"\n",
"
security_info.loc[(~security_info.CLASSCODE.str.startswith(\"220502\")
), \"货币型(子类)\"] = \"场外货币型基金\""
]
},
{
"cell_type": "code",
"execution_count": 1
4
,
"execution_count": 1
0
,
"id": "9d34507e-9efd-479a-8b25-a095de5a552c",
"metadata": {},
"outputs": [
...
...
@@ -104,11 +84,9 @@
" <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",
" <th>INVESTSTYLE</th>\n",
" <th>BEGINDATE</th>\n",
" <th>ENDDATE</th>\n",
" <th>CLASSCODE</th>\n",
" </tr>\n",
" <tr>\n",
" <th>货币型(子类)</th>\n",
...
...
@@ -116,57 +94,43 @@
" <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>19</td>\n",
" <td>19</td>\n",
" <td>19</td>\n",
" <td>19</td>\n",
" <td>19</td>\n",
" <td>19</td>\n",
" <td>41</td>\n",
" <td>41</td>\n",
" <td>41</td>\n",
" <td>41</td>\n",
" </tr>\n",
" <tr>\n",
" <th>场外货币型基金</th>\n",
" <td>542</td>\n",
" <td>542</td>\n",
" <td>496</td>\n",
" <td>542</td>\n",
" <td>542</td>\n",
" <td>542</td>\n",
" <td>622</td>\n",
" <td>622</td>\n",
" <td>622</td>\n",
" <td>622</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" SECURITYID
FDNAME SNAMECOMP FSYMBOL FDNATURE INVESTSTYL
E\n",
"货币型(子类)
\n",
"场内货币型基金
19 19 19 19 19 19
\n",
"场外货币型基金
542 542 496 542 542 54
2"
" SECURITYID
BEGINDATE ENDDATE CLASSCOD
E\n",
"货币型(子类) \n",
"场内货币型基金
41 41 41 41
\n",
"场外货币型基金
622 622 622 62
2"
]
},
"execution_count": 1
4
,
"execution_count": 1
0
,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"
df
.groupby(\"货币型(子类)\").count()"
"
security_info
.groupby(\"货币型(子类)\").count()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c46e44f3-62a7-4409-a276-e7493cbb98aa",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
...
...
category/050 另类投资基金.ipynb
View file @
041faa29
This diff is collapsed.
Click to expand it.
category/060 QDII基金.ipynb
View file @
041faa29
This diff is collapsed.
Click to expand it.
category/070 FOF基金.ipynb
View file @
041faa29
...
...
@@ -33,232 +33,60 @@
},
{
"cell_type": "code",
"execution_count":
28
,
"execution_count":
4
,
"id": "004a8f9f-4011-48c6-a5dd-327cce42de51",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"13"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 获取所有目标基金(清算结束日期晚于当前日)\n",
"\n",
"security_ids = fd_alive_funds(today, \"2210\")"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "acf00858-6782-4ecb-8a87-9045810ce589",
"metadata": {},
"outputs": [],
"source": [
"basic_info = fd_basicinfo(security_ids)"
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "08bfc149-90e5-405d-a1f2-6ec750c26f9e",
"metadata": {},
"outputs": [],
"source": [
"df = basic_info[basic_info.FDNATURE == 'FOF']"
"security_info = fd_alive_funds(today, 2210)\n",
"security_ids = security_info.SECURITYID.unique().tolist()\n",
"len(security_ids)"
]
},
{
"cell_type": "code",
"execution_count":
32
,
"execution_count":
7
,
"id": "fc897e0e-46f1-48a2-be9a-6381086c94bf",
"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",
" <th>INVESTSTYLE</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1030010449</td>\n",
" <td>南方全天候策略混合型基金中基金(FOF)</td>\n",
" <td>南方全天候策略混合(FOF)</td>\n",
" <td>005215</td>\n",
" <td>FOF</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1030010450</td>\n",
" <td>南方全天候策略混合型基金中基金(FOF)</td>\n",
" <td>南方全天候策略混合(FOF)</td>\n",
" <td>005216</td>\n",
" <td>FOF</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1030010443</td>\n",
" <td>华夏聚惠稳健目标风险混合型基金中基金(FOF)</td>\n",
" <td>华夏聚惠(FOF)</td>\n",
" <td>005218</td>\n",
" <td>FOF</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1030010444</td>\n",
" <td>华夏聚惠稳健目标风险混合型基金中基金(FOF)</td>\n",
" <td>华夏聚惠(FOF)</td>\n",
" <td>005219</td>\n",
" <td>FOF</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1030010446</td>\n",
" <td>嘉实领航资产配置混合型基金中基金(FOF)</td>\n",
" <td>嘉实领航资产配置混合(FOF)</td>\n",
" <td>005156</td>\n",
" <td>FOF</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>1030010447</td>\n",
" <td>嘉实领航资产配置混合型基金中基金(FOF)</td>\n",
" <td>嘉实领航资产配置混合(FOF)</td>\n",
" <td>005157</td>\n",
" <td>FOF</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>1030010441</td>\n",
" <td>海富通聚优精选混合型基金中基金(FOF)</td>\n",
" <td>None</td>\n",
" <td>005220</td>\n",
" <td>FOF</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>1030010451</td>\n",
" <td>建信福泽安泰混合型基金中基金(FOF)</td>\n",
" <td>None</td>\n",
" <td>005217</td>\n",
" <td>FOF</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>1030010459</td>\n",
" <td>泰达宏利全能优选混合型基金中基金(FOF)</td>\n",
" <td>泰达宏利全能混合(FOF)</td>\n",
" <td>005221</td>\n",
" <td>FOF</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>1030010460</td>\n",
" <td>泰达宏利全能优选混合型基金中基金(FOF)</td>\n",
" <td>泰达宏利全能混合(FOF)</td>\n",
" <td>005222</td>\n",
" <td>FOF</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>1030011412</td>\n",
" <td>中融量化精选混合型基金中基金(FOF)</td>\n",
" <td>中融量化精选FOF</td>\n",
" <td>005758</td>\n",
" <td>FOF</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>1030011413</td>\n",
" <td>中融量化精选混合型基金中基金(FOF)</td>\n",
" <td>中融量化精选FOF</td>\n",
" <td>005759</td>\n",
" <td>FOF</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>1030011474</td>\n",
" <td>前海开源裕源混合型基金中基金(FOF)</td>\n",
" <td>None</td>\n",
" <td>005809</td>\n",
" <td>FOF</td>\n",
" <td>稳健成长型</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" SECURITYID FDNAME SNAMECOMP FSYMBOL FDNATURE \\\n",
"0 1030010449 南方全天候策略混合型基金中基金(FOF) 南方全天候策略混合(FOF) 005215 FOF \n",
"1 1030010450 南方全天候策略混合型基金中基金(FOF) 南方全天候策略混合(FOF) 005216 FOF \n",
"2 1030010443 华夏聚惠稳健目标风险混合型基金中基金(FOF) 华夏聚惠(FOF) 005218 FOF \n",
"3 1030010444 华夏聚惠稳健目标风险混合型基金中基金(FOF) 华夏聚惠(FOF) 005219 FOF \n",
"4 1030010446 嘉实领航资产配置混合型基金中基金(FOF) 嘉实领航资产配置混合(FOF) 005156 FOF \n",
"5 1030010447 嘉实领航资产配置混合型基金中基金(FOF) 嘉实领航资产配置混合(FOF) 005157 FOF \n",
"6 1030010441 海富通聚优精选混合型基金中基金(FOF) None 005220 FOF \n",
"7 1030010451 建信福泽安泰混合型基金中基金(FOF) None 005217 FOF \n",
"8 1030010459 泰达宏利全能优选混合型基金中基金(FOF) 泰达宏利全能混合(FOF) 005221 FOF \n",
"9 1030010460 泰达宏利全能优选混合型基金中基金(FOF) 泰达宏利全能混合(FOF) 005222 FOF \n",
"10 1030011412 中融量化精选混合型基金中基金(FOF) 中融量化精选FOF 005758 FOF \n",
"11 1030011413 中融量化精选混合型基金中基金(FOF) 中融量化精选FOF 005759 FOF \n",
"12 1030011474 前海开源裕源混合型基金中基金(FOF) None 005809 FOF \n",
"\n",
" INVESTSTYLE \n",
"0 稳健成长型 \n",
"1 稳健成长型 \n",
"2 稳健成长型 \n",
"3 稳健成长型 \n",
"4 稳健成长型 \n",
"5 稳健成长型 \n",
"6 稳健成长型 \n",
"7 稳健成长型 \n",
"8 稳健成长型 \n",
"9 稳健成长型 \n",
"10 稳健成长型 \n",
"11 稳健成长型 \n",
"12 稳健成长型 "
"['1030010441',\n",
" '1030010443',\n",
" '1030010444',\n",
" '1030010446',\n",
" '1030010447',\n",
" '1030010449',\n",
" '1030010450',\n",
" '1030010451',\n",
" '1030010459',\n",
" '1030010460',\n",
" '1030011412',\n",
" '1030011413',\n",
" '1030011474']"
]
},
"execution_count":
32
,
"execution_count":
7
,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"
df
"
"
security_ids
"
]
},
{
...
...
@@ -286,7 +114,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.
8.12
"
"version": "3.
9.7
"
}
},
"nbformat": 4,
...
...
fof/utility.py
View file @
041faa29
...
...
@@ -72,12 +72,24 @@ def nearest_report_date(date):
def
fd_alive_funds
(
trade_dt
,
class_code
=
None
):
if
class_code
:
if
isinstance
(
class_code
,
str
)
or
isinstance
(
class_code
,
int
):
condition
=
f
" CLASSCODE like '{class_code}
%
' AND "
else
:
condition
=
[]
for
c
in
class_code
:
condition
.
append
(
f
" CLASSCODE like '{c}
%
' "
)
condition
=
"OR"
.
join
(
condition
)
condition
=
"("
+
condition
+
") AND"
query
=
f
"""
select SECODE FROM TQ_FD_TYPE
select SECODE
as SECURITYID, BEGINDATE, ENDDATE, CLASSCODE
FROM TQ_FD_TYPE
WHERE
ISVALID = 1 AND
CLASSCODE like '{class_code}
%
' AND
{condition}
TYPESTYLE = '22' AND
BEGINDATE <= '{trade_dt}' AND
(ENDDATE>='{trade_dt}' or ENDDATE = '19000101')
...
...
@@ -85,7 +97,7 @@ def fd_alive_funds(trade_dt, class_code=None):
"""
else
:
query
=
f
"""
select SECODE FROM TQ_FD_TYPE
select SECODE
as SECURITYID,BEGINDATE, ENDDATE, CLASSCODE
FROM TQ_FD_TYPE
WHERE
ISVALID = 1 AND
BEGINDATE <= '{trade_dt}' AND
...
...
@@ -93,8 +105,7 @@ def fd_alive_funds(trade_dt, class_code=None):
(ENDDATE>='{trade_dt}' or ENDDATE = '19000101')
ORDER BY SECODE;
"""
sec_codes
=
read_sql
(
query
)[
"SECODE"
]
.
unique
()
.
tolist
()
return
sec_codes
return
read_sql
(
query
)
def
fd_basicinfo
(
security_ids
=
None
,
trade_dt
=
None
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment