fix mypy tests

This commit is contained in:
werkkrew 2021-03-13 20:15:32 -05:00
parent 98e12892ca
commit 795a40c2a6
2 changed files with 6 additions and 4 deletions

View File

@ -217,7 +217,7 @@ class IHyperOpt(ABC):
] ]
@staticmethod @staticmethod
def generate_dynamic_roi_table(params: Dict) -> Dict[int, float]: def generate_dynamic_roi_table(params: Dict) -> Dict:
""" """
Create a dynamic_roi table. Create a dynamic_roi table.
""" """

View File

@ -82,6 +82,9 @@ class IStrategy(ABC):
# associated minimal roi # associated minimal roi
minimal_roi: Dict minimal_roi: Dict
# associated dynamic roi
dynamic_roi: Dict
# associated stoploss # associated stoploss
stoploss: float stoploss: float
@ -653,7 +656,6 @@ class IStrategy(ABC):
time = dynamic_roi['dynamic_roi_time'] time = dynamic_roi['dynamic_roi_time']
rate = (start - end) / time rate = (start - end) / time
min_roi = max(end, start - (rate * trade_dur)) min_roi = max(end, start - (rate * trade_dur))
return trade_dur, min_roi
else: else:
return None, None return None, None
# exponential decay: f(t) = start * e^(-rate*t) # exponential decay: f(t) = start * e^(-rate*t)
@ -664,7 +666,6 @@ class IStrategy(ABC):
end = dynamic_roi['dynamic_roi_end'] end = dynamic_roi['dynamic_roi_end']
rate = dynamic_roi['dynamic_roi_rate'] rate = dynamic_roi['dynamic_roi_rate']
min_roi = max(end, start * np.exp(-rate*trade_dur)) min_roi = max(end, start * np.exp(-rate*trade_dur))
return trade_dur, min_roi
else: else:
return None, None return None, None
# "connect the dots" between the points on the minima_roi table # "connect the dots" between the points on the minima_roi table
@ -688,10 +689,11 @@ class IStrategy(ABC):
m = (y1-y2)/(x1-x2) m = (y1-y2)/(x1-x2)
b = (x1*y2 - x2*y1)/(x1-x2) b = (x1*y2 - x2*y1)/(x1-x2)
min_roi = (m * trade_dur) + b min_roi = (m * trade_dur) + b
return trade_dur, min_roi
else: else:
return None, None return None, None
return trade_dur, min_roi
def min_roi_reached_entry(self, trade_dur: int) -> Tuple[Optional[int], Optional[float]]: def min_roi_reached_entry(self, trade_dur: int) -> Tuple[Optional[int], Optional[float]]:
""" """
Based on trade duration defines the ROI entry that may have been reached. Based on trade duration defines the ROI entry that may have been reached.