@
turan12 @
akira @
billlee @
cmdOptionKana 谢谢大家。
最后觉得就类的方式,每个决策做成一个类,主要为了后期维护方便
```
class BaseStrategy():
def __init__(self,
strategy_number=None,
monitor_time=None,
monitor_raise_min=None,
monitor_raise_max=None,
start_raise=None,
sell_time=None,
):
self.monitor_time = monitor_time,
self.monitor_raise_min = monitor_raise_min,
self.monitor_raise_max = monitor_raise_max,
self.start_raise = start_raise,
self.sell_time = sell_time,
self.strategy_number = strategy_number
def valid(self):
return True if self.monitor_time else False
def match_time(self, current):
return True if current >= self.monitor_time else False
def get_sell_time(self):
return self.sell_time
def start_raise_condition(self, v_value):
if self.strategy_number % 2 == 0:
return True if self.v_value < self.self.start_raise else False
else:
return True if self.v_value > self.self.start_raise else False
def meet(self, current, interval_raise_val, start_raise_val):
if self.valid() and self.match_time(current) and self.interval_raise(interval_raise_val) and self.start_raise_condition(start_raise_val):
return self.get_sell_time()
else:
return None
class StrategyCondition1(BaseStrategy):
def interval_raise(self, v_value):
return True if self.v_value >= self.self.monitor_raise_max else False
class StrategyCondition2(BaseStrategy):
def interval_raise(self, v_value):
return True if self.monitor_raise_min <= self.v_value < self.self.monitor_raise_max else False
```