Improve futures detection, add ccxt-compat test

This commit is contained in:
Matthias
2021-11-15 19:43:43 +01:00
parent 4e9b83e170
commit 75eccea88d
6 changed files with 39 additions and 3 deletions

View File

@@ -3,7 +3,7 @@ import json
import logging
from datetime import datetime
from pathlib import Path
from typing import Dict, List, Optional, Tuple
from typing import Any, Dict, List, Optional, Tuple
import arrow
import ccxt
@@ -119,6 +119,10 @@ class Binance(Exchange):
except ccxt.BaseError as e:
raise OperationalException(e) from e
def market_is_future(self, market: Dict[str, Any]) -> bool:
# TODO-lev: This should be unified in ccxt to "swap"...
return market.get('future', False) is True
@retrier
def fill_leverage_brackets(self):
"""

View File

@@ -340,7 +340,7 @@ class Exchange:
return self.markets.get(pair, {}).get('base', '')
def market_is_future(self, market: Dict[str, Any]) -> bool:
return market.get('future', False) is True or market.get('futures') is True
return market.get('swap', False) is True
def market_is_spot(self, market: Dict[str, Any]) -> bool:
return market.get('spot', False) is True

View File

@@ -159,3 +159,7 @@ class Ftx(Exchange):
if order['type'] == 'stop':
return safe_value_fallback2(order, order, 'id_stop', 'id')
return order['id']
def market_is_future(self, market: Dict[str, Any]) -> bool:
# TODO-lev: This should be unified in ccxt to "swap"...
return market.get('future', False) is True