Changed funding fee tracking method, need to get funding_rate and open prices at multiple candles

This commit is contained in:
Sam Germain
2021-09-06 02:24:15 -06:00
parent 92e630eb69
commit f5248be043
8 changed files with 157 additions and 98 deletions

View File

@@ -16,7 +16,7 @@ from sqlalchemy.sql.schema import UniqueConstraint
from freqtrade.constants import DATETIME_PRINT_FORMAT, NON_OPEN_EXCHANGE_STATES
from freqtrade.enums import SellType, TradingMode
from freqtrade.exceptions import DependencyException, OperationalException
from freqtrade.leverage import interest
from freqtrade.leverage import funding_fees, interest
from freqtrade.misc import safe_value_fallback
from freqtrade.persistence.migrations import check_migrate
@@ -707,6 +707,7 @@ class LocalTrade():
return float(self._calc_base_close(amount, rate, fee) - total_interest)
elif (trading_mode == TradingMode.FUTURES):
self.add_funding_fees()
funding_fees = self.funding_fees or 0.0
return float(self._calc_base_close(amount, rate, fee)) + funding_fees
else:
@@ -785,6 +786,16 @@ class LocalTrade():
else:
return None
def add_funding_fees(self):
if self.trading_mode == TradingMode.FUTURES:
self.funding_fees = funding_fees(
self.exchange,
self.pair,
self.amount,
self.open_date_utc,
self.close_date_utc
)
@staticmethod
def get_trades_proxy(*, pair: str = None, is_open: bool = None,
open_date: datetime = None, close_date: datetime = None,