test: add test for adjust_order_price and adjust_entry_price collision

This commit is contained in:
Matthias
2025-02-20 19:22:03 +01:00
parent 67ce9a41f2
commit dd8938ced2
2 changed files with 38 additions and 1 deletions

View File

@@ -21,10 +21,12 @@ class TestStrategyNoImplementSell(TestStrategyNoImplements):
return super().populate_entry_trend(dataframe, metadata)
class TestStrategyImplementCustomSell(TestStrategyNoImplementSell):
class TestStrategyImplementEmptyWorking(TestStrategyNoImplementSell):
def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
return super().populate_exit_trend(dataframe, metadata)
class TestStrategyImplementCustomSell(TestStrategyImplementEmptyWorking):
def custom_sell(
self,
pair: str,
@@ -55,3 +57,34 @@ class TestStrategyImplementSellTimeout(TestStrategyNoImplementSell):
self, pair: str, trade, order: Order, current_time: datetime, **kwargs
) -> bool:
return False
class TestStrategyAdjustOrderPrice(TestStrategyImplementEmptyWorking):
def adjust_entry_price(
self,
trade,
order,
pair,
current_time,
proposed_rate,
current_order_rate,
entry_tag,
side,
**kwargs,
):
return proposed_rate
def adjust_order_price(
self,
trade,
order,
pair,
current_time,
proposed_rate,
current_order_rate,
entry_tag,
side,
is_entry,
**kwargs,
):
return proposed_rate

View File

@@ -460,6 +460,10 @@ def test_missing_implements(default_conf, caplog):
):
StrategyResolver.load_strategy(default_conf)
default_conf["strategy"] = "TestStrategyAdjustOrderPrice"
with pytest.raises(OperationalException, match=r"If you implement `adjust_order_price`.*"):
StrategyResolver.load_strategy(default_conf)
def test_call_deprecated_function(default_conf):
default_location = Path(__file__).parent / "strats/broken_strats/"