diff --git a/freqtrade/exchange/binance.py b/freqtrade/exchange/binance.py index e40135055..d18f53e6d 100644 --- a/freqtrade/exchange/binance.py +++ b/freqtrade/exchange/binance.py @@ -59,6 +59,7 @@ class Binance(Exchange): "BNFCR": "USDC", "BFUSD": "USDT", }, + "delivery_column": "deliveryDate", } _supported_trading_mode_margin_pairs: list[tuple[TradingMode, MarginMode]] = [ diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 7d086677d..3fa381a03 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -3911,3 +3911,26 @@ class Exchange: # describes the min amt for a tier, and the lowest tier will always go down to 0 else: raise ExchangeError(f"Cannot get maintenance ratio using {self.name}") + + def check_delivery_time(self, pair: str) -> int: + """ + Check if the futures contract is a delivery contract + :param pair: Market symbol + :return: True if the contract is a delivery contract, False otherwise + """ + if self.trading_mode != TradingMode.FUTURES: + return 0 + + column_to_check = self._ft_has.get("delivery_column", "") + + logger.info(f"Checking delivery time at {column_to_check}") + + delivery_time = self.markets.get(pair, {}).get("info", {}).get(column_to_check, None) + if delivery_time is not None: + if isinstance(delivery_time, str) and (delivery_time != ""): + delivery_time = int(delivery_time) + + return delivery_time + # if "delivery" in market and market["delivery"] is not None: + # return True + return 0 diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index fed9a6533..a98a9a372 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -661,6 +661,15 @@ class FreqtradeBot(LoggingMixin): """ logger.debug(f"create_trade for pair {pair}") + delivery_time = self.exchange.check_delivery_time(pair) + if delivery_time: + delivery_date = dt_from_ts(delivery_time) + logger.info( + f"Pair {pair} has a delivery time of " + f"{delivery_date.strftime(constants.DATETIME_PRINT_FORMAT)}. Skipping." + ) + return False + analyzed_df, _ = self.dataprovider.get_analyzed_dataframe(pair, self.strategy.timeframe) nowtime = analyzed_df.iloc[-1]["date"] if len(analyzed_df) > 0 else None