How can I pull historical data using eikon in python

Here is the answer I got from customer support. I tried to pull the value using the same data item code in python3 but I get none for all of them. How should I get the data in python3 using eikon data api? One example ric is US240421348=.

screen-shot-2022-02-14-at-104210-am.png

Tagged:

Best Answer

  • Gurpreet
    Answer ✓

    Hi @vuk.magdelinic,

    Not all historical data from RHistory is available through Python API. You can take a look at Data Item Browser in Eikon and see which fields support history and other supported parameters.

    For this instrument, I can see that only daily yields are available through Python. Try something along these lines -

    >>> df, err = ek.get_data('US240421348=', ['TR.BIDYIELD', 'TR.MIDYIELD', 'TR.ASKYIELD', 'TR.BIDYIELD.date'], {'SDate':'0', 'EDate':'-20', 'Frq': 'D', 'Points': 20})
    >>> df
    Instrument Bid Yield Mid Yield Ask Yield Date
    0 US240421348= 1.045 1.03 1.02 2022-02-11T00:00:00Z
    1 US240421348= 1.031 1.02 1.006 2022-02-10T00:00:00Z
    2 US240421348= 0.96 0.95 0.935 2022-02-09T00:00:00Z
    3 US240421348= 1.023 1.01 0.998 2022-02-08T00:00:00Z
    4 US240421348= 1.01 1.0 0.985 2022-02-07T00:00:00Z
    5 US240421348= 0.94 0.93 0.915 2022-02-04T00:00:00Z
    6 US240421348= 0.797 0.78 0.772 2022-02-03T00:00:00Z
    7 US240421348= 0.681 0.67 0.656 2022-02-02T00:00:00Z
    8 US240421348= 0.688 0.68 0.664 2022-02-01T00:00:00Z
    9 US240421348= 0.658 0.64 0.633 2022-01-31T00:00:00Z
    10 US240421348= 0.597 0.58 0.572 2022-01-28T00:00:00Z
    11 US240421348= 0.566 0.55 0.541 2022-01-27T00:00:00Z
    12 US240421348= 0.553 0.54 0.529 2022-01-26T00:00:00Z
    13 US240421348= 0.538 0.53 0.513 2022-01-25T00:00:00Z
    14 US240421348= 0.518 0.51 0.493 2022-01-24T00:00:00Z

    Please see data item browser (DIB) in Eikon about various parameters.

Answers

  • @vuk.magdelinic

    You can use the Refinitiv Data Platform Python library with the desktop session.

    import refinitiv.dataplatform as rdp
    rdp.open_desktop_session(APP_KEY)

    Then, use the get_historical_price_summaries method to get daily historical data.

    rdp.get_historical_price_summaries(
        universe = 'US240421348=',
        interval = rdp.Intervals.DAILY,          # Supported intervals: DAILY, WEEKLY, MONTHLY, QUARTERLY, YEARLY.
        count = 20,
        fields = ['B_YLD_1','A_YLD_1','MID_YLD_1','BID','ASK','MID_PRICE']
    )

    The output is:

    1644903191289.png