# Buggy code
def import_strategy(strategy: IStrategy, config: dict) -> IStrategy:
    """
    Imports given Strategy instance to global scope
    of freqtrade.strategy and returns an instance of it
    """
    # Copy all attributes from base class and class
    attr = deepcopy({**strategy.__class__.__dict__, **strategy.__dict__})
    # Adjust module name
    attr["__module__"] = "freqtrade.strategy"

    name = strategy.__class__.__name__
    clazz = type(name, (IStrategy,), attr)

    logger.debug(
        "Imported strategy %s.%s as %s.%s",
        strategy.__module__,
        strategy.__class__.__name__,
        clazz.__module__,
        strategy.__class__.__name__,
    )

    # Modify global scope to declare class
    globals()[name] = clazz

    return clazz(config)


# Traceback (TypeError)
2018-07-24 12:47:43,113 - freqtrade.configuration - INFO - Verbosity set to 0
2018-07-24 12:47:43,113 - freqtrade.configuration - INFO - Parameter --dynamic-whitelist detected. Using dynamically generated whitelist. (not applicable with Backtesting and Hyperopt)
2018-07-24 12:47:43,113 - freqtrade.configuration - INFO - Dry run is enabled
2018-07-24 12:47:43,113 - freqtrade.configuration - INFO - Using DB: "sqlite://"
2018-07-24 12:47:43,113 - freqtrade.configuration - INFO - Using max_open_trades: 15 ...
2018-07-24 12:47:43,113 - freqtrade.configuration - INFO - Using data folder: user_data/data/binance ...
2018-07-24 12:47:43,114 - freqtrade.freqtradebot - INFO - Starting freqtrade 0.17.1
2018-07-24 12:47:43,118 - freqtrade.strategy.resolver - INFO - Using resolved strategy DefaultStrategy from '/Users/shusso/GoogleDrive/code/freqtrade/freqtrade/strategy'
2018-07-24 12:47:43,118 - freqtrade - ERROR - Fatal exception!
Traceback (most recent call last):
File "/Users/shusso/GoogleDrive/code/freqtrade/freqtrade/main.py", line 45, in main
freqtrade = FreqtradeBot(config)
File "/Users/shusso/GoogleDrive/code/freqtrade/freqtrade/freqtradebot.py", line 51, in __init__
self.strategy: IStrategy = StrategyResolver(self.config).strategy
File "/Users/shusso/GoogleDrive/code/freqtrade/freqtrade/strategy/resolver.py", line 38, in __init__
extra_dir=config.get('strategy_path'))
File "/Users/shusso/GoogleDrive/code/freqtrade/freqtrade/strategy/resolver.py", line 95, in _load_strategy
return import_strategy(strategy, config=config)
File "/Users/shusso/GoogleDrive/code/freqtrade/freqtrade/strategy/__init__.py", line 16, in import_strategy
attr = deepcopy({**strategy.__class__.__dict__, **strategy.__dict__})
File "/Users/shusso/.local/share/virtualenvs/freqtrade-IlLijMZy/lib/python3.7/copy.py", line 150, in deepcopy
y = copier(x, memo)
File "/Users/shusso/.local/share/virtualenvs/freqtrade-IlLijMZy/lib/python3.7/copy.py", line 240, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/Users/shusso/.local/share/virtualenvs/freqtrade-IlLijMZy/lib/python3.7/copy.py", line 169, in deepcopy
rv = reductor(4)
TypeError: can't pickle _abc_data objects

# Fixed code
def import_strategy(strategy: IStrategy, config: dict) -> IStrategy:
    """
    Imports given Strategy instance to global scope
    of freqtrade.strategy and returns an instance of it
    """

    # Copy all attributes from base class and class

    comb = {**strategy.__class__.__dict__, **strategy.__dict__}

    # Delete '_abc_impl' from dict as deepcopy fails on 3.7 with
    # `TypeError: can't pickle _abc_data objects``
    # This will only apply to python 3.7
    if (
        sys.version_info.major == 3
        and sys.version_info.minor == 7
        and "_abc_impl" in comb
    ):
        del comb["_abc_impl"]

    attr = deepcopy(comb)
    # Adjust module name
    attr["__module__"] = "freqtrade.strategy"

    name = strategy.__class__.__name__
    clazz = type(name, (IStrategy,), attr)

    logger.debug(
        "Imported strategy %s.%s as %s.%s",
        strategy.__module__,
        strategy.__class__.__name__,
        clazz.__module__,
        strategy.__class__.__name__,
    )

    # Modify global scope to declare class
    globals()[name] = clazz

    return clazz(config)