Add additional test scenarios
This commit is contained in:
parent
1c1a7150ae
commit
8b186dbe0e
@ -135,7 +135,7 @@ class Awesomestrategy(IStrategy):
|
|||||||
"""
|
"""
|
||||||
Called right before placing a buy order.
|
Called right before placing a buy order.
|
||||||
Timing for this function is critical, so avoid doing heavy computations or
|
Timing for this function is critical, so avoid doing heavy computations or
|
||||||
network reqeusts in this method.
|
network requests in this method.
|
||||||
|
|
||||||
For full documentation please go to https://www.freqtrade.io/en/latest/strategy-advanced/
|
For full documentation please go to https://www.freqtrade.io/en/latest/strategy-advanced/
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ class Awesomestrategy(IStrategy):
|
|||||||
"""
|
"""
|
||||||
Called right before placing a regular sell order.
|
Called right before placing a regular sell order.
|
||||||
Timing for this function is critical, so avoid doing heavy computations or
|
Timing for this function is critical, so avoid doing heavy computations or
|
||||||
network reqeusts in this method.
|
network requests in this method.
|
||||||
|
|
||||||
For full documentation please go to https://www.freqtrade.io/en/latest/strategy-advanced/
|
For full documentation please go to https://www.freqtrade.io/en/latest/strategy-advanced/
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ class IStrategy(ABC):
|
|||||||
"""
|
"""
|
||||||
Called right before placing a buy order.
|
Called right before placing a buy order.
|
||||||
Timing for this function is critical, so avoid doing heavy computations or
|
Timing for this function is critical, so avoid doing heavy computations or
|
||||||
network reqeusts in this method.
|
network requests in this method.
|
||||||
|
|
||||||
For full documentation please go to https://www.freqtrade.io/en/latest/strategy-advanced/
|
For full documentation please go to https://www.freqtrade.io/en/latest/strategy-advanced/
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ class IStrategy(ABC):
|
|||||||
"""
|
"""
|
||||||
Called right before placing a regular sell order.
|
Called right before placing a regular sell order.
|
||||||
Timing for this function is critical, so avoid doing heavy computations or
|
Timing for this function is critical, so avoid doing heavy computations or
|
||||||
network reqeusts in this method.
|
network requests in this method.
|
||||||
|
|
||||||
For full documentation please go to https://www.freqtrade.io/en/latest/strategy-advanced/
|
For full documentation please go to https://www.freqtrade.io/en/latest/strategy-advanced/
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ def confirm_trade_entry(self, pair: str, order_type: str, amount: float, rate: f
|
|||||||
"""
|
"""
|
||||||
Called right before placing a buy order.
|
Called right before placing a buy order.
|
||||||
Timing for this function is critical, so avoid doing heavy computations or
|
Timing for this function is critical, so avoid doing heavy computations or
|
||||||
network reqeusts in this method.
|
network requests in this method.
|
||||||
|
|
||||||
For full documentation please go to https://www.freqtrade.io/en/latest/strategy-advanced/
|
For full documentation please go to https://www.freqtrade.io/en/latest/strategy-advanced/
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ def confirm_trade_exit(self, pair: str, trade: 'Trade', order_type: str, amount:
|
|||||||
"""
|
"""
|
||||||
Called right before placing a regular sell order.
|
Called right before placing a regular sell order.
|
||||||
Timing for this function is critical, so avoid doing heavy computations or
|
Timing for this function is critical, so avoid doing heavy computations or
|
||||||
network reqeusts in this method.
|
network requests in this method.
|
||||||
|
|
||||||
For full documentation please go to https://www.freqtrade.io/en/latest/strategy-advanced/
|
For full documentation please go to https://www.freqtrade.io/en/latest/strategy-advanced/
|
||||||
|
|
||||||
|
@ -787,6 +787,7 @@ def limit_buy_order():
|
|||||||
'price': 0.00001099,
|
'price': 0.00001099,
|
||||||
'amount': 90.99181073,
|
'amount': 90.99181073,
|
||||||
'filled': 90.99181073,
|
'filled': 90.99181073,
|
||||||
|
'cost': 0.0009999,
|
||||||
'remaining': 0.0,
|
'remaining': 0.0,
|
||||||
'status': 'closed'
|
'status': 'closed'
|
||||||
}
|
}
|
||||||
|
@ -57,9 +57,9 @@ def test_returns_latest_signal(mocker, default_conf, ohlcv_history):
|
|||||||
|
|
||||||
def test_trade_no_dataprovider(default_conf, mocker, caplog):
|
def test_trade_no_dataprovider(default_conf, mocker, caplog):
|
||||||
strategy = DefaultStrategy({})
|
strategy = DefaultStrategy({})
|
||||||
# Delete DP for sure (suffers from test leakage, as we update this in the base class)
|
# Delete DP for sure (suffers from test leakage, as this is updated in the base class)
|
||||||
if strategy.dp:
|
if strategy.dp is not None:
|
||||||
del strategy.dp
|
strategy.dp = None
|
||||||
with pytest.raises(OperationalException, match="DataProvider not found."):
|
with pytest.raises(OperationalException, match="DataProvider not found."):
|
||||||
strategy.get_signal('ETH/BTC', '5m')
|
strategy.get_signal('ETH/BTC', '5m')
|
||||||
|
|
||||||
|
@ -1070,6 +1070,39 @@ def test_execute_buy(mocker, default_conf, fee, limit_buy_order) -> None:
|
|||||||
assert not freqtrade.execute_buy(pair, stake_amount)
|
assert not freqtrade.execute_buy(pair, stake_amount)
|
||||||
|
|
||||||
|
|
||||||
|
def test_execute_buy_confirm_error(mocker, default_conf, fee, limit_buy_order) -> None:
|
||||||
|
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||||
|
mocker.patch.multiple(
|
||||||
|
'freqtrade.freqtradebot.FreqtradeBot',
|
||||||
|
get_buy_rate=MagicMock(return_value=0.11),
|
||||||
|
_get_min_pair_stake_amount=MagicMock(return_value=1)
|
||||||
|
)
|
||||||
|
mocker.patch.multiple(
|
||||||
|
'freqtrade.exchange.Exchange',
|
||||||
|
fetch_ticker=MagicMock(return_value={
|
||||||
|
'bid': 0.00001172,
|
||||||
|
'ask': 0.00001173,
|
||||||
|
'last': 0.00001172
|
||||||
|
}),
|
||||||
|
buy=MagicMock(return_value=limit_buy_order),
|
||||||
|
get_fee=fee,
|
||||||
|
)
|
||||||
|
stake_amount = 2
|
||||||
|
pair = 'ETH/BTC'
|
||||||
|
|
||||||
|
freqtrade.strategy.confirm_trade_entry = MagicMock(side_effect=ValueError)
|
||||||
|
assert freqtrade.execute_buy(pair, stake_amount)
|
||||||
|
|
||||||
|
freqtrade.strategy.confirm_trade_entry = MagicMock(side_effect=Exception)
|
||||||
|
assert freqtrade.execute_buy(pair, stake_amount)
|
||||||
|
|
||||||
|
freqtrade.strategy.confirm_trade_entry = MagicMock(return_value=True)
|
||||||
|
assert freqtrade.execute_buy(pair, stake_amount)
|
||||||
|
|
||||||
|
freqtrade.strategy.confirm_trade_entry = MagicMock(return_value=False)
|
||||||
|
assert not freqtrade.execute_buy(pair, stake_amount)
|
||||||
|
|
||||||
|
|
||||||
def test_add_stoploss_on_exchange(mocker, default_conf, limit_buy_order) -> None:
|
def test_add_stoploss_on_exchange(mocker, default_conf, limit_buy_order) -> None:
|
||||||
patch_RPCManager(mocker)
|
patch_RPCManager(mocker)
|
||||||
patch_exchange(mocker)
|
patch_exchange(mocker)
|
||||||
|
Loading…
Reference in New Issue
Block a user