Commit d18d36f1 authored by Dr.李's avatar Dr.李

added flag for is relative checking

parent a10b289f
......@@ -12,9 +12,10 @@ from alphamind.execution.baseexecutor import ExecutorBase
class ThresholdExecutor(ExecutorBase):
def __init__(self, turn_over_threshold: float):
def __init__(self, turn_over_threshold: float, is_relative=True):
super().__init__()
self.threshold = turn_over_threshold
self.is_relative = is_relative
def execute(self, target_pos: pd.DataFrame) -> Tuple[float, pd.DataFrame]:
......@@ -23,7 +24,9 @@ class ThresholdExecutor(ExecutorBase):
else:
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
else:
return 0., self.current_pos.copy()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment