chrisleekr / binance-trading-bot

Automated Binance trading bot - Trade multiple cryptocurrencies. Buy low/sell high with Grid Trading. Integrated with TradingView technical analysis
MIT License
5k stars 1.09k forks source link

Unknown order sent #149

Closed lilianchiassai closed 3 years ago

lilianchiassai commented 3 years ago

This morning I got a ton of Execution failed error message on Slack.

Execution failed
Code: -2011
Message:
Unknown order sent.```Stack:```Error: Unknown order sent.
    at /srv/node_modules/binance-api-node/dist/http-client.js:93:17
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async s (/srv/dist/server.js:1:14096)
    at async execute (/srv/dist/server.js:1:14527)
    at async execute (/srv/dist/server.js:1:5317)
    at async CronJob.<anonymous> (/srv/dist/server.js:1:22789)

Unfortunately the docker logs have already been truncated, so I don't have more than that.

The bot fire those logs only when an order is already open and I did not notice anything weird in the bot behaviour appart from the logs (the timestamp of the logs do not match any order in the order history and the orders were properly cancelled).

chrisleekr commented 3 years ago

Hmm, that is strange.

Do you know which coin was for the order?

picklerickft commented 3 years ago

Getting this same error this morning. Pair was XRP/AUD.

Checked the order history in Binance and the bot has entered three XRPAUD orders with a different price point. It looks like the error is caused by the bot not being able to cancel the currently open order.

image

image

lilianchiassai commented 3 years ago

It was with BTCUSD, BTTUSD and XRPUSD. I suspect it's either when the bot is trying to buy into two different symbols or when trying to fire multiple orders for one symbol.

chrisleekr commented 3 years ago

If the order was for buy or sell, it would have a prior message such as this - https://github.com/chrisleekr/binance-trading-bot/blob/master/app/jobs/trailingTrade/step/place-buy-order.js#L114

So I can guess that is cancelling the order, which does not send a prior message - https://github.com/chrisleekr/binance-trading-bot/blob/master/app/jobs/trailingTrade/step/handle-open-orders.js#L12

What I can assume here, for some reason, the bot assumed there is an open order and try to cancel, which is already executed. And the Binance API was, for some reason, continuously returns open orders including the executed one.

Is it continuously happening or once off?

lilianchiassai commented 3 years ago

It happened several times - not every time - and it stops after some time.

Here are my logs:

Buy Action: STOP_LOSS_LIMIT
 - Order Params:
{
  "symbol": "BTCUSDT",
  "side": "buy",
  "type": "STOP_LOSS_LIMIT",
  "quantity": 0.009735,
  "stopPrice": 55089.35,
  "price": 55144,
  "timeInForce": "GTC"
}

2:37
Buy Action Result: STOP_LOSS_LIMIT
   - Order Result:
{
  "symbol": "BTCUSDT",
  "orderId": 5774856131,
  "orderListId": -1,
  "clientOrderId": "k469vMGIy2UnVGpiUAJqsY",
  "transactTime": 1620139038530
}

2:37
Execution failed
Code: -2011
Message:
Unknown order sent.```Stack:```Error: Unknown order sent.
    at /srv/node_modules/binance-api-node/dist/http-client.js:93:17
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async s (/srv/dist/server.js:1:14096)
    at async execute (/srv/dist/server.js:1:14527)
    at async execute (/srv/dist/server.js:1:5317)
    at async CronJob.<anonymous> (/srv/dist/server.js:1:22789)

2:37
Execution failed
Code: -2011
Message:
Unknown order sent.```Stack:```Error: Unknown order sent.
    at /srv/node_modules/binance-api-node/dist/http-client.js:93:17
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async s (/srv/dist/server.js:1:14096)
    at async execute (/srv/dist/server.js:1:14527)
    at async execute (/srv/dist/server.js:1:5317)
    at async CronJob.<anonymous> (/srv/dist/server.js:1:22789)
chrisleekr commented 3 years ago

@AllirionX

That is really odd. It never happened to me. Probably try to use #77. It has a feature that confirms the placed order to make sure it is showing in the open order. Note that PR 77 is still in development. Try to read through the comments to make sure you understand what the changes are.

silkyland commented 3 years ago

It's happened to me too.

{
  "symbol": "LTCUSDT",
  "orderId": 1722079314,
  "orderListId": -1,
  "clientOrderId": "dSFYOlspnriemywvQuigwA",
  "transactTime": 1620353701021
}
Unknown order sent.```Stack:```Error: Unknown order sent.
    at /srv/node_modules/binance-api-node/dist/http-client.js:93:17
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async s (/srv/dist/server.js:1:14096)
    at async execute (/srv/dist/server.js:1:14920)
    at async execute (/srv/dist/server.js:1:5317)
    at async CronJob.<anonymous> (/srv/dist/server.js:1:22789)
chrisleekr commented 3 years ago

@AllirionX Are you using PR #77? And is it still happening?

@silkyland Try to use PR #77 and see how it goes.

lilianchiassai commented 3 years ago

@chrisleekr I have not had time to review PR #77 and did not wish to run an un-reviewed branch. I'll test it once I've had a read at the changes.

snettah commented 3 years ago

Same for me

It's right after an order have been filled

at 02:27am

image

at 02:27am

image

BTC/USDT

The bot run on raspberry 4

chrisleekr commented 3 years ago

@AllirionX That is ok. Please review and let me know if you find any issue.

@snettah As mentioned earlier, please try to use PR #77, as this PR would be the next version.

chrisleekr commented 3 years ago

@AllirionX

PR #77 will be merged in soon and will be released as the next version. If you have reviewed the code, and there is no more issue, then please close the issue.