ctubio / Krypto-trading-bot

Self-hosted crypto trading bot (automated high frequency market making) written in C++
https://127.0.0.1:3000
Other
3.37k stars 823 forks source link

Bitfinex: CURL recv Error: Failed sending data to the peer #1056

Closed MiningInMySleep closed 3 years ago

MiningInMySleep commented 3 years ago

Still seeing this issue with --lifetime=2000. Sometimes it has no problem. Other times it will just get stuck. After reconnect the web UI shows orders, but held amounts are both 0 and the orders don't show up on the exchange.

Could it be because the quoting engine is enabled before all WS subscriptions are opened that causes this problem?

After reconnect: 02/08 11:26:38.807004 GW BITFINEX WS Streaming channel 537961:trades. 02/08 11:26:38.836461 GW BITFINEX Quoting state changed to CONNECTED. 02/08 11:26:38.836534 GW BITFINEX WS Streaming wallet and orders OK 0:"auth". 02/08 11:26:39.561294 GW BITFINEX WS Streaming channel 632817:book.

Restarting the quoting engine seems to fix it.

ctubio commented 3 years ago

:koala: thank you for insist; can you please let me know if this was on BTC/USD? or was in another bitfinex market? (is just to test the very same, but should not matter)

MiningInMySleep commented 3 years ago

Yes, it's the same BTC/USD pair. Here is another log of it happening, but this time it continued trading just fine.

02/08 15:42:21.530698 GW BITFINEX Warrrrning: CURL recv Error: Failure when receiving data from the peer. 02/08 15:42:21.609159 GW BITFINEX Quoting state changed to DISCONNECTED. 02/08 15:42:21.610145 GW BITFINEX WS Disconnected, reconnecting in 7s.. 02/08 15:42:28.686387 QE Warrrrning: Unable to calculate quote, missing market data. 02/08 15:42:28.689548 GW BITFINEX WS Info {"event":"info","platform":{"status":1},"serverId":"9b3bb500-56ac-4d44-9136-33b5570b9721","version":2}. 02/08 15:42:28.718477 GW BITFINEX WS Streaming channel 244988:trades. 02/08 15:42:28.719331 GW BITFINEX Quoting state changed to CONNECTED. 02/08 15:42:28.720151 GW BITFINEX WS Streaming wallet and orders OK 0:"auth". 02/08 15:42:29.609172 QE Warrrrning: Unable to calculate quote, missing market data. 02/08 15:42:30.609218 QE Warrrrning: Unable to calculate quote, missing market data. 02/08 15:42:31.186471 GW BITFINEX WS Streaming channel 337094:book.

eniware-org commented 3 years ago

+1 I also opened a new issue

ctubio commented 3 years ago

im afraid ima conclude this is an issue of the great connectivity of bitfinex

do you expect the bot to do something else when bitfinex drops the connection without notice? (im happy as-is if you ask me)

MiningInMySleep commented 3 years ago

Is there a way to check if the orders placed after the bot reconnects are actually on the exchange? Because the main issue is that the bot will disconnect, K UI will show new orders, but those orders aren't actually in the books/on the exchange until the quoting engine is restarted AFTER the reconnect. This behavior is unpredictable and there is a chance that the orders are real as well.

ctubio commented 3 years ago

is there a way to check if orders are still alive, but that is just too complex; i preffer to just cancel&clean current orders in memory and let the quoting engine place new ones

(is not complex, is just extra useless calls up and down)

MiningInMySleep commented 3 years ago

I'm fine with clearing the orders and re-placing them upon reconnect, but a lot of the time it reconnects there are no real orders placed. The bot will just sit there forever with no orders until QE is restarted. Would delaying the enabling of the QE upon reconnecting help with this?

MiningInMySleep commented 3 years ago

One other thing that comes to mind would be increasing the time between reconnects? If it is not a problem with the bot itself and an issue on the API, an increased delay on reconnect could help. If it is an issue with the QE upon reconnect though, it won't help much.

ctubio commented 3 years ago

after next commit enabling cxl in the UI now cleans local as well as remote orders