Open little-bit-time opened 1 month ago
Thanks for reporting @little-bit-time! I'll check this with the team on the best solution and open a PR shortly. Below are the proposed solutions:
I investigated and the following is happening:
Issues of current behavior:
- [ Trade 1 ]
- [ Trade 2, Trade 3, Trade 4 ]
- [ Trade 2, Trade 3, Trade 4 ]
- [[ Trade 2, Trade 3, Trade 4 ]
Solution 1 (set useMessageQueue to false):
- [ Trade 1 ]
- [ Trade 2, Trade 3, Trade 4 ]
What the user would see:
- [ Trade 1 ]
- [ Trade 2, Trade 3, Trade 4 ]
- [ ]
- [ ]
Would have to apply probably to all exchanges What the user would see:
- [ Trade 1 ]
- [ Trade 2, Trade 3, Trade 4 ]
What the user would see:
- [ Trade 1 ]
- [ Trade 2, Trade 3, Trade 4 ]
I implemented solution 4 locally, however gateio sends several messages at the exact same time, so it did not solve the issue. This also raised an issue in ArrayCache, that when calling getLimit, the limit is not reset until the next time an item is pushed to the array. I'm not sure if this is expected behavior.
It is not pretty but my recommendation would be:
@little-bit-time , unitl we merge this solution I would recommend you set the following option to stop seeing duplicates: exchange.options['ws']['useMessageQueue'] = false
Thanks for the proposed solution
'options': {
'defaultType': 'swap',
'ws': {
'useMessageQueue': false
}
}
I'll test it now.
I'm not sure about duplicates.
1721936533623;1721936533599;sell;64810.3;4
1721936533717;1721936533686;sell;64805.8;10
1721936533717;1721936533686;sell;64805.8;10
1721936533717;1721936533686;sell;64805.8;10
1721936533717;1721936533686;sell;64805.8;10
1721936533720;1721936533686;sell;64805.8;256
1721936534937;1721936534917;buy;64801.1;221
1721936543790;1721936543774;sell;64784.8;2
1721936545023;1721936545003;sell;64778.6;10
1721936545024;1721936545003;sell;64778.6;10
1721936545024;1721936545003;sell;64778.6;10
1721936545024;1721936545003;sell;64778.6;10
1721936545026;1721936545003;sell;64778.6;10
1721936545026;1721936545003;sell;64778.6;10
1721936545026;1721936545003;sell;64778.6;10
1721936545026;1721936545003;sell;64778.6;10
1721936545026;1721936545003;sell;64778.6;10
1721936545026;1721936545003;sell;64778.6;10
1721936545029;1721936545003;sell;64778.6;100
1721936545029;1721936545003;sell;64778.6;209
1721936545029;1721936545003;sell;64778.6;224
1721936545029;1721936545003;sell;64778.6;112
1721936545029;1721936545003;sell;64778.6;10
1721936545029;1721936545003;sell;64778.6;10
1721936545031;1721936545003;sell;64778.3;2
1721936545031;1721936545003;sell;64775.9;2129
1721936545031;1721936545004;sell;64775.8;320
But now it can return trades out of order. 1721936468035 -> 1721936468036 -> 1721936468037 -> 1721936468035 -> 1721936468037 -> 1721936468038 -> 1721936468037
1721936466791;1721936466765;buy;64802.5;35
1721936466791;1721936466765;buy;64803.9;50
1721936466791;1721936466765;buy;64804.2;2
1721936466791;1721936466765;buy;64804.2;5
1721936467790;1721936467775;sell;64805.9;104
1721936467834;1721936467818;buy;64806;309
1721936467860;1721936467834;buy;64808;1
1721936467860;1721936467834;buy;64808.4;1
1721936467860;1721936467834;buy;64808.5;1
1721936468043;1721936468018;buy;64810.3;81
1721936468042;1721936468016;buy;64809.5;60
1721936468069;1721936468035;buy;64810.7;2
1721936468073;1721936468035;buy;64811.5;10
1721936468073;1721936468036;buy;64811.5;2
1721936468073;1721936468037;buy;64811.7;6
1721936468073;1721936468035;buy;64811.5;6
1721936468073;1721936468037;buy;64811.7;3
1721936468073;1721936468037;buy;64811.7;1
1721936468073;1721936468037;buy;64811.7;3
1721936468073;1721936468037;buy;64811.7;1
1721936468074;1721936468037;buy;64811.7;1
1721936468074;1721936468038;buy;64812.8;4
1721936468074;1721936468037;buy;64811.7;1
1721936468079;1721936468043;buy;64813.6;24
1721936468085;1721936468043;buy;64814;1
1721936468085;1721936468043;buy;64816;7
1721936468098;1721936468071;buy;64817.2;2
1721936468118;1721936468090;buy;64819;1
1721936468118;1721936468090;buy;64819;2
1721936468152;1721936468128;buy;64819.2;7
1721936468331;1721936468314;buy;64820;214
1721936468630;1721936468610;sell;64819.9;5
1721936468663;1721936468642;sell;64819.9;341
1721936468663;1721936468644;sell;64819.9;168
1721936468664;1721936468644;sell;64819.9;85
I am having the same problem on BINANCE, using Python and ccxt 4.3.68. Although I can understand @pcriadoperez comments I would like to point out that I did not have this issue before. I tested ccxt 4.3.50 and it seemed OK, but ccxt 4.3.60 and 4.3.68 are both generating a lot of duplicates. Please let me know if this helps.
Operating System
debian
Programming Languages
JavaScript
CCXT Version
4.3.67
Description
Hello, I'm receiving duplicate websocket trades.
After reviewing the code and printing to the console, I see that the limit set with limit = trades.getLimit(tradeSymbol, limit); fluctuates. It starts at 1, 2, 3, 4, and then goes back to 1.
Could you help me understand what might be causing this issue? Thank you.
Code