hootnot / oandapyV20-examples

Examples demonstrating the use of oandapyV20 (oanda-api-v20)
MIT License
147 stars 65 forks source link

ContentDecodingError with InstrumentsCandles #30

Closed flowtrader2016 closed 1 year ago

flowtrader2016 commented 1 year ago

Hi,

I'm seeing intermittent issues with the response ContentDecodingError when using instruments.InstrumentsCandles. Appreciate any help.

Issue

Received response with content-encoding: gzip, but failed to decode it

To reproduce

event = { "ticker": "UK100_GBP", "granularity": "M15"}

granularity = event["granularity"]
ticker = event["ticker"]
  count = 500
  params = {
            "count": count,
            "granularity": granularity,
            "dailyAlignment": 0,
            "alignmentTimezone": "UTC",
        }
r = instruments.InstrumentsCandles(instrument=ticker, params=params)
oandaData = client.request(r)

stackTrace

{
  "errorMessage": "('Received response with content-encoding: gzip, but failed to decode it.', error('Error -3 while decompressing data: incorrect data check'))",
  "errorType": "ContentDecodingError",
  "requestId": "fdc8726c-bbbe-4b50-beed-e2c198a4e54f",
  "stackTrace": [
    "  File \"/var/task/handler.py\", line 3662, in sls_getOandaData\n    oandaData = client.request(r)\n",
    "  File \"/var/task/oandapyV20/oandapyV20.py\", line 337, in request\n    response = self.__request(method, url,\n",
    "  File \"/var/task/oandapyV20/oandapyV20.py\", line 266, in __request\n    raise err\n",
    "  File \"/var/task/oandapyV20/oandapyV20.py\", line 262, in __request\n    response = func(url, stream=stream, headers=headers,\n",
    "  File \"/var/task/requests/sessions.py\", line 600, in get\n    return self.request(\"GET\", url, **kwargs)\n",
    "  File \"/var/task/requests/sessions.py\", line 587, in request\n    resp = self.send(prep, **send_kwargs)\n",
    "  File \"/var/task/requests/sessions.py\", line 745, in send\n    r.content\n",
    "  File \"/var/task/requests/models.py\", line 899, in content\n    self._content = b\"\".join(self.iter_content(CONTENT_CHUNK_SIZE)) or b\"\"\n",
    "  File \"/var/task/requests/models.py\", line 820, in generate\n    raise ContentDecodingError(e)\n"
  ]
}

Thanks

flowtrader2016 commented 1 year ago

Raised in error in the examples section. Close and raise again as #193