let Strategy hold a sorted roi map
This commit is contained in:
parent
a28ffcbcf7
commit
5c02f0983d
@ -302,7 +302,7 @@ def min_roi_reached(trade: Trade, current_rate: float, current_time: datetime) -
|
||||
|
||||
# Check if time matches and current rate is above threshold
|
||||
time_diff = (current_time - trade.open_date).total_seconds() / 60
|
||||
for duration, threshold in sorted(strategy.minimal_roi.items()):
|
||||
for duration, threshold in strategy.minimal_roi.items():
|
||||
if time_diff > float(duration) and current_profit > threshold:
|
||||
return True
|
||||
|
||||
|
@ -7,6 +7,7 @@ import os
|
||||
import sys
|
||||
import logging
|
||||
import importlib
|
||||
from collections import OrderedDict
|
||||
|
||||
from pandas import DataFrame
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
@ -69,7 +70,9 @@ class Strategy(object):
|
||||
)
|
||||
|
||||
# Minimal ROI designed for the strategy
|
||||
self.minimal_roi = self.custom_strategy.minimal_roi
|
||||
self.minimal_roi = OrderedDict(sorted(
|
||||
self.custom_strategy.minimal_roi.items(),
|
||||
key=lambda tuple: float(tuple[0]))) # sort after converting to number
|
||||
|
||||
# Optimal stoploss designed for the strategy
|
||||
self.stoploss = self.custom_strategy.stoploss
|
||||
|
Loading…
Reference in New Issue
Block a user