Move "funding fillup" logic to exchange class

This commit is contained in:
Matthias
2022-05-21 08:50:39 +02:00
parent 6bd5535d6c
commit 2df42a3035
2 changed files with 26 additions and 26 deletions

View File

@@ -276,30 +276,11 @@ class Backtesting:
unavailable_pairs.append(pair)
continue
if (pair in mark_rates_dict
and len(funding_rates_dict[pair]) == 0
and "futures_funding_rate" in self.config):
mark_rates_dict[pair]["open_fund"] = self.config.get('futures_funding_rate')
mark_rates_dict[pair].rename(
columns={'open': 'open_mark',
'close': 'close_mark',
'high': 'high_mark',
'low': 'low_mark',
'volume': 'volume_mark'},
inplace=True)
self.futures_data[pair] = mark_rates_dict[pair]
else:
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=["_mark", "_fund"])['open_fund'].fillna(
self.config.get('futures_funding_rate'))
else:
self.futures_data[pair] = self.exchange.combine_funding_and_mark(
funding_rates=funding_rates_dict[pair],
mark_rates=mark_rates_dict[pair]
)
self.futures_data[pair] = self.exchange.combine_funding_and_mark(
funding_rates=funding_rates_dict[pair],
mark_rates=mark_rates_dict[pair],
futures_funding_rate=self.config.get('futures_funding_rate'),
)
if unavailable_pairs:
raise OperationalException(