ERRATIC Behaviour of lseg.data API

I ran the same lines of code in Jupyter and Sublime Text, both using the same venv and python interpreter (so there is no reason for differences in their behaviour)

On Sublime text and sometimes in Jupyter as well, the price field data download is erratic. Sometimes it will download ALL the price fields I have requested, sometimes just ONE price field.

In this screenshot, Sublime Text was never able to retrieve all my price field requests (see left window) but Jupyter was able to (right window). Sometimes, it just spits out an error that says TR.OPENPRICE request

ANY KNOWN FIXES TO THIS ERRATIC API DOWNLOAD BEHAVIOUR???

erratic api.png
Tagged:

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @tanjunjie91

    Thank you for reaching out to us.

    You can enable the debug log in the library to verify what the problem is. Run the following code before opening a session to enable the debug log.

    config = ld.get_config()
    config.set_param("logs.transports.file.enabled", True)
    config.set_param("logs.transports.file.name", "lseg-data-lib.log")
    config.set_param("logs.level", "debug")

    The lseg-data-lib.log file will be created. Please share the log files from both environments. The log file may contain your credentials. Please remove the credentials before sharing the log files.

  • tanjunjie91
    tanjunjie91 Newcomer
    edited March 6

    Hi attached three logs for three attempts on the same code. I don't think the issue is whether Sublime or Jupyter was used. Here, I only use Sublime and as you can see, the unreliability of data retrieval is evident. Sometimes. it was able to retrieve all the data fields nicely for all symbols; sometimes, there are inconsistent errors on each run.

    On the THIRD TRY, there was even a "Service unavailable" error.

    I retrieve contract data symbol by symbol based on code below:

    symbols used: ["TFMBMc1", "TFMBSc1", "NGLNMc1", "NGLNSc1", "DEBYc1", "CFI2Z5", "LCOc1", "NGc1"]

    	try:
    print(get_contract_data(
    universe=[sym],
    fields=["TR.OPENPRICE", "TR.HIGHPRICE", "TR.LOWPRICE", "TR.SETTLEMENTPRICE"],
    interval="1D",
    start_date=start_date,
    end_date=end_date
    ))
    print(f"New contract data successfully updated for {sym}.")

    except Exception as e:
    print(f"Error trying to get contract data for {sym}: \n{e}")

  • tanjunjie91
    tanjunjie91 Newcomer

    Attached logs for FOURTH TRY. Here, you can see that an error only occurred for one ticker LCOc1 but it was able to retrieve for all others.

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @tanjunjie91

    Thank you for the log files.

    It looks like to be a problem in the backend service, not in the library.

    I don't have visibility in the backend service so I have submitted this issue on your behalf. The case number is 14479808. The support team will contact you regarding this issue.

  • tanjunjie91
    tanjunjie91 Newcomer

    Thanks vm