Esempio n. 1
0
 def _normalize_attributes(strategy: IStrategy) -> IStrategy:
     """
     Normalize attributes to have the correct type.
     """
     # Sort and apply type conversions
     if hasattr(strategy, 'minimal_roi'):
         strategy.minimal_roi = dict(
             sorted({
                 int(key): value
                 for (key, value) in strategy.minimal_roi.items()
             }.items(),
                    key=lambda t: t[0]))
     if hasattr(strategy, 'stoploss'):
         strategy.stoploss = float(strategy.stoploss)
     return strategy
Esempio n. 2
0
    def _normalize_attributes(strategy: IStrategy) -> IStrategy:
        """
        Normalize attributes to have the correct type.
        """
        # Assign deprecated variable - to not break users code relying on this.
        if hasattr(strategy, 'timeframe'):
            strategy.ticker_interval = strategy.timeframe

        # Sort and apply type conversions
        if hasattr(strategy, 'minimal_roi'):
            strategy.minimal_roi = dict(sorted(
                {int(key): value for (key, value) in strategy.minimal_roi.items()}.items(),
                key=lambda t: t[0]))
        if hasattr(strategy, 'stoploss'):
            strategy.stoploss = float(strategy.stoploss)
        return strategy