So I tried to compare level2 channel between Advanced Trade and Pro…
Pro has level2 that seems to deliver updates/changes as they are happening and level_batch that are batching updates and sends them every 50 ms.
After comparing data it seems that Advanced Trade only has batch version that seems to send updates every ~500 ms. Also here updates are sorted by price.
Comparing random changes I saw up to 500 ms delay in Advanced Trade. That is not good for anyone writing bot that reacts to changes in order book.
Are there any plans to provide something that is comparable to Pro? Or better, something that would be real improvement?
The time property of l2update is the time of the event as recorded by our trading engine.
To make tests more meaningful I redone my tests to check time it takes to receive data. This time I used BTC-EUR. I am comparing Prolevel2 channel (non batch version that I was using) to Advanced Tradelevel2 channel (batch version as that is only one that is available)! Did 3 test runs that each counted 10000 changes/updates:
Pro tests:
avg: 0.056001, min: 0.049160, max: 0.306200
avg: 0.056309, min: 0.049337, max: 0.386209
avg: 0.054377, min: 0.049135, max: 0.339917
Advanced Trade tests:
avg: 0.168327, min: 0.080070, max: 1.482573
avg: 0.160521, min: 0.074409, max: 2.599032
avg: 0.185642, min: 0.072532, max: 2.802550
Above times are seconds! In Pro on average my bot got order book change/update after 56 ms with worst case 386 ms. In Advanced Trade average time is 160 ms, that is almost 3 times slower while worst case is almost 3 seconds.
Redone same test for BAT-EUR (as it has less frequent changes)!
Pro tests:
avg: 0.054625, min: 0.048921, max: 0.184618
avg: 0.058209, min: 0.050745, max: 0.154411 (reduced to 500 changes/updates)
avg: 0.057030, min: 0.050688, max: 0.185831 (reduced to 500 changes/updates)
Advanced Trade tests:
avg: 0.229105, min: 0.066123, max: 3.330473
avg: 0.236263, min: 0.077449, max: 1.479663 (reduced to 500 changes/updates)
avg: 0.158182, min: 0.070894, max: 1.046427 (reduced to 500 changes/updates)
Pro average time is better than best time in Advanced Trade.
Have you looked at a round-trio setup, like placing a LIMIT_MAKER and seeing how quickly you get the websocket feed from user and order-book?
I seem to find that the websocket is very flaky, I get tons of Connection Reset and aiohttp.ws_connect takes forever to reply. I actually use a timeout and spams the connect. Do you have hints as to what I may be doing incorrectly? Initially I used a gather for all pairs, then switched to a sequential, then sequential with sleep, now I am doing the tiemout/connect spam which seems to work better, but this is quite ugly
No. Also as I am already forcefully migrated to Advanced Trade I would not be able to compare that to Pro.
Also I have not tested Advanced Trade Websocket for long times. In Pro I just reconnected when I was disconnected without any timeouts. Reconnection did not seem to take more time then initial connection.
Do you trade multiple pairs simultaneously? Are you able to connect to one websocket connection for each pair (it seems to be what they recommend)? I do this for the user channel. For the order book, I used the older implementation that creates one connection and subscribes all the pairs through it
Ok, it is my mistake, I mis-read the doc, only 1 user channel should be opened with all the subs, so possibly they automatically close existing user connections. resulting in the Reset.
In Pro it worked. For Advanced Trade I have no bots, so I have no idea how good / bad multiple connections work.
I have not used user channel.
I noticed that in documentation too! Looks like Pro did not have such limitation…
I just opened 3 connections for BTC-EUR and one for BAT-EUR. All 4 outputted related info when I created test limit orders and canceled them. In short testing time I was not disconnected.
After longer time (4 tests are still running) websocket (random, not all!) does get closed but looks like there are no problems to reconnect. It does not look like they are actively disconnecting if there are multiple connections for user channel…
Thanks. I resorted to subscribing all the pairs for User (as they mentioned in the doc) with a 2s timeout on websocket connect, with a 0.1s reconnect if a ConnectionResetError occurs
It seems to be better.
I find it very odd that a 1s timeout would expire before Coinbase websocket replies
I used to have a 250ms, which would generate tons of timeout, maybe I just have a very bad internet connection, even though the call is located in the US
I was forcefully migrated from Pro to Advanced Trade and was tinkering with porting my code. I also noticed that Advanced Trade has the level2 websocket channel batched to ~500ms updates, which I agree is unsuitable for any trader reacting to changes in the orderbook. The API documentation does not document such batching so I am hoping that it isn’t actually intended…
In the meantime, I’m using a Pro websocket. Although my account was migrated, my API credentials still allow for me to authenticate a websocket. Not sure how long that will last.