From 736f9f4972add41a066bfc23705d1664915aa9b4 Mon Sep 17 00:00:00 2001 From: froggleston Date: Wed, 18 May 2022 12:47:37 +0100 Subject: [PATCH] Fix docs and add outer join support for merging funding rates across full timerange --- docs/configuration.md | 2 +- freqtrade/optimize/backtesting.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 5a6d5849a..4a05ad3d4 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -230,7 +230,7 @@ Mandatory parameters are marked as **Required**, which means that they are requi | `dataformat_trades` | Data format to use to store historical trades data.
*Defaults to `jsongz`*.
**Datatype:** String | `position_adjustment_enable` | Enables the strategy to use position adjustments (additional buys or sells). [More information here](strategy-callbacks.md#adjust-trade-position).
[Strategy Override](#parameters-in-the-strategy).
*Defaults to `false`.*
**Datatype:** Boolean | `max_entry_position_adjustment` | Maximum additional order(s) for each open trade on top of the first entry Order. Set it to `-1` for unlimited additional orders. [More information here](strategy-callbacks.md#adjust-trade-position).
[Strategy Override](#parameters-in-the-strategy).
*Defaults to `-1`.*
**Datatype:** Positive Integer or -1 -| `futures_funding_rate` | User-specified funding rate to be used when historical funding rates are not available from the exchange. This does not overwrite real historical rates. It is recommended that this be set to 0 unless you are testing a specific coin and you understand how the funding rate will affect freqtrade's profit calculations. [More information here](configuration.md)
*Defaults to None.*
**Datatype:** Float +| `futures_funding_rate` | User-specified funding rate to be used when historical funding rates are not available from the exchange. This does not overwrite real historical rates. It is recommended that this be set to 0 unless you are testing a specific coin and you understand how the funding rate will affect freqtrade's profit calculations. [More information here](leverage.md)
*Defaults to None.*
**Datatype:** Float ### Parameters in the strategy diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index 8d5a5fcea..78faf65be 100755 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -294,9 +294,15 @@ class Backtesting: self.futures_data[pair] = mark_rates_dict[pair] else: - self.futures_data[pair] = mark_rates_dict[pair].merge( - funding_rates_dict[pair], on='date', - how="inner", suffixes=["_fund", "_mark"]) + if "futures_funding_rate" in self.config: + self.futures_data[pair] = mark_rates_dict[pair].merge( + funding_rates_dict[pair], on='date', + how="outer", suffixes=["_fund", "_mark"]).fillna( + self.config.get('futures_funding_rate')) + else: + self.futures_data[pair] = mark_rates_dict[pair].merge( + funding_rates_dict[pair], on='date', + how="inner", suffixes=["_fund", "_mark"]) if unavailable_pairs: raise OperationalException(