# Buggy code
def init_plotscript(config):
    """
    Initialize objects needed for plotting
    :return: Dict with tickers, trades, pairs and strategy
    """
    exchange: Optional[Exchange] = None

    # Exchange is only needed when downloading data!
    if config.get("live", False) or config.get("refresh_pairs", False):
        exchange = ExchangeResolver(
            config.get("exchange", {}).get("name"), config
        ).exchange

    strategy = StrategyResolver(config).strategy
    if "pairs" in config:
        pairs = config["pairs"].split(",")
    else:
        pairs = config["exchange"]["pair_whitelist"]

    # Set timerange to use
    timerange = Arguments.parse_timerange(config["timerange"])

    tickers = history.load_data(
        datadir=Path(str(config.get("datadir"))),
        pairs=pairs,
        ticker_interval=config["ticker_interval"],
        refresh_pairs=config.get("refresh_pairs", False),
        timerange=timerange,
        exchange=exchange,
        live=config.get("live", False),
    )

    trades = load_trades(config)
    return {
        "tickers": tickers,
        "trades": trades,
        "pairs": pairs,
        "strategy": strategy,
    }


# Traceback (KeyError)
python scripts/plot_dataframe.py -s BBRSI -p ETH/BTC
2019-07-08 21:27:52,077 - freqtrade.configuration - INFO - Verbosity set to 0
2019-07-08 21:27:52,078 - freqtrade.configuration - INFO - Dry run is enabled
2019-07-08 21:27:52,078 - freqtrade.configuration - INFO - Using DB: "sqlite://"
2019-07-08 21:27:52,078 - freqtrade.configuration - INFO - Checking exchange...
2019-07-08 21:27:52,078 - freqtrade.configuration - INFO - Exchange "binance" is officially supported by the Freqtrade development team.
2019-07-08 21:27:52,078 - freqtrade.configuration - INFO - Using max_open_trades: 15 ...
2019-07-08 21:27:52,078 - freqtrade.configuration - INFO - Using data directory: user_data/data/binance ...
2019-07-08 21:27:52,078 - freqtrade.configuration - INFO - Storing backtest results to user_data/backtest_data/backtest-result.json ...
2019-07-08 21:27:52,078 - freqtrade.configuration - INFO - Using pairs ETH/BTC
2019-07-08 21:27:52,078 - freqtrade.configuration - INFO - Using indicators1: sma,ema3,ema5
2019-07-08 21:27:52,078 - freqtrade.configuration - INFO - Using indicators2: macd,macdsignal
2019-07-08 21:27:52,078 - freqtrade.configuration - INFO - Limiting plot to: 750
2019-07-08 21:27:52,078 - freqtrade.configuration - INFO - Using trades from: file
2019-07-08 21:27:52,079 - freqtrade.resolvers.strategy_resolver - INFO - Using resolved strategy BBRSI from '/home/zero/freq/freqtrade/freqtrade/strategy'
2019-07-08 21:27:52,079 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'ticker_interval' with value in config file: 1h.
2019-07-08 21:27:52,080 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'trailing_stop' with value in config file: False.
2019-07-08 21:27:52,080 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stake_currency' with value in config file: BTC.
2019-07-08 21:27:52,080 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stake_amount' with value in config file: 0.01.
2019-07-08 21:27:52,080 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'use_sell_signal' with value in config file: True.
2019-07-08 21:27:52,080 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'sell_profit_only' with value in config file: False.
2019-07-08 21:27:52,080 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'ignore_roi_if_buy_signal' with value in config file: False.
2019-07-08 21:27:52,080 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using minimal_roi: {}
2019-07-08 21:27:52,080 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using ticker_interval: 1h
2019-07-08 21:27:52,080 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stoploss: -0.99
2019-07-08 21:27:52,080 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop: False
2019-07-08 21:27:52,080 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop_positive_offset: 0.0
2019-07-08 21:27:52,080 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_only_offset_is_reached: False
2019-07-08 21:27:52,080 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using process_only_new_candles: False
2019-07-08 21:27:52,080 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using order_types: {'buy': 'limit', 'sell': 'limit', 'stoploss': 'limit', 'stoploss_on_exchange': False}
2019-07-08 21:27:52,080 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using order_time_in_force: {'buy': 'gtc', 'sell': 'gtc'}
2019-07-08 21:27:52,080 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stake_currency: BTC
2019-07-08 21:27:52,080 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stake_amount: 0.01
2019-07-08 21:27:52,080 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using use_sell_signal: True
2019-07-08 21:27:52,080 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using sell_profit_only: False
2019-07-08 21:27:52,080 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using ignore_roi_if_buy_signal: False
Traceback (most recent call last):
File "scripts/plot_dataframe.py", line 113, in <module>
main(sys.argv[1:])
File "scripts/plot_dataframe.py", line 107, in main
plot_parse_args(sysargv)
File "scripts/plot_dataframe.py", line 57, in analyse_and_plot_pairs
plot_elements = init_plotscript(config)
File "/home/zero/freq/freqtrade/freqtrade/plot/plotting.py", line 45, in init_plotscript
timerange = Arguments.parse_timerange(config["timerange"])
KeyError: 'timerange'

# Fixed code
def init_plotscript(config):
    """
    Initialize objects needed for plotting
    :return: Dict with tickers, trades, pairs and strategy
    """
    exchange: Optional[Exchange] = None

    # Exchange is only needed when downloading data!
    if config.get("live", False) or config.get("refresh_pairs", False):
        exchange = ExchangeResolver(
            config.get("exchange", {}).get("name"), config
        ).exchange

    strategy = StrategyResolver(config).strategy
    if "pairs" in config:
        pairs = config["pairs"].split(",")
    else:
        pairs = config["exchange"]["pair_whitelist"]

    # Set timerange to use
    timerange = Arguments.parse_timerange(config.get("timerange"))

    tickers = history.load_data(
        datadir=Path(str(config.get("datadir"))),
        pairs=pairs,
        ticker_interval=config["ticker_interval"],
        refresh_pairs=config.get("refresh_pairs", False),
        timerange=timerange,
        exchange=exchange,
        live=config.get("live", False),
    )

    trades = load_trades(config)
    return {
        "tickers": tickers,
        "trades": trades,
        "pairs": pairs,
        "strategy": strategy,
    }