lseg.data.content type conversions

When using lseg.data.content how can I control the type conversions occuring for response fields ?

For example :

import lseg.data as ld
universe = ["/SOGN.PA"]
fields = ["BID", "ASK", "CURRENCY", "RDN_EXCHID", "QUOTE_DATE", "QUOTIM", "QUOTIM_MS", "QUOTIM_NS"] stream = ld.content.pricing.Definition(universe = universe, fields = fields).get_stream()
stream.open(with_updates=False)
stream.close()
df = stream.get_snapshot()

image.png image.png

For Enum fields (RDN_EXCHID, CURRENCY) the response is the id, I would like to be able to get the text value instead.

For other fields is there a way to get the raw response (ie without the type inference attempt) ?

Thanks.

Answers

  • Hi @bastien.rousseau

    I woudl advise looking into the Data Item Browser (DIB): https://developers.refinitiv.com/en/video-catalog/data-item-browser

    WIth it, I was able to find the field `CF_CURR`; is that what you are after?

    import lseg.data as ld
    ld.open_session()

    universe = ["/SOGN.PA"]

    fields = ["BID", "ASK", "CF_CURR", "RDN_EXCHID", "QUOTE_DATE", "QUOTIM", "QUOTIM_MS", "QUOTIM_NS"]
    stream = ld.content.pricing.Definition(universe = universe, fields = fields).get_stream()

    stream.open(with_updates=False)

    stream.close()

    df = stream.get_snapshot()

    image.png image.png
  • I would prefer not to have to change each field.

    Moreover I notice that in your screenshot the RDN_EXCHID field has been translated to PAR, compared to 74 in mine, which could imply that even the CURRENCY field would have been displayed as EUR on your end. Could it be a configuration missing on my end?

    Thanks.

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @bastien.rousseau

    I am using the Workspace 1.26.155 and I got this data.

    image.png

    Are you using Eikon or Workspace?

    To access the raw data (JSON string), you may need to use the steaming endpoint in the Delivery layer. The examples are on GitHub.

  • Hi,

    Regarding the enum behavior, I am still on Eikon.

    I have also tried to use the dictionary :

    dictionary = lseg.data.delivery._dictionary.Dictionary(…)
    dictionary.load()
    dictionary.versions
    

    but this does work as it returns {} and the log shows :

    [2025-02-18T14:48:04.112501+01:00] - [sessions.desktop.workspace.0] - [DEBUG] - [13708 - ThreadOMMSTREAMING_DICTIONARY_0.0] - [stream_connection] - [_on_message] - [OMMSTREAMING_DICTIONARY_0.0] on_ws_message [{"ID": 7, "State": {"Code": "ConnectionError", "Data": "Suspect", "Stream": "Closed", "Text": "Dictionary domain is unavailable for Eikon4_Desktop"}, "Type": "Status"}]

    Regarding the streaming end point I already looked at it but the fact that each RIC has to be handled individually implies a lot of change on our side.

    Thanks.

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    You can enable the debug log to check the retrieved data.

    [2025-02-21T11:25:05.533438+07:00] - [sessions.desktop.workspace.0] - [DEBUG] - [77416 - OpenUniverseStreams-Thread_0] - [stream_connection] - [send_message] - [OMMSTREAMING_PRICING_0.0] send {"ID": 5, "Domain": "MarketPrice", "Streaming": false, "Key": {"Name": "/SOGN.PA"}, "View": ["BID", "ASK", "CURRENCY", "RDN_EXCHID", "QUOTE_DATE", "QUOTIM", "QUOTIM_MS", "QUOTIM_NS"]}
    [2025-02-21T11:25:05.533438+07:00] - [sessions.desktop.workspace.0] - [DEBUG] - [77416 - OpenUniverseStreams-Thread_0] - [_stream] - [_do_open] - _UniverseStream owner.id=0 id=5 name='/SOGN.PA' wait open event
    [2025-02-21T11:25:05.586455+07:00] - [sessions.desktop.workspace.0] - [DEBUG] - [59756 - ThreadOMMSTREAMING_PRICING_0.0] - [stream_connection] - [_on_message] - [OMMSTREAMING_PRICING_0.0] on_ws_message [{"Fields": {"ASK": null, "BID": 37.35, "CURRENCY": "EUR", "QUOTE_DATE": "2025-02-21", "QUOTIM": "02:01:05", "QUOTIM_MS": "02:01:05.179", "QUOTIM_NS": "02:01:05.179", "RDN_EXCHID": "PAR"}, "State": {"Data": "Ok", "Stream": "NonStreaming", "Code": "None", "Text": "All is well"}, "Qos": {"Rate": "TimeConflated", "Timeliness": "DelayedUnknown"}, "Type": "Refresh", "SeqNumber": 22126, "ID": 5, "Key": {"Name": "/SOGN.PA", "NameType": "Ric", "Service": "Q"}}]

    The library sent an item request to the desktop session then the session sent the data back. The response from the Workspace session contains the expanded enum values.

  • In a previous session I already looked at the debug : on my end enum values are not expanded :

    [2025-02-20T15:14:04.696983+01:00] - [sessions.desktop.workspace.0] - [DEBUG] - [13008 - ThreadOMMSTREAMING_PRICING_0.0] - [stream_connection] - [_on_message] - [OMMSTREAMING_PRICING_0.0] on_ws_message [{"ID": 5, "Type": "Refresh", "Key": {"Service": "IDN_FD3", "Name": "/SOGN.PA"}, "State": {"Stream": "NonStreaming", "Data": "Ok", "Text": "All is well"}, "Qos": {"Timeliness": "Realtime", "Rate": "JitConflated"}, "PermData": "AwECEZd8", "SeqNumber": 12382, "Fields": {"RDN_EXCHID": 74, "CURRENCY": 978, "BID": 38.07, "ASK": 38.08, "MATUR_DATE": null, "QUOTIM": "13:59:02", "QUOTE_DATE": "2025-02-20", "QUOTIM_MS": 50342691, "QUOTIM_NS": "13:59:02.691481935"}}]

    [2025-02-20T15:14:04.697982+01:00] - [sessions.desktop.workspace.0] - [DEBUG] - [14964 - Msg-Proc-ThreadOMMSTREAMING_PRICING_0.0] - [omm_stream_connection] - [_process_message] - [OMMSTREAMING_PRICING_0.0] process message {"ID": 5, "Type": "Refresh", "Key": {"Service": "IDN_FD3", "Name": "/SOGN.PA"}, "State": {"Stream": "NonStreaming", "Data": "Ok", "Text": "All is well"}, "Qos": {"Timeliness": "Realtime", "Rate": "JitConflated"}, "PermData": "AwECEZd8", "SeqNumber": 12382, "Fields": {"RDN_EXCHID": 74, "CURRENCY": 978, "BID": 38.07, "ASK": 38.08, "MATUR_DATE": null, "QUOTIM": "13:59:02", "QUOTE_DATE": "2025-02-20", "QUOTIM_MS": 50342691, "QUOTIM_NS": "13:59:02.691481935"}}

    I understand from the previous messages that this behaviour is caused by our use of Eikon instead of Workspace, is this correct ?

    Thanks.

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    Yes, it is possible. Sorry, I have uninstalled Eikon so I can't test it.

    I have a simple code to get expanded values at https://github.com/jirapongse-refinitiv/Python_Dictionary/tree/main. It required the RDMFieldDictionary and enumtype.def files. You can get those files from https://github.com/Refinitiv/Real-Time-SDK/tree/master/Cpp-C/etc.

  • OK I will have a look.

    Thanks for your help.