From df726a54f89af8f99cb5dd3969ba280187d22d58 Mon Sep 17 00:00:00 2001 From: Stefano Ariestasia Date: Fri, 25 Feb 2022 00:20:53 +0000 Subject: [PATCH 1/8] cater for case where sell limit order expired --- freqtrade/rpc/telegram.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index da613fab8..e71b5a9b9 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -448,7 +448,8 @@ class Telegram(RPCHandler): "*Current Pair:* {pair}", "*Amount:* `{amount} ({stake_amount} {base_currency})`", "*Entry Tag:* `{buy_tag}`" if r['buy_tag'] else "", - "*Exit Reason:* `{sell_reason}`" if r['sell_reason'] else "", + "*Exit Reason:* `{sell_reason}`" + if (r['sell_reason'] and not r['is_open']) else "", ] if position_adjust: From f26247e8e026901cc74c7602107fbb57d5115c23 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 1 Mar 2022 19:08:04 +0100 Subject: [PATCH 2/8] Revert wrong version string --- freqtrade/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freqtrade/__init__.py b/freqtrade/__init__.py index 54cecbec2..2747efc96 100644 --- a/freqtrade/__init__.py +++ b/freqtrade/__init__.py @@ -1,5 +1,5 @@ """ Freqtrade bot """ -__version__ = '2022.1' +__version__ = 'develop' if __version__ == 'develop': From a2c9879375e744b1bd7fba216f61c302ca45294e Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 1 Mar 2022 19:30:16 +0100 Subject: [PATCH 3/8] Reset sell-reason if order is cancelled --- freqtrade/freqtradebot.py | 1 + tests/test_freqtradebot.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 99872ff0b..8e26c4c3a 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -1108,6 +1108,7 @@ class FreqtradeBot(LoggingMixin): trade.close_date = None trade.is_open = True trade.open_order_id = None + trade.sell_reason = None else: # TODO: figure out how to handle partially complete sell orders reason = constants.CANCEL_REASON['PARTIALLY_FILLED_KEEP_OPEN'] diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index d7b47174b..997ec5159 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -2549,9 +2549,12 @@ def test_handle_cancel_exit_limit(mocker, default_conf_usdt, fee) -> None: exchange='binance', open_rate=0.245441, open_order_id="123456", - open_date=arrow.utcnow().datetime, + open_date=arrow.utcnow().shift(days=-2).datetime, fee_open=fee.return_value, fee_close=fee.return_value, + close_rate=0.555, + close_date=arrow.utcnow().datetime, + sell_reason="sell_reason_whatever", ) order = {'remaining': 1, 'amount': 1, @@ -2560,6 +2563,8 @@ def test_handle_cancel_exit_limit(mocker, default_conf_usdt, fee) -> None: assert freqtrade.handle_cancel_exit(trade, order, reason) assert cancel_order_mock.call_count == 1 assert send_msg_mock.call_count == 1 + assert trade.close_rate == None + assert trade.sell_reason is None send_msg_mock.reset_mock() From 69cfb0b278d1d78b528216ecd1f4ab4bc995014e Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 1 Mar 2022 19:32:25 +0100 Subject: [PATCH 4/8] Revert change to telegram - this should be handled at the source --- freqtrade/rpc/telegram.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index a4310e3a0..69f7f2858 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -452,8 +452,7 @@ class Telegram(RPCHandler): "*Current Pair:* {pair}", "*Amount:* `{amount} ({stake_amount} {base_currency})`", "*Entry Tag:* `{buy_tag}`" if r['buy_tag'] else "", - "*Exit Reason:* `{sell_reason}`" - if (r['sell_reason'] and not r['is_open']) else "", + "*Exit Reason:* `{sell_reason}`" if r['sell_reason'] else "", ] if position_adjust: From 54165662cec1e7b53ded4f00769ae94b02ef3ee9 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 1 Mar 2022 19:41:26 +0100 Subject: [PATCH 5/8] Don't require unfilledtimeout, it's optional. --- freqtrade/constants.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/freqtrade/constants.py b/freqtrade/constants.py index 077be51f7..066a07c62 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -440,7 +440,6 @@ SCHEMA_TRADE_REQUIRED = [ 'dry_run_wallet', 'ask_strategy', 'bid_strategy', - 'unfilledtimeout', 'stoploss', 'minimal_roi', 'internals', @@ -456,7 +455,6 @@ SCHEMA_BACKTEST_REQUIRED = [ 'dry_run_wallet', 'dataformat_ohlcv', 'dataformat_trades', - 'unfilledtimeout', ] SCHEMA_MINIMAL_REQUIRED = [ From f74de1cca34ae22e7d173feeac8dd375b812ee72 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 1 Mar 2022 19:46:13 +0100 Subject: [PATCH 6/8] Improve Backtesting "wrong setup" message to include tradable_balance --- freqtrade/commands/optimize_commands.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/freqtrade/commands/optimize_commands.py b/freqtrade/commands/optimize_commands.py index f230b696c..1bfd384fc 100644 --- a/freqtrade/commands/optimize_commands.py +++ b/freqtrade/commands/optimize_commands.py @@ -25,12 +25,16 @@ def setup_optimize_configuration(args: Dict[str, Any], method: RunMode) -> Dict[ RunMode.HYPEROPT: 'hyperoptimization', } if method in no_unlimited_runmodes.keys(): + wallet_size = config['dry_run_wallet'] * config['tradable_balance_ratio'] + # tradable_balance_ratio if (config['stake_amount'] != constants.UNLIMITED_STAKE_AMOUNT - and config['stake_amount'] > config['dry_run_wallet']): - wallet = round_coin_value(config['dry_run_wallet'], config['stake_currency']) + and config['stake_amount'] > wallet_size): + wallet = round_coin_value(wallet_size, config['stake_currency']) stake = round_coin_value(config['stake_amount'], config['stake_currency']) - raise OperationalException(f"Starting balance ({wallet}) " - f"is smaller than stake_amount {stake}.") + raise OperationalException( + f"Starting balance ({wallet}) is smaller than stake_amount {stake}. " + f"Wallet is calculated as `dry_run_wallet * tradable_balance_ratio`." + ) return config From abc8854b5a1b5d3161241685b26509329db5c4be Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Tue, 1 Mar 2022 17:36:11 -0600 Subject: [PATCH 7/8] setup.sh install gettext for mac --- setup.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.sh b/setup.sh index c642a654d..865a1cc89 100755 --- a/setup.sh +++ b/setup.sh @@ -132,6 +132,9 @@ function install_macos() { echo_block "Installing Brew" /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" fi + + brew install gettext + #Gets number after decimal in python version version=$(egrep -o 3.\[0-9\]+ <<< $PYTHON | sed 's/3.//g') From 71be547d82629d748436f34c19097094d3313e87 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 2 Mar 2022 06:26:00 +0100 Subject: [PATCH 8/8] Bump ccxt to 1.74.63 closes #6484 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c524eb49d..bcdcb02a9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ numpy==1.22.2 pandas==1.4.1 pandas-ta==0.3.14b -ccxt==1.74.43 +ccxt==1.74.63 # Pin cryptography for now due to rust build errors with piwheels cryptography==36.0.1 aiohttp==3.8.1