BinaryOptionsTools-v2 icon indicating copy to clipboard operation
BinaryOptionsTools-v2 copied to clipboard

check_win error

Open Lem4aks opened this issue 8 months ago • 6 comments

Traceback (most recent call last): File "C:\Users\Asus\AppData\Local\Programs\Python\Python310\lib\site-packages\BinaryOptionsToolsV2\pocketoption\asynchronous.py", line 356, in _get_trade_result trade = await self.client.check_win(id) asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\Asus\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 458, in wait_for fut.result() asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:\Users\Asus\AppData\Local\Programs\Python\Python310\lib\site-packages\BinaryOptionsToolsV2\pocketoption\asynchronous.py", line 340, in check_win trade = await asyncio.wait_for(self._get_trade_result(id), timeout=timeout_seconds) File "C:\Users\Asus\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 460, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Project\BinaryOptionsTools-v2-master\examples\python\async\check_win.py", line 27, in asyncio.run(main(ssid)) File "C:\Users\Asus\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\Asus\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 641, in run_until_complete return future.result() File "C:\Project\BinaryOptionsTools-v2-master\examples\python\async\check_win.py", line 19, in main buy_data = await api.check_win(buy_id) File "C:\Users\Asus\AppData\Local\Programs\Python\Python310\lib\site-packages\BinaryOptionsToolsV2\pocketoption\asynchronous.py", line 343, in check_win raise TimeoutError(f"Timeout waiting for trade result for ID: {id}") TimeoutError: Timeout waiting for trade result for ID: 2606b3c9-ac25-4862-a7ac-63d6a0e6ecb0

Lem4aks avatar Mar 14 '26 12:03 Lem4aks

Hello!

Could you show us the relevant part of the code so that me, @Rick-29 and @sixtysixx can check this?

Thank you in advance.

theshadow76 avatar Mar 14 '26 13:03 theshadow76

That used from example check_win in python

Lem4aks avatar Mar 16 '26 11:03 Lem4aks

I see, @Rick-29 could you help us with this?

theshadow76 avatar Mar 16 '26 17:03 theshadow76

I think i have a fix for that bug. i just recompiled the rust on my pc and it works returning the actual trade data. So basically when a trade is placed, the deal result is sent from PocketOption as a binary WebSocket message, but the DealsApiModule in BinaryOptionsToolsV2 fails to parse it. This causes check_win() to timeout waiting for a result that was never delivered to the waiter. The library expects Socket.IO formatted messages (e.g., 42["updateOpenedDeals",...] or 451-["updateClosedDeals",...]) before receiving binary data. However, PocketOption sometimes sends raw JSON binary messages WITHOUT the Socket.IO header when delivering deal results. When this "headerless" binary data arrives, the code at line 326-333 simply logged a warning and discarded the data. I modified crates/binary_options_tools/src/pocketoption/modules/deals.rs to attempt parsing binary data even when there's no Socket.IO header. In my opinion this is just a temporary fix because actually getting the headers back would probably be best.

souder14 avatar Mar 17 '26 09:03 souder14

Yeah, i checked, you are right , there was an error, i fixed it using an older version of the deals.rs file, it seems that in one of the latest updates someone modified it incorrectly causing the bug. In a few hours i will push the fix to github and in a cupple of days i shoud push a new release on pypi that fixes that issue. I will close this thread in a few hours when i push the fix. Please tell us if there is any more issues to work on!

Rick-29 avatar Mar 18 '26 10:03 Rick-29

Pushed the fix, closing issue.

Rick-29 avatar Mar 18 '26 14:03 Rick-29