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
43955e6c
Commit
43955e6c
authored
Nov 29, 2021
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
fa4f0b67
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
61 additions
and
53 deletions
+61
-53
010 股票型基金.ipynb
010 股票型基金.ipynb
+0
-0
020 混合型基金.ipynb
020 混合型基金.ipynb
+0
-0
030 债券型基金.ipynb
030 债券型基金.ipynb
+0
-0
040 货币基金.ipynb
040 货币基金.ipynb
+28
-31
050 另类投资基金.ipynb
050 另类投资基金.ipynb
+0
-0
060 QDII基金.ipynb
060 QDII基金.ipynb
+0
-0
070 FOF基金.ipynb
070 FOF基金.ipynb
+0
-0
utility.py
utility.py
+33
-22
No files found.
010 股票型基金.ipynb
View file @
43955e6c
This diff is collapsed.
Click to expand it.
020 混合型基金.ipynb
View file @
43955e6c
This diff is collapsed.
Click to expand it.
030 债券型基金.ipynb
View file @
43955e6c
This diff is collapsed.
Click to expand it.
040 货币基金.ipynb
View file @
43955e6c
...
...
@@ -2,14 +2,14 @@
"cells": [
{
"cell_type": "code",
"execution_count":
4
,
"execution_count":
1
,
"id": "51382765-24b4-4e5e-a118-077b276e0774",
"metadata": {},
"outputs": [],
"source": [
"import datetime as dt\n",
"from utility import (\n",
"
read_sql
,\n",
"
fd_alive_funds
,\n",
" fd_basicinfo,\n",
" fd_typeclass,\n",
" nearest_report_date\n",
...
...
@@ -19,7 +19,7 @@
},
{
"cell_type": "code",
"execution_count":
5
,
"execution_count":
2
,
"id": "47939edc-07d2-4c8e-b061-187806e124ea",
"metadata": {},
"outputs": [],
...
...
@@ -31,26 +31,19 @@
},
{
"cell_type": "code",
"execution_count":
11
,
"execution_count":
3
,
"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()"
"security_ids = fd_alive_funds(today, 204)"
]
},
{
"cell_type": "code",
"execution_count":
12
,
"execution_count":
4
,
"id": "7e1a0517-e3de-4ea7-ae3c-9c2292c63260",
"metadata": {},
"outputs": [],
...
...
@@ -61,7 +54,7 @@
},
{
"cell_type": "code",
"execution_count":
13
,
"execution_count":
5
,
"id": "b0d0d48b-708b-447a-922b-500fbfb97600",
"metadata": {},
"outputs": [],
...
...
@@ -71,7 +64,7 @@
},
{
"cell_type": "code",
"execution_count":
14
,
"execution_count":
6
,
"id": "5ccf2dc7-fea9-4d52-b15d-e8ff55fac3dc",
"metadata": {},
"outputs": [],
...
...
@@ -83,7 +76,7 @@
},
{
"cell_type": "code",
"execution_count":
15
,
"execution_count":
7
,
"id": "9d34507e-9efd-479a-8b25-a095de5a552c",
"metadata": {},
"outputs": [
...
...
@@ -113,6 +106,7 @@
" <th>SNAMECOMP</th>\n",
" <th>FSYMBOL</th>\n",
" <th>FDNATURE</th>\n",
" <th>INVESTSTYLE</th>\n",
" </tr>\n",
" <tr>\n",
" <th>货币型(子类)</th>\n",
...
...
@@ -121,37 +115,40 @@
" <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",
" <td>19</td>\n",
" <td>19</td>\n",
" <td>19</td>\n",
" <td>19</td>\n",
" <td>19</td>\n",
" <td>19</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",
" <td>542</td>\n",
" <td>542</td>\n",
" <td>496</td>\n",
" <td>542</td>\n",
" <td>542</td>\n",
" <td>542</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" SECURITYID FDNAME SNAMECOMP FSYMBOL FDNATURE\n",
"货币型(子类) \n",
"场内货币型基金
44 44 42 44 44
\n",
"场外货币型基金 54
9 549 503 549 549
"
" SECURITYID FDNAME SNAMECOMP FSYMBOL FDNATURE
INVESTSTYLE
\n",
"货币型(子类)
\n",
"场内货币型基金
19 19 19 19 19 19
\n",
"场外货币型基金 54
2 542 496 542 542 542
"
]
},
"execution_count":
15
,
"execution_count":
7
,
"metadata": {},
"output_type": "execute_result"
}
...
...
050 另类投资基金.ipynb
View file @
43955e6c
This diff is collapsed.
Click to expand it.
060 QDII基金.ipynb
View file @
43955e6c
This diff is collapsed.
Click to expand it.
070 FOF基金.ipynb
View file @
43955e6c
This diff is collapsed.
Click to expand it.
utility.py
View file @
43955e6c
...
...
@@ -24,17 +24,28 @@ def nearest_report_date(date):
return
dt
.
date
(
last_year
,
q
,
last
)
.
strftime
(
"
%
Y
%
m
%
d"
)
def
fd_alive_funds
(
trade_dt
,
type_style
,
class_code
):
sec_codes
=
read_sql
(
f
"""
select SECODE from TQ_FD_TYPE
WHERE
ISVALID = 1 AND
TYPESTYLE = '{type_style}' AND
CLASSCODE = '{class_code}' AND
BEGINDATE <= '{trade_dt}' AND
(ENDDATE>='{trade_dt}' or ENDDATE = '19000101')
ORDER BY SECODE;
"""
)[
"SECODE"
]
.
unique
()
.
tolist
()
def
fd_alive_funds
(
trade_dt
,
class_code
=
None
):
if
class_code
:
query
=
f
"""
select SECODE from TQ_FD_TYPE
WHERE
ISVALID = 1 AND
TYPESTYLE = '{str(class_code)[0]}' AND
CLASSCODE = '{class_code}' AND
BEGINDATE <= '{trade_dt}' AND
(ENDDATE>='{trade_dt}' or ENDDATE = '19000101')
ORDER BY SECODE;
"""
else
:
query
=
f
"""
select SECODE from TQ_FD_TYPE
WHERE
ISVALID = 1 AND
BEGINDATE <= '{trade_dt}' AND
(ENDDATE>='{trade_dt}' or ENDDATE = '19000101')
ORDER BY SECODE;
"""
sec_codes
=
read_sql
(
query
)[
"SECODE"
]
.
unique
()
.
tolist
()
return
sec_codes
...
...
@@ -53,15 +64,15 @@ def fd_basicinfo(security_ids=None, trade_dt=None):
if
sec_id_strs
:
query
=
f
"""
select SECURITYID, FDNAME, SNAMECOMP, FSYMBOL, FDNATURE, INVESTSTYLE from TQ_FD_BASICINFO
select SEC
ODE as SEC
URITYID, FDNAME, SNAMECOMP, FSYMBOL, FDNATURE, INVESTSTYLE from TQ_FD_BASICINFO
WHERE
ISVALID = 1 AND
SEC
URITYID
in ({sec_id_strs}) AND
SEC
ODE
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
select SEC
ODE as SEC
URITYID, FDNAME, SNAMECOMP, FSYMBOL, FDNATURE, INVESTSTYLE from TQ_FD_BASICINFO
WHERE
ISVALID = 1 AND
(LIQUENDDATE >= '{trade_dt}' or LIQUENDDATE = '19000101')
...
...
@@ -127,35 +138,35 @@ 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 SECURITYID, REPORTDATE, BDRTO, CONVBDRTO, EQUITYINVERTO from TQ_FD_ASSETPORTFOLIO
SELECT SEC
ODE as SEC
URITYID, REPORTDATE, BDRTO, CONVBDRTO, EQUITYINVERTO from TQ_FD_ASSETPORTFOLIO
WHERE
REPORTDATE >= '{report_dates_begin}' AND
REPORTDATE <= '{report_dates_end}' AND
ISVALID = 1 AND
SEC
URITYID
in ({sec_id_strs})
SEC
ODE
in ({sec_id_strs})
"""
else
:
query
=
f
"""
SELECT SECURITYID, REPORTDATE, BDRTO, CONVBDRTO, EQUITYINVERTO from TQ_FD_ASSETPORTFOLIO
SELECT SEC
ODE as SEC
URITYID, REPORTDATE, BDRTO, CONVBDRTO, EQUITYINVERTO from TQ_FD_ASSETPORTFOLIO
WHERE
REPORTDATE >= '{report_dates_begin}' AND
ISVALID = 1 AND
SEC
URITYID
in ({sec_id_strs})
SEC
ODE
in ({sec_id_strs})
"""
return
read_sql
(
query
)
.
sort_values
(
"SECURITYID"
)
def
fd_
derieden
(
security_ids
,
trade_dt
):
def
fd_
qtfdnav
(
security_ids
,
trade_dt
):
if
isinstance
(
security_ids
,
str
):
sec_id_strs
=
security_ids
else
:
sec_id_strs
=
","
.
join
([
"'"
+
s
+
"'"
for
s
in
security_ids
])
query
=
f
"""
SELECT SEC
URITYID, UNITNAV, UNITACCNAV, REPAIRUNITNAV, NAVGRTD from TQ_FD_DERIVEDN
SELECT SEC
ODE as SECURITYID, UNITNAV, ACCUNITNAV from TQ_QT_FDNAV
WHERE
END
DATE = '{trade_dt}' AND
NAV
DATE = '{trade_dt}' AND
ISVALID = 1 AND
SEC
URITYID
in ({sec_id_strs})
SEC
ODE
in ({sec_id_strs})
"""
return
read_sql
(
query
)
.
sort_values
(
"SECURITYID"
)
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