Fix PocketOption websocket timeout by implementing client-side aggregation for new tick data format #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Users reported "Failed to execute 'GetCandles' task before the maximum allowed time of '16s'" errors when fetching candle data from PocketOption. The root cause was that PocketOption updated their websocket message format from returning aggregated OHLC candles to raw tick data.
Before (Old Format):
{ "period": 3600, "data": [ { "symbol_id": 291, "time": 1726902000, "open": 172.218, "close": 172.193, "high": 172.256, "low": 172.065 } ] }After (New Format):
{ "period": 0, "data": [ { "asset": "EURUSD_otc", "time": 1734725463.364, "price": 1.04642 }, { "asset": "EURUSD_otc", "time": 1734725463.864, "price": 1.04643 }, // ... thousands more tick data points ] }Solution
Implemented smart client-side aggregation that:
period: 0+ raw tick data)Key Changes
candle_data_with_period()method toLoadHistoryPeriodResultget_candles_advanced()to use new aggregation logicTest Results
Impact
Fixes #17.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
api.ipify.org/home/REDACTED/work/BinaryOptionsTools-v2/BinaryOptionsTools-v2/target/debug/deps/binary_options_tools-bf0e6b2adb8abbb6(dns block)demo-api-eu.po.market/home/REDACTED/work/BinaryOptionsTools-v2/BinaryOptionsTools-v2/target/debug/deps/binary_options_tools-bf0e6b2adb8abbb6(dns block)/home/REDACTED/work/BinaryOptionsTools-v2/BinaryOptionsTools-v2/target/debug/deps/binary_options_tools-bf0e6b2adb8abbb6 test_get_candles --nocapture(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.