Merge branch 'funding-fee-dry-run' of https://github.com/samgermain/freqtrade into funding-fee-dry-run
This commit is contained in:
commit
e713f5188f
@ -230,9 +230,9 @@ class Binance(Exchange):
|
|||||||
pair=pair, timeframe=timeframe, since_ms=since_ms, is_new_pair=is_new_pair)
|
pair=pair, timeframe=timeframe, since_ms=since_ms, is_new_pair=is_new_pair)
|
||||||
|
|
||||||
def funding_fee_cutoff(self, open_date: datetime):
|
def funding_fee_cutoff(self, open_date: datetime):
|
||||||
'''
|
"""
|
||||||
# TODO-lev: Double check that gateio, ftx, and kraken don't also have this
|
# TODO-lev: Double check that gateio, ftx, and kraken don't also have this
|
||||||
:param open_date: The open date for a trade
|
:param open_date: The open date for a trade
|
||||||
:return: The cutoff open time for when a funding fee is charged
|
:return: The cutoff open time for when a funding fee is charged
|
||||||
'''
|
"""
|
||||||
return open_date.minute > 0 or (open_date.minute == 0 and open_date.second > 15)
|
return open_date.minute > 0 or (open_date.minute == 0 and open_date.second > 15)
|
||||||
|
@ -1705,10 +1705,10 @@ class Exchange:
|
|||||||
raise OperationalException(e) from e
|
raise OperationalException(e) from e
|
||||||
|
|
||||||
def funding_fee_cutoff(self, open_date: datetime):
|
def funding_fee_cutoff(self, open_date: datetime):
|
||||||
'''
|
"""
|
||||||
:param open_date: The open date for a trade
|
:param open_date: The open date for a trade
|
||||||
:return: The cutoff open time for when a funding fee is charged
|
:return: The cutoff open time for when a funding fee is charged
|
||||||
'''
|
"""
|
||||||
return open_date.minute > 0 or open_date.second > 0
|
return open_date.minute > 0 or open_date.second > 0
|
||||||
|
|
||||||
def _get_funding_fee_dates(self, start: datetime, end: datetime):
|
def _get_funding_fee_dates(self, start: datetime, end: datetime):
|
||||||
@ -1849,30 +1849,26 @@ class Exchange:
|
|||||||
return fees
|
return fees
|
||||||
|
|
||||||
def get_funding_fees(self, pair: str, amount: float, open_date: datetime):
|
def get_funding_fees(self, pair: str, amount: float, open_date: datetime):
|
||||||
|
"""
|
||||||
|
Fetch funding fees, either from the exchange (live) or calculates them
|
||||||
|
based on funding rate/mark price history
|
||||||
|
:param pair: The quote/base pair of the trade
|
||||||
|
:param amount: Trade amount
|
||||||
|
:param open_date: Open date of the trade
|
||||||
|
"""
|
||||||
if self._config['dry_run']:
|
if self._config['dry_run']:
|
||||||
funding_fees = self._calculate_funding_fees(
|
funding_fees = self._calculate_funding_fees(pair, amount, open_date)
|
||||||
pair,
|
|
||||||
amount,
|
|
||||||
open_date
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
funding_fees = self._get_funding_fees_from_exchange(
|
funding_fees = self._get_funding_fees_from_exchange(pair, open_date)
|
||||||
pair,
|
|
||||||
open_date
|
|
||||||
)
|
|
||||||
return funding_fees
|
return funding_fees
|
||||||
|
|
||||||
@retrier
|
@retrier
|
||||||
def get_funding_rate_history(
|
def get_funding_rate_history(self, pair: str, since: int) -> Dict:
|
||||||
self,
|
"""
|
||||||
pair: str,
|
|
||||||
since: int,
|
|
||||||
) -> Dict:
|
|
||||||
'''
|
|
||||||
:param pair: quote/base currency pair
|
:param pair: quote/base currency pair
|
||||||
:param since: timestamp in ms of the beginning time
|
:param since: timestamp in ms of the beginning time
|
||||||
:param end: timestamp in ms of the end time
|
:param end: timestamp in ms of the end time
|
||||||
'''
|
"""
|
||||||
if not self.exchange_has("fetchFundingRateHistory"):
|
if not self.exchange_has("fetchFundingRateHistory"):
|
||||||
raise ExchangeError(
|
raise ExchangeError(
|
||||||
f"CCXT has not implemented fetchFundingRateHistory for {self.name}; "
|
f"CCXT has not implemented fetchFundingRateHistory for {self.name}; "
|
||||||
|
Loading…
Reference in New Issue
Block a user