For LSEG Data chain.py, example using platform.deployed, getting A18: Service unknown.

Options
mark.sinner
mark.sinner Newcomer
edited August 6 in WebSocket API

The connection is to RTC. I see in a post need: \*rtc\*defaultJsonServiceId, I believe in RTC rtc.cnf.

Is this correct ? How to use chain.py example to connect to local rtc ? 

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @mark.sinner

    Thank you for reaching out to us.

    If item requests don't have the service name property, it will use the service from the *rtc*defaultJsonServiceId configuration. Please refer to the Testing Real-time Streaming applications with Docker & Refinitiv Real-Time Connector (part 2) article.

    image.png

    Where did you get the chain.py example?

  • Hello @mark.sinner

    You can specify the service name in the item request message as follows:

    Example: service name is ELEKTRON_DD

    {
    "ID":2,
    "Key":{
    "Name":"VOD.L",
    "Service": "ELEKTRON_DD"
    }
    }
  • The example is from LSEG Data Python:

    Example.DataLibrary.Python/Examples/1-Access/EX-1.01.07-Chains.ipynb at lseg-data-examples · LSEG-API-Samples/Example.DataLibrary.Python

    I don't see a way to specify the Service other than the rtc config. Trying below gets error with service= or Service=:
    chn = ld.discovery.Chain(name="0#USTSY=TWEB",Service="IDN_RDF")

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

    TypeError: Chain.init() got an unexpected keyword argument 'Service'

    Code:

    import os
    import lseg.data as ld
    from lseg.data.discovery import Chain
    import datetime
    from IPython.display import display, clear_output
    import logging.config

    def display_data(data, instrument, stream):
    clear_output(wait=True)
    current_time = datetime.datetime.now().time()
    print(current_time, "- Data received for", instrument)
    display(data)
    ld.open_session(config_name='./lseg-data.config.json')

    chn = ld.discovery.Chain(name="0#USTSY=TWEB",Service="IDN_RDF")
    print(chn.constituents)
    print(chn.summary_links)
    ld.get_data(chn, ['BID', 'ASK'])

    ld.close_session()

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @mark.sinner

    To connect to RTC, you need to use the platform.deployed session with the following configurations.

                "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" : ""
    }
    }
    }

    For example:

                "deployed": {
                    "app-key": "",
                    "realtime-distribution-system": {
                        "url" : "127.0.0.1:15000",
                        "dacs" : {
                            "username" : "api",
                            "application-id" : 256,
                            "position" : ""
                        }
                    }
                }
    

    Then, you can use the EX-2.02.06-Pricing-StreamingChain.ipynb example. For example:

    chain = pricing.chain.Definition(name="0#USTSY=TWEB", service="ELEKTRON_DD").get_stream()
    chain.open(with_updates=False)
    chain.close()
    print(chain.constituents)