tests: Improve sample_order online testing
This commit is contained in:
@@ -30,6 +30,7 @@ EXCHANGES = {
|
||||
"private_methods": ["fapiPrivateGetPositionSideDual", "fapiPrivateGetMultiAssetsMargin"],
|
||||
"sample_order": [
|
||||
{
|
||||
"exchange_response": {
|
||||
"symbol": "SOLUSDT",
|
||||
"orderId": 3551312894,
|
||||
"orderListId": -1,
|
||||
@@ -47,7 +48,19 @@ EXCHANGES = {
|
||||
"fills": [],
|
||||
"selfTradePreventionMode": "NONE",
|
||||
},
|
||||
"pair": "SOL/USDT",
|
||||
"expected": {
|
||||
"symbol": "SOL/USDT",
|
||||
"orderId": "3551312894",
|
||||
"timestamp": 1674493798550,
|
||||
"datetime": "2023-03-25T15:49:58.550Z",
|
||||
"price": 15.5,
|
||||
"status": "open",
|
||||
"amount": 1.1,
|
||||
},
|
||||
},
|
||||
{
|
||||
"exchange_response": {
|
||||
"symbol": "SOLUSDT",
|
||||
"orderId": 3551312894,
|
||||
"orderListId": -1,
|
||||
@@ -65,6 +78,17 @@ EXCHANGES = {
|
||||
"fills": [],
|
||||
"selfTradePreventionMode": "NONE",
|
||||
},
|
||||
"pair": "SOL/USDT",
|
||||
"expected": {
|
||||
"symbol": "SOL/USDT",
|
||||
"orderId": "3551312894",
|
||||
"timestamp": 1674493798550,
|
||||
"datetime": "2023-03-25T15:49:58.550Z",
|
||||
"price": 15.5,
|
||||
"status": "open",
|
||||
"amount": 1.1,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
"binanceus": {
|
||||
@@ -76,6 +100,7 @@ EXCHANGES = {
|
||||
"skip_ws_tests": True,
|
||||
"sample_order": [
|
||||
{
|
||||
"exchange_response": {
|
||||
"symbol": "SOLUSDT",
|
||||
"orderId": 3551312894,
|
||||
"orderListId": -1,
|
||||
@@ -92,6 +117,17 @@ EXCHANGES = {
|
||||
"workingTime": 1674493798550,
|
||||
"fills": [],
|
||||
"selfTradePreventionMode": "NONE",
|
||||
},
|
||||
"pair": "SOL/USDT",
|
||||
"expected": {
|
||||
"symbol": "SOL/USDT",
|
||||
"orderId": "3551312894",
|
||||
"timestamp": 1674493798550,
|
||||
"datetime": "2023-03-25T15:49:58.550Z",
|
||||
"price": 15.5,
|
||||
"status": "open",
|
||||
"amount": 1.1,
|
||||
},
|
||||
}
|
||||
],
|
||||
},
|
||||
@@ -112,8 +148,21 @@ EXCHANGES = {
|
||||
"leverage_tiers_public": False,
|
||||
"leverage_in_spot_market": True,
|
||||
"sample_order": [
|
||||
{"id": "63d6742d0adc5570001d2bbf7"}, # create order
|
||||
{
|
||||
"exchange_response": {"id": "63d6742d0adc5570001d2bbf7"},
|
||||
"pair": "SOL/USDT",
|
||||
"expected": {
|
||||
"symbol": "SOL/USDT",
|
||||
"orderId": "3551312894",
|
||||
"timestamp": 1674493798550,
|
||||
"datetime": "2023-03-25T15:49:58.550Z",
|
||||
"price": 15.5,
|
||||
"status": "open",
|
||||
"amount": 1.1,
|
||||
},
|
||||
}, # create order
|
||||
{
|
||||
"exchange_response": {
|
||||
"id": "63d6742d0adc5570001d2bbf7",
|
||||
"symbol": "SOL-USDT",
|
||||
"opType": "DEAL",
|
||||
@@ -145,6 +194,17 @@ EXCHANGES = {
|
||||
"createdAt": 1674493798550,
|
||||
"tradeType": "TRADE",
|
||||
},
|
||||
"pair": "SOL/USDT",
|
||||
"expected": {
|
||||
"symbol": "SOL/USDT",
|
||||
"orderId": "3551312894",
|
||||
"timestamp": 1674493798550,
|
||||
"datetime": "2023-03-25T15:49:58.550Z",
|
||||
"price": 15.5,
|
||||
"status": "open",
|
||||
"amount": 1.1,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
"gate": {
|
||||
@@ -159,6 +219,7 @@ EXCHANGES = {
|
||||
"leverage_in_spot_market": True,
|
||||
"sample_order": [
|
||||
{
|
||||
"exchange_response": {
|
||||
"id": "276266139423",
|
||||
"text": "apiv4",
|
||||
"create_time": "1674493798",
|
||||
@@ -188,7 +249,19 @@ EXCHANGES = {
|
||||
"rebated_fee": "0",
|
||||
"rebated_fee_currency": "USDT",
|
||||
},
|
||||
"pair": "SOL/USDT",
|
||||
"expected": {
|
||||
"symbol": "SOL/USDT",
|
||||
"orderId": "3551312894",
|
||||
"timestamp": 1674493798550,
|
||||
"datetime": "2023-03-25T15:49:58.550Z",
|
||||
"price": 15.5,
|
||||
"status": "open",
|
||||
"amount": 1.1,
|
||||
},
|
||||
},
|
||||
{
|
||||
"exchange_response": {
|
||||
# market order
|
||||
"id": "276401180529",
|
||||
"text": "apiv4",
|
||||
@@ -219,6 +292,17 @@ EXCHANGES = {
|
||||
"rebated_fee": "0",
|
||||
"rebated_fee_currency": "USDT",
|
||||
},
|
||||
"pair": "SOL/USDT",
|
||||
"expected": {
|
||||
"symbol": "SOL/USDT",
|
||||
"orderId": "3551312894",
|
||||
"timestamp": 1674493798550,
|
||||
"datetime": "2023-03-25T15:49:58.550Z",
|
||||
"price": 15.5,
|
||||
"status": "open",
|
||||
"amount": 1.1,
|
||||
},
|
||||
},
|
||||
],
|
||||
"sample_my_trades": [
|
||||
{
|
||||
@@ -264,6 +348,7 @@ EXCHANGES = {
|
||||
"leverage_in_spot_market": True,
|
||||
"sample_order": [
|
||||
{
|
||||
"exchange_response": {
|
||||
"orderId": "1274754916287346280",
|
||||
"orderLinkId": "1666798627015730",
|
||||
"symbol": "SOLUSDT",
|
||||
@@ -277,6 +362,17 @@ EXCHANGES = {
|
||||
"accountId": "5555555",
|
||||
"execQty": "0",
|
||||
"orderCategory": "0",
|
||||
},
|
||||
"pair": "SOL/USDT",
|
||||
"expected": {
|
||||
"symbol": "SOL/USDT",
|
||||
"orderId": "3551312894",
|
||||
"timestamp": 1674493798550,
|
||||
"datetime": "2023-03-25T15:49:58.550Z",
|
||||
"price": 15.5,
|
||||
"status": "open",
|
||||
"amount": 1.1,
|
||||
},
|
||||
}
|
||||
],
|
||||
},
|
||||
@@ -310,6 +406,7 @@ EXCHANGES = {
|
||||
"futures": False,
|
||||
"sample_order": [
|
||||
{
|
||||
"exchange_response": {
|
||||
"symbol": "SOL-USDT",
|
||||
"orderId": "1762393630149869568",
|
||||
"transactTime": "1674493798550",
|
||||
@@ -323,7 +420,19 @@ EXCHANGES = {
|
||||
"side": "BUY",
|
||||
"clientOrderID": "",
|
||||
},
|
||||
"pair": "SOL/USDT",
|
||||
"expected": {
|
||||
"symbol": "SOL/USDT",
|
||||
"orderId": "3551312894",
|
||||
"timestamp": 1674493798550,
|
||||
"datetime": "2023-03-25T15:49:58.550Z",
|
||||
"price": 15.5,
|
||||
"status": "open",
|
||||
"amount": 1.1,
|
||||
},
|
||||
},
|
||||
{
|
||||
"exchange_response": {
|
||||
"symbol": "SOL-USDT",
|
||||
"orderId": "1762393630149869568",
|
||||
"transactTime": "1674493798550",
|
||||
@@ -337,6 +446,17 @@ EXCHANGES = {
|
||||
"side": "BUY",
|
||||
"clientOrderID": "",
|
||||
},
|
||||
"pair": "SOL/USDT",
|
||||
"expected": {
|
||||
"symbol": "SOL/USDT",
|
||||
"orderId": "3551312894",
|
||||
"timestamp": 1674493798550,
|
||||
"datetime": "2023-03-25T15:49:58.550Z",
|
||||
"price": 15.5,
|
||||
"status": "open",
|
||||
"amount": 1.1,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
"hyperliquid": {
|
||||
|
||||
@@ -61,28 +61,31 @@ class TestCCXTExchange:
|
||||
def test_ccxt_order_parse(self, exchange: EXCHANGE_FIXTURE_TYPE):
|
||||
exch, exchange_name = exchange
|
||||
if orders := EXCHANGES[exchange_name].get("sample_order"):
|
||||
pair = "SOL/USDT"
|
||||
for order in orders:
|
||||
pair = order["pair"]
|
||||
exchange_response: dict = order["exchange_response"]
|
||||
|
||||
market = exch._api.markets[pair]
|
||||
po = exch._api.parse_order(order, market)
|
||||
po = exch._api.parse_order(exchange_response, market)
|
||||
expected = order["expected"]
|
||||
assert isinstance(po["id"], str)
|
||||
assert po["id"] is not None
|
||||
if len(order.keys()) < 5:
|
||||
if len(exchange_response.keys()) < 5:
|
||||
# Kucoin case
|
||||
assert po["status"] is None
|
||||
continue
|
||||
assert po["timestamp"] == 1674493798550
|
||||
assert po["timestamp"] == expected["timestamp"]
|
||||
assert isinstance(po["datetime"], str)
|
||||
assert isinstance(po["timestamp"], int)
|
||||
assert isinstance(po["price"], float)
|
||||
assert po["price"] == 15.5
|
||||
assert po["price"] == expected["price"]
|
||||
if po["status"] == "closed":
|
||||
# Filled orders should have average assigned.
|
||||
assert isinstance(po["average"], float)
|
||||
assert po["average"] == 15.5
|
||||
assert po["symbol"] == pair
|
||||
assert isinstance(po["amount"], float)
|
||||
assert po["amount"] == 1.1
|
||||
assert po["amount"] == expected["amount"]
|
||||
assert isinstance(po["status"], str)
|
||||
else:
|
||||
pytest.skip(f"No sample order available for exchange {exchange_name}")
|
||||
|
||||
Reference in New Issue
Block a user