Move rate-calcuation for stoploss-limit order to exchange

This commit is contained in:
Matthias
2020-01-19 13:12:28 +01:00
parent 2f82122fc4
commit 8d2e0bfd62
3 changed files with 9 additions and 7 deletions

View File

@@ -32,13 +32,17 @@ class Binance(Exchange):
return super().get_order_book(pair, limit)
def stoploss_limit(self, pair: str, amount: float, stop_price: float, rate: float) -> Dict:
def stoploss_limit(self, pair: str, amount: float, stop_price: float,
order_types: Dict) -> Dict:
"""
creates a stoploss limit order.
this stoploss-limit is binance-specific.
It may work with a limited number of other exchanges, but this has not been tested yet.
"""
# 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)
rate = stop_price * LIMIT_PRICE_PCT
ordertype = "stop_loss_limit"
stop_price = self.price_to_precision(pair, stop_price)

View File

@@ -519,7 +519,8 @@ class Exchange:
return self.create_order(pair, ordertype, 'sell', amount, rate, params)
def stoploss_limit(self, pair: str, amount: float, stop_price: float, rate: float) -> Dict:
def stoploss_limit(self, pair: str, amount: float, stop_price: float,
order_types: Dict) -> Dict:
"""
creates a stoploss limit order.
Since ccxt does not unify stoploss-limit orders yet, this needs to be implemented in each