replace 'open_orders' with "has_open_orders" in api
This commit is contained in:
@@ -542,8 +542,6 @@ class LocalTrade:
|
|||||||
def to_json(self, minified: bool = False) -> Dict[str, Any]:
|
def to_json(self, minified: bool = False) -> Dict[str, Any]:
|
||||||
filled_or_open_orders = self.select_filled_or_open_orders()
|
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]
|
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 {
|
return {
|
||||||
'trade_id': self.id,
|
'trade_id': self.id,
|
||||||
@@ -623,7 +621,7 @@ class LocalTrade:
|
|||||||
'price_precision': self.price_precision,
|
'price_precision': self.price_precision,
|
||||||
'precision_mode': self.precision_mode,
|
'precision_mode': self.precision_mode,
|
||||||
'orders': orders_json,
|
'orders': orders_json,
|
||||||
'open_orders': open_orders_json
|
'has_open_orders': self.has_open_orders,
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -1128,16 +1126,6 @@ class LocalTrade:
|
|||||||
or (o.ft_is_open is True and o.status is not None)
|
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
|
@property
|
||||||
def nr_of_successful_entries(self) -> int:
|
def nr_of_successful_entries(self) -> int:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -331,6 +331,7 @@ class OpenTradeSchema(TradeSchema):
|
|||||||
total_profit_abs: float
|
total_profit_abs: float
|
||||||
total_profit_fiat: Optional[float] = None
|
total_profit_fiat: Optional[float] = None
|
||||||
total_profit_ratio: Optional[float] = None
|
total_profit_ratio: Optional[float] = None
|
||||||
|
has_open_orders: bool
|
||||||
|
|
||||||
|
|
||||||
class TradeResponse(BaseModel):
|
class TradeResponse(BaseModel):
|
||||||
|
|||||||
@@ -1446,7 +1446,7 @@ def test_to_json(fee):
|
|||||||
'price_precision': 7.0,
|
'price_precision': 7.0,
|
||||||
'precision_mode': 1,
|
'precision_mode': 1,
|
||||||
'orders': [],
|
'orders': [],
|
||||||
'open_orders': [],
|
'has_open_orders': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Simulate dry_run entries
|
# Simulate dry_run entries
|
||||||
@@ -1532,7 +1532,7 @@ def test_to_json(fee):
|
|||||||
'price_precision': 8.0,
|
'price_precision': 8.0,
|
||||||
'precision_mode': 2,
|
'precision_mode': 2,
|
||||||
'orders': [],
|
'orders': [],
|
||||||
'open_orders': [],
|
'has_open_orders': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
|||||||
'amount_precision': 8.0,
|
'amount_precision': 8.0,
|
||||||
'price_precision': 8.0,
|
'price_precision': 8.0,
|
||||||
'precision_mode': 2,
|
'precision_mode': 2,
|
||||||
|
'has_open_orders': False,
|
||||||
'orders': [{
|
'orders': [{
|
||||||
'amount': 91.07468123, 'average': 1.098e-05, 'safe_price': 1.098e-05,
|
'amount': 91.07468123, 'average': 1.098e-05, 'safe_price': 1.098e-05,
|
||||||
'cost': 0.0009999999999054, 'filled': 91.07468123, 'ft_order_side': 'buy',
|
'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,
|
'profit_abs': 0.0,
|
||||||
'total_profit_abs': 0.0,
|
'total_profit_abs': 0.0,
|
||||||
'open_orders': '(limit buy rem=91.07468123)',
|
'open_orders': '(limit buy rem=91.07468123)',
|
||||||
|
'has_open_orders': True,
|
||||||
})
|
})
|
||||||
response_unfilled['orders'][0].update({
|
response_unfilled['orders'][0].update({
|
||||||
'is_open': True,
|
'is_open': True,
|
||||||
@@ -145,7 +147,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
|||||||
results = rpc._rpc_trade_status()
|
results = rpc._rpc_trade_status()
|
||||||
# Reuse above object, only remaining changed.
|
# Reuse above object, only remaining changed.
|
||||||
response_unfilled['orders'][0].update({
|
response_unfilled['orders'][0].update({
|
||||||
'remaining': None
|
'remaining': None,
|
||||||
})
|
})
|
||||||
assert results[0] == response_unfilled
|
assert results[0] == response_unfilled
|
||||||
|
|
||||||
@@ -164,6 +166,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
|||||||
response.update({
|
response.update({
|
||||||
'max_stake_amount': 0.001,
|
'max_stake_amount': 0.001,
|
||||||
'total_profit_ratio': pytest.approx(-0.00409153),
|
'total_profit_ratio': pytest.approx(-0.00409153),
|
||||||
|
'has_open_orders': False,
|
||||||
})
|
})
|
||||||
assert results[0] == response
|
assert results[0] == response
|
||||||
|
|
||||||
|
|||||||
@@ -1158,6 +1158,7 @@ def test_api_status(botclient, mocker, ticker, fee, markets, is_short,
|
|||||||
'price_precision': None,
|
'price_precision': None,
|
||||||
'precision_mode': None,
|
'precision_mode': None,
|
||||||
'orders': [ANY],
|
'orders': [ANY],
|
||||||
|
'has_open_orders': True,
|
||||||
}
|
}
|
||||||
|
|
||||||
mocker.patch(f'{EXMS}.get_rate',
|
mocker.patch(f'{EXMS}.get_rate',
|
||||||
|
|||||||
Reference in New Issue
Block a user