Issue with order price and total qty

Hello,

I’m testing on the Testnet and I would like to understand what’s happening in order to avoid issues in production.
As a test I was selling around 16 BNB at 485$ but I noticed in the order that the last two fills have a different price (364 and 100, instead of the average of 485).

{
"symbol": "BNBUSDT",
"orderId": 6630050,
"orderListId": -1,
"clientOrderId": "DGRaUozNw41URGdqfZJgWg",
"transactTime": 1630245149956,
"price": "0.00000000",
"origQty": "16.09000000",
"executedQty": "16.09000000",
"cummulativeQuoteQty": "7173.46200000",
"status": "FILLED",
"timeInForce": "GTC",
"type": "MARKET",
"side": "SELL",
"fills": [
    {
        "price": "485.30000000",
        "qty": "0.92000000",
        "commission": "0.00000000",
        "commissionAsset": "USDT",
        "tradeId": 494745
    },
    {
        "price": "485.10000000",
        "qty": "1.04000000",
        "commission": "0.00000000",
        "commissionAsset": "USDT",
        "tradeId": 494746
    },
    {
        "price": "484.90000000",
        "qty": "1.04000000",
        "commission": "0.00000000",
        "commissionAsset": "USDT",
        "tradeId": 494747
    },
    {
        "price": "484.80000000",
        "qty": "1.04000000",
        "commission": "0.00000000",
        "commissionAsset": "USDT",
        "tradeId": 494748
    },
    {
        "price": "484.70000000",
        "qty": "1.04000000",
        "commission": "0.00000000",
        "commissionAsset": "USDT",
        "tradeId": 494749
    },
    {
        "price": "484.60000000",
        "qty": "1.04000000",
        "commission": "0.00000000",
        "commissionAsset": "USDT",
        "tradeId": 494750
    },
    {
        "price": "484.50000000",
        "qty": "1.04000000",
        "commission": "0.00000000",
        "commissionAsset": "USDT",
        "tradeId": 494751
    },
    {
        "price": "484.40000000",
        "qty": "1.04000000",
        "commission": "0.00000000",
        "commissionAsset": "USDT",
        "tradeId": 494752
    },
    {
        "price": "484.30000000",
        "qty": "1.04000000",
        "commission": "0.00000000",
        "commissionAsset": "USDT",
        "tradeId": 494753
    },
    {
        "price": "484.20000000",
        "qty": "1.04000000",
        "commission": "0.00000000",
        "commissionAsset": "USDT",
        "tradeId": 494754
    },
    {
        "price": "484.10000000",
        "qty": "1.04000000",
        "commission": "0.00000000",
        "commissionAsset": "USDT",
        "tradeId": 494755
    },
    {
        "price": "484.00000000",
        "qty": "1.04000000",
        "commission": "0.00000000",
        "commissionAsset": "USDT",
        "tradeId": 494756
    },
    {
        "price": "483.90000000",
        "qty": "1.04000000",
        "commission": "0.00000000",
        "commissionAsset": "USDT",
        "tradeId": 494757
    },
    {
        "price": "483.40000000",
        "qty": "1.04000000",
        "commission": "0.00000000",
        "commissionAsset": "USDT",
        "tradeId": 494758
    },
    {
        "price": "364.20000000",
        "qty": "0.05000000",
        "commission": "0.00000000",
        "commissionAsset": "USDT",
        "tradeId": 494759
    },
    {
        "price": "100.00000000",
        "qty": "1.60000000",
        "commission": "0.00000000",
        "commissionAsset": "USDT",
        "tradeId": 494760
    }
]

Right after I wanted to test the opposite and tried to buy BNB with all the USDT left and something similar happened, leaving me with a total of around 11.6 BNB.

{
"symbol": "BNBUSDT",
"orderId": 6630073,
"orderListId": -1,
"clientOrderId": "uvppLvF5tkaR1RVJMFPbcQ",
"transactTime": 1630245160362,
"price": "0.00000000",
"origQty": "11.60000000",
"executedQty": "11.60000000",
"cummulativeQuoteQty": "7167.64200000",
"status": "FILLED",
"timeInForce": "GTC",
"type": "MARKET",
"side": "BUY",
"fills": [
    {
        "price": "485.70000000",
        "qty": "1.03000000",
        "commission": "0.00000000",
        "commissionAsset": "BNB",
        "tradeId": 494763
    },
    {
        "price": "630.54000000",
        "qty": "2.56000000",
        "commission": "0.00000000",
        "commissionAsset": "BNB",
        "tradeId": 494764
    },
    {
        "price": "630.86000000",
        "qty": "8.01000000",
        "commission": "0.00000000",
        "commissionAsset": "BNB",
        "tradeId": 494765
    }
]

Is there something wrong in the testnet or am I doing something wrong?

Hi.
This is the characteristic of the market order. It matches whatever resides in the order book until the quantity meets what you set or the order book is cleared.

Hello Ishuen,

Thank you for your reply. Based on my understanding and your answer, it is a problem of Testnet only, as the order book differ from the real order book. So this would not happen in production. Am I correct?

By my test selling 16 BNB at 485$ I should have got around 7.760$ while I got 7.173$ (Burned 587$). And right after by buying BNB with all 7.173$ at 485$ I should have got 14.8 BNB while I got 11.6 BNB (Burned 1.547$).
In short If I run this again other 2 or 3 times in a period of just 30 seconds or 1 minute I will be left with no liquidity in the Testnet.
I mean in real we will not see so much difference in the order book to burn liquidity like in the Testnet, correct?

We can only say this is less likely to happen in production. If you want to secure the minimum sell price, you should consider placing a limit order or a take profit order instead of a market order.

Thank you Ishuen.
It was simply to understand where the problem was and I understood that it’s just an issue with testnet.
Thank you for your support.