Specifying a list of instruments for Market Prices for Historical Price Summaries

Options

response = rdp.get_historical_price_summaries(
universe= ccy_pair,
interval=rdp.Intervals.DAILY,
# Supported intervals: ONE_MINUTE, FIVE_MINUTES, TEN_MINUTES, THIRTY_MINUTES, ONE_HOUR
#fields = ['BID','ASK'],
start=start_date_ts,
end=end_date_ts
)

I want to specify a list of ccy pairs instead of one ccy pair. Do you have an example of this in Python.

Welcome!

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

Best Answer

  • wasin.w
    wasin.w admin
    Answer ✓

    Hello @navtej.riyait

    Did you try the new Data Library - Python yet? The RD historical_pricing.summaries.Definition object support list of string as follows:

    rd-object.png

    Code:

    response = historical_pricing.summaries.Definition(
        universe = ['HUF=', 'EUR=', 'GBP=', 'CNH='], 
        interval=Intervals.ONE_MINUTE,
        fields = ['BID','ASK'],
        start = '2023-08-01 01:00:00',
        end = '2023-08-02 01:00:00    '
    ).get_data()
    response.data.df

    Result:

    result.png


Answers

  • Hi @navtej.riyait ,

    Could you please try using the list of instrument, for example, ['RIC1','RIC2','RIC3']

    In addition, I
    would recommend you look at the newer and strategic RD Library for Python

    For a position statement on the older
    RDP Library please see the overview page.

  • start_date = '2023-10-02 00:00:00.000'
    end_date = '2023-10-03 00:00:00.000'
    ccy_pair1 = ['HUF=', 'EUR=', 'GBP=', 'CNH=']

    response = rdp.get_historical_price_summaries(
    universe= ccy_pair1,
    interval=rdp.Intervals.DAILY,
    start=start_date,
    end=end_date
    )

    I get an error when using an instrument list. See below

    Traceback (most recent call last):

    File "C:\FX Surveillance\FX Options\get_market_prices_options_underlying.py", line 134, in <module>

    get_market_prices()

    File "C:\FX Surveillance\FX Options\get_market_prices_options_underlying.py", line 116, in get_market_prices

    historical_mkt_prices = get_historical_prices(ccy_pair, start_date, end_date)

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    File "C:\FX Surveillance\FX Options\get_market_prices_options_underlying.py", line 70, in get_historical_prices

    response = rdp.get_historical_price_summaries(

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    File "C:\Users\U6082634\AppData\Local\Programs\Python\Python311\Lib\site-packages\refinitiv\dataplatform\factory\content_factory.py", line 646, in get_historical_price_summaries

    return ContentFactory._get_historical_price_summaries(

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    File "C:\Users\U6082634\AppData\Local\Programs\Python\Python311\Lib\site-packages\refinitiv\dataplatform\factory\content_factory.py", line 252, in _get_historical_price_summaries

    historic_summaries = historical_pricing.get_summaries(

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    File "C:\Users\U6082634\AppData\Local\Programs\Python\Python311\Lib\site-packages\refinitiv\dataplatform\content\data\historical_pricing.py", line 302, in get_summaries

    result = historical_pricing._get_summaries(

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    File "C:\Users\U6082634\AppData\Local\Programs\Python\Python311\Lib\site-packages\refinitiv\dataplatform\content\data\historical_pricing.py", line 327, in _get_summaries

    return self._endpoint.session._loop.run_until_complete(

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    File "C:\Users\U6082634\AppData\Local\Programs\Python\Python311\Lib\site-packages\nest_asyncio.py", line 59, in run_until_complete

    return f.result()

    ^^^^^^^^^^

    File "C:\Users\U6082634\AppData\Local\Programs\Python\Python311\Lib\asyncio\futures.py", line 203, in result

    raise self._exception.with_traceback(self._exception_tb)

    File "C:\Users\U6082634\AppData\Local\Programs\Python\Python311\Lib\asyncio\tasks.py", line 267, in __step

    result = coro.send(None)

    ^^^^^^^^^^^^^^^

    File "C:\Users\U6082634\AppData\Local\Programs\Python\Python311\Lib\site-packages\refinitiv\dataplatform\content\data\historical_pricing.py", line 523, in _get_summaries_async

    _result = await self._get_historicalpricing(

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    File "C:\Users\U6082634\AppData\Local\Programs\Python\Python311\Lib\site-packages\refinitiv\dataplatform\content\data\historical_pricing.py", line 665, in _get_historicalpricing

    _result = await self._endpoint.send_request_async(

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    File "C:\Users\U6082634\AppData\Local\Programs\Python\Python311\Lib\site-packages\refinitiv\dataplatform\delivery\data\endpoint.py", line 518, in send_request_async

    _url = self._update_url(

    ^^^^^^^^^^^^^^^^^

    File "C:\Users\U6082634\AppData\Local\Programs\Python\Python311\Lib\site-packages\refinitiv\dataplatform\delivery\data\endpoint.py", line 410, in _update_url

    value = urllib.parse.quote(value)

    ^^^^^^^^^^^^^^^^^^^^^^^^^

    File "C:\Users\U6082634\AppData\Local\Programs\Python\Python311\Lib\urllib\parse.py", line 893, in quote

    return quote_from_bytes(string, safe)

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    File "C:\Users\U6082634\AppData\Local\Programs\Python\Python311\Lib\urllib\parse.py", line 923, in quote_from_bytes

    raise TypeError("quote_from_bytes() expected bytes")

    TypeError: quote_from_bytes() expected bytes


  • Hi Wasin,

    I haven't had time to try yet.

    One question: Do I need to have Eikon running to use the RD libraries ?

    Regards

    Navtej

    ,

    Hi Wasin,

    I haven't had time to try yet.

    One question: Do I need to have Eikon running to use the RD libraries ?

    Regards

    Navtej

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.