calculate_funding_fees is actually a public exchange interface (used in backtesting).

This commit is contained in:
Matthias 2022-01-17 19:26:03 +01:00
parent e9e7fd749b
commit 84c6d92d4c
4 changed files with 7 additions and 7 deletions

View File

@ -1923,7 +1923,7 @@ class Exchange:
funding_rates = candle_histories[funding_comb] funding_rates = candle_histories[funding_comb]
mark_rates = candle_histories[mark_comb] mark_rates = candle_histories[mark_comb]
return self._calculate_funding_fees( return self.calculate_funding_fees(
funding_rates=funding_rates, funding_rates=funding_rates,
mark_rates=mark_rates, mark_rates=mark_rates,
amount=amount, amount=amount,
@ -1931,7 +1931,7 @@ class Exchange:
close_date=close_date close_date=close_date
) )
def _calculate_funding_fees( def calculate_funding_fees(
self, self,
funding_rates: DataFrame, funding_rates: DataFrame,
mark_rates: DataFrame, mark_rates: DataFrame,

View File

@ -159,7 +159,7 @@ class Kraken(Exchange):
params['leverage'] = leverage params['leverage'] = leverage
return params return params
def _calculate_funding_fees( def calculate_funding_fees(
self, self,
funding_rates: DataFrame, funding_rates: DataFrame,
mark_rates: DataFrame, mark_rates: DataFrame,

View File

@ -488,7 +488,7 @@ class Backtesting:
sell_candle_time: datetime = sell_row[DATE_IDX].to_pydatetime() sell_candle_time: datetime = sell_row[DATE_IDX].to_pydatetime()
if self.trading_mode == TradingMode.FUTURES: if self.trading_mode == TradingMode.FUTURES:
trade.funding_fees = self.exchange._calculate_funding_fees( trade.funding_fees = self.exchange.calculate_funding_fees(
funding_rates=self.futures_data[CandleType.FUNDING_RATE][trade.pair], funding_rates=self.futures_data[CandleType.FUNDING_RATE][trade.pair],
mark_rates=self.futures_data[CandleType.MARK][trade.pair], mark_rates=self.futures_data[CandleType.MARK][trade.pair],
amount=trade.amount, amount=trade.amount,

View File

@ -3563,7 +3563,7 @@ def test__calculate_funding_fees(
{'date': trade_date, 'open': mark_price}, {'date': trade_date, 'open': mark_price},
]) ])
assert exchange._calculate_funding_fees( assert exchange.calculate_funding_fees(
funding_rates=funding_rates, funding_rates=funding_rates,
mark_rates=mark_rates, mark_rates=mark_rates,
amount=size, amount=size,
@ -3574,7 +3574,7 @@ def test__calculate_funding_fees(
if (kraken_fee is None): if (kraken_fee is None):
with pytest.raises(OperationalException): with pytest.raises(OperationalException):
kraken._calculate_funding_fees( kraken.calculate_funding_fees(
funding_rates=funding_rates, funding_rates=funding_rates,
mark_rates=mark_rates, mark_rates=mark_rates,
amount=size, amount=size,
@ -3584,7 +3584,7 @@ def test__calculate_funding_fees(
) )
else: else:
assert kraken._calculate_funding_fees( assert kraken.calculate_funding_fees(
funding_rates=funding_rates, funding_rates=funding_rates,
mark_rates=mark_rates, mark_rates=mark_rates,
amount=size, amount=size,