Can I one ownload historical stock price data using API for a list of ISINs contain in a CSV file?

Can I one ownload historical stock price data using API for a list of ISINs contain in a CSV file?

Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @barbara.petracci

    I have a CSV file with the following data.

    RIC
    IBM.N
    PTT.BK
    BDMS.BK
    GOOG.O
    BAC.N
    AAL.L
    AV.L
    JD.L
    AVV.L
    LSE.L
    VOD.L

    I have used the RDP library to retrieve the interday summary data.

    First, I connect to the RDP by using the application key, user name, and password. Then I use the pd.read_csv function to read the CSV file. Next, I iterate to all items in the RIC column and call the rdp.HistoricalPricing.get_summaries function for each item.

    import refinitiv.dataplatform as rdp
    import pandas as pd
    import time
    rdp.open_platform_session(
        "APP_KEY", 
        rdp.GrantPassword(
            username = "username", 
            password = "password"
        )
    )
    rics = pd.read_csv("ricsdata.csv")
    for item in rics["RIC"]:
        print(item)
        response = rdp.HistoricalPricing.get_summaries(item)
        print(response.data.df)
        time.sleep(1)

    For more information, please refer to the following links:

    1. Getting Started with Python

    2. Python RDP Library examples

    3. RDP API Docs Please search for historical-pricing.


Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @barbara.petracci

    I assume that you are using /data/historical-pricing/v1 on the Refinitiv Data Platform. If you are using different APIs, please let me know.

    From my testing, the /data/historical-pricing/v1 endpoint returns "The universe is not found. " when using ISIN. Therefore, you may need to map ISIN to RIC before using /data/historical-pricing/v1. You can use other endpoints, such as /discovery/symbology/v1/lookup to map ISIN to RIC.




  • thank you. Anyway, can you post the python code with ten RICs in column 1 of "sheet1" in a file called ricdata.csv?

    yes I use the refinitiv data platform. thanks

  • really helpful! thanks