From 1e44f93c31a5adbc0617f3767574b2a06b9ec56d Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 3 Nov 2019 10:38:21 +0100 Subject: [PATCH] Fix pandas access warning --- freqtrade/optimize/backtesting.py | 3 ++- tests/optimize/test_backtest_detail.py | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index fe31912bc..076857e62 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -245,7 +245,8 @@ class Backtesting: ticker: Dict = {} # Create ticker dict for pair, pair_data in processed.items(): - pair_data['buy'], pair_data['sell'] = 0, 0 # cleanup from previous run + pair_data.loc[:, 'buy'] = 0 # cleanup from previous run + pair_data.loc[:, 'sell'] = 0 # cleanup from previous run ticker_data = self.strategy.advise_sell( self.strategy.advise_buy(pair_data, {'pair': pair}), {'pair': pair})[headers].copy() diff --git a/tests/optimize/test_backtest_detail.py b/tests/optimize/test_backtest_detail.py index 345e423cd..54f4c8796 100644 --- a/tests/optimize/test_backtest_detail.py +++ b/tests/optimize/test_backtest_detail.py @@ -3,7 +3,6 @@ import logging from unittest.mock import MagicMock import pytest -from pandas import DataFrame from freqtrade.data.history import get_timeframe from freqtrade.optimize.backtesting import Backtesting @@ -313,7 +312,7 @@ def test_backtest_results(default_conf, fee, mocker, caplog, data) -> None: pair = "UNITTEST/BTC" # Dummy data as we mock the analyze functions - data_processed = {pair: DataFrame()} + data_processed = {pair: frame.copy()} min_date, max_date = get_timeframe({pair: frame}) results = backtesting.backtest( {