Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
A
alpha-mind
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.李
alpha-mind
Commits
c25eaf4a
Commit
c25eaf4a
authored
May 24, 2017
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed linear builder when bm sum not to 1
parent
4ffafbb4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
3 deletions
+31
-3
brisonanalysis.py
alphamind/analysis/brisonanalysis.py
+6
-0
calculators.py
alphamind/analysis/calculators.py
+22
-0
single_day_portfolio.py
alphamind/examples/single_day_portfolio.py
+1
-1
linearbuilder.py
alphamind/portfolio/linearbuilder.py
+2
-2
No files found.
alphamind/analysis/brisonanalysis.py
0 → 100644
View file @
c25eaf4a
# -*- coding: utf-8 -*-
"""
Created on 2017-5-17
@author: cheng.li
"""
alphamind/analysis/calculators.py
0 → 100644
View file @
c25eaf4a
# -*- coding: utf-8 -*-
"""
Created on 2017-5-18
@author: cheng.li
"""
import
pandas
as
pd
def
calculate_turn_over
(
pos_table
):
turn_over_table
=
{}
total_factors
=
pos_table
.
columns
.
difference
([
'Code'
])
pos_table
.
reset_index
()
for
name
in
total_factors
:
pivot_position
=
pos_table
.
pivot
(
values
=
name
,
columns
=
'Code'
)
.
fillna
(
0.
)
turn_over_series
=
pivot_position
.
diff
()
.
abs
()
.
sum
(
axis
=
1
)
turn_over_table
[
name
]
=
turn_over_series
.
values
turn_over_table
=
pd
.
DataFrame
(
turn_over_table
,
index
=
pos_table
.
Date
.
unique
())
return
turn_over_table
[
total_factors
]
alphamind/examples/single_day_portfolio.py
View file @
c25eaf4a
...
...
@@ -82,7 +82,7 @@ else:
'industry'
:
total_data
[
'申万一级行业'
]
.
values
,
'zz500'
:
total_data
[
index_components
]
.
values
},
index
=
total_data
.
Code
)
portfolio
.
to_csv
(
r'\\10.63.6.71\sharespace\personal\licheng\portfolio\{0}.csv'
.
format
(
ref_date
))
portfolio
.
to_csv
(
r'\\10.63.6.71\sharespace\personal\licheng\portfolio\
zz500\
{0}.csv'
.
format
(
ref_date
))
...
...
alphamind/portfolio/linearbuilder.py
View file @
c25eaf4a
...
...
@@ -34,13 +34,13 @@ def linear_build(er: np.ndarray,
constraints
=
[
w
>=
lbound
,
w
<=
ubound
,
curr_risk_exposure
==
risk_eq_target
,
cvxpy
.
sum_entries
(
w
)
==
1.
]
cvxpy
.
sum_entries
(
w
)
==
bm
.
sum
()
]
else
:
constraints
=
[
w
>=
lbound
,
w
<=
ubound
,
curr_risk_exposure
>=
risk_target
[
0
]
*
np
.
abs
(
risk_exposure
.
T
@
bm
),
curr_risk_exposure
<=
risk_target
[
1
]
*
np
.
abs
(
risk_exposure
.
T
@
bm
),
cvxpy
.
sum_entries
(
w
)
==
1.
]
cvxpy
.
sum_entries
(
w
)
==
bm
.
sum
()
]
if
exchange_flag
is
not
None
:
constraints
.
append
(
exchange_flag
@
w
<=
exchange_limit
[
1
])
...
...
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