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
2c46b551
Commit
2c46b551
authored
May 19, 2018
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update example
parent
741b2f62
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
15 deletions
+22
-15
strategy.py
alphamind/strategy/strategy.py
+22
-15
No files found.
alphamind/strategy/strategy.py
View file @
2c46b551
...
...
@@ -292,8 +292,9 @@ class Strategy(object):
if
__name__
==
'__main__'
:
from
matplotlib
import
pyplot
as
plt
from
PyFin.api
import
*
from
dask.distributed
import
Client
from
PyFin.api
import
CSQuantiles
from
PyFin.api
import
LAST
from
alphamind.api
import
Universe
from
alphamind.api
import
ConstLinearModel
from
alphamind.api
import
XGBTrainer
...
...
@@ -302,14 +303,20 @@ if __name__ == '__main__':
from
alphamind.api
import
winsorize_normal
from
alphamind.api
import
standardize
start_date
=
'2018-01-01'
end_date
=
'2018-05-04'
freq
=
'20b'
from
matplotlib
import
pyplot
as
plt
from
matplotlib.pylab
import
mpl
plt
.
style
.
use
(
'seaborn-whitegrid'
)
mpl
.
rcParams
[
'font.sans-serif'
]
=
[
'SimHei'
]
mpl
.
rcParams
[
'axes.unicode_minus'
]
=
False
start_date
=
'2010-01-01'
end_date
=
'2018-05-14'
freq
=
'10b'
neutralized_risk
=
None
universe
=
Universe
(
"custom"
,
[
'zz800'
])
dask_client
=
Client
(
'10.63.6.176:8786'
)
factor
=
CSQuantiles
(
LAST
(
'ILLIQUIDITY'
)
*
LAST
(
'NegMktValue'
)
,
factor
=
CSQuantiles
(
LAST
(
'ILLIQUIDITY'
),
groups
=
'sw1_adj'
)
alpha_factors
=
{
str
(
factor
):
factor
,
...
...
@@ -327,22 +334,21 @@ if __name__ == '__main__':
data_meta
=
DataMeta
(
freq
=
freq
,
universe
=
universe
,
batch
=
32
,
batch
=
1
,
neutralized_risk
=
None
,
# industry_styles,
pre_process
=
None
,
# [winsorize_normal, standardize],
post_process
=
None
,
warm_start
=
1
2
)
# [standardize])
warm_start
=
1
)
# [standardize])
industries
=
industry_list
(
'sw_adj'
,
1
)
total_risk_names
=
[
'total'
]
total_risk_names
=
[
'total'
]
+
industries
b_type
=
[]
l_val
=
[]
u_val
=
[]
for
name
in
total_risk_names
:
if
name
==
'total'
:
b_type
.
append
(
BoundaryType
.
ABSOLUTE
)
l_val
.
append
(
.0
)
u_val
.
append
(
.0
)
...
...
@@ -357,11 +363,12 @@ if __name__ == '__main__':
weights_bandwidth
=
0.01
,
rebalance_method
=
'tv'
,
bounds
=
bounds
,
target_vol
=
0.0
4
5
,
target_vol
=
0.05
,
turn_over_target
=
0.4
)
strategy
=
Strategy
(
alpha_model
,
data_meta
,
running_setting
,
dask_client
=
dask_client
)
ret_df
,
positions
=
strategy
.
run
()
ret_df
[[
'excess_return'
,
'turn_over'
]]
.
cumsum
()
.
plot
(
secondary_y
=
'turn_over'
)
plt
.
title
(
f
"{str(factor)[20:60]}"
)
ret_df
.
rename
(
columns
=
{
'excess_return'
:
'超额收益'
,
'turn_over'
:
'换手率'
},
inplace
=
True
)
ret_df
[[
'超额收益'
,
'换手率'
]]
.
cumsum
()
.
plot
(
secondary_y
=
'换手率'
,
figsize
=
(
14
,
7
))
plt
.
title
(
"原始ILLIQUIDITY因子"
)
plt
.
show
()
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