Add explicit test for order_to_ccxt

This commit is contained in:
Matthias 2022-05-19 19:29:39 +02:00
parent 5e18e51ce0
commit 56a73575a1
3 changed files with 20 additions and 1 deletions

View File

@ -130,7 +130,7 @@ class Order(_DECL_BASE):
'side': self.ft_order_side, 'side': self.ft_order_side,
'filled': self.filled, 'filled': self.filled,
'remaining': self.remaining, 'remaining': self.remaining,
'datetime': self.order_date_utc.strftime('%Y-%m-%dT%H:%M:%S.%3f'), 'datetime': self.order_date_utc.strftime('%Y-%m-%dT%H:%M:%S.%f'),
'timestamp': int(self.order_date_utc.timestamp() * 1000), 'timestamp': int(self.order_date_utc.timestamp() * 1000),
'status': self.status, 'status': self.status,
'fee': None, 'fee': None,

View File

@ -1616,6 +1616,7 @@ def limit_buy_order_open():
'datetime': arrow.utcnow().isoformat(), 'datetime': arrow.utcnow().isoformat(),
'price': 0.00001099, 'price': 0.00001099,
'amount': 90.99181073, 'amount': 90.99181073,
'average': None,
'filled': 0.0, 'filled': 0.0,
'cost': 0.0009999, 'cost': 0.0009999,
'remaining': 90.99181073, 'remaining': 90.99181073,

View File

@ -2671,3 +2671,21 @@ def test_select_filled_orders(fee):
orders = trades[4].select_filled_orders('sell') orders = trades[4].select_filled_orders('sell')
assert orders is not None assert orders is not None
assert len(orders) == 0 assert len(orders) == 0
@pytest.mark.usefixtures("init_persistence")
def test_order_to_ccxt(limit_buy_order_open):
order = Order.parse_from_ccxt_object(limit_buy_order_open, 'mocked', 'buy')
order.query.session.add(order)
Order.query.session.commit()
order_resp = Order.order_by_id(limit_buy_order_open['id'])
assert order_resp
raw_order = order_resp.to_ccxt_object()
del raw_order['fee']
del raw_order['datetime']
del raw_order['info']
del limit_buy_order_open['datetime']
assert raw_order == limit_buy_order_open