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
d18d36f1
Commit
d18d36f1
authored
Sep 25, 2017
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added flag for is relative checking
parent
a10b289f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
thresholdexecutor.py
alphamind/execution/thresholdexecutor.py
+5
-2
No files found.
alphamind/execution/thresholdexecutor.py
View file @
d18d36f1
...
@@ -12,9 +12,10 @@ from alphamind.execution.baseexecutor import ExecutorBase
...
@@ -12,9 +12,10 @@ from alphamind.execution.baseexecutor import ExecutorBase
class
ThresholdExecutor
(
ExecutorBase
):
class
ThresholdExecutor
(
ExecutorBase
):
def
__init__
(
self
,
turn_over_threshold
:
float
):
def
__init__
(
self
,
turn_over_threshold
:
float
,
is_relative
=
True
):
super
()
.
__init__
()
super
()
.
__init__
()
self
.
threshold
=
turn_over_threshold
self
.
threshold
=
turn_over_threshold
self
.
is_relative
=
is_relative
def
execute
(
self
,
target_pos
:
pd
.
DataFrame
)
->
Tuple
[
float
,
pd
.
DataFrame
]:
def
execute
(
self
,
target_pos
:
pd
.
DataFrame
)
->
Tuple
[
float
,
pd
.
DataFrame
]:
...
@@ -23,7 +24,9 @@ class ThresholdExecutor(ExecutorBase):
...
@@ -23,7 +24,9 @@ class ThresholdExecutor(ExecutorBase):
else
:
else
:
turn_over
=
self
.
calc_turn_over
(
target_pos
,
self
.
current_pos
)
turn_over
=
self
.
calc_turn_over
(
target_pos
,
self
.
current_pos
)
if
turn_over
>=
self
.
threshold
*
self
.
current_pos
.
weight
.
sum
():
is_break
=
turn_over
>=
self
.
threshold
*
self
.
current_pos
.
weight
.
sum
()
if
self
.
is_relative
else
turn_over
>=
self
.
threshold
if
is_break
:
return
turn_over
,
target_pos
return
turn_over
,
target_pos
else
:
else
:
return
0.
,
self
.
current_pos
.
copy
()
return
0.
,
self
.
current_pos
.
copy
()
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