Test for short exchange.stoploss exchange.stoploss_adjust

This commit is contained in:
Sam Germain
2021-09-09 14:24:07 -06:00
parent 785b71aec1
commit 2c7cf794f5
6 changed files with 105 additions and 57 deletions

View File

@@ -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"

View File

@@ -624,6 +624,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

View File

@@ -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,