When running the code for fetching market data, we got the error shown in the screenshot.

Hi Team,

Could you please provide some guidance of data fields and data fetching functions in both Excel and Python API? And sometimes the connection is not stable when fetching a larger amount of stock historical price data when running Python API interface, so it get time out error code when we are running loops for getting stock data. Do you have any suggestions about fetching data more smoothly?


When running the code for fetching market data, we got the error shown in the screenshot. May you please advise the reason? Thank you.

1706772009318.png

Thank you!

Best Answer

  • aramyan.h
    Answer ✓

    Hi @Edwin.Kwan ,


    Since I don't know what is the API call and library you are using, below I will provide a general workflow for ingesting larger amount of data iteratively. So as shown below you can wrap your code under try except statement and introduce a while loop to retry a couple of times which will help you getting the data you are after more smoothly.

    max_steps = 3
    step = 0
    while step < max_steps:
    try:
    # your API call goes here
    break

    except rd.errors.RDError as e:
    print("RDError code :", e.code)
    print("RDError message:", e.message)
    step +=1
    continue

    Hope this helps.


    Best regards,

    Haykaz