diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 74629a630..72d9c5136 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: - types-requests==2.32.0.20250306 - types-tabulate==0.9.0.20241207 - types-python-dateutil==2.9.0.20241206 - - SQLAlchemy==2.0.38 + - SQLAlchemy==2.0.39 # stages: [push] - repo: https://github.com/pycqa/isort diff --git a/README.md b/README.md index 4a0b8121b..e0eaf55a9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ![freqtrade](https://raw.githubusercontent.com/freqtrade/freqtrade/develop/docs/assets/freqtrade_poweredby.svg) -[![Freqtrade CI](https://github.com/freqtrade/freqtrade/workflows/Freqtrade%20CI/badge.svg)](https://github.com/freqtrade/freqtrade/actions/) +[![Freqtrade CI](https://github.com/freqtrade/freqtrade/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/freqtrade/freqtrade/actions/) [![DOI](https://joss.theoj.org/papers/10.21105/joss.04864/status.svg)](https://doi.org/10.21105/joss.04864) [![Coverage Status](https://coveralls.io/repos/github/freqtrade/freqtrade/badge.svg?branch=develop&service=github)](https://coveralls.io/github/freqtrade/freqtrade?branch=develop) [![Documentation](https://readthedocs.org/projects/freqtrade/badge/)](https://www.freqtrade.io) diff --git a/build_helpers/schema.json b/build_helpers/schema.json index 5fb1772c6..1d71184b1 100644 --- a/build_helpers/schema.json +++ b/build_helpers/schema.json @@ -613,6 +613,14 @@ "description": "Telegram topic ID - only applicable for group chats", "type": "string" }, + "authorized_users": { + "description": "Authorized users for the bot.", + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, "allow_custom_messages": { "description": "Allow sending custom messages from the Strategy.", "type": "boolean", @@ -1417,8 +1425,7 @@ }, "fit_live_predictions_candles": { "description": "Number of historical candles to use for computing target (label) statistics from prediction data, instead of from the training dataset.", - "type": "boolean", - "default": false + "type": "integer" }, "data_kitchen_thread_count": { "description": "Designate the number of threads you want to use for data processing (outlier methods, normalization, etc.).", diff --git a/docs/index.md b/docs/index.md index 79c60072d..d05fcc2c1 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,6 +1,6 @@ ![freqtrade](assets/freqtrade_poweredby.svg) -[![Freqtrade CI](https://github.com/freqtrade/freqtrade/workflows/Freqtrade%20CI/badge.svg)](https://github.com/freqtrade/freqtrade/actions/) +[![Freqtrade CI](https://github.com/freqtrade/freqtrade/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/freqtrade/freqtrade/actions/) [![DOI](https://joss.theoj.org/papers/10.21105/joss.04864/status.svg)](https://doi.org/10.21105/joss.04864) [![Coverage Status](https://coveralls.io/repos/github/freqtrade/freqtrade/badge.svg?branch=develop&service=github)](https://coveralls.io/github/freqtrade/freqtrade?branch=develop) [![Maintainability](https://api.codeclimate.com/v1/badges/5737e6d668200b7518ff/maintainability)](https://codeclimate.com/github/freqtrade/freqtrade/maintainability) diff --git a/docs/requirements-docs.txt b/docs/requirements-docs.txt index 60e6666ba..1b019c5a2 100644 --- a/docs/requirements-docs.txt +++ b/docs/requirements-docs.txt @@ -1,6 +1,6 @@ markdown==3.7 mkdocs==1.6.1 -mkdocs-material==9.6.7 +mkdocs-material==9.6.8 mdx_truly_sane_lists==1.3 pymdown-extensions==10.14.3 jinja2==3.1.6 diff --git a/docs/telegram-usage.md b/docs/telegram-usage.md index 946686b1c..c7c434140 100644 --- a/docs/telegram-usage.md +++ b/docs/telegram-usage.md @@ -81,6 +81,19 @@ Without this, the bot will always respond to the general channel in the group if Similar to the group-id - you can use `/tg_info` from the topic/thread to get the correct topic-id. +#### Authorized users + +For groups, it can be useful to limit who can send commands to the bot. + +If `"authorized_users": []` is present and empty, no user will be allowed to control the bot. +In the below example, only the user with the id "1234567" is allowed to control the bot - all other users will only be able to receive messages. + +```json + "chat_id": "-1001332619709", + "topic_id": "3", + "authorized_users": ["1234567"] +``` + ## Control telegram noise Freqtrade provides means to control the verbosity of your telegram bot. diff --git a/freqtrade/configuration/config_schema.py b/freqtrade/configuration/config_schema.py index f50334938..0ef37027d 100644 --- a/freqtrade/configuration/config_schema.py +++ b/freqtrade/configuration/config_schema.py @@ -471,6 +471,12 @@ CONF_SCHEMA = { "description": "Telegram topic ID - only applicable for group chats", "type": "string", }, + "authorized_users": { + "description": "Authorized users for the bot.", + "type": "array", + "items": {"type": "string"}, + "uniqueItems": True, + }, "allow_custom_messages": { "description": "Allow sending custom messages from the Strategy.", "type": "boolean", @@ -1026,8 +1032,7 @@ CONF_SCHEMA = { "Number of historical candles to use for computing target (label) " "statistics from prediction data, instead of from the training dataset." ), - "type": "boolean", - "default": False, + "type": "integer", }, "data_kitchen_thread_count": { "description": ( diff --git a/freqtrade/exchange/binance_leverage_tiers.json b/freqtrade/exchange/binance_leverage_tiers.json index 093a54176..0f11869ca 100644 --- a/freqtrade/exchange/binance_leverage_tiers.json +++ b/freqtrade/exchange/binance_leverage_tiers.json @@ -3496,6 +3496,161 @@ } } ], + "ADA/USDC:USDC": [ + { + "tier": 1.0, + "symbol": "ADA/USDC:USDC", + "currency": "USDC", + "minNotional": 0.0, + "maxNotional": 10000.0, + "maintenanceMarginRate": 0.01, + "maxLeverage": 25.0, + "info": { + "bracket": "1", + "initialLeverage": "25", + "notionalCap": "10000", + "notionalFloor": "0", + "maintMarginRatio": "0.01", + "cum": "0.0" + } + }, + { + "tier": 2.0, + "symbol": "ADA/USDC:USDC", + "currency": "USDC", + "minNotional": 10000.0, + "maxNotional": 20000.0, + "maintenanceMarginRate": 0.015, + "maxLeverage": 20.0, + "info": { + "bracket": "2", + "initialLeverage": "20", + "notionalCap": "20000", + "notionalFloor": "10000", + "maintMarginRatio": "0.015", + "cum": "50.0" + } + }, + { + "tier": 3.0, + "symbol": "ADA/USDC:USDC", + "currency": "USDC", + "minNotional": 20000.0, + "maxNotional": 60000.0, + "maintenanceMarginRate": 0.02, + "maxLeverage": 15.0, + "info": { + "bracket": "3", + "initialLeverage": "15", + "notionalCap": "60000", + "notionalFloor": "20000", + "maintMarginRatio": "0.02", + "cum": "150.0" + } + }, + { + "tier": 4.0, + "symbol": "ADA/USDC:USDC", + "currency": "USDC", + "minNotional": 60000.0, + "maxNotional": 120000.0, + "maintenanceMarginRate": 0.025, + "maxLeverage": 10.0, + "info": { + "bracket": "4", + "initialLeverage": "10", + "notionalCap": "120000", + "notionalFloor": "60000", + "maintMarginRatio": "0.025", + "cum": "450.0" + } + }, + { + "tier": 5.0, + "symbol": "ADA/USDC:USDC", + "currency": "USDC", + "minNotional": 120000.0, + "maxNotional": 600000.0, + "maintenanceMarginRate": 0.05, + "maxLeverage": 8.0, + "info": { + "bracket": "5", + "initialLeverage": "8", + "notionalCap": "600000", + "notionalFloor": "120000", + "maintMarginRatio": "0.05", + "cum": "3450.0" + } + }, + { + "tier": 6.0, + "symbol": "ADA/USDC:USDC", + "currency": "USDC", + "minNotional": 600000.0, + "maxNotional": 1200000.0, + "maintenanceMarginRate": 0.1, + "maxLeverage": 5.0, + "info": { + "bracket": "6", + "initialLeverage": "5", + "notionalCap": "1200000", + "notionalFloor": "600000", + "maintMarginRatio": "0.1", + "cum": "33450.0" + } + }, + { + "tier": 7.0, + "symbol": "ADA/USDC:USDC", + "currency": "USDC", + "minNotional": 1200000.0, + "maxNotional": 1500000.0, + "maintenanceMarginRate": 0.125, + "maxLeverage": 4.0, + "info": { + "bracket": "7", + "initialLeverage": "4", + "notionalCap": "1500000", + "notionalFloor": "1200000", + "maintMarginRatio": "0.125", + "cum": "63450.0" + } + }, + { + "tier": 8.0, + "symbol": "ADA/USDC:USDC", + "currency": "USDC", + "minNotional": 1500000.0, + "maxNotional": 3000000.0, + "maintenanceMarginRate": 0.25, + "maxLeverage": 2.0, + "info": { + "bracket": "8", + "initialLeverage": "2", + "notionalCap": "3000000", + "notionalFloor": "1500000", + "maintMarginRatio": "0.25", + "cum": "250950.0" + } + }, + { + "tier": 9.0, + "symbol": "ADA/USDC:USDC", + "currency": "USDC", + "minNotional": 3000000.0, + "maxNotional": 6000000.0, + "maintenanceMarginRate": 0.5, + "maxLeverage": 1.0, + "info": { + "bracket": "9", + "initialLeverage": "1", + "notionalCap": "6000000", + "notionalFloor": "3000000", + "maintMarginRatio": "0.5", + "cum": "1000950.0" + } + } + ], "ADA/USDT:USDT": [ { "tier": 1.0, @@ -9086,15 +9241,15 @@ "symbol": "AXS/USDT:USDT", "currency": "USDT", "minNotional": 0.0, - "maxNotional": 5000.0, - "maintenanceMarginRate": 0.006, + "maxNotional": 20000.0, + "maintenanceMarginRate": 0.007, "maxLeverage": 50.0, "info": { "bracket": "1", "initialLeverage": "50", - "notionalCap": "5000", + "notionalCap": "20000", "notionalFloor": "0", - "maintMarginRatio": "0.006", + "maintMarginRatio": "0.007", "cum": "0.0" } }, @@ -9102,38 +9257,21 @@ "tier": 2.0, "symbol": "AXS/USDT:USDT", "currency": "USDT", - "minNotional": 5000.0, - "maxNotional": 25000.0, - "maintenanceMarginRate": 0.007, - "maxLeverage": 30.0, - "info": { - "bracket": "2", - "initialLeverage": "30", - "notionalCap": "25000", - "notionalFloor": "5000", - "maintMarginRatio": "0.007", - "cum": "5.0" - } - }, - { - "tier": 3.0, - "symbol": "AXS/USDT:USDT", - "currency": "USDT", - "minNotional": 25000.0, + "minNotional": 20000.0, "maxNotional": 400000.0, "maintenanceMarginRate": 0.01, "maxLeverage": 25.0, "info": { - "bracket": "3", + "bracket": "2", "initialLeverage": "25", "notionalCap": "400000", - "notionalFloor": "25000", + "notionalFloor": "20000", "maintMarginRatio": "0.01", - "cum": "80.0" + "cum": "60.0" } }, { - "tier": 4.0, + "tier": 3.0, "symbol": "AXS/USDT:USDT", "currency": "USDT", "minNotional": 400000.0, @@ -9141,16 +9279,16 @@ "maintenanceMarginRate": 0.02, "maxLeverage": 20.0, "info": { - "bracket": "4", + "bracket": "3", "initialLeverage": "20", "notionalCap": "600000", "notionalFloor": "400000", "maintMarginRatio": "0.02", - "cum": "4080.0" + "cum": "4060.0" } }, { - "tier": 5.0, + "tier": 4.0, "symbol": "AXS/USDT:USDT", "currency": "USDT", "minNotional": 600000.0, @@ -9158,97 +9296,97 @@ "maintenanceMarginRate": 0.05, "maxLeverage": 10.0, "info": { - "bracket": "5", + "bracket": "4", "initialLeverage": "10", "notionalCap": "1200000", "notionalFloor": "600000", "maintMarginRatio": "0.05", - "cum": "22080.0" + "cum": "22060.0" + } + }, + { + "tier": 5.0, + "symbol": "AXS/USDT:USDT", + "currency": "USDT", + "minNotional": 1200000.0, + "maxNotional": 2000000.0, + "maintenanceMarginRate": 0.1, + "maxLeverage": 5.0, + "info": { + "bracket": "5", + "initialLeverage": "5", + "notionalCap": "2000000", + "notionalFloor": "1200000", + "maintMarginRatio": "0.1", + "cum": "82060.0" } }, { "tier": 6.0, "symbol": "AXS/USDT:USDT", "currency": "USDT", - "minNotional": 1200000.0, - "maxNotional": 3200000.0, - "maintenanceMarginRate": 0.1, - "maxLeverage": 5.0, + "minNotional": 2000000.0, + "maxNotional": 2500000.0, + "maintenanceMarginRate": 0.125, + "maxLeverage": 4.0, "info": { "bracket": "6", - "initialLeverage": "5", - "notionalCap": "3200000", - "notionalFloor": "1200000", - "maintMarginRatio": "0.1", - "cum": "82080.0" + "initialLeverage": "4", + "notionalCap": "2500000", + "notionalFloor": "2000000", + "maintMarginRatio": "0.125", + "cum": "132060.0" } }, { "tier": 7.0, "symbol": "AXS/USDT:USDT", "currency": "USDT", - "minNotional": 3200000.0, - "maxNotional": 5000000.0, - "maintenanceMarginRate": 0.125, - "maxLeverage": 4.0, + "minNotional": 2500000.0, + "maxNotional": 3000000.0, + "maintenanceMarginRate": 0.15, + "maxLeverage": 3.0, "info": { "bracket": "7", - "initialLeverage": "4", - "notionalCap": "5000000", - "notionalFloor": "3200000", - "maintMarginRatio": "0.125", - "cum": "162080.0" + "initialLeverage": "3", + "notionalCap": "3000000", + "notionalFloor": "2500000", + "maintMarginRatio": "0.15", + "cum": "194560.0" } }, { "tier": 8.0, "symbol": "AXS/USDT:USDT", "currency": "USDT", - "minNotional": 5000000.0, - "maxNotional": 10000000.0, - "maintenanceMarginRate": 0.15, - "maxLeverage": 3.0, + "minNotional": 3000000.0, + "maxNotional": 3500000.0, + "maintenanceMarginRate": 0.25, + "maxLeverage": 2.0, "info": { "bracket": "8", - "initialLeverage": "3", - "notionalCap": "10000000", - "notionalFloor": "5000000", - "maintMarginRatio": "0.15", - "cum": "287080.0" + "initialLeverage": "2", + "notionalCap": "3500000", + "notionalFloor": "3000000", + "maintMarginRatio": "0.25", + "cum": "494560.0" } }, { "tier": 9.0, "symbol": "AXS/USDT:USDT", "currency": "USDT", - "minNotional": 10000000.0, - "maxNotional": 15000000.0, - "maintenanceMarginRate": 0.25, - "maxLeverage": 2.0, - "info": { - "bracket": "9", - "initialLeverage": "2", - "notionalCap": "15000000", - "notionalFloor": "10000000", - "maintMarginRatio": "0.25", - "cum": "1287080.0" - } - }, - { - "tier": 10.0, - "symbol": "AXS/USDT:USDT", - "currency": "USDT", - "minNotional": 15000000.0, - "maxNotional": 20000000.0, + "minNotional": 3500000.0, + "maxNotional": 4000000.0, "maintenanceMarginRate": 0.5, "maxLeverage": 1.0, "info": { - "bracket": "10", + "bracket": "9", "initialLeverage": "1", - "notionalCap": "20000000", - "notionalFloor": "15000000", + "notionalCap": "4000000", + "notionalFloor": "3500000", "maintMarginRatio": "0.5", - "cum": "5037080.0" + "cum": "1369560.0" } } ], @@ -14568,13 +14706,13 @@ "symbol": "CATI/USDT:USDT", "currency": "USDT", "minNotional": 300000.0, - "maxNotional": 1500000.0, + "maxNotional": 800000.0, "maintenanceMarginRate": 0.05, "maxLeverage": 10.0, "info": { "bracket": "5", "initialLeverage": "10", - "notionalCap": "1500000", + "notionalCap": "800000", "notionalFloor": "300000", "maintMarginRatio": "0.05", "cum": "8450.0" @@ -14584,68 +14722,68 @@ "tier": 6.0, "symbol": "CATI/USDT:USDT", "currency": "USDT", - "minNotional": 1500000.0, - "maxNotional": 3000000.0, + "minNotional": 800000.0, + "maxNotional": 1000000.0, "maintenanceMarginRate": 0.1, "maxLeverage": 5.0, "info": { "bracket": "6", "initialLeverage": "5", - "notionalCap": "3000000", - "notionalFloor": "1500000", + "notionalCap": "1000000", + "notionalFloor": "800000", "maintMarginRatio": "0.1", - "cum": "83450.0" + "cum": "48450.0" } }, { "tier": 7.0, "symbol": "CATI/USDT:USDT", "currency": "USDT", - "minNotional": 3000000.0, - "maxNotional": 3750000.0, + "minNotional": 1000000.0, + "maxNotional": 1200000.0, "maintenanceMarginRate": 0.125, "maxLeverage": 4.0, "info": { "bracket": "7", "initialLeverage": "4", - "notionalCap": "3750000", - "notionalFloor": "3000000", + "notionalCap": "1200000", + "notionalFloor": "1000000", "maintMarginRatio": "0.125", - "cum": "158450.0" + "cum": "73450.0" } }, { "tier": 8.0, "symbol": "CATI/USDT:USDT", "currency": "USDT", - "minNotional": 3750000.0, - "maxNotional": 7500000.0, + "minNotional": 1200000.0, + "maxNotional": 1500000.0, "maintenanceMarginRate": 0.25, "maxLeverage": 2.0, "info": { "bracket": "8", "initialLeverage": "2", - "notionalCap": "7500000", - "notionalFloor": "3750000", + "notionalCap": "1500000", + "notionalFloor": "1200000", "maintMarginRatio": "0.25", - "cum": "627200.0" + "cum": "223450.0" } }, { "tier": 9.0, "symbol": "CATI/USDT:USDT", "currency": "USDT", - "minNotional": 7500000.0, - "maxNotional": 15000000.0, + "minNotional": 1500000.0, + "maxNotional": 2000000.0, "maintenanceMarginRate": 0.5, "maxLeverage": 1.0, "info": { "bracket": "9", "initialLeverage": "1", - "notionalCap": "15000000", - "notionalFloor": "7500000", + "notionalCap": "2000000", + "notionalFloor": "1500000", "maintMarginRatio": "0.5", - "cum": "2502200.0" + "cum": "598450.0" } } ], @@ -27231,6 +27369,161 @@ } } ], + "HBAR/USDC:USDC": [ + { + "tier": 1.0, + "symbol": "HBAR/USDC:USDC", + "currency": "USDC", + "minNotional": 0.0, + "maxNotional": 5000.0, + "maintenanceMarginRate": 0.01, + "maxLeverage": 25.0, + "info": { + "bracket": "1", + "initialLeverage": "25", + "notionalCap": "5000", + "notionalFloor": "0", + "maintMarginRatio": "0.01", + "cum": "0.0" + } + }, + { + "tier": 2.0, + "symbol": "HBAR/USDC:USDC", + "currency": "USDC", + "minNotional": 5000.0, + "maxNotional": 10000.0, + "maintenanceMarginRate": 0.015, + "maxLeverage": 20.0, + "info": { + "bracket": "2", + "initialLeverage": "20", + "notionalCap": "10000", + "notionalFloor": "5000", + "maintMarginRatio": "0.015", + "cum": "25.0" + } + }, + { + "tier": 3.0, + "symbol": "HBAR/USDC:USDC", + "currency": "USDC", + "minNotional": 10000.0, + "maxNotional": 30000.0, + "maintenanceMarginRate": 0.02, + "maxLeverage": 15.0, + "info": { + "bracket": "3", + "initialLeverage": "15", + "notionalCap": "30000", + "notionalFloor": "10000", + "maintMarginRatio": "0.02", + "cum": "75.0" + } + }, + { + "tier": 4.0, + "symbol": "HBAR/USDC:USDC", + "currency": "USDC", + "minNotional": 30000.0, + "maxNotional": 60000.0, + "maintenanceMarginRate": 0.025, + "maxLeverage": 10.0, + "info": { + "bracket": "4", + "initialLeverage": "10", + "notionalCap": "60000", + "notionalFloor": "30000", + "maintMarginRatio": "0.025", + "cum": "225.0" + } + }, + { + "tier": 5.0, + "symbol": "HBAR/USDC:USDC", + "currency": "USDC", + "minNotional": 60000.0, + "maxNotional": 300000.0, + "maintenanceMarginRate": 0.05, + "maxLeverage": 8.0, + "info": { + "bracket": "5", + "initialLeverage": "8", + "notionalCap": "300000", + "notionalFloor": "60000", + "maintMarginRatio": "0.05", + "cum": "1725.0" + } + }, + { + "tier": 6.0, + "symbol": "HBAR/USDC:USDC", + "currency": "USDC", + "minNotional": 300000.0, + "maxNotional": 600000.0, + "maintenanceMarginRate": 0.1, + "maxLeverage": 5.0, + "info": { + "bracket": "6", + "initialLeverage": "5", + "notionalCap": "600000", + "notionalFloor": "300000", + "maintMarginRatio": "0.1", + "cum": "16725.0" + } + }, + { + "tier": 7.0, + "symbol": "HBAR/USDC:USDC", + "currency": "USDC", + "minNotional": 600000.0, + "maxNotional": 750000.0, + "maintenanceMarginRate": 0.125, + "maxLeverage": 4.0, + "info": { + "bracket": "7", + "initialLeverage": "4", + "notionalCap": "750000", + "notionalFloor": "600000", + "maintMarginRatio": "0.125", + "cum": "31725.0" + } + }, + { + "tier": 8.0, + "symbol": "HBAR/USDC:USDC", + "currency": "USDC", + "minNotional": 750000.0, + "maxNotional": 1500000.0, + "maintenanceMarginRate": 0.25, + "maxLeverage": 2.0, + "info": { + "bracket": "8", + "initialLeverage": "2", + "notionalCap": "1500000", + "notionalFloor": "750000", + "maintMarginRatio": "0.25", + "cum": "125475.0" + } + }, + { + "tier": 9.0, + "symbol": "HBAR/USDC:USDC", + "currency": "USDC", + "minNotional": 1500000.0, + "maxNotional": 3000000.0, + "maintenanceMarginRate": 0.5, + "maxLeverage": 1.0, + "info": { + "bracket": "9", + "initialLeverage": "1", + "notionalCap": "3000000", + "notionalFloor": "1500000", + "maintMarginRatio": "0.5", + "cum": "500475.0" + } + } + ], "HBAR/USDT:USDT": [ { "tier": 1.0, @@ -43422,6 +43715,161 @@ } } ], + "PNUT/USDC:USDC": [ + { + "tier": 1.0, + "symbol": "PNUT/USDC:USDC", + "currency": "USDC", + "minNotional": 0.0, + "maxNotional": 5000.0, + "maintenanceMarginRate": 0.01, + "maxLeverage": 25.0, + "info": { + "bracket": "1", + "initialLeverage": "25", + "notionalCap": "5000", + "notionalFloor": "0", + "maintMarginRatio": "0.01", + "cum": "0.0" + } + }, + { + "tier": 2.0, + "symbol": "PNUT/USDC:USDC", + "currency": "USDC", + "minNotional": 5000.0, + "maxNotional": 10000.0, + "maintenanceMarginRate": 0.015, + "maxLeverage": 20.0, + "info": { + "bracket": "2", + "initialLeverage": "20", + "notionalCap": "10000", + "notionalFloor": "5000", + "maintMarginRatio": "0.015", + "cum": "25.0" + } + }, + { + "tier": 3.0, + "symbol": "PNUT/USDC:USDC", + "currency": "USDC", + "minNotional": 10000.0, + "maxNotional": 30000.0, + "maintenanceMarginRate": 0.02, + "maxLeverage": 15.0, + "info": { + "bracket": "3", + "initialLeverage": "15", + "notionalCap": "30000", + "notionalFloor": "10000", + "maintMarginRatio": "0.02", + "cum": "75.0" + } + }, + { + "tier": 4.0, + "symbol": "PNUT/USDC:USDC", + "currency": "USDC", + "minNotional": 30000.0, + "maxNotional": 60000.0, + "maintenanceMarginRate": 0.025, + "maxLeverage": 10.0, + "info": { + "bracket": "4", + "initialLeverage": "10", + "notionalCap": "60000", + "notionalFloor": "30000", + "maintMarginRatio": "0.025", + "cum": "225.0" + } + }, + { + "tier": 5.0, + "symbol": "PNUT/USDC:USDC", + "currency": "USDC", + "minNotional": 60000.0, + "maxNotional": 300000.0, + "maintenanceMarginRate": 0.05, + "maxLeverage": 8.0, + "info": { + "bracket": "5", + "initialLeverage": "8", + "notionalCap": "300000", + "notionalFloor": "60000", + "maintMarginRatio": "0.05", + "cum": "1725.0" + } + }, + { + "tier": 6.0, + "symbol": "PNUT/USDC:USDC", + "currency": "USDC", + "minNotional": 300000.0, + "maxNotional": 600000.0, + "maintenanceMarginRate": 0.1, + "maxLeverage": 5.0, + "info": { + "bracket": "6", + "initialLeverage": "5", + "notionalCap": "600000", + "notionalFloor": "300000", + "maintMarginRatio": "0.1", + "cum": "16725.0" + } + }, + { + "tier": 7.0, + "symbol": "PNUT/USDC:USDC", + "currency": "USDC", + "minNotional": 600000.0, + "maxNotional": 750000.0, + "maintenanceMarginRate": 0.125, + "maxLeverage": 4.0, + "info": { + "bracket": "7", + "initialLeverage": "4", + "notionalCap": "750000", + "notionalFloor": "600000", + "maintMarginRatio": "0.125", + "cum": "31725.0" + } + }, + { + "tier": 8.0, + "symbol": "PNUT/USDC:USDC", + "currency": "USDC", + "minNotional": 750000.0, + "maxNotional": 1500000.0, + "maintenanceMarginRate": 0.25, + "maxLeverage": 2.0, + "info": { + "bracket": "8", + "initialLeverage": "2", + "notionalCap": "1500000", + "notionalFloor": "750000", + "maintMarginRatio": "0.25", + "cum": "125475.0" + } + }, + { + "tier": 9.0, + "symbol": "PNUT/USDC:USDC", + "currency": "USDC", + "minNotional": 1500000.0, + "maxNotional": 3000000.0, + "maintenanceMarginRate": 0.5, + "maxLeverage": 1.0, + "info": { + "bracket": "9", + "initialLeverage": "1", + "notionalCap": "3000000", + "notionalFloor": "1500000", + "maintMarginRatio": "0.5", + "cum": "500475.0" + } + } + ], "PNUT/USDT:USDT": [ { "tier": 1.0, @@ -45292,10 +45740,10 @@ "minNotional": 0.0, "maxNotional": 10000.0, "maintenanceMarginRate": 0.01, - "maxLeverage": 75.0, + "maxLeverage": 25.0, "info": { "bracket": "1", - "initialLeverage": "75", + "initialLeverage": "25", "notionalCap": "10000", "notionalFloor": "0", "maintMarginRatio": "0.01", @@ -45309,10 +45757,10 @@ "minNotional": 10000.0, "maxNotional": 30000.0, "maintenanceMarginRate": 0.015, - "maxLeverage": 50.0, + "maxLeverage": 20.0, "info": { "bracket": "2", - "initialLeverage": "50", + "initialLeverage": "20", "notionalCap": "30000", "notionalFloor": "10000", "maintMarginRatio": "0.015", @@ -45326,10 +45774,10 @@ "minNotional": 30000.0, "maxNotional": 150000.0, "maintenanceMarginRate": 0.02, - "maxLeverage": 25.0, + "maxLeverage": 15.0, "info": { "bracket": "3", - "initialLeverage": "25", + "initialLeverage": "15", "notionalCap": "150000", "notionalFloor": "30000", "maintMarginRatio": "0.02", @@ -45343,10 +45791,10 @@ "minNotional": 150000.0, "maxNotional": 300000.0, "maintenanceMarginRate": 0.025, - "maxLeverage": 20.0, + "maxLeverage": 10.0, "info": { "bracket": "4", - "initialLeverage": "20", + "initialLeverage": "10", "notionalCap": "300000", "notionalFloor": "150000", "maintMarginRatio": "0.025", @@ -45360,10 +45808,10 @@ "minNotional": 300000.0, "maxNotional": 500000.0, "maintenanceMarginRate": 0.05, - "maxLeverage": 10.0, + "maxLeverage": 8.0, "info": { "bracket": "5", - "initialLeverage": "10", + "initialLeverage": "8", "notionalCap": "500000", "notionalFloor": "300000", "maintMarginRatio": "0.05", @@ -45853,6 +46301,161 @@ } } ], + "RED/USDT:USDT": [ + { + "tier": 1.0, + "symbol": "RED/USDT:USDT", + "currency": "USDT", + "minNotional": 0.0, + "maxNotional": 5000.0, + "maintenanceMarginRate": 0.01, + "maxLeverage": 75.0, + "info": { + "bracket": "1", + "initialLeverage": "75", + "notionalCap": "5000", + "notionalFloor": "0", + "maintMarginRatio": "0.01", + "cum": "0.0" + } + }, + { + "tier": 2.0, + "symbol": "RED/USDT:USDT", + "currency": "USDT", + "minNotional": 5000.0, + "maxNotional": 10000.0, + "maintenanceMarginRate": 0.015, + "maxLeverage": 50.0, + "info": { + "bracket": "2", + "initialLeverage": "50", + "notionalCap": "10000", + "notionalFloor": "5000", + "maintMarginRatio": "0.015", + "cum": "25.0" + } + }, + { + "tier": 3.0, + "symbol": "RED/USDT:USDT", + "currency": "USDT", + "minNotional": 10000.0, + "maxNotional": 30000.0, + "maintenanceMarginRate": 0.02, + "maxLeverage": 25.0, + "info": { + "bracket": "3", + "initialLeverage": "25", + "notionalCap": "30000", + "notionalFloor": "10000", + "maintMarginRatio": "0.02", + "cum": "75.0" + } + }, + { + "tier": 4.0, + "symbol": "RED/USDT:USDT", + "currency": "USDT", + "minNotional": 30000.0, + "maxNotional": 60000.0, + "maintenanceMarginRate": 0.025, + "maxLeverage": 20.0, + "info": { + "bracket": "4", + "initialLeverage": "20", + "notionalCap": "60000", + "notionalFloor": "30000", + "maintMarginRatio": "0.025", + "cum": "225.0" + } + }, + { + "tier": 5.0, + "symbol": "RED/USDT:USDT", + "currency": "USDT", + "minNotional": 60000.0, + "maxNotional": 300000.0, + "maintenanceMarginRate": 0.05, + "maxLeverage": 10.0, + "info": { + "bracket": "5", + "initialLeverage": "10", + "notionalCap": "300000", + "notionalFloor": "60000", + "maintMarginRatio": "0.05", + "cum": "1725.0" + } + }, + { + "tier": 6.0, + "symbol": "RED/USDT:USDT", + "currency": "USDT", + "minNotional": 300000.0, + "maxNotional": 600000.0, + "maintenanceMarginRate": 0.1, + "maxLeverage": 5.0, + "info": { + "bracket": "6", + "initialLeverage": "5", + "notionalCap": "600000", + "notionalFloor": "300000", + "maintMarginRatio": "0.1", + "cum": "16725.0" + } + }, + { + "tier": 7.0, + "symbol": "RED/USDT:USDT", + "currency": "USDT", + "minNotional": 600000.0, + "maxNotional": 750000.0, + "maintenanceMarginRate": 0.125, + "maxLeverage": 4.0, + "info": { + "bracket": "7", + "initialLeverage": "4", + "notionalCap": "750000", + "notionalFloor": "600000", + "maintMarginRatio": "0.125", + "cum": "31725.0" + } + }, + { + "tier": 8.0, + "symbol": "RED/USDT:USDT", + "currency": "USDT", + "minNotional": 750000.0, + "maxNotional": 1500000.0, + "maintenanceMarginRate": 0.25, + "maxLeverage": 2.0, + "info": { + "bracket": "8", + "initialLeverage": "2", + "notionalCap": "1500000", + "notionalFloor": "750000", + "maintMarginRatio": "0.25", + "cum": "125475.0" + } + }, + { + "tier": 9.0, + "symbol": "RED/USDT:USDT", + "currency": "USDT", + "minNotional": 1500000.0, + "maxNotional": 3000000.0, + "maintenanceMarginRate": 0.5, + "maxLeverage": 1.0, + "info": { + "bracket": "9", + "initialLeverage": "1", + "notionalCap": "3000000", + "notionalFloor": "1500000", + "maintMarginRatio": "0.5", + "cum": "500475.0" + } + } + ], "REEF/USDT:USDT": [ { "tier": 1.0, @@ -48065,13 +48668,13 @@ "symbol": "SAGA/USDT:USDT", "currency": "USDT", "minNotional": 1500000.0, - "maxNotional": 3000000.0, + "maxNotional": 2000000.0, "maintenanceMarginRate": 0.1, "maxLeverage": 5.0, "info": { "bracket": "6", "initialLeverage": "5", - "notionalCap": "3000000", + "notionalCap": "2000000", "notionalFloor": "1500000", "maintMarginRatio": "0.1", "cum": "83450.0" @@ -48081,51 +48684,51 @@ "tier": 7.0, "symbol": "SAGA/USDT:USDT", "currency": "USDT", - "minNotional": 3000000.0, - "maxNotional": 3750000.0, + "minNotional": 2000000.0, + "maxNotional": 2500000.0, "maintenanceMarginRate": 0.125, "maxLeverage": 4.0, "info": { "bracket": "7", "initialLeverage": "4", - "notionalCap": "3750000", - "notionalFloor": "3000000", + "notionalCap": "2500000", + "notionalFloor": "2000000", "maintMarginRatio": "0.125", - "cum": "158450.0" + "cum": "133450.0" } }, { "tier": 8.0, "symbol": "SAGA/USDT:USDT", "currency": "USDT", - "minNotional": 3750000.0, - "maxNotional": 7500000.0, + "minNotional": 2500000.0, + "maxNotional": 3000000.0, "maintenanceMarginRate": 0.25, "maxLeverage": 2.0, "info": { "bracket": "8", "initialLeverage": "2", - "notionalCap": "7500000", - "notionalFloor": "3750000", + "notionalCap": "3000000", + "notionalFloor": "2500000", "maintMarginRatio": "0.25", - "cum": "627200.0" + "cum": "445950.0" } }, { "tier": 9.0, "symbol": "SAGA/USDT:USDT", "currency": "USDT", - "minNotional": 7500000.0, - "maxNotional": 15000000.0, + "minNotional": 3000000.0, + "maxNotional": 3500000.0, "maintenanceMarginRate": 0.5, "maxLeverage": 1.0, "info": { "bracket": "9", "initialLeverage": "1", - "notionalCap": "15000000", - "notionalFloor": "7500000", + "notionalCap": "3500000", + "notionalFloor": "3000000", "maintMarginRatio": "0.5", - "cum": "2502200.0" + "cum": "1195950.0" } } ], @@ -55371,6 +55974,161 @@ } } ], + "TRUMP/USDC:USDC": [ + { + "tier": 1.0, + "symbol": "TRUMP/USDC:USDC", + "currency": "USDC", + "minNotional": 0.0, + "maxNotional": 10000.0, + "maintenanceMarginRate": 0.01, + "maxLeverage": 25.0, + "info": { + "bracket": "1", + "initialLeverage": "25", + "notionalCap": "10000", + "notionalFloor": "0", + "maintMarginRatio": "0.01", + "cum": "0.0" + } + }, + { + "tier": 2.0, + "symbol": "TRUMP/USDC:USDC", + "currency": "USDC", + "minNotional": 10000.0, + "maxNotional": 20000.0, + "maintenanceMarginRate": 0.015, + "maxLeverage": 20.0, + "info": { + "bracket": "2", + "initialLeverage": "20", + "notionalCap": "20000", + "notionalFloor": "10000", + "maintMarginRatio": "0.015", + "cum": "50.0" + } + }, + { + "tier": 3.0, + "symbol": "TRUMP/USDC:USDC", + "currency": "USDC", + "minNotional": 20000.0, + "maxNotional": 100000.0, + "maintenanceMarginRate": 0.02, + "maxLeverage": 15.0, + "info": { + "bracket": "3", + "initialLeverage": "15", + "notionalCap": "100000", + "notionalFloor": "20000", + "maintMarginRatio": "0.02", + "cum": "150.0" + } + }, + { + "tier": 4.0, + "symbol": "TRUMP/USDC:USDC", + "currency": "USDC", + "minNotional": 100000.0, + "maxNotional": 200000.0, + "maintenanceMarginRate": 0.025, + "maxLeverage": 10.0, + "info": { + "bracket": "4", + "initialLeverage": "10", + "notionalCap": "200000", + "notionalFloor": "100000", + "maintMarginRatio": "0.025", + "cum": "650.0" + } + }, + { + "tier": 5.0, + "symbol": "TRUMP/USDC:USDC", + "currency": "USDC", + "minNotional": 200000.0, + "maxNotional": 500000.0, + "maintenanceMarginRate": 0.05, + "maxLeverage": 8.0, + "info": { + "bracket": "5", + "initialLeverage": "8", + "notionalCap": "500000", + "notionalFloor": "200000", + "maintMarginRatio": "0.05", + "cum": "5650.0" + } + }, + { + "tier": 6.0, + "symbol": "TRUMP/USDC:USDC", + "currency": "USDC", + "minNotional": 500000.0, + "maxNotional": 1000000.0, + "maintenanceMarginRate": 0.1, + "maxLeverage": 5.0, + "info": { + "bracket": "6", + "initialLeverage": "5", + "notionalCap": "1000000", + "notionalFloor": "500000", + "maintMarginRatio": "0.1", + "cum": "30650.0" + } + }, + { + "tier": 7.0, + "symbol": "TRUMP/USDC:USDC", + "currency": "USDC", + "minNotional": 1000000.0, + "maxNotional": 1500000.0, + "maintenanceMarginRate": 0.125, + "maxLeverage": 4.0, + "info": { + "bracket": "7", + "initialLeverage": "4", + "notionalCap": "1500000", + "notionalFloor": "1000000", + "maintMarginRatio": "0.125", + "cum": "55650.0" + } + }, + { + "tier": 8.0, + "symbol": "TRUMP/USDC:USDC", + "currency": "USDC", + "minNotional": 1500000.0, + "maxNotional": 2000000.0, + "maintenanceMarginRate": 0.25, + "maxLeverage": 2.0, + "info": { + "bracket": "8", + "initialLeverage": "2", + "notionalCap": "2000000", + "notionalFloor": "1500000", + "maintMarginRatio": "0.25", + "cum": "243150.0" + } + }, + { + "tier": 9.0, + "symbol": "TRUMP/USDC:USDC", + "currency": "USDC", + "minNotional": 2000000.0, + "maxNotional": 3000000.0, + "maintenanceMarginRate": 0.5, + "maxLeverage": 1.0, + "info": { + "bracket": "9", + "initialLeverage": "1", + "notionalCap": "3000000", + "notionalFloor": "2000000", + "maintMarginRatio": "0.5", + "cum": "743150.0" + } + } + ], "TRUMP/USDT:USDT": [ { "tier": 1.0, @@ -57732,6 +58490,161 @@ } } ], + "VIC/USDT:USDT": [ + { + "tier": 1.0, + "symbol": "VIC/USDT:USDT", + "currency": "USDT", + "minNotional": 0.0, + "maxNotional": 5000.0, + "maintenanceMarginRate": 0.01, + "maxLeverage": 75.0, + "info": { + "bracket": "1", + "initialLeverage": "75", + "notionalCap": "5000", + "notionalFloor": "0", + "maintMarginRatio": "0.01", + "cum": "0.0" + } + }, + { + "tier": 2.0, + "symbol": "VIC/USDT:USDT", + "currency": "USDT", + "minNotional": 5000.0, + "maxNotional": 10000.0, + "maintenanceMarginRate": 0.015, + "maxLeverage": 50.0, + "info": { + "bracket": "2", + "initialLeverage": "50", + "notionalCap": "10000", + "notionalFloor": "5000", + "maintMarginRatio": "0.015", + "cum": "25.0" + } + }, + { + "tier": 3.0, + "symbol": "VIC/USDT:USDT", + "currency": "USDT", + "minNotional": 10000.0, + "maxNotional": 30000.0, + "maintenanceMarginRate": 0.02, + "maxLeverage": 25.0, + "info": { + "bracket": "3", + "initialLeverage": "25", + "notionalCap": "30000", + "notionalFloor": "10000", + "maintMarginRatio": "0.02", + "cum": "75.0" + } + }, + { + "tier": 4.0, + "symbol": "VIC/USDT:USDT", + "currency": "USDT", + "minNotional": 30000.0, + "maxNotional": 60000.0, + "maintenanceMarginRate": 0.025, + "maxLeverage": 20.0, + "info": { + "bracket": "4", + "initialLeverage": "20", + "notionalCap": "60000", + "notionalFloor": "30000", + "maintMarginRatio": "0.025", + "cum": "225.0" + } + }, + { + "tier": 5.0, + "symbol": "VIC/USDT:USDT", + "currency": "USDT", + "minNotional": 60000.0, + "maxNotional": 300000.0, + "maintenanceMarginRate": 0.05, + "maxLeverage": 10.0, + "info": { + "bracket": "5", + "initialLeverage": "10", + "notionalCap": "300000", + "notionalFloor": "60000", + "maintMarginRatio": "0.05", + "cum": "1725.0" + } + }, + { + "tier": 6.0, + "symbol": "VIC/USDT:USDT", + "currency": "USDT", + "minNotional": 300000.0, + "maxNotional": 600000.0, + "maintenanceMarginRate": 0.1, + "maxLeverage": 5.0, + "info": { + "bracket": "6", + "initialLeverage": "5", + "notionalCap": "600000", + "notionalFloor": "300000", + "maintMarginRatio": "0.1", + "cum": "16725.0" + } + }, + { + "tier": 7.0, + "symbol": "VIC/USDT:USDT", + "currency": "USDT", + "minNotional": 600000.0, + "maxNotional": 750000.0, + "maintenanceMarginRate": 0.125, + "maxLeverage": 4.0, + "info": { + "bracket": "7", + "initialLeverage": "4", + "notionalCap": "750000", + "notionalFloor": "600000", + "maintMarginRatio": "0.125", + "cum": "31725.0" + } + }, + { + "tier": 8.0, + "symbol": "VIC/USDT:USDT", + "currency": "USDT", + "minNotional": 750000.0, + "maxNotional": 1500000.0, + "maintenanceMarginRate": 0.25, + "maxLeverage": 2.0, + "info": { + "bracket": "8", + "initialLeverage": "2", + "notionalCap": "1500000", + "notionalFloor": "750000", + "maintMarginRatio": "0.25", + "cum": "125475.0" + } + }, + { + "tier": 9.0, + "symbol": "VIC/USDT:USDT", + "currency": "USDT", + "minNotional": 1500000.0, + "maxNotional": 3000000.0, + "maintenanceMarginRate": 0.5, + "maxLeverage": 1.0, + "info": { + "bracket": "9", + "initialLeverage": "1", + "notionalCap": "3000000", + "notionalFloor": "1500000", + "maintMarginRatio": "0.5", + "cum": "500475.0" + } + } + ], "VIDT/USDT:USDT": [ { "tier": 1.0, @@ -60668,13 +61581,13 @@ "symbol": "XTZ/USDT:USDT", "currency": "USDT", "minNotional": 1000000.0, - "maxNotional": 2000000.0, + "maxNotional": 1500000.0, "maintenanceMarginRate": 0.1, "maxLeverage": 5.0, "info": { "bracket": "5", "initialLeverage": "5", - "notionalCap": "2000000", + "notionalCap": "1500000", "notionalFloor": "1000000", "maintMarginRatio": "0.1", "cum": "55850.0" @@ -60684,51 +61597,51 @@ "tier": 6.0, "symbol": "XTZ/USDT:USDT", "currency": "USDT", - "minNotional": 2000000.0, - "maxNotional": 5000000.0, + "minNotional": 1500000.0, + "maxNotional": 2000000.0, "maintenanceMarginRate": 0.125, "maxLeverage": 4.0, "info": { "bracket": "6", "initialLeverage": "4", - "notionalCap": "5000000", - "notionalFloor": "2000000", + "notionalCap": "2000000", + "notionalFloor": "1500000", "maintMarginRatio": "0.125", - "cum": "105850.0" + "cum": "93350.0" } }, { "tier": 7.0, "symbol": "XTZ/USDT:USDT", "currency": "USDT", - "minNotional": 5000000.0, - "maxNotional": 10000000.0, + "minNotional": 2000000.0, + "maxNotional": 2500000.0, "maintenanceMarginRate": 0.25, "maxLeverage": 2.0, "info": { "bracket": "7", "initialLeverage": "2", - "notionalCap": "10000000", - "notionalFloor": "5000000", + "notionalCap": "2500000", + "notionalFloor": "2000000", "maintMarginRatio": "0.25", - "cum": "730850.0" + "cum": "343350.0" } }, { "tier": 8.0, "symbol": "XTZ/USDT:USDT", "currency": "USDT", - "minNotional": 10000000.0, - "maxNotional": 15000000.0, + "minNotional": 2500000.0, + "maxNotional": 3000000.0, "maintenanceMarginRate": 0.5, "maxLeverage": 1.0, "info": { "bracket": "8", "initialLeverage": "1", - "notionalCap": "15000000", - "notionalFloor": "10000000", + "notionalCap": "3000000", + "notionalFloor": "2500000", "maintMarginRatio": "0.5", - "cum": "3230850.0" + "cum": "968350.0" } } ], @@ -61445,13 +62358,13 @@ "symbol": "ZEN/USDT:USDT", "currency": "USDT", "minNotional": 1500000.0, - "maxNotional": 3000000.0, + "maxNotional": 2000000.0, "maintenanceMarginRate": 0.1, "maxLeverage": 5.0, "info": { "bracket": "6", "initialLeverage": "5", - "notionalCap": "3000000", + "notionalCap": "2000000", "notionalFloor": "1500000", "maintMarginRatio": "0.1", "cum": "83450.0" @@ -61461,51 +62374,51 @@ "tier": 7.0, "symbol": "ZEN/USDT:USDT", "currency": "USDT", - "minNotional": 3000000.0, - "maxNotional": 3750000.0, + "minNotional": 2000000.0, + "maxNotional": 2500000.0, "maintenanceMarginRate": 0.125, "maxLeverage": 4.0, "info": { "bracket": "7", "initialLeverage": "4", - "notionalCap": "3750000", - "notionalFloor": "3000000", + "notionalCap": "2500000", + "notionalFloor": "2000000", "maintMarginRatio": "0.125", - "cum": "158450.0" + "cum": "133450.0" } }, { "tier": 8.0, "symbol": "ZEN/USDT:USDT", "currency": "USDT", - "minNotional": 3750000.0, - "maxNotional": 7500000.0, + "minNotional": 2500000.0, + "maxNotional": 3000000.0, "maintenanceMarginRate": 0.25, "maxLeverage": 2.0, "info": { "bracket": "8", "initialLeverage": "2", - "notionalCap": "7500000", - "notionalFloor": "3750000", + "notionalCap": "3000000", + "notionalFloor": "2500000", "maintMarginRatio": "0.25", - "cum": "627200.0" + "cum": "445950.0" } }, { "tier": 9.0, "symbol": "ZEN/USDT:USDT", "currency": "USDT", - "minNotional": 7500000.0, - "maxNotional": 15000000.0, + "minNotional": 3000000.0, + "maxNotional": 3500000.0, "maintenanceMarginRate": 0.5, "maxLeverage": 1.0, "info": { "bracket": "9", "initialLeverage": "1", - "notionalCap": "15000000", - "notionalFloor": "7500000", + "notionalCap": "3500000", + "notionalFloor": "3000000", "maintMarginRatio": "0.5", - "cum": "2502200.0" + "cum": "1195950.0" } } ], diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 14b801bef..3a5974a8b 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -2441,8 +2441,8 @@ class Exchange: return self._exchange_ws.get_ohlcv(pair, timeframe, candle_type, candle_ts) logger.info( - f"Failed to reuse watch {pair}, {timeframe}, {candle_ts < last_refresh_time}," - f" {candle_ts}, {last_refresh_time}, " + f"Couldn't reuse watch for {pair}, {timeframe}, falling back to REST api. " + f"{candle_ts < last_refresh_time}, {candle_ts}, {last_refresh_time}, " f"{format_ms_time(candle_ts)}, {format_ms_time(last_refresh_time)} " ) diff --git a/freqtrade/optimize/optimize_reports/optimize_reports.py b/freqtrade/optimize/optimize_reports/optimize_reports.py index a798eaf7a..b7fa0e26d 100644 --- a/freqtrade/optimize/optimize_reports/optimize_reports.py +++ b/freqtrade/optimize/optimize_reports/optimize_reports.py @@ -213,7 +213,7 @@ def _get_resample_from_period(period: str) -> str: if period == "month": return "1ME" if period == "year": - return "1Y" + return "1YE" raise ValueError(f"Period {period} is not supported.") diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 1646699e0..320898899 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -25,6 +25,7 @@ from telegram import ( InlineKeyboardButton, InlineKeyboardMarkup, KeyboardButton, + Message, ReplyKeyboardMarkup, Update, ) @@ -96,17 +97,17 @@ def authorized_only(command_handler: Callable[..., Coroutine[Any, Any, None]]): """ @wraps(command_handler) - async def wrapper(self, *args, **kwargs): + async def wrapper(self, *args, **kwargs) -> None: """Decorator logic""" update = kwargs.get("update") or args[0] # Reject unauthorized messages - if update.callback_query: - cchat_id = int(update.callback_query.message.chat.id) - ctopic_id = update.callback_query.message.message_thread_id - else: - cchat_id = int(update.message.chat_id) - ctopic_id = update.message.message_thread_id + message: Message = ( + update.message if update.callback_query is None else update.callback_query.message + ) + cchat_id: int = int(message.chat_id) + ctopic_id: int | None = message.message_thread_id + from_user_id: str = str(update.effective_user.id if update.effective_user else "") chat_id = int(self._config["telegram"]["chat_id"]) if cchat_id != chat_id: @@ -118,6 +119,10 @@ def authorized_only(command_handler: Callable[..., Coroutine[Any, Any, None]]): logger.debug(f"Rejected message from wrong channel: {cchat_id}, {ctopic_id}") return None + authorized = self._config["telegram"].get("authorized_users", None) + if authorized is not None and from_user_id not in authorized: + logger.info(f"Unauthorized user tried to control the bot: {from_user_id}") + return None # Rollback session to avoid getting data stored in a transaction. Trade.rollback() logger.debug("Executing handler: %s for chat_id: %s", command_handler.__name__, chat_id) @@ -2155,6 +2160,9 @@ class Telegram(RPCHandler): return chat_id = update.message.chat_id topic_id = update.message.message_thread_id + user_id = ( + update.effective_user.id if topic_id is not None and update.effective_user else None + ) msg = f"""Freqtrade Bot Info: ```json @@ -2162,7 +2170,8 @@ class Telegram(RPCHandler): "enabled": true, "token": "********", "chat_id": "{chat_id}", - {f'"topic_id": "{topic_id}"' if topic_id else ""} + {f'"topic_id": "{topic_id}",' if topic_id else ""} + {f'//"authorized_users": ["{user_id}"]' if topic_id and user_id else ""} }} ``` """ diff --git a/pyproject.toml b/pyproject.toml index 91187cccd..8ee9818b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ classifiers = [ dependencies = [ # from requirements.txt - "ccxt>=4.3.24", + "ccxt>=4.4.60", "SQLAlchemy>=2.0.6", "python-telegram-bot>=20.1", "humanize>=4.0.0", diff --git a/requirements-dev.txt b/requirements-dev.txt index 25c299a36..df9196d82 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -7,7 +7,7 @@ -r docs/requirements-docs.txt coveralls==4.0.1 -ruff==0.9.10 +ruff==0.11.0 mypy==1.15.0 pre-commit==4.1.0 pytest==8.3.5 diff --git a/requirements-hyperopt.txt b/requirements-hyperopt.txt index d467669d3..2a326d654 100644 --- a/requirements-hyperopt.txt +++ b/requirements-hyperopt.txt @@ -5,4 +5,4 @@ scipy==1.15.2 scikit-learn==1.6.1 ft-scikit-optimize==0.9.2 -filelock==3.17.0 +filelock==3.18.0 diff --git a/requirements.txt b/requirements.txt index 228ba83a9..bb411d095 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,11 +4,11 @@ bottleneck==1.4.2 numexpr==2.10.2 pandas-ta==0.3.14b -ccxt==4.4.65 +ccxt==4.4.68 cryptography==44.0.2 aiohttp==3.9.5 -SQLAlchemy==2.0.38 -python-telegram-bot==21.11.1 +SQLAlchemy==2.0.39 +python-telegram-bot==22.0 # can't be hard-pinned due to telegram-bot pinning httpx with ~ httpx>=0.24.1 humanize==4.12.1 diff --git a/tests/rpc/test_rpc_telegram.py b/tests/rpc/test_rpc_telegram.py index f4f8ca2e9..47148165d 100644 --- a/tests/rpc/test_rpc_telegram.py +++ b/tests/rpc/test_rpc_telegram.py @@ -6,7 +6,7 @@ import asyncio import logging import re import threading -from datetime import datetime, timedelta, timezone +from datetime import timedelta from functools import reduce from random import choice, randint from string import ascii_uppercase @@ -16,7 +16,7 @@ import pytest import time_machine from pandas import DataFrame from sqlalchemy import select -from telegram import Chat, Message, ReplyKeyboardMarkup, Update +from telegram import Chat, Message, ReplyKeyboardMarkup, Update, User from telegram.error import BadRequest, NetworkError, TelegramError from freqtrade import __version__ @@ -67,7 +67,12 @@ def default_conf(default_conf) -> dict: @pytest.fixture def update(): - message = Message(0, datetime.now(timezone.utc), Chat(1235, 0)) + message = Message( + 0, + dt_now(), + Chat(1235, 0), + from_user=User(5432, "test", is_bot=False), + ) _update = Update(0, message=message) return _update @@ -232,8 +237,12 @@ async def test_authorized_only(default_conf, mocker, caplog, update) -> None: async def test_authorized_only_unauthorized(default_conf, mocker, caplog) -> None: patch_exchange(mocker) caplog.set_level(logging.DEBUG) - chat = Chat(0xDEADBEEF, 0) - message = Message(randint(1, 100), datetime.now(timezone.utc), chat) + message = Message( + randint(1, 100), + dt_now(), + Chat(0xDEADBEEF, 0), + from_user=User(5432, "test", is_bot=False), + ) update = Update(randint(1, 100), message=message) default_conf["telegram"]["enabled"] = False @@ -249,6 +258,42 @@ async def test_authorized_only_unauthorized(default_conf, mocker, caplog) -> Non assert not log_has("Exception occurred within Telegram module", caplog) +async def test_authorized_users(default_conf, mocker, caplog, update) -> None: + patch_exchange(mocker) + caplog.set_level(logging.DEBUG) + default_conf["telegram"]["enabled"] = False + default_conf["telegram"]["authorized_users"] = ["5432"] + bot = FreqtradeBot(default_conf) + rpc = RPC(bot) + dummy = DummyCls(rpc, default_conf) + + await dummy.dummy_handler(update=update, context=MagicMock()) + assert dummy.state["called"] is True + assert log_has("Executing handler: dummy_handler for chat_id: 1235", caplog) + caplog.clear() + # Test empty case + default_conf["telegram"]["authorized_users"] = [] + dummy1 = DummyCls(rpc, default_conf) + await dummy1.dummy_handler(update=update, context=MagicMock()) + assert dummy1.state["called"] is False + assert log_has_re(r"Unauthorized user tried to .*5432", caplog) + caplog.clear() + # Test wrong user + default_conf["telegram"]["authorized_users"] = ["1234"] + dummy1 = DummyCls(rpc, default_conf) + await dummy1.dummy_handler(update=update, context=MagicMock()) + assert dummy1.state["called"] is False + assert log_has_re(r"Unauthorized user tried to .*5432", caplog) + caplog.clear() + + # Test reverse case again + default_conf["telegram"]["authorized_users"] = ["5432"] + dummy1 = DummyCls(rpc, default_conf) + await dummy1.dummy_handler(update=update, context=MagicMock()) + assert dummy1.state["called"] is True + assert not log_has_re(r"Unauthorized user tried to .*5432", caplog) + + async def test_authorized_only_exception(default_conf, mocker, caplog, update) -> None: patch_exchange(mocker) @@ -638,7 +683,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.now(timezone.utc).date()) in msg_mock.call_args_list[0][0][0] + assert str(dt_now().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] @@ -651,11 +696,8 @@ 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.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 str(dt_now().date()) in msg_mock.call_args_list[0][0][0] + assert str((dt_now() - 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] @@ -725,7 +767,7 @@ async def test_weekly_handle(default_conf_usdt, update, ticker, fee, mocker, tim in msg_mock.call_args_list[0][0][0] ) assert "Monday " in msg_mock.call_args_list[0][0][0] - today = datetime.now(timezone.utc).date() + today = dt_now().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] @@ -793,7 +835,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.now(timezone.utc).date() + today = dt_now().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] @@ -898,7 +940,7 @@ async def test_telegram_profit_handle( trade.orders.append(oobj) trade.update_trade(oobj) - trade.close_date = datetime.now(timezone.utc) + trade.close_date = dt_now() trade.is_open = False Trade.commit()