From 66a97ff45de3e3ba39bf54a94657c8f52ba88536 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 13 May 2023 20:43:37 +0200 Subject: [PATCH 01/19] Remove some utcnow usages --- freqtrade/freqtradebot.py | 4 ++-- tests/persistence/test_persistence.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 436564b42..d068ef6e3 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -1018,7 +1018,7 @@ class FreqtradeBot(LoggingMixin): 'base_currency': self.exchange.get_pair_base_currency(trade.pair), 'fiat_currency': self.config.get('fiat_display_currency', None), 'amount': order.safe_amount_after_fee if fill else (order.amount or trade.amount), - 'open_date': trade.open_date or datetime.utcnow(), + 'open_date': trade.open_date or datetime.now(timezone.utc), 'current_rate': current_rate, 'sub_trade': sub_trade, } @@ -1742,7 +1742,7 @@ class FreqtradeBot(LoggingMixin): 'sell_reason': trade.exit_reason, # Deprecated 'exit_reason': trade.exit_reason, 'open_date': trade.open_date, - 'close_date': trade.close_date or datetime.utcnow(), + 'close_date': trade.close_date or datetime.now(timezone.utc), 'stake_amount': trade.stake_amount, 'stake_currency': self.config['stake_currency'], 'base_currency': self.exchange.get_pair_base_currency(trade.pair), diff --git a/tests/persistence/test_persistence.py b/tests/persistence/test_persistence.py index 1a7d84eca..6af629c75 100644 --- a/tests/persistence/test_persistence.py +++ b/tests/persistence/test_persistence.py @@ -239,7 +239,7 @@ def test_interest(fee, exchange, is_short, lev, minutes, rate, interest, stake_amount=20.0, amount=30.0, open_rate=2.0, - open_date=datetime.utcnow() - timedelta(minutes=minutes), + open_date=datetime.now(timezone.utc) - timedelta(minutes=minutes), fee_open=fee.return_value, fee_close=fee.return_value, exchange=exchange, @@ -2063,7 +2063,7 @@ def test_trade_truncates_string_fields(): stake_amount=20.0, amount=30.0, open_rate=2.0, - open_date=datetime.utcnow() - timedelta(minutes=20), + open_date=datetime.now(timezone.utc) - timedelta(minutes=20), fee_open=0.001, fee_close=0.001, exchange='binance', From bbce738523275eecd7f3850ee5d453ac545098c3 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 14 May 2023 08:42:30 +0200 Subject: [PATCH 02/19] Improve tests around timezone --- tests/plugins/test_protections.py | 10 +++++----- tests/rpc/test_rpc.py | 5 ++--- tests/rpc/test_rpc_apiserver.py | 4 ++-- tests/rpc/test_rpc_telegram.py | 15 ++++++++------- tests/strategy/test_default_strategy.py | 6 +++--- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/plugins/test_protections.py b/tests/plugins/test_protections.py index 5e6128c73..8fe8cec6b 100644 --- a/tests/plugins/test_protections.py +++ b/tests/plugins/test_protections.py @@ -1,5 +1,5 @@ import random -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone import pytest @@ -24,8 +24,8 @@ def generate_mock_trade(pair: str, fee: float, is_open: bool, stake_amount=0.01, fee_open=fee, fee_close=fee, - open_date=datetime.utcnow() - timedelta(minutes=min_ago_open or 200), - close_date=datetime.utcnow() - timedelta(minutes=min_ago_close or 30), + open_date=datetime.now(timezone.utc) - timedelta(minutes=min_ago_open or 200), + close_date=datetime.now(timezone.utc) - timedelta(minutes=min_ago_close or 30), open_rate=open_rate, is_open=is_open, amount=0.01 / open_rate, @@ -87,9 +87,9 @@ def test_protectionmanager(mocker, default_conf): for handler in freqtrade.protections._protection_handlers: assert handler.name in constants.AVAILABLE_PROTECTIONS if not handler.has_global_stop: - assert handler.global_stop(datetime.utcnow(), '*') is None + assert handler.global_stop(datetime.now(timezone.utc), '*') is None if not handler.has_local_stop: - assert handler.stop_per_pair('XRP/BTC', datetime.utcnow(), '*') is None + assert handler.stop_per_pair('XRP/BTC', datetime.now(timezone.utc), '*') is None @pytest.mark.parametrize('timeframe,expected,protconf', [ diff --git a/tests/rpc/test_rpc.py b/tests/rpc/test_rpc.py index bb84ff8e9..87b2475ca 100644 --- a/tests/rpc/test_rpc.py +++ b/tests/rpc/test_rpc.py @@ -261,8 +261,7 @@ def test_rpc_status_table(default_conf, ticker, fee, mocker) -> None: assert isnan(fiat_profit_sum) -def test__rpc_timeunit_profit(default_conf_usdt, ticker, fee, - limit_buy_order, limit_sell_order, markets, mocker) -> None: +def test__rpc_timeunit_profit(default_conf_usdt, ticker, fee, markets, mocker) -> None: mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock()) mocker.patch.multiple( EXMS, @@ -295,7 +294,7 @@ def test__rpc_timeunit_profit(default_conf_usdt, ticker, fee, assert day['starting_balance'] in (pytest.approx(1062.37), pytest.approx(1066.46)) assert day['fiat_value'] in (0.0, ) # ensure first day is current date - assert str(days['data'][0]['date']) == str(datetime.utcnow().date()) + assert str(days['data'][0]['date']) == str(datetime.now(timezone.utc).date()) # Try invalid data with pytest.raises(RPCException, match=r'.*must be an integer greater than 0*'): diff --git a/tests/rpc/test_rpc_apiserver.py b/tests/rpc/test_rpc_apiserver.py index 51fddbb88..78e713391 100644 --- a/tests/rpc/test_rpc_apiserver.py +++ b/tests/rpc/test_rpc_apiserver.py @@ -601,7 +601,7 @@ def test_api_daily(botclient, mocker, ticker, fee, markets): assert len(rc.json()['data']) == 7 assert rc.json()['stake_currency'] == 'BTC' assert rc.json()['fiat_display_currency'] == 'USD' - assert rc.json()['data'][0]['date'] == str(datetime.utcnow().date()) + assert rc.json()['data'][0]['date'] == str(datetime.now(timezone.utc).date()) @pytest.mark.parametrize('is_short', [True, False]) @@ -1224,7 +1224,7 @@ def test_api_force_entry(botclient, mocker, fee, endpoint): stake_amount=1, open_rate=0.245441, open_order_id="123456", - open_date=datetime.utcnow(), + open_date=datetime.now(timezone.utc), is_open=False, is_short=False, fee_close=fee.return_value, diff --git a/tests/rpc/test_rpc_telegram.py b/tests/rpc/test_rpc_telegram.py index 02e829b64..0d8c98d29 100644 --- a/tests/rpc/test_rpc_telegram.py +++ b/tests/rpc/test_rpc_telegram.py @@ -52,7 +52,7 @@ def default_conf(default_conf) -> dict: @pytest.fixture def update(): - message = Message(0, datetime.utcnow(), Chat(0, 0)) + message = Message(0, datetime.now(timezone.utc), Chat(0, 0)) _update = Update(0, message=message) return _update @@ -213,7 +213,7 @@ async def test_authorized_only_unauthorized(default_conf, mocker, caplog) -> Non patch_exchange(mocker) caplog.set_level(logging.DEBUG) chat = Chat(0xdeadbeef, 0) - message = Message(randint(1, 100), datetime.utcnow(), chat) + message = Message(randint(1, 100), datetime.now(timezone.utc), chat) update = Update(randint(1, 100), message=message) default_conf['telegram']['enabled'] = False @@ -520,7 +520,7 @@ async def test_daily_handle(default_conf_usdt, update, ticker, fee, mocker, time assert msg_mock.call_count == 1 assert "Daily Profit over the last 2 days:" in msg_mock.call_args_list[0][0][0] assert 'Day ' in msg_mock.call_args_list[0][0][0] - assert str(datetime.utcnow().date()) in msg_mock.call_args_list[0][0][0] + assert str(datetime.now(timezone.utc).date()) in msg_mock.call_args_list[0][0][0] assert ' 6.83 USDT' in msg_mock.call_args_list[0][0][0] assert ' 7.51 USD' in msg_mock.call_args_list[0][0][0] assert '(2)' in msg_mock.call_args_list[0][0][0] @@ -533,8 +533,9 @@ async def test_daily_handle(default_conf_usdt, update, ticker, fee, mocker, time await telegram._daily(update=update, context=context) assert msg_mock.call_count == 1 assert "Daily Profit over the last 7 days:" in msg_mock.call_args_list[0][0][0] - assert str(datetime.utcnow().date()) in msg_mock.call_args_list[0][0][0] - assert str((datetime.utcnow() - timedelta(days=5)).date()) in msg_mock.call_args_list[0][0][0] + assert str(datetime.now(timezone.utc).date()) in msg_mock.call_args_list[0][0][0] + assert str((datetime.now(timezone.utc) - timedelta(days=5)).date() + ) in msg_mock.call_args_list[0][0][0] assert ' 6.83 USDT' in msg_mock.call_args_list[0][0][0] assert ' 7.51 USD' in msg_mock.call_args_list[0][0][0] assert '(2)' in msg_mock.call_args_list[0][0][0] @@ -608,7 +609,7 @@ async def test_weekly_handle(default_conf_usdt, update, ticker, fee, mocker, tim assert "Weekly Profit over the last 2 weeks (starting from Monday):" \ in msg_mock.call_args_list[0][0][0] assert 'Monday ' in msg_mock.call_args_list[0][0][0] - today = datetime.utcnow().date() + today = datetime.now(timezone.utc).date() first_iso_day_of_current_week = today - timedelta(days=today.weekday()) assert str(first_iso_day_of_current_week) in msg_mock.call_args_list[0][0][0] assert ' 2.74 USDT' in msg_mock.call_args_list[0][0][0] @@ -677,7 +678,7 @@ async def test_monthly_handle(default_conf_usdt, update, ticker, fee, mocker, ti assert msg_mock.call_count == 1 assert 'Monthly Profit over the last 2 months:' in msg_mock.call_args_list[0][0][0] assert 'Month ' in msg_mock.call_args_list[0][0][0] - today = datetime.utcnow().date() + today = datetime.now(timezone.utc).date() current_month = f"{today.year}-{today.month:02} " assert current_month in msg_mock.call_args_list[0][0][0] assert ' 2.74 USDT' in msg_mock.call_args_list[0][0][0] diff --git a/tests/strategy/test_default_strategy.py b/tests/strategy/test_default_strategy.py index cb3d61e89..5f41177eb 100644 --- a/tests/strategy/test_default_strategy.py +++ b/tests/strategy/test_default_strategy.py @@ -1,4 +1,4 @@ -from datetime import datetime +from datetime import datetime, timezone import pytest from pandas import DataFrame @@ -43,12 +43,12 @@ def test_strategy_test_v3(dataframe_1m, fee, is_short, side): assert strategy.confirm_trade_entry(pair='ETH/BTC', order_type='limit', amount=0.1, rate=20000, time_in_force='gtc', - current_time=datetime.utcnow(), + current_time=datetime.now(timezone.utc), side=side, entry_tag=None) is True assert strategy.confirm_trade_exit(pair='ETH/BTC', trade=trade, order_type='limit', amount=0.1, rate=20000, time_in_force='gtc', exit_reason='roi', sell_reason='roi', - current_time=datetime.utcnow(), + current_time=datetime.now(timezone.utc), side=side) is True assert strategy.custom_stoploss(pair='ETH/BTC', trade=trade, current_time=datetime.now(), From af8fbad2814ff38a957eed5e07bda1a8a42e91b9 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 14 May 2023 08:54:26 +0200 Subject: [PATCH 03/19] Improve Date timezone useage --- freqtrade/freqtradebot.py | 6 +++--- freqtrade/persistence/trade_model.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index d068ef6e3..ef480a8e2 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -1018,7 +1018,7 @@ class FreqtradeBot(LoggingMixin): 'base_currency': self.exchange.get_pair_base_currency(trade.pair), 'fiat_currency': self.config.get('fiat_display_currency', None), 'amount': order.safe_amount_after_fee if fill else (order.amount or trade.amount), - 'open_date': trade.open_date or datetime.now(timezone.utc), + 'open_date': trade.open_date_utc or datetime.now(timezone.utc), 'current_rate': current_rate, 'sub_trade': sub_trade, } @@ -1741,8 +1741,8 @@ class FreqtradeBot(LoggingMixin): 'enter_tag': trade.enter_tag, 'sell_reason': trade.exit_reason, # Deprecated 'exit_reason': trade.exit_reason, - 'open_date': trade.open_date, - 'close_date': trade.close_date or datetime.now(timezone.utc), + 'open_date': trade.open_date_utc, + 'close_date': trade.close_date_utc or datetime.now(timezone.utc), 'stake_amount': trade.stake_amount, 'stake_currency': self.config['stake_currency'], 'base_currency': self.exchange.get_pair_base_currency(trade.pair), diff --git a/freqtrade/persistence/trade_model.py b/freqtrade/persistence/trade_model.py index cff2c37f0..cc72e2bf0 100644 --- a/freqtrade/persistence/trade_model.py +++ b/freqtrade/persistence/trade_model.py @@ -425,7 +425,7 @@ class LocalTrade(): @property def close_date_utc(self): - return self.close_date.replace(tzinfo=timezone.utc) + return self.close_date.replace(tzinfo=timezone.utc) if self.close_date else None @property def entry_side(self) -> str: From 675ab840f2dbfbf31551762074343dadddf855c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 03:56:38 +0000 Subject: [PATCH 04/19] Bump mypy from 1.2.0 to 1.3.0 Bumps [mypy](https://github.com/python/mypy) from 1.2.0 to 1.3.0. - [Commits](https://github.com/python/mypy/compare/v1.2.0...v1.3.0) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index c03063e1a..655159a99 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -8,7 +8,7 @@ coveralls==3.3.1 ruff==0.0.265 -mypy==1.2.0 +mypy==1.3.0 pre-commit==3.3.1 pytest==7.3.1 pytest-asyncio==0.21.0 From b0e7b43958d0016e86390821eb7657579cd0012f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 03:56:45 +0000 Subject: [PATCH 05/19] Bump ccxt from 3.0.97 to 3.0.103 Bumps [ccxt](https://github.com/ccxt/ccxt) from 3.0.97 to 3.0.103. - [Changelog](https://github.com/ccxt/ccxt/blob/master/CHANGELOG.md) - [Commits](https://github.com/ccxt/ccxt/compare/3.0.97...3.0.103) --- updated-dependencies: - dependency-name: ccxt dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 448bf1fc4..3336a2898 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ numpy==1.24.3 pandas==2.0.1 pandas-ta==0.3.14b -ccxt==3.0.97 +ccxt==3.0.103 cryptography==40.0.2 aiohttp==3.8.4 SQLAlchemy==2.0.12 From 5f01b823da35d14e4bf07613cd2a8aedaf80c315 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 03:56:55 +0000 Subject: [PATCH 06/19] Bump mkdocs-material from 9.1.10 to 9.1.12 Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 9.1.10 to 9.1.12. - [Release notes](https://github.com/squidfunk/mkdocs-material/releases) - [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG) - [Commits](https://github.com/squidfunk/mkdocs-material/compare/9.1.10...9.1.12) --- updated-dependencies: - dependency-name: mkdocs-material dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- docs/requirements-docs.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements-docs.txt b/docs/requirements-docs.txt index de2050335..0d0a25994 100644 --- a/docs/requirements-docs.txt +++ b/docs/requirements-docs.txt @@ -1,6 +1,6 @@ markdown==3.3.7 mkdocs==1.4.3 -mkdocs-material==9.1.10 +mkdocs-material==9.1.12 mdx_truly_sane_lists==1.3 pymdown-extensions==9.11 jinja2==3.1.2 From f21a7a25d28d105c8e9546f776f0463860124c42 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 03:57:21 +0000 Subject: [PATCH 07/19] Bump types-python-dateutil from 2.8.19.12 to 2.8.19.13 Bumps [types-python-dateutil](https://github.com/python/typeshed) from 2.8.19.12 to 2.8.19.13. - [Commits](https://github.com/python/typeshed/commits) --- updated-dependencies: - dependency-name: types-python-dateutil dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index c03063e1a..1f71e001e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -27,4 +27,4 @@ types-cachetools==5.3.0.5 types-filelock==3.2.7 types-requests==2.30.0.0 types-tabulate==0.9.0.2 -types-python-dateutil==2.8.19.12 +types-python-dateutil==2.8.19.13 From 33a0ed67df0c0d939d6d889fd9ece1b46b484100 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 03:57:33 +0000 Subject: [PATCH 08/19] Bump pyjwt from 2.6.0 to 2.7.0 Bumps [pyjwt](https://github.com/jpadilla/pyjwt) from 2.6.0 to 2.7.0. - [Release notes](https://github.com/jpadilla/pyjwt/releases) - [Changelog](https://github.com/jpadilla/pyjwt/blob/master/CHANGELOG.rst) - [Commits](https://github.com/jpadilla/pyjwt/compare/2.6.0...2.7.0) --- updated-dependencies: - dependency-name: pyjwt dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 448bf1fc4..46052de15 100644 --- a/requirements.txt +++ b/requirements.txt @@ -40,7 +40,7 @@ sdnotify==0.3.2 fastapi==0.95.1 pydantic==1.10.7 uvicorn==0.22.0 -pyjwt==2.6.0 +pyjwt==2.7.0 aiofiles==23.1.0 psutil==5.9.5 From acdd50aadabbfde00cd2a8807675792ac9c2a085 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 03:57:51 +0000 Subject: [PATCH 09/19] Bump torch from 2.0.0 to 2.0.1 Bumps [torch](https://github.com/pytorch/pytorch) from 2.0.0 to 2.0.1. - [Release notes](https://github.com/pytorch/pytorch/releases) - [Changelog](https://github.com/pytorch/pytorch/blob/main/RELEASE.md) - [Commits](https://github.com/pytorch/pytorch/compare/v2.0.0...v2.0.1) --- updated-dependencies: - dependency-name: torch dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements-freqai-rl.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-freqai-rl.txt b/requirements-freqai-rl.txt index 46703b255..535d10f4b 100644 --- a/requirements-freqai-rl.txt +++ b/requirements-freqai-rl.txt @@ -2,7 +2,7 @@ -r requirements-freqai.txt # Required for freqai-rl -torch==2.0.0 +torch==2.0.1 #until these branches will be released we can use this gymnasium==0.28.1 stable_baselines3==2.0.0a5 From dd762453931b9afdab226b5fe2e5e7fbbc7dfbef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 04:31:22 +0000 Subject: [PATCH 10/19] Bump ruff from 0.0.265 to 0.0.267 Bumps [ruff](https://github.com/charliermarsh/ruff) from 0.0.265 to 0.0.267. - [Release notes](https://github.com/charliermarsh/ruff/releases) - [Changelog](https://github.com/charliermarsh/ruff/blob/main/BREAKING_CHANGES.md) - [Commits](https://github.com/charliermarsh/ruff/compare/v0.0.265...v0.0.267) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 655159a99..b8c50bb25 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -7,7 +7,7 @@ -r docs/requirements-docs.txt coveralls==3.3.1 -ruff==0.0.265 +ruff==0.0.267 mypy==1.3.0 pre-commit==3.3.1 pytest==7.3.1 From 0ea47118e187c3ea98ffb54f4c81bf5d3cc2298f Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 14 May 2023 09:18:14 +0200 Subject: [PATCH 11/19] Create test Utils package --- tests/{exchange => utils}/test_ccxt_precise.py | 0 tests/{ => utils}/test_periodiccache.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/{exchange => utils}/test_ccxt_precise.py (100%) rename tests/{ => utils}/test_periodiccache.py (100%) diff --git a/tests/exchange/test_ccxt_precise.py b/tests/utils/test_ccxt_precise.py similarity index 100% rename from tests/exchange/test_ccxt_precise.py rename to tests/utils/test_ccxt_precise.py diff --git a/tests/test_periodiccache.py b/tests/utils/test_periodiccache.py similarity index 100% rename from tests/test_periodiccache.py rename to tests/utils/test_periodiccache.py From 28905885e5bbae03d53d5849825eee025825a414 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 06:18:13 +0000 Subject: [PATCH 12/19] Bump sqlalchemy from 2.0.12 to 2.0.13 Bumps [sqlalchemy](https://github.com/sqlalchemy/sqlalchemy) from 2.0.12 to 2.0.13. - [Release notes](https://github.com/sqlalchemy/sqlalchemy/releases) - [Changelog](https://github.com/sqlalchemy/sqlalchemy/blob/main/CHANGES.rst) - [Commits](https://github.com/sqlalchemy/sqlalchemy/commits) --- updated-dependencies: - dependency-name: sqlalchemy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0c8f8f839..a3f3bd947 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ pandas-ta==0.3.14b ccxt==3.0.103 cryptography==40.0.2 aiohttp==3.8.4 -SQLAlchemy==2.0.12 +SQLAlchemy==2.0.13 python-telegram-bot==20.3 # can't be hard-pinned due to telegram-bot pinning httpx with ~ httpx>=0.23.3 From ef15b7b3d80ce72f51f02ea2a22a909144928292 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 15 May 2023 08:42:28 +0200 Subject: [PATCH 13/19] pre-commit dateutil types --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6c3b99de8..8544bfa56 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: - types-filelock==3.2.7 - types-requests==2.30.0.0 - types-tabulate==0.9.0.2 - - types-python-dateutil==2.8.19.12 + - types-python-dateutil==2.8.19.13 - SQLAlchemy==2.0.12 # stages: [push] From 3a0e123c67671f45891bef570b3a426b77078f4a Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 15 May 2023 09:39:55 +0200 Subject: [PATCH 14/19] Bump pre-commit sqlalchemy --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6c3b99de8..857d730c9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: - types-requests==2.30.0.0 - types-tabulate==0.9.0.2 - types-python-dateutil==2.8.19.12 - - SQLAlchemy==2.0.12 + - SQLAlchemy==2.0.13 # stages: [push] - repo: https://github.com/pycqa/isort From 1b714fdb00d0ec4948c1ab4c704168e57b7d21fe Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 15 May 2023 18:06:17 +0200 Subject: [PATCH 15/19] Fix wrong "first trade" date in UI, improve interface closes https://github.com/freqtrade/freqtrade-strategies/issues/301 --- freqtrade/rpc/api_server/api_schemas.py | 2 ++ freqtrade/rpc/rpc.py | 10 ++++++---- freqtrade/rpc/telegram.py | 4 ++-- tests/rpc/test_rpc.py | 8 ++++---- tests/rpc/test_rpc_apiserver.py | 4 +++- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/freqtrade/rpc/api_server/api_schemas.py b/freqtrade/rpc/api_server/api_schemas.py index dd5ca3a62..a081f9fe9 100644 --- a/freqtrade/rpc/api_server/api_schemas.py +++ b/freqtrade/rpc/api_server/api_schemas.py @@ -100,8 +100,10 @@ class Profit(BaseModel): trade_count: int closed_trade_count: int first_trade_date: str + first_trade_humanized: str first_trade_timestamp: int latest_trade_date: str + latest_trade_humanized: str latest_trade_timestamp: int avg_duration: str best_pair: str diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index 4a67adf29..2e256ee98 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -540,8 +540,8 @@ class RPC: fiat_display_currency ) if self._fiat_converter else 0 - first_date = trades[0].open_date if trades else None - last_date = trades[-1].open_date if trades else None + first_date = trades[0].open_date_utc if trades else None + last_date = trades[-1].open_date_utc if trades else None num = float(len(durations) or 1) bot_start = KeyValueStore.get_datetime_value(KeyStoreKeys.BOT_START_TIME) return { @@ -563,9 +563,11 @@ class RPC: 'profit_all_fiat': profit_all_fiat, 'trade_count': len(trades), 'closed_trade_count': len([t for t in trades if not t.is_open]), - 'first_trade_date': arrow.get(first_date).humanize() if first_date else '', + 'first_trade_date': first_date.strftime(DATETIME_PRINT_FORMAT) if first_date else '', + 'first_trade_humanized': arrow.get(first_date).humanize() if first_date else '', 'first_trade_timestamp': int(first_date.timestamp() * 1000) if first_date else 0, - 'latest_trade_date': arrow.get(last_date).humanize() if last_date else '', + 'latest_trade_date': last_date.strftime(DATETIME_PRINT_FORMAT) if last_date else '', + 'latest_trade_humanized': arrow.get(last_date).humanize() if last_date else '', 'latest_trade_timestamp': int(last_date.timestamp() * 1000) if last_date else 0, 'avg_duration': str(timedelta(seconds=sum(durations) / num)).split('.')[0], 'best_pair': best_pair[0] if best_pair else '', diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index a5b948f69..9ecc2b677 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -853,8 +853,8 @@ class Telegram(RPCHandler): profit_all_percent = stats['profit_all_percent'] profit_all_fiat = stats['profit_all_fiat'] trade_count = stats['trade_count'] - first_trade_date = stats['first_trade_date'] - latest_trade_date = stats['latest_trade_date'] + first_trade_date = f"{stats['first_trade_humanized']} ({stats['first_trade_date']})" + latest_trade_date = f"{stats['latest_trade_humanized']} ({stats['latest_trade_date']})" avg_duration = stats['avg_duration'] best_pair = stats['best_pair'] best_pair_profit_ratio = stats['best_pair_profit_ratio'] diff --git a/tests/rpc/test_rpc.py b/tests/rpc/test_rpc.py index 87b2475ca..405727d8c 100644 --- a/tests/rpc/test_rpc.py +++ b/tests/rpc/test_rpc.py @@ -414,8 +414,8 @@ def test_rpc_trade_statistics(default_conf_usdt, ticker, fee, mocker) -> None: assert pytest.approx(stats['profit_all_percent_mean']) == -57.86 assert pytest.approx(stats['profit_all_fiat']) == -85.205614098 assert stats['trade_count'] == 7 - assert stats['first_trade_date'] == '2 days ago' - assert stats['latest_trade_date'] == '17 minutes ago' + assert stats['first_trade_humanized'] == '2 days ago' + assert stats['latest_trade_humanized'] == '17 minutes ago' assert stats['avg_duration'] in ('0:17:40') assert stats['best_pair'] == 'XRP/USDT' assert stats['best_rate'] == 10.0 @@ -425,8 +425,8 @@ def test_rpc_trade_statistics(default_conf_usdt, ticker, fee, mocker) -> None: MagicMock(side_effect=ExchangeError("Pair 'XRP/USDT' not available"))) stats = rpc._rpc_trade_statistics(stake_currency, fiat_display_currency) assert stats['trade_count'] == 7 - assert stats['first_trade_date'] == '2 days ago' - assert stats['latest_trade_date'] == '17 minutes ago' + assert stats['first_trade_humanized'] == '2 days ago' + assert stats['latest_trade_humanized'] == '17 minutes ago' assert stats['avg_duration'] in ('0:17:40') assert stats['best_pair'] == 'XRP/USDT' assert stats['best_rate'] == 10.0 diff --git a/tests/rpc/test_rpc_apiserver.py b/tests/rpc/test_rpc_apiserver.py index 78e713391..44d70e318 100644 --- a/tests/rpc/test_rpc_apiserver.py +++ b/tests/rpc/test_rpc_apiserver.py @@ -888,8 +888,10 @@ def test_api_profit(botclient, mocker, ticker, fee, markets, is_short, expected) 'best_pair_profit_ratio': expected['best_pair_profit_ratio'], 'best_rate': expected['best_rate'], 'first_trade_date': ANY, + 'first_trade_humanized': ANY, 'first_trade_timestamp': ANY, - 'latest_trade_date': '5 minutes ago', + 'latest_trade_date': ANY, + 'latest_trade_humanized': '5 minutes ago', 'latest_trade_timestamp': ANY, 'profit_all_coin': pytest.approx(expected['profit_all_coin']), 'profit_all_fiat': pytest.approx(expected['profit_all_fiat']), From 61ea3d817aa89b73fc7f7b53f52af4aa7461c07d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 May 2023 07:45:08 +0000 Subject: [PATCH 16/19] Bump pymdown-extensions from 9.11 to 10.0 in /docs Bumps [pymdown-extensions](https://github.com/facelessuser/pymdown-extensions) from 9.11 to 10.0. - [Release notes](https://github.com/facelessuser/pymdown-extensions/releases) - [Commits](https://github.com/facelessuser/pymdown-extensions/compare/9.11...10.0) --- updated-dependencies: - dependency-name: pymdown-extensions dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- docs/requirements-docs.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements-docs.txt b/docs/requirements-docs.txt index 0d0a25994..5eca0cc5b 100644 --- a/docs/requirements-docs.txt +++ b/docs/requirements-docs.txt @@ -2,5 +2,5 @@ markdown==3.3.7 mkdocs==1.4.3 mkdocs-material==9.1.12 mdx_truly_sane_lists==1.3 -pymdown-extensions==9.11 +pymdown-extensions==10.0 jinja2==3.1.2 From bb760a47d54178da113af80dbd356342787c4ae8 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 16 May 2023 10:15:46 +0200 Subject: [PATCH 17/19] Bump pymdown-extensions to 10.0.1 --- docs/requirements-docs.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements-docs.txt b/docs/requirements-docs.txt index 5eca0cc5b..f7c0aebe9 100644 --- a/docs/requirements-docs.txt +++ b/docs/requirements-docs.txt @@ -2,5 +2,5 @@ markdown==3.3.7 mkdocs==1.4.3 mkdocs-material==9.1.12 mdx_truly_sane_lists==1.3 -pymdown-extensions==10.0 +pymdown-extensions==10.0.1 jinja2==3.1.2 From 45ee12e25733ce8b1b808606ce59778f595304be Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 16 May 2023 20:27:07 +0200 Subject: [PATCH 18/19] reload_trade should be a post endpoint --- freqtrade/rpc/api_server/api_v1.py | 5 +++-- tests/rpc/test_rpc_apiserver.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/freqtrade/rpc/api_server/api_v1.py b/freqtrade/rpc/api_server/api_v1.py index ccbcbb94f..2354c4bf8 100644 --- a/freqtrade/rpc/api_server/api_v1.py +++ b/freqtrade/rpc/api_server/api_v1.py @@ -45,7 +45,8 @@ logger = logging.getLogger(__name__) # 2.25: Add several profit values to /status endpoint # 2.26: increase /balance output # 2.27: Add /trades//reload endpoint -API_VERSION = 2.27 +# 2.28: Switch reload endpoint to Post +API_VERSION = 2.28 # Public API, requires no auth. router_public = APIRouter() @@ -133,7 +134,7 @@ def trade_cancel_open_order(tradeid: int, rpc: RPC = Depends(get_rpc)): return rpc._rpc_trade_status([tradeid])[0] -@router.get('/trades/{tradeid}/reload', response_model=OpenTradeSchema, tags=['trading']) +@router.post('/trades/{tradeid}/reload', response_model=OpenTradeSchema, tags=['trading']) def trade_reload(tradeid: int, rpc: RPC = Depends(get_rpc)): rpc._rpc_reload_trade_from_exchange(tradeid) return rpc._rpc_trade_status([tradeid])[0] diff --git a/tests/rpc/test_rpc_apiserver.py b/tests/rpc/test_rpc_apiserver.py index 44d70e318..1e76ce557 100644 --- a/tests/rpc/test_rpc_apiserver.py +++ b/tests/rpc/test_rpc_apiserver.py @@ -755,7 +755,7 @@ def test_api_trade_reload_trade(botclient, mocker, fee, markets, ticker, is_shor cancel_stoploss_order=stoploss_mock, ) - rc = client_get(client, f"{BASE_URI}/trades/10/reload") + rc = client_post(client, f"{BASE_URI}/trades/10/reload") assert_response(rc, 502) assert 'Could not find trade with id 10.' in rc.json()['error'] assert ftbot.handle_onexchange_order.call_count == 0 @@ -763,7 +763,7 @@ def test_api_trade_reload_trade(botclient, mocker, fee, markets, ticker, is_shor create_mock_trades(fee, is_short=is_short) Trade.commit() - rc = client_get(client, f"{BASE_URI}/trades/5/reload") + rc = client_post(client, f"{BASE_URI}/trades/5/reload") assert ftbot.handle_onexchange_order.call_count == 1 From 2ab732480f9d3a19b138ca7ac7f3d57cbd197024 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 17 May 2023 06:26:57 +0200 Subject: [PATCH 19/19] Ensure pi image can be built --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index a3f3bd947..5d2f4147c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,8 @@ pandas==2.0.1 pandas-ta==0.3.14b ccxt==3.0.103 -cryptography==40.0.2 +cryptography==40.0.2; platform_machine != 'armv7l' +cryptography==40.0.1; platform_machine == 'armv7l' aiohttp==3.8.4 SQLAlchemy==2.0.13 python-telegram-bot==20.3