Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
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
57df73cd
Commit
57df73cd
authored
Mar 17, 2022
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
using hb classification
parent
64406a81
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
54 deletions
+115
-54
utility.py
fof/utility.py
+18
-8
010 基金经理指数.ipynb
manager/010 基金经理指数.ipynb
+97
-46
No files found.
fof/utility.py
View file @
57df73cd
...
...
@@ -497,15 +497,25 @@ def fd_fund_mktv(security_ids, trade_dt):
return
df
def
fd_rl_classification
(
security_ids
,
trade_dt
):
def
fd_rl_classification
(
security_ids
,
trade_dt
,
source
=
"hb"
):
sec_id_strs
=
_join_ids
(
security_ids
)
query
=
f
"""
SELECT security_id as SECURITYID, rl_class, rl_class_name, rl_sub_class, rl_sub_class_name FROM fd_rl_classification
WHERE
trade_date = '{_to_yyyymmdd(trade_dt)}' AND
security_id in ({sec_id_strs}) AND
flag = 1
"""
if
source
==
"rl"
:
table
=
"fd_rl_classification"
query
=
f
"""
SELECT security_id as SECURITYID, rl_class, rl_class_name, rl_sub_class, rl_sub_class_name FROM {table}
WHERE
trade_date = '{_to_yyyymmdd(trade_dt)}' AND
security_id in ({sec_id_strs}) AND
flag = 1
"""
elif
source
==
"hb"
:
table
=
"hb_fd_classification"
query
=
f
"""
SELECT security_code as SECURITYID, rl_class, rl_class_name, rl_sub_class, rl_sub_class_name FROM {table}
WHERE
security_code in ({sec_id_strs}) AND
flag = 1
"""
return
read_sql
(
query
,
source
=
"mysql"
)
.
sort_values
(
"SECURITYID"
)
.
reset_index
(
drop
=
True
)
...
...
manager/010 基金经理指数.ipynb
View file @
57df73cd
...
...
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count":
3
,
"execution_count":
1
,
"id": "ca389ee5-b800-4682-bfab-a22a6247bd67",
"metadata": {},
"outputs": [],
...
...
@@ -31,7 +31,7 @@
},
{
"cell_type": "code",
"execution_count":
4
,
"execution_count":
2
,
"id": "008213ed-f569-4535-8519-7a5b1b06503c",
"metadata": {},
"outputs": [],
...
...
@@ -41,7 +41,7 @@
},
{
"cell_type": "code",
"execution_count":
5
,
"execution_count":
3
,
"id": "be10d317-bca6-41db-9b54-56573cd564a6",
"metadata": {},
"outputs": [
...
...
@@ -146,7 +146,7 @@
"4 19000101 "
]
},
"execution_count":
5
,
"execution_count":
3
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -159,7 +159,7 @@
},
{
"cell_type": "code",
"execution_count":
6
,
"execution_count":
4
,
"id": "ffbac3af-39d6-4cd3-95cb-705c32380985",
"metadata": {},
"outputs": [
...
...
@@ -197,40 +197,40 @@
" <td>1030000867</td>\n",
" <td>1.9650</td>\n",
" <td>1.708075</td>\n",
" <td>1.
940913e+08
</td>\n",
" <td>
3.813894e+08
</td>\n",
" <td>1.
050033e+09
</td>\n",
" <td>
2.063315e+09
</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1030004356</td>\n",
" <td>1.5530</td>\n",
" <td>1.569653</td>\n",
" <td>
3.329090
e+08</td>\n",
" <td>
5.170077
e+08</td>\n",
" <td>
2.049993
e+08</td>\n",
" <td>
3.183639
e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1030005207</td>\n",
" <td>1.8904</td>\n",
" <td>1.689080</td>\n",
" <td>
8.860713
e+07</td>\n",
" <td>1.
675029
e+08</td>\n",
" <td>
9.794179
e+07</td>\n",
" <td>1.
851492
e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1030007006</td>\n",
" <td>1.1860</td>\n",
" <td>0.168919</td>\n",
" <td>
4.971115
e+08</td>\n",
" <td>
5.89574
2e+08</td>\n",
" <td>
5.582928
e+08</td>\n",
" <td>
6.62135
2e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1030008874</td>\n",
" <td>1.7560</td>\n",
" <td>1.679213</td>\n",
" <td>
1.152421e+07
</td>\n",
" <td>
2.023652e+07
</td>\n",
" <td>
2.997801e+06
</td>\n",
" <td>
5.264138e+06
</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
...
...
@@ -238,14 +238,14 @@
],
"text/plain": [
" SECURITYID UNITNAV NAVGRTD ENDFDSHARE MKTV\n",
"0 1030000867 1.9650 1.708075 1.
940913e+08 3.813894e+08
\n",
"1 1030004356 1.5530 1.569653
3.329090e+08 5.170077
e+08\n",
"2 1030005207 1.8904 1.689080
8.860713e+07 1.675029
e+08\n",
"3 1030007006 1.1860 0.168919
4.971115e+08 5.89574
2e+08\n",
"4 1030008874 1.7560 1.679213
1.152421e+07 2.023652e+07
"
"0 1030000867 1.9650 1.708075 1.
050033e+09 2.063315e+09
\n",
"1 1030004356 1.5530 1.569653
2.049993e+08 3.183639
e+08\n",
"2 1030005207 1.8904 1.689080
9.794179e+07 1.851492
e+08\n",
"3 1030007006 1.1860 0.168919
5.582928e+08 6.62135
2e+08\n",
"4 1030008874 1.7560 1.679213
2.997801e+06 5.264138e+06
"
]
},
"execution_count":
6
,
"execution_count":
4
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -258,7 +258,7 @@
},
{
"cell_type": "code",
"execution_count":
7
,
"execution_count":
5
,
"id": "3dc7be9d-e8c2-4566-bf14-d617ea230c14",
"metadata": {},
"outputs": [
...
...
@@ -325,11 +325,11 @@
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>10300
08874
</td>\n",
" <td>990
2
</td>\n",
" <td>
混合
型基金</td>\n",
" <td>990
2
02</td>\n",
" <td>
高权益仓位混合
型基金</td>\n",
" <td>10300
10453
</td>\n",
" <td>990
1
</td>\n",
" <td>
股票
型基金</td>\n",
" <td>990
1
02</td>\n",
" <td>
普通股票
型基金</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
...
...
@@ -341,10 +341,10 @@
"1 1030004356 9901 股票型基金 990102 普通股票型基金\n",
"2 1030005207 9901 股票型基金 990102 普通股票型基金\n",
"3 1030007006 9902 混合型基金 990202 高权益仓位混合型基金\n",
"4 10300
08874 9902 混合型基金 990202 高权益仓位混合
型基金"
"4 10300
10453 9901 股票型基金 990102 普通股票
型基金"
]
},
"execution_count":
7
,
"execution_count":
5
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -357,7 +357,7 @@
},
{
"cell_type": "code",
"execution_count":
8
,
"execution_count":
6
,
"id": "1055c68c-3875-489b-acaa-a9046d98a2c1",
"metadata": {},
"outputs": [],
...
...
@@ -368,7 +368,7 @@
},
{
"cell_type": "code",
"execution_count":
9
,
"execution_count":
7
,
"id": "00d6c888-682e-43c5-8c57-420a279effa3",
"metadata": {},
"outputs": [],
...
...
@@ -389,7 +389,7 @@
},
{
"cell_type": "code",
"execution_count":
10
,
"execution_count":
8
,
"id": "e1817df4-ce3f-48ca-b656-2a17abc18f8e",
"metadata": {},
"outputs": [],
...
...
@@ -406,17 +406,19 @@
" def calc(g):\n",
" market_manager_index_ret = g.MKTV @ g.NAVGRTD / (1e-10 + g.MKTV.sum()) / 100.0\n",
" flags = g.rl_sub_class.isin(BOND_CLASSES)\n",
" bond_market_mktv = g[flags].MKTV.sum()\n",
" bond_market_manager_index_ret = g[flags].MKTV @ g[flags].NAVGRTD / (1e-10 + g[flags].MKTV.sum()) / 100.0\n",
" equity_market_mktv = g[~flags].MKTV.sum()\n",
" equity_market_manager_index_ret = g[~flags].MKTV @ g[~flags].NAVGRTD / (1e-10 + g[~flags].MKTV.sum()) / 100.0\n",
" return pd.Series(\n",
" dict(MANAGERNAME=g.MANAGERNAME.values[0], all=market_manager_index_ret, bond=bond_market_manager_index_ret, equity=equity_market_manager_index_ret)\n",
" dict(MANAGERNAME=g.MANAGERNAME.values[0], all=market_manager_index_ret, bond=bond_market_manager_index_ret, equity=equity_market_manager_index_ret
, bond_mktv=bond_market_mktv, equity_mktv=equity_market_mktv
)\n",
" )\n",
" return total_df.groupby(\"MANAGERCODE\", as_index=False).apply(calc)"
]
},
{
"cell_type": "code",
"execution_count": 1
1
,
"execution_count": 1
3
,
"id": "3225d437-56a8-4fc6-80bc-22456a356754",
"metadata": {},
"outputs": [
...
...
@@ -446,26 +448,65 @@
" <th>all</th>\n",
" <th>bond</th>\n",
" <th>equity</th>\n",
" <th>bond_mktv</th>\n",
" <th>equity_mktv</th>\n",
" <th>trade_date</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>30026663</td>\n",
" <td>王安良</td>\n",
" <td>-0.009760</td>\n",
" <td>0.000000</td>\n",
" <td>-0.009760</td>\n",
" <td>0.000000e+00</td>\n",
" <td>3.521567e+07</td>\n",
" <td>20220207</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>30189744</td>\n",
" <td>张坤</td>\n",
" <td>0.039522</td>\n",
" <td>0.0</td>\n",
" <td>0.039522</td>\n",
" <td>0.020960</td>\n",
" <td>0.000000</td>\n",
" <td>0.020960</td>\n",
" <td>0.000000e+00</td>\n",
" <td>2.635986e+10</td>\n",
" <td>20220207</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" <td>30212064</td>\n",
" <td>董阳阳</td>\n",
" <td>0.003522</td>\n",
" <td>0.003466</td>\n",
" <td>0.004702</td>\n",
" <td>4.004395e+09</td>\n",
" <td>1.906394e+08</td>\n",
" <td>20220207</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>30241730</td>\n",
" <td>陈轶平</td>\n",
" <td>0.001170</td>\n",
" <td>0.001170</td>\n",
" <td>0.000000</td>\n",
" <td>1.935148e+10</td>\n",
" <td>0.000000e+00</td>\n",
" <td>20220207</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>30322345</td>\n",
" <td>左金保</td>\n",
" <td>0.011596</td>\n",
" <td>0.0</td>\n",
" <td>0.011596</td>\n",
" <td>0.013261</td>\n",
" <td>0.000000</td>\n",
" <td>0.013261</td>\n",
" <td>0.000000e+00</td>\n",
" <td>1.796571e+09</td>\n",
" <td>20220207</td>\n",
" </tr>\n",
" </tbody>\n",
...
...
@@ -473,18 +514,28 @@
"</div>"
],
"text/plain": [
" MANAGERCODE MANAGERNAME all bond equity trade_date\n",
"0 30189744 张坤 0.039522 0.0 0.039522 20220207\n",
"1 30322345 左金保 0.011596 0.0 0.011596 20220207"
" MANAGERCODE MANAGERNAME all bond equity bond_mktv \\\n",
"0 30026663 王安良 -0.009760 0.000000 -0.009760 0.000000e+00 \n",
"1 30189744 张坤 0.020960 0.000000 0.020960 0.000000e+00 \n",
"2 30212064 董阳阳 0.003522 0.003466 0.004702 4.004395e+09 \n",
"3 30241730 陈轶平 0.001170 0.001170 0.000000 1.935148e+10 \n",
"4 30322345 左金保 0.013261 0.000000 0.013261 0.000000e+00 \n",
"\n",
" equity_mktv trade_date \n",
"0 3.521567e+07 20220207 \n",
"1 2.635986e+10 20220207 \n",
"2 1.906394e+08 20220207 \n",
"3 0.000000e+00 20220207 \n",
"4 1.796571e+09 20220207 "
]
},
"execution_count": 1
1
,
"execution_count": 1
3
,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"res = cal_manager_index_ret([\"30322345\", \"30189744\"], trade_dt=trade_dt)\n",
"res = cal_manager_index_ret([\"30322345\", \"30189744\"
, \"30026663\", \"30241730\", \"30212064\"
], trade_dt=trade_dt)\n",
"res[\"trade_date\"] = trade_dt\n",
"res"
]
...
...
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