replace 'open_orders' with "has_open_orders" in api

This commit is contained in:
Matthias
2023-09-09 08:35:03 +02:00
parent f4e5ce892b
commit 067c9219b6
5 changed files with 9 additions and 16 deletions

View File

@@ -542,8 +542,6 @@ class LocalTrade:
def to_json(self, minified: bool = False) -> Dict[str, Any]:
filled_or_open_orders = self.select_filled_or_open_orders()
orders_json = [order.to_json(self.entry_side, minified) for order in filled_or_open_orders]
open_orders = self.select_open_orders()
open_orders_json = [order.to_json(self.entry_side, minified) for order in open_orders]
return {
'trade_id': self.id,
@@ -623,7 +621,7 @@ class LocalTrade:
'price_precision': self.price_precision,
'precision_mode': self.precision_mode,
'orders': orders_json,
'open_orders': open_orders_json
'has_open_orders': self.has_open_orders,
}
@staticmethod
@@ -1128,16 +1126,6 @@ class LocalTrade:
or (o.ft_is_open is True and o.status is not None)
]
def select_open_orders(self) -> List['Order']:
"""
Finds open orders
:param order_side: Side of the order (either 'buy', 'sell', or None)
:return: array of Order objects
"""
return [o for o in self.orders if
(o.ft_is_open is True and o.status is not None)
]
@property
def nr_of_successful_entries(self) -> int:
"""

View File

@@ -331,6 +331,7 @@ class OpenTradeSchema(TradeSchema):
total_profit_abs: float
total_profit_fiat: Optional[float] = None
total_profit_ratio: Optional[float] = None
has_open_orders: bool
class TradeResponse(BaseModel):

View File

@@ -1446,7 +1446,7 @@ def test_to_json(fee):
'price_precision': 7.0,
'precision_mode': 1,
'orders': [],
'open_orders': [],
'has_open_orders': False,
}
# Simulate dry_run entries
@@ -1532,7 +1532,7 @@ def test_to_json(fee):
'price_precision': 8.0,
'precision_mode': 2,
'orders': [],
'open_orders': [],
'has_open_orders': False,
}

View File

@@ -90,6 +90,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
'amount_precision': 8.0,
'price_precision': 8.0,
'precision_mode': 2,
'has_open_orders': False,
'orders': [{
'amount': 91.07468123, 'average': 1.098e-05, 'safe_price': 1.098e-05,
'cost': 0.0009999999999054, 'filled': 91.07468123, 'ft_order_side': 'buy',
@@ -128,6 +129,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
'profit_abs': 0.0,
'total_profit_abs': 0.0,
'open_orders': '(limit buy rem=91.07468123)',
'has_open_orders': True,
})
response_unfilled['orders'][0].update({
'is_open': True,
@@ -145,7 +147,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
results = rpc._rpc_trade_status()
# Reuse above object, only remaining changed.
response_unfilled['orders'][0].update({
'remaining': None
'remaining': None,
})
assert results[0] == response_unfilled
@@ -164,6 +166,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
response.update({
'max_stake_amount': 0.001,
'total_profit_ratio': pytest.approx(-0.00409153),
'has_open_orders': False,
})
assert results[0] == response

View File

@@ -1158,6 +1158,7 @@ def test_api_status(botclient, mocker, ticker, fee, markets, is_short,
'price_precision': None,
'precision_mode': None,
'orders': [ANY],
'has_open_orders': True,
}
mocker.patch(f'{EXMS}.get_rate',