My Script places a market order on “BTCUSDT” and calculates the initial limit orders for the grid. Just like in the Binance App. Then I implemented a user data stream for updating my orders and account info. Based on the order updates (“executionReport”) i go for a new exchange.new_order(). In general it works fine, but…
For example: Randomly the BTCUSDT price is at 21600 and i get an order update out of my socket userstream for a new placed BUY order at 21100. To make this happen, a previous SELL order for 21120 has to be filled, so that the buy order at 21100 is placed.
My questions:
Is it possible that a LIMIT BUY Order is placed at 21500 and is filled at 21100 (to generate the 21120 LIMIT SELL order)? Why would my LIMIT BUY Order be filled 400 USDT below my LIMIT BUY price of 21500? Is this normal or a “Bug” of the Testnet? I never had this szenario on the live Binance Trading App.
vice versa i see SELL Orders being filled at a price below the actual price. I guess this came from the place-sell-order - trigger when the websocket tells about an “below price”-filled BUY order update. Is this right? Not that script question - but furthermore a general question about filling BUY / SELL orders.
This is possible that if the current best sell price is 21100, and you place the BUY LIMIT at 21500, then it will be filled at 21100. The market is offering cheaper price, so your order will be filled with that price, because the SELL order comes to market first. It’s not a bug, it’s how order matching works.
Hey and thanks for your reply. This is correct and maybe i have expressed myself incorrectly. I mean how can the BUY LIMIT Order at 21500 be filled at 21100, when the Symbolprice “BTCUSDT” never hit the 21100 in that time period. The price ranged between 21600 and 21400 but has never fallen to the limit of 21100 in that time period.
And my exchange.new_order(symbol, side,…) function of the binance-connector that triggers the “POST /api/v3/order” is 100% based on my USER_STREAM (/api/v3/userDataStream) with my listenKey.
So the only way in my script to place a new SELL LIMIT Order is when the USER_STREAM tells me about a filled BUY LIMIT Order.
So my problem is, that the USER_STREAM informs me about filled BUY LIMIT Orders far below the current price level. And this is what is confusing me highly…
i test my grid bot at 80 usdt orders every 20 usdt range.
right now the btc price is 20.650 usdt and my user_data stream spams filled orders like the one below. (at price: 20040 usdt) how
order update
order id: 12366519
order creation datetime: 08.26.2022 - 23:49:53
transaction datetime: 08.27.2022 - 00:08:31
side: BUY
order quantity: 0.00399200
order price: 20040.00000000
current execution type: TRADE
current order status: FILLED
last executed quantity: 0.00399200
cumulative filled quantity: 0.00399200
last executed price: 20040.00000000
commission amount: 0.00000000
commission asset: BTC
cumulative quote asset transacted quantity: 79.99968000
last quote asset transacted quantity: 79.99968000
quote order quantity: 0.00000000
comparing open_order_list with own placed_order_list
checking missing orderId of open_order_list (has to be filled then)
if filled: create new order based on filled price +/- grid step
little delay
repeat
the websocket user_data stream is just the controlling instance right now. Just 2 mins ago I looked up my open_orders that contains only 18. Now, it has the correct value of 50 again. I didn’t do anything. I’m really confused because a new order will only be placed when the previous order[“status”] = “FILLED” is true.
Right now it is 00:25 o’clock.
Please have a look on the timestamp (it’s coded GMT+2) of filled order: So much happened around 00:01:58 o’clock… Do you have an idea? The posted data is from my user_data stream (Testnet). Of course I don’t have any influence on the websocket user_data stream.
I don’t even know why the last posted order (12369996) is filled with quote asset of 81.37769576 usdt. im placing 80 usdt orders and they get filled with 79.9… (I understand the 79.9… but not the 81…).
I’m full of hope! Have a nice evening.
regards Niels
order update
order id: 12369899
order creation datetime: 08.27.2022 - 00:01:40
transaction datetime: 08.27.2022 - 00:01:40
side: SELL
order quantity: 0.00387500
order price: 20640.00000000
current execution type: NEW
current order status: NEW
last executed quantity: 0.00000000
cumulative filled quantity: 0.00000000
last executed price: 0.00000000
commission amount: 0
commission asset: None
cumulative quote asset transacted quantity: 0.00000000
last quote asset transacted quantity: 0.00000000
quote order quantity: 0.00000000
order id: 12369996
order creation datetime: 08.27.2022 - 00:01:59
transaction datetime: 08.27.2022 - 00:01:59
side: SELL
order quantity: 0.00394400
order price: 20280.00000000
current execution type: NEW
current order status: NEW
last executed quantity: 0.00000000
cumulative filled quantity: 0.00000000
last executed price: 0.00000000
commission amount: 0
commission asset: None
cumulative quote asset transacted quantity: 0.00000000
last quote asset transacted quantity: 0.00000000
quote order quantity: 0.00000000
order update
order id: 12369996
order creation datetime: 08.27.2022 - 00:01:59
transaction datetime: 08.27.2022 - 00:01:59
side: SELL
order quantity: 0.00394400
order price: 20280.00000000
current execution type: TRADE
current order status: FILLED
last executed quantity: 0.00394400
cumulative filled quantity: 0.00394400
last executed price: 20633.29000000
commission amount: 0.00000000
commission asset: USDT
cumulative quote asset transacted quantity: 81.37769576
last quote asset transacted quantity: 81.37769576
quote order quantity: 0.00000000
→ 29.08.2022 - 12:24:20 - SELL order 13836560 filled at 19850.0!
It is 12:27 now. since 12:19 the highest price was 19838.49
Why is this limit SELL Order filled? Somebody bought a huge amount via MARKET Order so my Limit SELL Order was filled at better price?