merged with lev-exchange
This commit is contained in:
@@ -55,7 +55,10 @@ class Binance(Exchange):
|
||||
:param side: "buy" or "sell"
|
||||
"""
|
||||
# Limit price threshold: As limit price should always be below stop-price
|
||||
limit_price_pct = order_types.get('stoploss_on_exchange_limit_ratio', 0.99)
|
||||
limit_price_pct = order_types.get(
|
||||
'stoploss_on_exchange_limit_ratio',
|
||||
0.99 if side == 'sell' else 1.01
|
||||
)
|
||||
rate = stop_price * limit_price_pct
|
||||
|
||||
ordertype = "stop_loss_limit"
|
||||
|
@@ -75,8 +75,6 @@ class Exchange:
|
||||
}
|
||||
_ft_has: Dict = {}
|
||||
|
||||
_leverage_brackets: Dict = {}
|
||||
|
||||
_supported_trading_mode_collateral_pairs: List[Tuple[TradingMode, Collateral]] = [
|
||||
# TradingMode.SPOT always supported and not required in this list
|
||||
]
|
||||
@@ -90,6 +88,7 @@ class Exchange:
|
||||
self._api: ccxt.Exchange = None
|
||||
self._api_async: ccxt_async.Exchange = None
|
||||
self._markets: Dict = {}
|
||||
self._leverage_brackets: Dict = {}
|
||||
|
||||
self._config.update(config)
|
||||
|
||||
@@ -624,6 +623,7 @@ class Exchange:
|
||||
|
||||
def _apply_leverage_to_stake_amount(self, stake_amount: float, leverage: float):
|
||||
"""
|
||||
#TODO-lev: Find out how this works on Kraken and FTX
|
||||
# * Should be implemented by child classes if leverage affects the stake_amount
|
||||
Takes the minimum stake amount for a pair with no leverage and returns the minimum
|
||||
stake amount when leverage is considered
|
||||
@@ -1581,31 +1581,6 @@ class Exchange:
|
||||
self._async_get_trade_history(pair=pair, since=since,
|
||||
until=until, from_id=from_id))
|
||||
|
||||
@retrier
|
||||
def get_interest_rate(
|
||||
self,
|
||||
pair: str,
|
||||
maker_or_taker: str,
|
||||
is_short: bool
|
||||
) -> Tuple[float, float]:
|
||||
"""
|
||||
Gets the rate of interest for borrowed currency when margin trading
|
||||
:param pair: base/quote currency pair
|
||||
:param maker_or_taker: "maker" if limit order, "taker" if market order
|
||||
:param is_short: True if requesting base interest, False if requesting quote interest
|
||||
:return: (open_interest, rollover_interest)
|
||||
"""
|
||||
try:
|
||||
# TODO-lev: implement, currently there is no ccxt method for this
|
||||
return (0.0005, 0.0005)
|
||||
except ccxt.DDoSProtection as e:
|
||||
raise DDosProtection(e) from e
|
||||
except (ccxt.NetworkError, ccxt.ExchangeError) as e:
|
||||
raise TemporaryError(
|
||||
f'Could not set leverage due to {e.__class__.__name__}. Message: {e}') from e
|
||||
except ccxt.BaseError as e:
|
||||
raise OperationalException(e) from e
|
||||
|
||||
@retrier
|
||||
def fill_leverage_brackets(self):
|
||||
"""
|
||||
|
@@ -57,7 +57,10 @@ class Ftx(Exchange):
|
||||
|
||||
Limit orders are defined by having orderPrice set, otherwise a market order is used.
|
||||
"""
|
||||
limit_price_pct = order_types.get('stoploss_on_exchange_limit_ratio', 0.99)
|
||||
limit_price_pct = order_types.get(
|
||||
'stoploss_on_exchange_limit_ratio',
|
||||
0.99 if side == "sell" else 1.01
|
||||
)
|
||||
limit_rate = stop_price * limit_price_pct
|
||||
|
||||
ordertype = "stop"
|
||||
@@ -164,10 +167,6 @@ class Ftx(Exchange):
|
||||
return safe_value_fallback2(order, order, 'id_stop', 'id')
|
||||
return order['id']
|
||||
|
||||
def _apply_leverage_to_stake_amount(self, stake_amount: float, leverage: float):
|
||||
# TODO-lev: implement
|
||||
return stake_amount
|
||||
|
||||
def fill_leverage_brackets(self):
|
||||
"""
|
||||
FTX leverage is static across the account, and doesn't change from pair to pair,
|
||||
|
@@ -84,7 +84,7 @@ class Kraken(Exchange):
|
||||
(side == "buy" and stop_loss < float(order['price']))
|
||||
))
|
||||
|
||||
@ retrier(retries=0)
|
||||
@retrier(retries=0)
|
||||
def stoploss(self, pair: str, amount: float,
|
||||
stop_price: float, order_types: Dict, side: str) -> Dict:
|
||||
"""
|
||||
|
Reference in New Issue
Block a user