make Strategy store roi and stoploss values as numbers to avoid later casting

This commit is contained in:
Janne Sinivirta
2018-02-11 15:02:42 +02:00
parent 5190cd507e
commit 2ce03ab1b5
5 changed files with 15 additions and 16 deletions

View File

@@ -296,14 +296,13 @@ def min_roi_reached(trade: Trade, current_rate: float, current_time: datetime) -
strategy = Strategy()
current_profit = trade.calc_profit_percent(current_rate)
if strategy.stoploss is not None and current_profit < float(strategy.stoploss):
if strategy.stoploss is not None and current_profit < strategy.stoploss:
logger.debug('Stop loss hit.')
return True
# Check if time matches and current rate is above threshold
time_diff = (current_time.timestamp() - trade.open_date.timestamp()) / 60
for duration_string, threshold in strategy.minimal_roi.items():
duration = float(duration_string)
for duration, threshold in strategy.minimal_roi.items():
if time_diff < duration:
return False
if time_diff > duration and current_profit > threshold: