freqtradebot.execute_entry test for too high stake amount
This commit is contained in:
		| @@ -825,10 +825,13 @@ class FreqtradeBot(LoggingMixin): | ||||
|         return trade | ||||
|  | ||||
|     def get_valid_enter_price_and_stake( | ||||
|             self, pair: str, price: Optional[float], stake_amount: float, | ||||
|             side: str, trade_side: str, | ||||
|             entry_tag: Optional[str], | ||||
|             trade: Optional[Trade]) -> Tuple[float, float]: | ||||
|         self, pair: str, price: Optional[float], stake_amount: float, | ||||
|         side: str, trade_side: str, | ||||
|         entry_tag: Optional[str], | ||||
|         trade: Optional[Trade] | ||||
|     ) -> Tuple[float, float]: | ||||
|         # TODO: This method has no tests | ||||
|  | ||||
|         if price: | ||||
|             enter_limit_requested = price | ||||
|         else: | ||||
|   | ||||
| @@ -410,7 +410,7 @@ class Backtesting: | ||||
|  | ||||
|     def _get_adjust_trade_entry_for_candle(self, trade: LocalTrade, row: Tuple | ||||
|                                            ) -> LocalTrade: | ||||
|  | ||||
|         # TODO: Write tests | ||||
|         current_profit = trade.calc_profit_ratio(row[OPEN_IDX]) | ||||
|         min_stake = self.exchange.get_min_pair_stake_amount(trade.pair, row[OPEN_IDX], -0.1) | ||||
|         max_stake = self.exchange.get_max_pair_stake_amount(trade.pair, row[OPEN_IDX], -0.1) | ||||
|   | ||||
| @@ -497,6 +497,7 @@ def test_backtesting_pairlist_list(default_conf, mocker, caplog, testdatadir, ti | ||||
|  | ||||
|  | ||||
| def test_backtest__enter_trade(default_conf, fee, mocker) -> None: | ||||
|     # TODO-lev: test max_pair_stake_amount | ||||
|     default_conf['use_sell_signal'] = False | ||||
|     mocker.patch('freqtrade.exchange.Exchange.get_fee', fee) | ||||
|     mocker.patch("freqtrade.exchange.Exchange.get_min_pair_stake_amount", return_value=0.00001) | ||||
|   | ||||
| @@ -932,6 +932,22 @@ def test_execute_entry(mocker, default_conf_usdt, fee, limit_order, | ||||
|     assert trade.open_rate_requested == 10 | ||||
|     assert trade.isolated_liq == liq_price | ||||
|  | ||||
|     # In case of too high stake amount | ||||
|  | ||||
|     order['status'] = 'open' | ||||
|     order['id'] = '55672' | ||||
|  | ||||
|     mocker.patch.multiple( | ||||
|         'freqtrade.exchange.Exchange', | ||||
|         get_max_pair_stake_amount=MagicMock(return_value=500), | ||||
|     ) | ||||
|     freqtrade.exchange.get_max_pair_stake_amount = MagicMock(return_value=500) | ||||
|  | ||||
|     assert freqtrade.execute_entry(pair, 2000, is_short=is_short) | ||||
|     trade = Trade.query.all()[9] | ||||
|     trade.is_short = is_short | ||||
|     assert trade.stake_amount == 500 | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize("is_short", [False, True]) | ||||
| def test_execute_entry_confirm_error(mocker, default_conf_usdt, fee, limit_order, is_short) -> None: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user