Skip to content
This repository was archived by the owner on Apr 26, 2026. It is now read-only.

Commit de33747

Browse files
authored
Merge pull request #50 from ChipaDevTeam/copilot/fix-retrieved-otc-candles
Fix OTC candle data parsing field order
2 parents 8f87552 + da4c738 commit de33747

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

pocketoptionapi_async/client.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -974,21 +974,13 @@ def _parse_candles_data(self, candles_data: List[Any], asset: str, timeframe: in
974974
if isinstance(candles_data, list):
975975
for candle_data in candles_data:
976976
if isinstance(candle_data, (list, tuple)) and len(candle_data) >= 5:
977-
# Server format: [timestamp, open, low, high, close]
978-
# Note: Server sends low/high swapped compared to standard OHLC format
979-
raw_high = float(candle_data[2])
980-
raw_low = float(candle_data[3])
981-
982-
# Ensure high >= low by swapping if necessary
983-
actual_high = max(raw_high, raw_low)
984-
actual_low = min(raw_high, raw_low)
985-
977+
# Server format: [timestamp, open, close, high, low]
986978
candle = Candle(
987979
timestamp=datetime.fromtimestamp(candle_data[0]),
988980
open=float(candle_data[1]),
989-
high=actual_high,
990-
low=actual_low,
991-
close=float(candle_data[4]),
981+
high=float(candle_data[3]),
982+
low=float(candle_data[4]),
983+
close=float(candle_data[2]),
992984
volume=float(candle_data[5])
993985
if len(candle_data) > 5
994986
else 0.0,
@@ -1283,7 +1275,8 @@ def _parse_stream_candles(
12831275
timeframe=timeframe,
12841276
)
12851277
candles.append(candle)
1286-
elif isinstance(item, (list, tuple)) and len(item) >= 6:
1278+
elif isinstance(item, (list, tuple)) and len(item) >= 5:
1279+
# Server format: [timestamp, open, close, high, low]
12871280
candle = Candle(
12881281
timestamp=datetime.fromtimestamp(item[0]),
12891282
open=float(item[1]),

0 commit comments

Comments
 (0)