Get_prices fails for realtime aggregate database (argument list too long 'psql')

Hey guys, running into an issue when trying to query the entire usstock universe (~10k securities) from a realtime aggregate database using get_prices. Output is below. Note that it works fine if I specify a few sids instead. Any help is much appreciated; thanks!

realtime_prices = get_prices(["usstock-realtime-minute"], universes='usstock', start_date="2021-05-19", end_date="2021-05-21", fields=["MinuteCloseClose"], timezone="America/New_York")

---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
<ipython-input-67-027c69403348> in <module>
      6 
      7 #prices = get_prices(["usstock-minute", "usstock-minute-extended-unadjusted"], universes='usstock', start_date="2021-05-20", end_date="2021-05-20", fields=["Open", "High", "Low", "Close", "Volume"], timezone="America/New_York")
----> 8 realtime_prices = get_prices(["usstock-realtime-minute"], universes='usstock', start_date="2021-05-19", end_date="2021-05-21", fields=["MinuteCloseClose"], timezone="America/New_York")

/opt/conda/lib/python3.8/site-packages/quantrocket/price.py in get_prices(codes, start_date, end_date, universes, sids, exclude_universes, exclude_sids, times, fields, timezone, infer_timezone, cont_fut, data_frequency)
    356 
    357             try:
--> 358                 download_market_data_file(db, tmp_filepath, **kwargs)
    359             except NoRealtimeData as e:
    360                 # don't complain about NoRealtimeData if we're checking

/opt/conda/lib/python3.8/site-packages/quantrocket/realtime.py in download_market_data_file(code, filepath_or_buffer, output, start_date, end_date, universes, sids, exclude_universes, exclude_sids, fields)
    653 
    654     try:
--> 655         houston.raise_for_status_with_json(response)
    656     except requests.HTTPError as e:
    657         # Raise a dedicated exception

/opt/conda/lib/python3.8/site-packages/quantrocket/houston.py in raise_for_status_with_json(response)
    204                 e.json_response = {}
    205                 e.args = e.args + ("please check the logs for more details",)
--> 206             raise e
    207 
    208 # Instantiate houston so that all callers can share a TCP connection (for

/opt/conda/lib/python3.8/site-packages/quantrocket/houston.py in raise_for_status_with_json(response)
    196         """
    197         try:
--> 198             response.raise_for_status()
    199         except requests.exceptions.HTTPError as e:
    200             try:

/opt/conda/lib/python3.8/site-packages/requests/models.py in raise_for_status(self)
    939 
    940         if http_error_msg:
--> 941             raise HTTPError(http_error_msg, response=self)
    942 
    943     def close(self):

HTTPError: ('500 Server Error: Internal Server Error for url: http://houston/realtime/usstock-realtime-minute.csv?start_date=2021-05-19&end_date=2021-05-21&universes=usstock&fields=MinuteCloseClose', {'status': 'error', 'msg': 'an unhandled exception occurred, please check flightlog for the traceback and notify support if the problem persists as this might be a bug', 'error': "[Errno 7] Argument list too long: 'psql'"})

The universes=usstock param results in a query that contains all 10,000 sids which is too long for the linux command line. We can fix it in the next release. Omitting the parameter should avoid the error and give you everything in the database.

Ah, that makes perfect sense. Pulling everything in the database is exactly what I need; thanks for the workaround Brian!

This issue is fixed in version 2.6.0.

This topic was automatically closed after 5 days. New replies are no longer allowed.