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
3e50b6a9
Commit
3e50b6a9
authored
Feb 05, 2022
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added style attribution
parent
6eee2118
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
705 additions
and
635 deletions
+705
-635
010 style attribution.ipynb
attribution/010 style attribution.ipynb
+260
-297
020 brison attribution.ipynb
attribution/020 brison attribution.ipynb
+426
-337
style.py
fof/style.py
+18
-0
utility.py
fof/utility.py
+1
-1
No files found.
attribution/010 style attribution.ipynb
View file @
3e50b6a9
This diff is collapsed.
Click to expand it.
attribution/020 brison attribution.ipynb
View file @
3e50b6a9
This diff is collapsed.
Click to expand it.
fof/style.py
0 → 100644
View file @
3e50b6a9
import
pandas
as
pd
from
.utility
import
RISK_STYLES
,
INDUSTRY_STYLES
def
single_style
(
portfolio
,
risk_exposure
,
risk_returns
,
specific_returns
):
risk_combined
=
pd
.
merge
(
portfolio
[[
"security_code"
,
"weight"
]],
risk_exposure
,
on
=
[
"security_code"
])
risk_combined
[
RISK_STYLES
+
INDUSTRY_STYLES
]
\
=
(
risk_combined
[
RISK_STYLES
+
INDUSTRY_STYLES
]
.
values
.
T
*
risk_combined
[
"weight"
]
.
values
)
.
T
portfolio_risk_style_exposure
=
risk_combined
[
RISK_STYLES
]
.
sum
()
portfolio_exposure
=
risk_combined
[
RISK_STYLES
+
INDUSTRY_STYLES
]
.
sum
()
risk_attributed_rtn
=
risk_returns
[
RISK_STYLES
+
INDUSTRY_STYLES
]
*
portfolio_exposure
risk_combined
=
pd
.
merge
(
risk_combined
,
specific_returns
[[
"security_code"
,
"spret"
]],
on
=
[
"security_code"
])
spec_attributed_rtn
=
risk_combined
[
"weight"
]
@
risk_combined
[
"spret"
]
/
100.0
risk_attributed_rtn
[
"SPECIFIC"
]
=
spec_attributed_rtn
attributed_rtn
=
risk_attributed_rtn
.
copy
()
return
portfolio_risk_style_exposure
,
attributed_rtn
fof/utility.py
View file @
3e50b6a9
...
...
@@ -247,7 +247,7 @@ def fd_skdetail(security_ids, trade_dt):
p_id_strs
=
_security_ids
(
security_ids
)
query
=
f
"""
SELECT SECODE as pid, SKCODE as security_code, SKNAME, HOLDMKTCAP, HOLDAMT FROM TQ_FD_SKDETAIL
SELECT SECODE as pid, SKCODE as security_code, SKNAME, HOLDMKTCAP, HOLDAMT
, NAVRTO
FROM TQ_FD_SKDETAIL
WHERE
ENDDATE = '{trade_dt}' AND
ISVALID = 1 AND
...
...
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