From b87f8e7034ee9ddb229be29aff3f729925ce9450 Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Wed, 10 Nov 2021 00:43:55 -0600 Subject: [PATCH] Removed unnecessary todo comments --- freqtrade/exchange/exchange.py | 1 - freqtrade/freqtradebot.py | 6 +++--- tests/test_freqtradebot.py | 37 ++++++++++++++++++---------------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index ae390ec27..cf7772600 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -1612,7 +1612,6 @@ class Exchange: :param since: The earliest time of consideration for calculating funding fees, in unix time or as a datetime """ - # TODO-lev: Add dry-run handling for this. if not self.exchange_has("fetchFundingHistory"): raise OperationalException( diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index aec2a6891..8369a8579 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -617,8 +617,9 @@ class FreqtradeBot(LoggingMixin): default_retval=stake_amount)( pair=pair, current_time=datetime.now(timezone.utc), current_rate=enter_limit_requested, proposed_stake=stake_amount, - min_stake=min_stake_amount, max_stake=max_stake_amount, side='long') - # TODO-lev: Add non-hardcoded "side" parameter + min_stake=min_stake_amount, max_stake=max_stake_amount, + side='short' if is_short else 'long' + ) stake_amount = self.wallets._validate_stake_amount(pair, stake_amount, min_stake_amount) @@ -638,7 +639,6 @@ class FreqtradeBot(LoggingMixin): order_type = self.strategy.order_types.get('forcebuy', order_type) # TODO-lev: Will this work for shorting? - # TODO-lev: Add non-hardcoded "side" parameter if not strategy_safe_wrapper(self.strategy.confirm_trade_entry, default_retval=True)( pair=pair, order_type=order_type, amount=amount, rate=enter_limit_requested, time_in_force=time_in_force, current_time=datetime.now(timezone.utc), diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index 385c360a0..e5a6195f3 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -906,7 +906,6 @@ def test_execute_entry_confirm_error(mocker, default_conf_usdt, fee, limit_order pair = 'ETH/USDT' freqtrade.strategy.confirm_trade_entry = MagicMock(side_effect=ValueError) - # TODO-lev: KeyError happens on short, why? assert freqtrade.execute_entry(pair, stake_amount) limit_order[enter_side(is_short)]['id'] = '222' @@ -1228,7 +1227,6 @@ def test_create_stoploss_order_insufficient_funds( def test_handle_stoploss_on_exchange_trailing( mocker, default_conf_usdt, fee, is_short, bid, ask, limit_order, stop_price, amt, hang_price ) -> None: - # TODO-lev: test for short # When trailing stoploss is set enter_order = limit_order[enter_side(is_short)] exit_order = limit_order[exit_side(is_short)] @@ -1435,7 +1433,6 @@ def test_handle_stoploss_on_exchange_custom_stop( enter_order = limit_order[enter_side(is_short)] exit_order = limit_order[exit_side(is_short)] # When trailing stoploss is set - # TODO-lev: test for short stoploss = MagicMock(return_value={'id': 13434334}) patch_RPCManager(mocker) mocker.patch.multiple( @@ -2973,9 +2970,11 @@ def test_execute_trade_exit_custom_exit_price( # Set a custom exit price freqtrade.strategy.custom_exit_price = lambda **kwargs: 2.25 - # TODO-lev: side="buy" - freqtrade.execute_trade_exit(trade=trade, limit=ticker_usdt_sell_up()['bid'], - sell_reason=SellCheckTuple(sell_type=SellType.SELL_SIGNAL)) + freqtrade.execute_trade_exit( + trade=trade, + limit=ticker_usdt_sell_up()['ask' if is_short else 'bid'], + sell_reason=SellCheckTuple(sell_type=SellType.SELL_SIGNAL) + ) # Sell price must be different to default bid price @@ -3098,7 +3097,6 @@ def test_execute_trade_exit_sloe_cancel_exception( freqtrade.config['dry_run'] = False trade.stoploss_order_id = "abcd" - # TODO-lev: side="buy" freqtrade.execute_trade_exit(trade=trade, limit=1234, sell_reason=SellCheckTuple(sell_type=SellType.STOP_LOSS)) assert create_order_mock.call_count == 2 @@ -3152,9 +3150,11 @@ def test_execute_trade_exit_with_stoploss_on_exchange( fetch_ticker=ticker_usdt_sell_up ) - # TODO-lev: side="buy" - freqtrade.execute_trade_exit(trade=trade, limit=ticker_usdt_sell_up()['bid'], - sell_reason=SellCheckTuple(sell_type=SellType.STOP_LOSS)) + freqtrade.execute_trade_exit( + trade=trade, + limit=ticker_usdt_sell_up()['ask' if is_short else 'bid'], + sell_reason=SellCheckTuple(sell_type=SellType.STOP_LOSS) + ) trade = Trade.query.first() trade.is_short = is_short @@ -3288,7 +3288,6 @@ def test_execute_trade_exit_market_order( ) freqtrade.config['order_types']['sell'] = 'market' - # TODO-lev: side="buy" freqtrade.execute_trade_exit( trade=trade, limit=ticker_usdt_sell_up()['ask' if is_short else 'bid'], @@ -3354,9 +3353,11 @@ def test_execute_trade_exit_insufficient_funds_error(default_conf_usdt, ticker_u ) sell_reason = SellCheckTuple(sell_type=SellType.ROI) - # TODO-lev: side="buy" - assert not freqtrade.execute_trade_exit(trade=trade, limit=ticker_usdt_sell_up()['bid'], - sell_reason=sell_reason) + assert not freqtrade.execute_trade_exit( + trade=trade, + limit=ticker_usdt_sell_up()['ask' if is_short else 'bid'], + sell_reason=sell_reason + ) assert mock_insuf.call_count == 1 @@ -3517,9 +3518,11 @@ def test_locked_pairs(default_conf_usdt, ticker_usdt, fee, fetch_ticker=ticker_usdt_sell_down ) - # TODO-lev: side="buy" - freqtrade.execute_trade_exit(trade=trade, limit=ticker_usdt_sell_down()['bid'], - sell_reason=SellCheckTuple(sell_type=SellType.STOP_LOSS)) + freqtrade.execute_trade_exit( + trade=trade, + limit=ticker_usdt_sell_down()['ask' if is_short else 'bid'], + sell_reason=SellCheckTuple(sell_type=SellType.STOP_LOSS) + ) trade.close(ticker_usdt_sell_down()['bid']) assert freqtrade.strategy.is_pair_locked(trade.pair)