use stop_price_param for dry stops

closes #8555
This commit is contained in:
Matthias
2023-04-25 08:53:02 +02:00
parent 1df01a2634
commit 6a271317bc
2 changed files with 8 additions and 5 deletions

View File

@@ -867,7 +867,7 @@ class Exchange:
}
if stop_loss:
dry_order["info"] = {"stopPrice": dry_order["price"]}
dry_order["stopPrice"] = dry_order["price"]
dry_order[self._ft_has['stop_price_param']] = dry_order["price"]
# Workaround to avoid filling stoploss orders immediately
dry_order["ft_order_type"] = "stoploss"
orderbook: Optional[OrderBook] = None
@@ -1019,7 +1019,7 @@ class Exchange:
from freqtrade.persistence import Order
order = Order.order_by_id(order_id)
if order:
ccxt_order = order.to_ccxt_object()
ccxt_order = order.to_ccxt_object(self._ft_has['stop_price_param'])
self._dry_run_open_orders[order_id] = ccxt_order
return ccxt_order
# Gracefully handle errors with dry-run orders.

View File

@@ -158,7 +158,7 @@ class Order(ModelBase):
self.order_filled_date = datetime.now(timezone.utc)
self.order_update_date = datetime.now(timezone.utc)
def to_ccxt_object(self) -> Dict[str, Any]:
def to_ccxt_object(self, stopPriceName: str = 'stopPrice') -> Dict[str, Any]:
order: Dict[str, Any] = {
'id': self.order_id,
'symbol': self.ft_pair,
@@ -170,7 +170,6 @@ class Order(ModelBase):
'side': self.ft_order_side,
'filled': self.filled,
'remaining': self.remaining,
'stopPrice': self.stop_price,
'datetime': self.order_date_utc.strftime('%Y-%m-%dT%H:%M:%S.%f'),
'timestamp': int(self.order_date_utc.timestamp() * 1000),
'status': self.status,
@@ -178,7 +177,11 @@ class Order(ModelBase):
'info': {},
}
if self.ft_order_side == 'stoploss':
order['ft_order_type'] = 'stoploss'
order.update({
stopPriceName: self.stop_price,
'ft_order_type': 'stoploss',
})
return order
def to_json(self, entry_side: str, minified: bool = False) -> Dict[str, Any]: