"failed to calculate cost basis" submitting order with python api

This code has been working fine for about a month against a paper trading account, but today it threw this error:
[ERROR] APIError: failed to calculate cost basis
Traceback (most recent call last):
File “/var/task/lambda_main.py”, line 141, in lambda_handler
order = api.submit_order(STOCK_ASSET_ID, shares_to_buy, ‘buy’, ‘market’, ‘day’)
File “/var/task/alpaca_trade_api/rest.py”, line 236, in submit_order
resp = self.post(’/orders’, params)
File “/var/task/alpaca_trade_api/rest.py”, line 152, in post
return self._request(‘POST’, path, data)
File “/var/task/alpaca_trade_api/rest.py”, line 112, in _request
return self._one_request(method, url, opts, retry)
File “/var/task/alpaca_trade_api/rest.py”, line 141, in _one_request
raise APIError(error, http_error)

My code is the lambda_main.py which is calling submit_order on a REST api instance. I traced this down and it appears that the API is calling Alpaca to execute the order but Alpaca is sending back an HTTP 500 error code which triggers the APIError in rest.py line 141.

My code retried this 2 more times over a couple minutes and same problem each time.

I Googled for this error with no luck. Does anyone know what it means?

Thanks for the report. We have updated our order management system recently and may have some issue there. Will look into it.

I’m making the following call:
api.submit_order(‘2d9e926c-e17c-47c3-ad8c-26c7a594e48f’, 489, ‘buy’, ‘market’, ‘day’)

I’ve checked to be sure my API key is the same one that shows on my Alpaca paper trading account.

In case it helps, I turned on logging in the urllib3 module you used, and I see the following (keys hidden):
header: Server header: Date header: Content-Type header: Content-Length header: Connection send: b’POST /v2/orders HTTP/1.1\r\nHost: paper-api.alpaca.markets\r\nUser-Agent: python-requests/2.22.0\r\nAccept-Encoding: gzip, deflate\r\nAccept: /\r\nConnection: keep-alive\r\nAPCA-API-KEY-ID: xxxxxxxxxxxxxxxxxxxx\r\nAPCA-API-SECRET-KEY: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\nContent-Length: 119\r\nContent-Type: application/json\r\n\r\n’
send: b’{“symbol”: “2d9e926c-e17c-47c3-ad8c-26c7a594e48f”, “qty”: 489, “side”: “buy”, “type”: “market”, “time_in_force”: “day”}’
reply: ‘HTTP/1.1 500 Internal Server Error\r\n’
2019-12-06 14:13:05,512 urllib3.connectionpool DEBUG:https://paper-api.alpaca.markets:443 “POST /v2/orders HTTP/1.1” 500 60

I did this logging outside market hours, but it is still giving the same “failed to calculate cost basis” error.