From 6410a6528be7a34da85baacb259340f2d7afdba0 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 4 Aug 2021 06:46:21 +0200 Subject: [PATCH 1/4] Add missing methods to advanced strategy template --- freqtrade/strategy/interface.py | 6 +-- .../subtemplates/strategy_methods_advanced.j2 | 41 +++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 6f3e047eb..bf5cc10af 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -288,10 +288,10 @@ class IStrategy(ABC, HyperStrategyMixin): time. This method is not called when sell signal is set. This method should be overridden to create sell signals that depend on trade parameters. For - example you could implement a stoploss relative to candle when trade was opened, or a custom - 1:2 risk-reward ROI. + example you could implement a sell relative to the candle when the trade was opened, + or a custom 1:2 risk-reward ROI. - Custom sell reason max length is 64. Exceeding this limit will raise OperationalException. + Custom sell reason max length is 64. Exceeding characters will be removed. :param pair: Pair that's currently analyzed :param trade: trade object. diff --git a/freqtrade/templates/subtemplates/strategy_methods_advanced.j2 b/freqtrade/templates/subtemplates/strategy_methods_advanced.j2 index 2a9ac0690..2df23f365 100644 --- a/freqtrade/templates/subtemplates/strategy_methods_advanced.j2 +++ b/freqtrade/templates/subtemplates/strategy_methods_advanced.j2 @@ -12,6 +12,23 @@ def bot_loop_start(self, **kwargs) -> None: """ pass +def custom_stake_amount(self, pair: str, current_time: 'datetime', current_rate: float, + proposed_stake: float, min_stake: float, max_stake: float, + **kwargs) -> float: + """ + Customize stake size for each new trade. This method is not called when edge module is + enabled. + + :param pair: Pair that's currently analyzed + :param current_time: datetime object, containing the current datetime + :param current_rate: Rate, calculated based on pricing settings in ask_strategy. + :param proposed_stake: A stake amount proposed by the bot. + :param min_stake: Minimal stake size allowed by exchange. + :param max_stake: Balance available for trading. + :return: A stake size, which is between min_stake and max_stake. + """ + return proposed_stake + use_custom_stoploss = True def custom_stoploss(self, pair: str, trade: 'Trade', current_time: 'datetime', @@ -38,6 +55,30 @@ def custom_stoploss(self, pair: str, trade: 'Trade', current_time: 'datetime', """ return self.stoploss +def custom_sell(self, pair: str, trade: 'Trade', current_time: 'datetime', current_rate: float, + current_profit: float, **kwargs) -> 'Optional[Union[str, bool]]': + """ + Custom sell signal logic indicating that specified position should be sold. Returning a + string or True from this method is equal to setting sell signal on a candle at specified + time. This method is not called when sell signal is set. + + This method should be overridden to create sell signals that depend on trade parameters. For + example you could implement a sell relative to the candle when the trade was opened, + or a custom 1:2 risk-reward ROI. + + Custom sell reason max length is 64. Exceeding characters will be removed. + + :param pair: Pair that's currently analyzed + :param trade: trade object. + :param current_time: datetime object, containing the current datetime + :param current_rate: Rate, calculated based on pricing settings in ask_strategy. + :param current_profit: Current profit (as ratio), calculated based on current_rate. + :param **kwargs: Ensure to keep this here so updates to this won't break your strategy. + :return: To execute sell, return a string with custom sell reason or True. Otherwise return + None or False. + """ + return None + def confirm_trade_entry(self, pair: str, order_type: str, amount: float, rate: float, time_in_force: str, current_time: 'datetime', **kwargs) -> bool: """ From 74a5cb3c21d33bcee48a64470c4d9117efa86fc3 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 4 Aug 2021 06:49:53 +0200 Subject: [PATCH 2/4] Remove protections from full config They are supposed to be configured in the strategy --- config_examples/config_full.example.json | 27 ------------------------ 1 file changed, 27 deletions(-) diff --git a/config_examples/config_full.example.json b/config_examples/config_full.example.json index d404391a4..3ca413281 100644 --- a/config_examples/config_full.example.json +++ b/config_examples/config_full.example.json @@ -78,33 +78,6 @@ "refresh_period": 1440 } ], - "protections": [ - { - "method": "StoplossGuard", - "lookback_period_candles": 60, - "trade_limit": 4, - "stop_duration_candles": 60, - "only_per_pair": false - }, - { - "method": "CooldownPeriod", - "stop_duration_candles": 20 - }, - { - "method": "MaxDrawdown", - "lookback_period_candles": 200, - "trade_limit": 20, - "stop_duration_candles": 10, - "max_allowed_drawdown": 0.2 - }, - { - "method": "LowProfitPairs", - "lookback_period_candles": 360, - "trade_limit": 1, - "stop_duration_candles": 2, - "required_profit": 0.02 - } - ], "exchange": { "name": "binance", "sandbox": false, From eee5f174fca4954e9a20d46c0cbded00547dcd49 Mon Sep 17 00:00:00 2001 From: Kamontat Chantrachirathumrong Date: Thu, 5 Aug 2021 20:33:15 +0700 Subject: [PATCH 3/4] update link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8cba78136..e10c15c11 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ hesitate to read the source code and understand the mechanism of this bot. Please read the [exchange specific notes](docs/exchanges.md) to learn about eventual, special configurations needed for each exchange. - [X] [Bittrex](https://bittrex.com/) -- [X] [Binance](https://www.binance.com/) ([*Note for binance users](docs/exchanges.md#blacklists)) +- [X] [Binance](https://www.binance.com/) ([*Note for binance users](docs/exchanges.md#binance-blacklist)) - [X] [Kraken](https://kraken.com/) - [X] [FTX](https://ftx.com) - [ ] [potentially many others](https://github.com/ccxt/ccxt/). _(We cannot guarantee they will work)_ From 90c194de1f6ef83a8899bd0ed7873656f70c802a Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 5 Aug 2021 19:27:38 +0200 Subject: [PATCH 4/4] Align Readme and documentation index in supported exchange lists --- README.md | 2 +- docs/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e10c15c11..78ea3cecd 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,8 @@ hesitate to read the source code and understand the mechanism of this bot. Please read the [exchange specific notes](docs/exchanges.md) to learn about eventual, special configurations needed for each exchange. -- [X] [Bittrex](https://bittrex.com/) - [X] [Binance](https://www.binance.com/) ([*Note for binance users](docs/exchanges.md#binance-blacklist)) +- [X] [Bittrex](https://bittrex.com/) - [X] [Kraken](https://kraken.com/) - [X] [FTX](https://ftx.com) - [ ] [potentially many others](https://github.com/ccxt/ccxt/). _(We cannot guarantee they will work)_ diff --git a/docs/index.md b/docs/index.md index 8077cd303..05eaa7552 100644 --- a/docs/index.md +++ b/docs/index.md @@ -36,7 +36,7 @@ Freqtrade is a crypto-currency algorithmic trading software developed in python Please read the [exchange specific notes](exchanges.md) to learn about eventual, special configurations needed for each exchange. -- [X] [Binance](https://www.binance.com/) ([*Note for binance users](exchanges.md#blacklists)) +- [X] [Binance](https://www.binance.com/) ([*Note for binance users](docs/exchanges.md#binance-blacklist)) - [X] [Bittrex](https://bittrex.com/) - [X] [FTX](https://ftx.com) - [X] [Kraken](https://kraken.com/)