diff --git a/freqtrade/data/converter/orderflow.py b/freqtrade/data/converter/orderflow.py index d2df46723..11d17e52f 100644 --- a/freqtrade/data/converter/orderflow.py +++ b/freqtrade/data/converter/orderflow.py @@ -115,7 +115,11 @@ def populate_dataframe_with_trades( indices = dataframe.index[is_between].tolist() # Add trades to each candle - trades_series.loc[indices] = [trades_grouped_df.to_dict(orient="records")] + trades_series.loc[indices] = [ + trades_grouped_df.drop(columns=["candle_start", "candle_end"]).to_dict( + orient="records" + ) + ] # Use caching mechanism if (candle_start, candle_next) in cached_grouped_trades: cache_entry = cached_grouped_trades[ @@ -191,7 +195,6 @@ def populate_dataframe_with_trades( logger.debug(f"trades.groups_keys in {time.time() - start_time} seconds") # Merge the complex data Series back into the DataFrame - # TODO: maybe candle_start and candle_end should be dropped before assignment? dataframe["trades"] = trades_series dataframe["orderflow"] = orderflow_series dataframe["imbalances"] = imbalances_series diff --git a/tests/data/test_converter_public_trades.py b/tests/data/test_converter_public_trades.py index a08ba8d8e..9126edfe3 100644 --- a/tests/data/test_converter_public_trades.py +++ b/tests/data/test_converter_public_trades.py @@ -279,6 +279,7 @@ def test_public_trades_trades_mock_populate_dataframe_with_trades__check_trades( # Assert specific details of the first trade t = row["trades"][0] + assert list(t.keys()) == ["timestamp", "id", "type", "side", "price", "amount", "cost", "date"] assert trades["id"][0] == t["id"] assert int(trades["timestamp"][0]) == int(t["timestamp"]) assert t["side"] == "sell"