tests: Improve sample_order online testing
This commit is contained in:
+293
-173
@@ -30,40 +30,64 @@ EXCHANGES = {
|
|||||||
"private_methods": ["fapiPrivateGetPositionSideDual", "fapiPrivateGetMultiAssetsMargin"],
|
"private_methods": ["fapiPrivateGetPositionSideDual", "fapiPrivateGetMultiAssetsMargin"],
|
||||||
"sample_order": [
|
"sample_order": [
|
||||||
{
|
{
|
||||||
"symbol": "SOLUSDT",
|
"exchange_response": {
|
||||||
"orderId": 3551312894,
|
"symbol": "SOLUSDT",
|
||||||
"orderListId": -1,
|
"orderId": 3551312894,
|
||||||
"clientOrderId": "x-R4DD3S8297c73a11ccb9dc8f2811ba",
|
"orderListId": -1,
|
||||||
"transactTime": 1674493798550,
|
"clientOrderId": "x-R4DD3S8297c73a11ccb9dc8f2811ba",
|
||||||
"price": "15.50000000",
|
"transactTime": 1674493798550,
|
||||||
"origQty": "1.10000000",
|
"price": "15.50000000",
|
||||||
"executedQty": "0.00000000",
|
"origQty": "1.10000000",
|
||||||
"cummulativeQuoteQty": "0.00000000",
|
"executedQty": "0.00000000",
|
||||||
"status": "NEW",
|
"cummulativeQuoteQty": "0.00000000",
|
||||||
"timeInForce": "GTC",
|
"status": "NEW",
|
||||||
"type": "LIMIT",
|
"timeInForce": "GTC",
|
||||||
"side": "BUY",
|
"type": "LIMIT",
|
||||||
"workingTime": 1674493798550,
|
"side": "BUY",
|
||||||
"fills": [],
|
"workingTime": 1674493798550,
|
||||||
"selfTradePreventionMode": "NONE",
|
"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,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"symbol": "SOLUSDT",
|
"exchange_response": {
|
||||||
"orderId": 3551312894,
|
"symbol": "SOLUSDT",
|
||||||
"orderListId": -1,
|
"orderId": 3551312894,
|
||||||
"clientOrderId": "x-R4DD3S8297c73a11ccb9dc8f2811ba",
|
"orderListId": -1,
|
||||||
"transactTime": 1674493798550,
|
"clientOrderId": "x-R4DD3S8297c73a11ccb9dc8f2811ba",
|
||||||
"price": "15.50000000",
|
"transactTime": 1674493798550,
|
||||||
"origQty": "1.10000000",
|
"price": "15.50000000",
|
||||||
"executedQty": "1.10000000",
|
"origQty": "1.10000000",
|
||||||
"cummulativeQuoteQty": "17.05",
|
"executedQty": "1.10000000",
|
||||||
"status": "FILLED",
|
"cummulativeQuoteQty": "17.05",
|
||||||
"timeInForce": "GTC",
|
"status": "FILLED",
|
||||||
"type": "LIMIT",
|
"timeInForce": "GTC",
|
||||||
"side": "BUY",
|
"type": "LIMIT",
|
||||||
"workingTime": 1674493798550,
|
"side": "BUY",
|
||||||
"fills": [],
|
"workingTime": 1674493798550,
|
||||||
"selfTradePreventionMode": "NONE",
|
"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,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -76,22 +100,34 @@ EXCHANGES = {
|
|||||||
"skip_ws_tests": True,
|
"skip_ws_tests": True,
|
||||||
"sample_order": [
|
"sample_order": [
|
||||||
{
|
{
|
||||||
"symbol": "SOLUSDT",
|
"exchange_response": {
|
||||||
"orderId": 3551312894,
|
"symbol": "SOLUSDT",
|
||||||
"orderListId": -1,
|
"orderId": 3551312894,
|
||||||
"clientOrderId": "x-R4DD3S8297c73a11ccb9dc8f2811ba",
|
"orderListId": -1,
|
||||||
"transactTime": 1674493798550,
|
"clientOrderId": "x-R4DD3S8297c73a11ccb9dc8f2811ba",
|
||||||
"price": "15.50000000",
|
"transactTime": 1674493798550,
|
||||||
"origQty": "1.10000000",
|
"price": "15.50000000",
|
||||||
"executedQty": "0.00000000",
|
"origQty": "1.10000000",
|
||||||
"cummulativeQuoteQty": "0.00000000",
|
"executedQty": "0.00000000",
|
||||||
"status": "NEW",
|
"cummulativeQuoteQty": "0.00000000",
|
||||||
"timeInForce": "GTC",
|
"status": "NEW",
|
||||||
"type": "LIMIT",
|
"timeInForce": "GTC",
|
||||||
"side": "BUY",
|
"type": "LIMIT",
|
||||||
"workingTime": 1674493798550,
|
"side": "BUY",
|
||||||
"fills": [],
|
"workingTime": 1674493798550,
|
||||||
"selfTradePreventionMode": "NONE",
|
"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,38 +148,62 @@ EXCHANGES = {
|
|||||||
"leverage_tiers_public": False,
|
"leverage_tiers_public": False,
|
||||||
"leverage_in_spot_market": True,
|
"leverage_in_spot_market": True,
|
||||||
"sample_order": [
|
"sample_order": [
|
||||||
{"id": "63d6742d0adc5570001d2bbf7"}, # create order
|
|
||||||
{
|
{
|
||||||
"id": "63d6742d0adc5570001d2bbf7",
|
"exchange_response": {"id": "63d6742d0adc5570001d2bbf7"},
|
||||||
"symbol": "SOL-USDT",
|
"pair": "SOL/USDT",
|
||||||
"opType": "DEAL",
|
"expected": {
|
||||||
"type": "limit",
|
"symbol": "SOL/USDT",
|
||||||
"side": "buy",
|
"orderId": "3551312894",
|
||||||
"price": "15.5",
|
"timestamp": 1674493798550,
|
||||||
"size": "1.1",
|
"datetime": "2023-03-25T15:49:58.550Z",
|
||||||
"funds": "0",
|
"price": 15.5,
|
||||||
"dealFunds": "17.05",
|
"status": "open",
|
||||||
"dealSize": "1.1",
|
"amount": 1.1,
|
||||||
"fee": "0.000065252",
|
},
|
||||||
"feeCurrency": "USDT",
|
}, # create order
|
||||||
"stp": "",
|
{
|
||||||
"stop": "",
|
"exchange_response": {
|
||||||
"stopTriggered": False,
|
"id": "63d6742d0adc5570001d2bbf7",
|
||||||
"stopPrice": "0",
|
"symbol": "SOL-USDT",
|
||||||
"timeInForce": "GTC",
|
"opType": "DEAL",
|
||||||
"postOnly": False,
|
"type": "limit",
|
||||||
"hidden": False,
|
"side": "buy",
|
||||||
"iceberg": False,
|
"price": "15.5",
|
||||||
"visibleSize": "0",
|
"size": "1.1",
|
||||||
"cancelAfter": 0,
|
"funds": "0",
|
||||||
"channel": "API",
|
"dealFunds": "17.05",
|
||||||
"clientOid": "0a053870-11bf-41e5-be61-b272a4cb62e1",
|
"dealSize": "1.1",
|
||||||
"remark": None,
|
"fee": "0.000065252",
|
||||||
"tags": "partner:ccxt",
|
"feeCurrency": "USDT",
|
||||||
"isActive": False,
|
"stp": "",
|
||||||
"cancelExist": False,
|
"stop": "",
|
||||||
"createdAt": 1674493798550,
|
"stopTriggered": False,
|
||||||
"tradeType": "TRADE",
|
"stopPrice": "0",
|
||||||
|
"timeInForce": "GTC",
|
||||||
|
"postOnly": False,
|
||||||
|
"hidden": False,
|
||||||
|
"iceberg": False,
|
||||||
|
"visibleSize": "0",
|
||||||
|
"cancelAfter": 0,
|
||||||
|
"channel": "API",
|
||||||
|
"clientOid": "0a053870-11bf-41e5-be61-b272a4cb62e1",
|
||||||
|
"remark": None,
|
||||||
|
"tags": "partner:ccxt",
|
||||||
|
"isActive": False,
|
||||||
|
"cancelExist": False,
|
||||||
|
"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,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -159,65 +219,89 @@ EXCHANGES = {
|
|||||||
"leverage_in_spot_market": True,
|
"leverage_in_spot_market": True,
|
||||||
"sample_order": [
|
"sample_order": [
|
||||||
{
|
{
|
||||||
"id": "276266139423",
|
"exchange_response": {
|
||||||
"text": "apiv4",
|
"id": "276266139423",
|
||||||
"create_time": "1674493798",
|
"text": "apiv4",
|
||||||
"update_time": "1674493798",
|
"create_time": "1674493798",
|
||||||
"create_time_ms": "1674493798550",
|
"update_time": "1674493798",
|
||||||
"update_time_ms": "1674493798550",
|
"create_time_ms": "1674493798550",
|
||||||
"status": "closed",
|
"update_time_ms": "1674493798550",
|
||||||
"currency_pair": "SOL_USDT",
|
"status": "closed",
|
||||||
"type": "limit",
|
"currency_pair": "SOL_USDT",
|
||||||
"account": "spot",
|
"type": "limit",
|
||||||
"side": "buy",
|
"account": "spot",
|
||||||
"amount": "1.1",
|
"side": "buy",
|
||||||
"price": "15.5",
|
"amount": "1.1",
|
||||||
"time_in_force": "gtc",
|
"price": "15.5",
|
||||||
"iceberg": "0",
|
"time_in_force": "gtc",
|
||||||
"left": "0",
|
"iceberg": "0",
|
||||||
"fill_price": "17.05",
|
"left": "0",
|
||||||
"filled_total": "17.05",
|
"fill_price": "17.05",
|
||||||
"avg_deal_price": "15.5",
|
"filled_total": "17.05",
|
||||||
"fee": "0.0000018",
|
"avg_deal_price": "15.5",
|
||||||
"fee_currency": "SOL",
|
"fee": "0.0000018",
|
||||||
"point_fee": "0",
|
"fee_currency": "SOL",
|
||||||
"gt_fee": "0",
|
"point_fee": "0",
|
||||||
"gt_maker_fee": "0",
|
"gt_fee": "0",
|
||||||
"gt_taker_fee": "0.0015",
|
"gt_maker_fee": "0",
|
||||||
"gt_discount": True,
|
"gt_taker_fee": "0.0015",
|
||||||
"rebated_fee": "0",
|
"gt_discount": True,
|
||||||
"rebated_fee_currency": "USDT",
|
"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,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
# market order
|
"exchange_response": {
|
||||||
"id": "276401180529",
|
# market order
|
||||||
"text": "apiv4",
|
"id": "276401180529",
|
||||||
"create_time": "1674493798",
|
"text": "apiv4",
|
||||||
"update_time": "1674493798",
|
"create_time": "1674493798",
|
||||||
"create_time_ms": "1674493798550",
|
"update_time": "1674493798",
|
||||||
"update_time_ms": "1674493798550",
|
"create_time_ms": "1674493798550",
|
||||||
"status": "cancelled",
|
"update_time_ms": "1674493798550",
|
||||||
"currency_pair": "SOL_USDT",
|
"status": "cancelled",
|
||||||
"type": "market",
|
"currency_pair": "SOL_USDT",
|
||||||
"account": "spot",
|
"type": "market",
|
||||||
"side": "buy",
|
"account": "spot",
|
||||||
"amount": "17.05",
|
"side": "buy",
|
||||||
"price": "0",
|
"amount": "17.05",
|
||||||
"time_in_force": "ioc",
|
"price": "0",
|
||||||
"iceberg": "0",
|
"time_in_force": "ioc",
|
||||||
"left": "0.0000000016228",
|
"iceberg": "0",
|
||||||
"fill_price": "17.05",
|
"left": "0.0000000016228",
|
||||||
"filled_total": "17.05",
|
"fill_price": "17.05",
|
||||||
"avg_deal_price": "15.5",
|
"filled_total": "17.05",
|
||||||
"fee": "0",
|
"avg_deal_price": "15.5",
|
||||||
"fee_currency": "SOL",
|
"fee": "0",
|
||||||
"point_fee": "0.0199999999967544",
|
"fee_currency": "SOL",
|
||||||
"gt_fee": "0",
|
"point_fee": "0.0199999999967544",
|
||||||
"gt_maker_fee": "0",
|
"gt_fee": "0",
|
||||||
"gt_taker_fee": "0",
|
"gt_maker_fee": "0",
|
||||||
"gt_discount": False,
|
"gt_taker_fee": "0",
|
||||||
"rebated_fee": "0",
|
"gt_discount": False,
|
||||||
"rebated_fee_currency": "USDT",
|
"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": [
|
"sample_my_trades": [
|
||||||
@@ -264,19 +348,31 @@ EXCHANGES = {
|
|||||||
"leverage_in_spot_market": True,
|
"leverage_in_spot_market": True,
|
||||||
"sample_order": [
|
"sample_order": [
|
||||||
{
|
{
|
||||||
"orderId": "1274754916287346280",
|
"exchange_response": {
|
||||||
"orderLinkId": "1666798627015730",
|
"orderId": "1274754916287346280",
|
||||||
"symbol": "SOLUSDT",
|
"orderLinkId": "1666798627015730",
|
||||||
"createdTime": "1674493798550",
|
"symbol": "SOLUSDT",
|
||||||
"price": "15.5",
|
"createdTime": "1674493798550",
|
||||||
"qty": "1.1",
|
"price": "15.5",
|
||||||
"orderType": "Limit",
|
"qty": "1.1",
|
||||||
"side": "Buy",
|
"orderType": "Limit",
|
||||||
"orderStatus": "New",
|
"side": "Buy",
|
||||||
"timeInForce": "GTC",
|
"orderStatus": "New",
|
||||||
"accountId": "5555555",
|
"timeInForce": "GTC",
|
||||||
"execQty": "0",
|
"accountId": "5555555",
|
||||||
"orderCategory": "0",
|
"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,32 +406,56 @@ EXCHANGES = {
|
|||||||
"futures": False,
|
"futures": False,
|
||||||
"sample_order": [
|
"sample_order": [
|
||||||
{
|
{
|
||||||
"symbol": "SOL-USDT",
|
"exchange_response": {
|
||||||
"orderId": "1762393630149869568",
|
"symbol": "SOL-USDT",
|
||||||
"transactTime": "1674493798550",
|
"orderId": "1762393630149869568",
|
||||||
"price": "15.5",
|
"transactTime": "1674493798550",
|
||||||
"stopPrice": "0",
|
"price": "15.5",
|
||||||
"origQty": "1.1",
|
"stopPrice": "0",
|
||||||
"executedQty": "1.1",
|
"origQty": "1.1",
|
||||||
"cummulativeQuoteQty": "17.05",
|
"executedQty": "1.1",
|
||||||
"status": "FILLED",
|
"cummulativeQuoteQty": "17.05",
|
||||||
"type": "LIMIT",
|
"status": "FILLED",
|
||||||
"side": "BUY",
|
"type": "LIMIT",
|
||||||
"clientOrderID": "",
|
"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,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"symbol": "SOL-USDT",
|
"exchange_response": {
|
||||||
"orderId": "1762393630149869568",
|
"symbol": "SOL-USDT",
|
||||||
"transactTime": "1674493798550",
|
"orderId": "1762393630149869568",
|
||||||
"price": "15.5",
|
"transactTime": "1674493798550",
|
||||||
"stopPrice": "0",
|
"price": "15.5",
|
||||||
"origQty": "1.1",
|
"stopPrice": "0",
|
||||||
"executedQty": "1.1",
|
"origQty": "1.1",
|
||||||
"cummulativeQuoteQty": "17.05",
|
"executedQty": "1.1",
|
||||||
"status": "FILLED",
|
"cummulativeQuoteQty": "17.05",
|
||||||
"type": "MARKET",
|
"status": "FILLED",
|
||||||
"side": "BUY",
|
"type": "MARKET",
|
||||||
"clientOrderID": "",
|
"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,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -61,28 +61,31 @@ class TestCCXTExchange:
|
|||||||
def test_ccxt_order_parse(self, exchange: EXCHANGE_FIXTURE_TYPE):
|
def test_ccxt_order_parse(self, exchange: EXCHANGE_FIXTURE_TYPE):
|
||||||
exch, exchange_name = exchange
|
exch, exchange_name = exchange
|
||||||
if orders := EXCHANGES[exchange_name].get("sample_order"):
|
if orders := EXCHANGES[exchange_name].get("sample_order"):
|
||||||
pair = "SOL/USDT"
|
|
||||||
for order in orders:
|
for order in orders:
|
||||||
|
pair = order["pair"]
|
||||||
|
exchange_response: dict = order["exchange_response"]
|
||||||
|
|
||||||
market = exch._api.markets[pair]
|
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 isinstance(po["id"], str)
|
||||||
assert po["id"] is not None
|
assert po["id"] is not None
|
||||||
if len(order.keys()) < 5:
|
if len(exchange_response.keys()) < 5:
|
||||||
# Kucoin case
|
# Kucoin case
|
||||||
assert po["status"] is None
|
assert po["status"] is None
|
||||||
continue
|
continue
|
||||||
assert po["timestamp"] == 1674493798550
|
assert po["timestamp"] == expected["timestamp"]
|
||||||
assert isinstance(po["datetime"], str)
|
assert isinstance(po["datetime"], str)
|
||||||
assert isinstance(po["timestamp"], int)
|
assert isinstance(po["timestamp"], int)
|
||||||
assert isinstance(po["price"], float)
|
assert isinstance(po["price"], float)
|
||||||
assert po["price"] == 15.5
|
assert po["price"] == expected["price"]
|
||||||
if po["status"] == "closed":
|
if po["status"] == "closed":
|
||||||
# Filled orders should have average assigned.
|
# Filled orders should have average assigned.
|
||||||
assert isinstance(po["average"], float)
|
assert isinstance(po["average"], float)
|
||||||
assert po["average"] == 15.5
|
assert po["average"] == 15.5
|
||||||
assert po["symbol"] == pair
|
assert po["symbol"] == pair
|
||||||
assert isinstance(po["amount"], float)
|
assert isinstance(po["amount"], float)
|
||||||
assert po["amount"] == 1.1
|
assert po["amount"] == expected["amount"]
|
||||||
assert isinstance(po["status"], str)
|
assert isinstance(po["status"], str)
|
||||||
else:
|
else:
|
||||||
pytest.skip(f"No sample order available for exchange {exchange_name}")
|
pytest.skip(f"No sample order available for exchange {exchange_name}")
|
||||||
|
|||||||
Reference in New Issue
Block a user