add Combine dataframes with pct_change

This commit is contained in:
Matthias
2024-04-16 07:14:00 +02:00
parent e7b907a175
commit 3f8078618e
2 changed files with 50 additions and 6 deletions
+14 -2
View File
@@ -16,7 +16,7 @@ from freqtrade.data.metrics import (calculate_cagr, calculate_calmar, calculate_
calculate_expectancy, calculate_market_change,
calculate_max_drawdown, calculate_sharpe, calculate_sortino,
calculate_underwater, combine_dataframes_with_mean,
create_cum_profit)
combined_dataframes_with_rel_mean, create_cum_profit)
from freqtrade.exceptions import OperationalException
from freqtrade.util import dt_utc
from tests.conftest import CURRENT_TEST_STRATEGY, create_mock_trades
@@ -251,10 +251,22 @@ def test_combine_dataframes_with_mean(testdatadir):
assert "mean" in df.columns
def test_combined_dataframes_with_rel_mean(testdatadir):
pairs = ["ETH/BTC", "ADA/BTC"]
data = load_data(datadir=testdatadir, pairs=pairs, timeframe='5m')
df = combined_dataframes_with_rel_mean(data)
assert isinstance(df, DataFrame)
assert "ETH/BTC" not in df.columns
assert "ADA/BTC" not in df.columns
assert "mean" in df.columns
assert "rel_mean" in df.columns
assert "count" in df.columns
def test_combine_dataframes_with_mean_no_data(testdatadir):
pairs = ["ETH/BTC", "ADA/BTC"]
data = load_data(datadir=testdatadir, pairs=pairs, timeframe='6m')
with pytest.raises(ValueError, match=r"No objects to concatenate"):
with pytest.raises(ValueError, match=r"No data provided\."):
combine_dataframes_with_mean(data)