From 7be260f08d61103de1233cb37ba42b173bb835ec Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 29 Nov 2025 11:40:02 +0000 Subject: [PATCH 1/3] Initial plan From d034c3c32a079bab444a772fc1adc8918404267c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 29 Nov 2025 11:46:18 +0000 Subject: [PATCH 2/3] Fix OTC candle data parsing to use correct server format [timestamp, open, close, high, low] Co-authored-by: theshadow76 <59869868+theshadow76@users.noreply.github.com> --- pocketoptionapi_async/client.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/pocketoptionapi_async/client.py b/pocketoptionapi_async/client.py index 8c2b335..7fb063d 100644 --- a/pocketoptionapi_async/client.py +++ b/pocketoptionapi_async/client.py @@ -973,21 +973,13 @@ def _parse_candles_data(self, candles_data: List[Any], asset: str, timeframe: in if isinstance(candles_data, list): for candle_data in candles_data: if isinstance(candle_data, (list, tuple)) and len(candle_data) >= 5: - # Server format: [timestamp, open, low, high, close] - # Note: Server sends low/high swapped compared to standard OHLC format - raw_high = float(candle_data[2]) - raw_low = float(candle_data[3]) - - # Ensure high >= low by swapping if necessary - actual_high = max(raw_high, raw_low) - actual_low = min(raw_high, raw_low) - + # Server format: [timestamp, open, close, high, low] candle = Candle( timestamp=datetime.fromtimestamp(candle_data[0]), open=float(candle_data[1]), - high=actual_high, - low=actual_low, - close=float(candle_data[4]), + high=float(candle_data[3]), + low=float(candle_data[4]), + close=float(candle_data[2]), volume=float(candle_data[5]) if len(candle_data) > 5 else 0.0, @@ -1263,7 +1255,7 @@ def _parse_stream_candles( timeframe=timeframe, ) candles.append(candle) - elif isinstance(item, (list, tuple)) and len(item) >= 6: + elif isinstance(item, (list, tuple)) and len(item) >= 5: candle = Candle( timestamp=datetime.fromtimestamp(item[0]), open=float(item[1]), From da4c7385c71a06ef6079f2428766512f9c25b3a5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 29 Nov 2025 11:48:12 +0000 Subject: [PATCH 3/3] Add format comment to _parse_stream_candles for consistency Co-authored-by: theshadow76 <59869868+theshadow76@users.noreply.github.com> --- pocketoptionapi_async/client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pocketoptionapi_async/client.py b/pocketoptionapi_async/client.py index 7fb063d..7c9d939 100644 --- a/pocketoptionapi_async/client.py +++ b/pocketoptionapi_async/client.py @@ -1256,6 +1256,7 @@ def _parse_stream_candles( ) candles.append(candle) elif isinstance(item, (list, tuple)) and len(item) >= 5: + # Server format: [timestamp, open, close, high, low] candle = Candle( timestamp=datetime.fromtimestamp(item[0]), open=float(item[1]),