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
960f9b92
Commit
960f9b92
authored
May 14, 2018
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added lbound and ubound settings
parent
542408cd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
strategy.py
alphamind/strategy/strategy.py
+13
-5
No files found.
alphamind/strategy/strategy.py
View file @
960f9b92
...
...
@@ -35,7 +35,9 @@ class RunningSetting(object):
end_date
,
freq
,
benchmark
=
905
,
weights_bandwidth
=
0.02
,
lbound
=
None
,
ubound
=
None
,
weights_bandwidth
=
None
,
industry_cat
=
'sw_adj'
,
industry_level
=
1
,
rebalance_method
=
'risk_neutral'
,
...
...
@@ -45,6 +47,8 @@ class RunningSetting(object):
self
.
dates
=
makeSchedule
(
start_date
,
end_date
,
freq
,
'china.sse'
)
self
.
dates
=
[
d
.
strftime
(
'
%
Y-
%
m-
%
d'
)
for
d
in
self
.
dates
]
self
.
benchmark
=
benchmark
self
.
lbound
=
lbound
self
.
ubound
=
ubound
self
.
weights_bandwidth
=
weights_bandwidth
self
.
freq
=
freq
self
.
horizon
=
map_freq
(
freq
)
...
...
@@ -149,8 +153,12 @@ class Strategy(object):
this_data
,
benchmark_w
)
if
self
.
running_setting
.
weights_bandwidth
:
lbound
=
np
.
maximum
(
0.
,
benchmark_w
-
self
.
running_setting
.
weights_bandwidth
)
ubound
=
self
.
running_setting
.
weights_bandwidth
+
benchmark_w
else
:
lbound
=
np
.
ones
(
benchmark_w
)
*
self
.
running_setting
.
lbound
ubound
=
np
.
ones
(
benchmark_w
)
*
self
.
running_setting
.
ubound
if
previous_pos
.
empty
:
current_position
=
None
...
...
@@ -257,7 +265,7 @@ if __name__ == '__main__':
universe
=
Universe
(
"custom"
,
[
'zz800'
])
dask_client
=
Client
(
'10.63.6.176:8786'
)
factor
=
CSQuantiles
(
LAST
(
'
NetProfitRatio
'
),
factor
=
CSQuantiles
(
LAST
(
'
ILLIQUIDITY'
)
*
LAST
(
'NegMktValue
'
),
groups
=
'sw1_adj'
)
alpha_factors
=
{
str
(
factor
):
factor
,
...
...
@@ -311,5 +319,5 @@ if __name__ == '__main__':
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:
4
0]}"
)
plt
.
title
(
f
"{str(factor)[20:
6
0]}"
)
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