mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-04-29 05:20:10 +00:00
Extract global cached_grouped_trades_per_pair into IStrategy
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from collections import OrderedDict
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import pytest
|
||||
@@ -47,15 +49,6 @@ def public_trades_list_simple(testdatadir):
|
||||
return read_csv(testdatadir / "orderflow/public_trades_list_simple_example.csv").copy()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def reset_cache(request):
|
||||
import freqtrade.data.converter.orderflow as orderflow
|
||||
|
||||
global orderflow # noqa F811
|
||||
orderflow.cached_grouped_trades_per_pair = {}
|
||||
yield
|
||||
|
||||
|
||||
def test_public_trades_columns_before_change(
|
||||
populate_dataframe_with_trades_dataframe, populate_dataframe_with_trades_trades
|
||||
):
|
||||
@@ -80,7 +73,7 @@ def test_public_trades_columns_before_change(
|
||||
|
||||
|
||||
def test_public_trades_mock_populate_dataframe_with_trades__check_orderflow(
|
||||
reset_cache, populate_dataframe_with_trades_dataframe, populate_dataframe_with_trades_trades
|
||||
populate_dataframe_with_trades_dataframe, populate_dataframe_with_trades_trades
|
||||
):
|
||||
"""
|
||||
Tests the `populate_dataframe_with_trades` function's order flow calculation.
|
||||
@@ -108,7 +101,7 @@ def test_public_trades_mock_populate_dataframe_with_trades__check_orderflow(
|
||||
},
|
||||
}
|
||||
# Apply the function to populate the data frame with order flow data
|
||||
df = populate_dataframe_with_trades("BTC/UDST", config, dataframe, trades)
|
||||
df, _ = populate_dataframe_with_trades(OrderedDict(), config, dataframe, trades)
|
||||
# Extract results from the first row of the DataFrame
|
||||
results = df.iloc[0]
|
||||
t = results["trades"]
|
||||
@@ -179,7 +172,7 @@ def test_public_trades_mock_populate_dataframe_with_trades__check_orderflow(
|
||||
|
||||
|
||||
def test_public_trades_trades_mock_populate_dataframe_with_trades__check_trades(
|
||||
reset_cache, populate_dataframe_with_trades_dataframe, populate_dataframe_with_trades_trades
|
||||
populate_dataframe_with_trades_dataframe, populate_dataframe_with_trades_trades
|
||||
):
|
||||
"""
|
||||
Tests the `populate_dataframe_with_trades` function's handling of trades,
|
||||
@@ -221,7 +214,7 @@ def test_public_trades_trades_mock_populate_dataframe_with_trades__check_trades(
|
||||
}
|
||||
|
||||
# Populate the DataFrame with trades and order flow data
|
||||
df = populate_dataframe_with_trades("BTC/UDST", config, dataframe, trades)
|
||||
df, _ = populate_dataframe_with_trades(OrderedDict(), config, dataframe, trades)
|
||||
|
||||
# --- DataFrame and Trade Data Validation ---
|
||||
|
||||
@@ -387,8 +380,8 @@ def test_public_trades_config_max_trades(
|
||||
},
|
||||
}
|
||||
|
||||
df = populate_dataframe_with_trades(
|
||||
"BTC/UDST", default_conf | orderflow_config, dataframe, trades
|
||||
df, _ = populate_dataframe_with_trades(
|
||||
OrderedDict(), default_conf | orderflow_config, dataframe, trades
|
||||
)
|
||||
assert df.delta.count() == 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user