From 7c2e8420af05f6708f07fa0983fb59d891d15b6c Mon Sep 17 00:00:00 2001 From: Stefano Ariestasia Date: Tue, 29 Mar 2022 09:27:30 +0900 Subject: [PATCH 1/6] Add note that enter_long must be set --- docs/strategy_migration.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/strategy_migration.md b/docs/strategy_migration.md index ee6f1a494..c7a2fb851 100644 --- a/docs/strategy_migration.md +++ b/docs/strategy_migration.md @@ -18,6 +18,7 @@ If you intend on using markets other than spot markets, please migrate your stra * `sell` -> `exit_long` * `buy_tag` -> `enter_tag` (used for both long and short trades) * New column `enter_short` and corresponding new column `exit_short` + * `enter_long` MUST be set even if the strategy is a shorting strategy. * trade-object now has the following new properties: `is_short`, `enter_side`, `exit_side` and `trade_direction`. * New `side` argument to callbacks without trade object * `custom_stake_amount` From 05db0067ee76c9f6c85bc55e53c77775cf4fb3e7 Mon Sep 17 00:00:00 2001 From: Stefano Ariestasia Date: Tue, 29 Mar 2022 10:51:36 +0900 Subject: [PATCH 2/6] Add few missing info on shorting setup --- docs/configuration.md | 2 ++ docs/includes/pricing.md | 20 ++++++++++++++++++++ docs/strategy-customization.md | 23 +++++++++++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 3f3086833..8d7bce43d 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -100,6 +100,7 @@ Mandatory parameters are marked as **Required**, which means that they are requi | `trailing_only_offset_is_reached` | Only apply trailing stoploss when the offset is reached. [stoploss documentation](stoploss.md). [Strategy Override](#parameters-in-the-strategy).
*Defaults to `false`.*
**Datatype:** Boolean | `fee` | Fee used during backtesting / dry-runs. Should normally not be configured, which has freqtrade fall back to the exchange default fee. Set as ratio (e.g. 0.001 = 0.1%). Fee is applied twice for each trade, once when buying, once when selling.
**Datatype:** Float (as ratio) | `trading_mode` | Specifies if you want to trade regularly, trade with leverage, or trade contracts whose prices are derived from matching cryptocurrency prices. [leverage documentation](leverage.md).
*Defaults to `"spot"`.*
**Datatype:** String +| `can_short` | Specifies if the bot can do futures shorting trade.
[Strategy Override](#parameters-in-the-strategy)
*Defaults to `false`.*
**Datatype:** Boolean | `margin_mode` | When trading with leverage, this determines if the collateral owned by the trader will be shared or isolated to each trading pair [leverage documentation](leverage.md).
**Datatype:** String | `liquidation_buffer` | A ratio specifying how large of a safety net to place between the liquidation price and the stoploss to prevent a position from reaching the liquidation price [leverage documentation](leverage.md).
*Defaults to `0.05`.*
**Datatype:** Float | `unfilledtimeout.entry` | **Required.** How long (in minutes or seconds) the bot will wait for an unfilled entry order to complete, after which the order will be cancelled and repeated at current (new) price, as long as there is a signal. [Strategy Override](#parameters-in-the-strategy).
**Datatype:** Integer @@ -203,6 +204,7 @@ Values set in the configuration file always overwrite values set in the strategy * `ignore_buying_expired_candle_after` * `position_adjustment_enable` * `max_entry_position_adjustment` +* `can_short` ### Configuring amount per trade diff --git a/docs/includes/pricing.md b/docs/includes/pricing.md index 8a551d8a9..7506aaa1e 100644 --- a/docs/includes/pricing.md +++ b/docs/includes/pricing.md @@ -116,3 +116,23 @@ Assuming both buy and sell are using market orders, a configuration similar to t ``` Obviously, if only one side is using limit orders, different pricing combinations can be used. + +### Futures market's order pricing + +When trading on futures market. orderbook must be used because there is no ticker data for futures. + +``` jsonc + "bid_strategy": { + "ask_last_balance": 0.0, + "use_order_book": true, + "order_book_top": 1, + "check_depth_of_market": { + "enabled": false, + "bids_to_ask_delta": 1 + } + }, + "ask_strategy": { + "use_order_book": true, + "order_book_top": 1 + }, +``` diff --git a/docs/strategy-customization.md b/docs/strategy-customization.md index fd2119753..e7695a118 100644 --- a/docs/strategy-customization.md +++ b/docs/strategy-customization.md @@ -235,7 +235,7 @@ def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFram Short-trades need to be supported by your exchange and market configuration! Please make sure to set [`can_short`]() appropriately on your strategy if you intend to short. - ```python +```python def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe.loc[ ( @@ -256,7 +256,26 @@ def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFram ['enter_short', 'enter_tag']] = (1, 'rsi_cross') return dataframe - ``` +``` + +!!! Note + `enter_long` column must be set, even when your strategy is a shorting-only strategy. On other hand, enter_short is an optional column and don't need to be set if the strategy is a long-only strategy + +```python + def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: + dataframe.loc[: ,'enter_long'] = 0 + + dataframe.loc[ + ( + (qtpylib.crossed_below(dataframe['rsi'], 70)) & # Signal: RSI crosses below 70 + (dataframe['tema'] > dataframe['bb_middleband']) & # Guard + (dataframe['tema'] < dataframe['tema'].shift(1)) & # Guard + (dataframe['volume'] > 0) # Make sure Volume is not 0 + ), + ['enter_short', 'enter_tag']] = (1, 'rsi_cross') + + return dataframe +``` !!! Note Buying requires sellers to buy from - therefore volume needs to be > 0 (`dataframe['volume'] > 0`) to make sure that the bot does not buy/sell in no-activity periods. From c615e4fcc2cd120bb842da17d8e89b0bf18b11bc Mon Sep 17 00:00:00 2001 From: Stefano Ariestasia Date: Wed, 30 Mar 2022 08:35:49 +0900 Subject: [PATCH 3/6] updates --- docs/configuration.md | 1 - docs/exchanges.md | 20 +++++++++++ docs/includes/pricing.md | 20 ----------- docs/strategy-customization.md | 61 ++++++++++++---------------------- docs/strategy_migration.md | 1 - 5 files changed, 41 insertions(+), 62 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 8d7bce43d..0ef29a99c 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -100,7 +100,6 @@ Mandatory parameters are marked as **Required**, which means that they are requi | `trailing_only_offset_is_reached` | Only apply trailing stoploss when the offset is reached. [stoploss documentation](stoploss.md). [Strategy Override](#parameters-in-the-strategy).
*Defaults to `false`.*
**Datatype:** Boolean | `fee` | Fee used during backtesting / dry-runs. Should normally not be configured, which has freqtrade fall back to the exchange default fee. Set as ratio (e.g. 0.001 = 0.1%). Fee is applied twice for each trade, once when buying, once when selling.
**Datatype:** Float (as ratio) | `trading_mode` | Specifies if you want to trade regularly, trade with leverage, or trade contracts whose prices are derived from matching cryptocurrency prices. [leverage documentation](leverage.md).
*Defaults to `"spot"`.*
**Datatype:** String -| `can_short` | Specifies if the bot can do futures shorting trade.
[Strategy Override](#parameters-in-the-strategy)
*Defaults to `false`.*
**Datatype:** Boolean | `margin_mode` | When trading with leverage, this determines if the collateral owned by the trader will be shared or isolated to each trading pair [leverage documentation](leverage.md).
**Datatype:** String | `liquidation_buffer` | A ratio specifying how large of a safety net to place between the liquidation price and the stoploss to prevent a position from reaching the liquidation price [leverage documentation](leverage.md).
*Defaults to `0.05`.*
**Datatype:** Float | `unfilledtimeout.entry` | **Required.** How long (in minutes or seconds) the bot will wait for an unfilled entry order to complete, after which the order will be cancelled and repeated at current (new) price, as long as there is a signal. [Strategy Override](#parameters-in-the-strategy).
**Datatype:** Integer diff --git a/docs/exchanges.md b/docs/exchanges.md index 38183b0bc..4509ffef1 100644 --- a/docs/exchanges.md +++ b/docs/exchanges.md @@ -64,6 +64,26 @@ Binance supports [time_in_force](configuration.md#understand-order_time_in_force For Binance, please add `"BNB/"` to your blacklist to avoid issues. Accounts having BNB accounts use this to pay for fees - if your first trade happens to be on `BNB`, further trades will consume this position and make the initial BNB trade unsellable as the expected amount is not there anymore. +### Binance Futures' order pricing + +When trading on Binance Futures market. orderbook must be used because there is no price ticker data for futures. + +``` jsonc + "bid_strategy": { + "ask_last_balance": 0.0, + "use_order_book": true, + "order_book_top": 1, + "check_depth_of_market": { + "enabled": false, + "bids_to_ask_delta": 1 + } + }, + "ask_strategy": { + "use_order_book": true, + "order_book_top": 1 + }, +``` + ### Binance sites Binance has been split into 2, and users must use the correct ccxt exchange ID for their exchange, otherwise API keys are not recognized. diff --git a/docs/includes/pricing.md b/docs/includes/pricing.md index 7506aaa1e..8a551d8a9 100644 --- a/docs/includes/pricing.md +++ b/docs/includes/pricing.md @@ -116,23 +116,3 @@ Assuming both buy and sell are using market orders, a configuration similar to t ``` Obviously, if only one side is using limit orders, different pricing combinations can be used. - -### Futures market's order pricing - -When trading on futures market. orderbook must be used because there is no ticker data for futures. - -``` jsonc - "bid_strategy": { - "ask_last_balance": 0.0, - "use_order_book": true, - "order_book_top": 1, - "check_depth_of_market": { - "enabled": false, - "bids_to_ask_delta": 1 - } - }, - "ask_strategy": { - "use_order_book": true, - "order_book_top": 1 - }, -``` diff --git a/docs/strategy-customization.md b/docs/strategy-customization.md index e7695a118..e3fccbd38 100644 --- a/docs/strategy-customization.md +++ b/docs/strategy-customization.md @@ -205,7 +205,7 @@ Edit the method `populate_entry_trend()` in your strategy file to update your en It's important to always return the dataframe without removing/modifying the columns `"open", "high", "low", "close", "volume"`, otherwise these fields would contain something unexpected. -This method will also define a new column, `"enter_long"`, which needs to contain 1 for entries, and 0 for "no action". +This method will also define a new column, `"enter_long"`, which needs to contain 1 for entries, and 0 for "no action". `enter_long` column is a mandatory column that must be set even if the strategy is shorting only. Sample from `user_data/strategies/sample_strategy.py`: @@ -235,47 +235,28 @@ def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFram Short-trades need to be supported by your exchange and market configuration! Please make sure to set [`can_short`]() appropriately on your strategy if you intend to short. -```python - def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: - dataframe.loc[ - ( - (qtpylib.crossed_above(dataframe['rsi'], 30)) & # Signal: RSI crosses above 30 - (dataframe['tema'] <= dataframe['bb_middleband']) & # Guard - (dataframe['tema'] > dataframe['tema'].shift(1)) & # Guard - (dataframe['volume'] > 0) # Make sure Volume is not 0 - ), - ['enter_long', 'enter_tag']] = (1, 'rsi_cross') + ```python + def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: + dataframe.loc[ + ( + (qtpylib.crossed_above(dataframe['rsi'], 30)) & # Signal: RSI crosses above 30 + (dataframe['tema'] <= dataframe['bb_middleband']) & # Guard + (dataframe['tema'] > dataframe['tema'].shift(1)) & # Guard + (dataframe['volume'] > 0) # Make sure Volume is not 0 + ), + ['enter_long', 'enter_tag']] = (1, 'rsi_cross') - dataframe.loc[ - ( - (qtpylib.crossed_below(dataframe['rsi'], 70)) & # Signal: RSI crosses below 70 - (dataframe['tema'] > dataframe['bb_middleband']) & # Guard - (dataframe['tema'] < dataframe['tema'].shift(1)) & # Guard - (dataframe['volume'] > 0) # Make sure Volume is not 0 - ), - ['enter_short', 'enter_tag']] = (1, 'rsi_cross') + dataframe.loc[ + ( + (qtpylib.crossed_below(dataframe['rsi'], 70)) & # Signal: RSI crosses below 70 + (dataframe['tema'] > dataframe['bb_middleband']) & # Guard + (dataframe['tema'] < dataframe['tema'].shift(1)) & # Guard + (dataframe['volume'] > 0) # Make sure Volume is not 0 + ), + ['enter_short', 'enter_tag']] = (1, 'rsi_cross') - return dataframe -``` - -!!! Note - `enter_long` column must be set, even when your strategy is a shorting-only strategy. On other hand, enter_short is an optional column and don't need to be set if the strategy is a long-only strategy - -```python - def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: - dataframe.loc[: ,'enter_long'] = 0 - - dataframe.loc[ - ( - (qtpylib.crossed_below(dataframe['rsi'], 70)) & # Signal: RSI crosses below 70 - (dataframe['tema'] > dataframe['bb_middleband']) & # Guard - (dataframe['tema'] < dataframe['tema'].shift(1)) & # Guard - (dataframe['volume'] > 0) # Make sure Volume is not 0 - ), - ['enter_short', 'enter_tag']] = (1, 'rsi_cross') - - return dataframe -``` + return dataframe + ``` !!! Note Buying requires sellers to buy from - therefore volume needs to be > 0 (`dataframe['volume'] > 0`) to make sure that the bot does not buy/sell in no-activity periods. diff --git a/docs/strategy_migration.md b/docs/strategy_migration.md index c7a2fb851..ee6f1a494 100644 --- a/docs/strategy_migration.md +++ b/docs/strategy_migration.md @@ -18,7 +18,6 @@ If you intend on using markets other than spot markets, please migrate your stra * `sell` -> `exit_long` * `buy_tag` -> `enter_tag` (used for both long and short trades) * New column `enter_short` and corresponding new column `exit_short` - * `enter_long` MUST be set even if the strategy is a shorting strategy. * trade-object now has the following new properties: `is_short`, `enter_side`, `exit_side` and `trade_direction`. * New `side` argument to callbacks without trade object * `custom_stake_amount` From 4d5f6ed5e2ded66acf186e38d0bf9c6bf064b2e5 Mon Sep 17 00:00:00 2001 From: Stefano Ariestasia Date: Wed, 30 Mar 2022 08:37:11 +0900 Subject: [PATCH 4/6] Update strategy-customization.md --- docs/strategy-customization.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/strategy-customization.md b/docs/strategy-customization.md index e3fccbd38..9abe53ddf 100644 --- a/docs/strategy-customization.md +++ b/docs/strategy-customization.md @@ -236,24 +236,24 @@ def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFram Please make sure to set [`can_short`]() appropriately on your strategy if you intend to short. ```python - def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: - dataframe.loc[ - ( - (qtpylib.crossed_above(dataframe['rsi'], 30)) & # Signal: RSI crosses above 30 - (dataframe['tema'] <= dataframe['bb_middleband']) & # Guard - (dataframe['tema'] > dataframe['tema'].shift(1)) & # Guard - (dataframe['volume'] > 0) # Make sure Volume is not 0 - ), - ['enter_long', 'enter_tag']] = (1, 'rsi_cross') + def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: + dataframe.loc[ + ( + (qtpylib.crossed_above(dataframe['rsi'], 30)) & # Signal: RSI crosses above 30 + (dataframe['tema'] <= dataframe['bb_middleband']) & # Guard + (dataframe['tema'] > dataframe['tema'].shift(1)) & # Guard + (dataframe['volume'] > 0) # Make sure Volume is not 0 + ), + ['enter_long', 'enter_tag']] = (1, 'rsi_cross') - dataframe.loc[ - ( - (qtpylib.crossed_below(dataframe['rsi'], 70)) & # Signal: RSI crosses below 70 - (dataframe['tema'] > dataframe['bb_middleband']) & # Guard - (dataframe['tema'] < dataframe['tema'].shift(1)) & # Guard - (dataframe['volume'] > 0) # Make sure Volume is not 0 - ), - ['enter_short', 'enter_tag']] = (1, 'rsi_cross') + dataframe.loc[ + ( + (qtpylib.crossed_below(dataframe['rsi'], 70)) & # Signal: RSI crosses below 70 + (dataframe['tema'] > dataframe['bb_middleband']) & # Guard + (dataframe['tema'] < dataframe['tema'].shift(1)) & # Guard + (dataframe['volume'] > 0) # Make sure Volume is not 0 + ), + ['enter_short', 'enter_tag']] = (1, 'rsi_cross') return dataframe ``` From 02aded68f90d83104d2dc296d8001d8a59fe2044 Mon Sep 17 00:00:00 2001 From: Stefano Ariestasia Date: Wed, 30 Mar 2022 08:37:35 +0900 Subject: [PATCH 5/6] Update strategy-customization.md --- docs/strategy-customization.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/strategy-customization.md b/docs/strategy-customization.md index 9abe53ddf..c33ec5fb9 100644 --- a/docs/strategy-customization.md +++ b/docs/strategy-customization.md @@ -255,7 +255,7 @@ def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFram ), ['enter_short', 'enter_tag']] = (1, 'rsi_cross') - return dataframe + return dataframe ``` !!! Note From 9a7867971a87be016468ae1c229a40a77befd469 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 30 Mar 2022 07:13:28 +0200 Subject: [PATCH 6/6] Update wording to new pricing definition --- docs/configuration.md | 1 - docs/exchanges.md | 7 +++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 0ef29a99c..3f3086833 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -203,7 +203,6 @@ Values set in the configuration file always overwrite values set in the strategy * `ignore_buying_expired_candle_after` * `position_adjustment_enable` * `max_entry_position_adjustment` -* `can_short` ### Configuring amount per trade diff --git a/docs/exchanges.md b/docs/exchanges.md index 4509ffef1..b808096d2 100644 --- a/docs/exchanges.md +++ b/docs/exchanges.md @@ -66,11 +66,10 @@ Accounts having BNB accounts use this to pay for fees - if your first trade happ ### Binance Futures' order pricing -When trading on Binance Futures market. orderbook must be used because there is no price ticker data for futures. +When trading on Binance Futures market, orderbook must be used because there is no price ticker data for futures. ``` jsonc - "bid_strategy": { - "ask_last_balance": 0.0, + "entry_pricing": { "use_order_book": true, "order_book_top": 1, "check_depth_of_market": { @@ -78,7 +77,7 @@ When trading on Binance Futures market. orderbook must be used because there is "bids_to_ask_delta": 1 } }, - "ask_strategy": { + "exit_pricing": { "use_order_book": true, "order_book_top": 1 },