price history request minutes level

Options

I am looking for a way to request price history data in Python locally (not in the refinitiv codebook environment) on a minutes level to get Close, Open, Low, High, Volume, Bid, Ask for a given stock ticker . If I request the data manually in Refinitiv the output looks as follows:

1657059587808.png Now, I want to get the same automatically using python. I have used

get_timeseries and get_data

function but was not successfull in getting to the exact same output.

Welcome!

It looks like you're new here. Sign in or register to get started.

Best Answer

  • umer.nalla
    umer.nalla LSEG
    Answer ✓

    hi @basilio.konstantin.kalus

    That error does look odd - as the os.environ line is pointing it to a Configuration folder several folders upstream from the location of your notebook - so not sure why it is looking in your users Eikon folder.

    One thing to try is to comment out the os.environ line i.e.

    import os
    # os.environ["RD_LIB_CONFIG_PATH"] = "../../../Configuration"

    import refinitiv.data as rd
    from refinitiv.data.content import historical_pricing
    rd.open_session()

    This will rely on the default behaviour and try and use a default app-key for a desktop connection. It will mean you cant enable logging etc for now - but at least we can get past this point for now and let you try out the code.

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @basilio.konstantin.kalus

    You can use the get_timeseries method to retrieve minute intervals of historical data.

    df = ek.get_timeseries(['ADSGn.DE'], interval="minute")

    However, the output contains only the HIGH, LOW, OPEN, CLOSE, COUNT, and VOLUME fields.

    1657072086230.png

    You can run help(ek.get_timeseries) to see all parameters of the get_timeseries method.

    To get other fields, you can use the Refinitiv Data Library for Python. The examples are available on GitHub.

    First, configure the Refntiiv Data Library (refinitiv-data.config.json) to use the Desktop session.

     "sessions": {
            "default": "desktop.workspace",
            "platform": {
                "rdp": {
                    "app-key": "YOUR APP KEY GOES HERE!",
                    "username": "YOUR RDP LOGIN OR MACHINE GOES HERE!",
                    "password": "YOUR RDP PASSWORD GOES HERE!"
                },
                "deployed": {
                    "app-key": "YOUR APP KEY GOES HERE!",
                    "realtime-distribution-system": {
                        "url" : "YOUR DEPLOYED HOST:PORT GOES HERE!",
                        "dacs" : {
                            "username" : "YOUR DACS ID GOES HERE!",
                            "application-id" : 256,
                            "position" : ""
                        }
                    }
                }
            },
            "desktop": {
                "workspace": {
                    "app-key": "YOUR APP KEY GOES HERE!"
                }
    }

        }

    Then, run the EX-2.01.01-HistoricalPricing.ipynb example.

    The code looks like this:

    response = historical_pricing.summaries.Definition(
        "ADSGn.DE", 
        interval=Intervals.ONE_MINUTE,
        fields=["HIGH_1", "LOW_1", "OPEN_PRC", "TRDPRC_1", "BID", "ASK"]
    ).get_data()
    response.data.df

    The output is:

    1657072564776.png

    You can also run help(historical_pricing.summaries.Definition) to see all parameters of this method.

  • Thanks for your quick response. However, I dont know which url I need to plug into "YOUR DEPLOYED HOST:PORT GOES HERE! ". Additionally, I have problems getting my DACS username/ ID, could you help me where I get this DACS ID?

    Many thanks!

  • Hi @basilio.konstantin.kalus

    You are asking about Deployed host and DACS username - these are only required if connecting to a local ADS server.

    To connect to your Eikon - you only need to fill in the desktop workspace app-key section

    "desktop": {
    "workspace": {
    "app-key": "YOUR APP KEY GOES HERE!"
    }
    }

    You can generate an App-Key at http://amers1-apps.platform.refinitiv.com/apps/appkeygenerator or inside Eikon by searching for AppKey - as described here Quick Start | Refinitiv Developers



  • My refinitiv-data.config.json configuration file now looks as follows:

    "desktop": {
    "workspace": {
    "app-key": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    }
    }

    However, when running the code:

    import os
    os.environ["RD_LIB_CONFIG_PATH"] = "../../../Configuration"

    import refinitiv.data as rd
    from refinitiv.data.content import historical_pricing
    rd.open_session()

    response = historical_pricing.events.Definition("LSEG.L").get_data()
    response.data.df

    I get the following error:

    raise RDError(0, f"Error happened during config file {path} read") from exc

    refinitiv.data._errors.RDError: Error code 0 | Error happened during config file C:\Users\Basilio\PycharmProjects\EIKON\refinitiv-data.config.json read

    I checked the path, and its correct, I have also tried other versions of the refinitiv-data.config.json configuration file like:

    "sessions": {
    "default": "desktop.workspace",
    "desktop": {
    "workspace": {
    "app-key": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    }
    }
    }
    }

    leading to the same error message.

  • Hi @basilio.konstantin.kalus

    Can you also confirm you are using the latest version

    pip install refinitiv-data==1.0.0b16 

    Thanks.

  • Thank you very much, with the latest version it works!

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.