defining FIDs in websocket API for streaming prices

I use the Python example : market_price_edpgw_authentication

I can run the example but I want to optimize the solution. There is no need to get in the initialization all the available FIDs. I only want to see with the initialization 10-15 FIDs and only want to receive updates for these FIDS. How do I define the FIDS in the request . In the demo video "view" was used but that isn't supported in the Python example.

Best Answer

  • pimchaya.wongrukun01
    Answer ✓

    Hello @wim.ooms

    You can add 'View' in the request to specify your preference fields. The example below show how to request BID(FID 22) and ASK(FID 25) field below:

     mp_req_json = {
            'ID': 2,
            'Key': {
                'Name': ric_name,
                'Service': service
            },
             'View': [
                22,
                25
            ]
        }

    The example output:

    SENT:
    {
      "ID":2,
      "Key":{
        "Name":"JPY=",
        "Service":"ELEKTRON_DD"
      },
      "View":[
        22,
        25
      ]
    }
    RECEIVED: 
    [
      {
        "Fields":{
          "ASK":106.86,
          "BID":106.83
        },
        "ID":2,
        "Key":{
          "Name":"JPY=",
          "Service":"ELEKTRON_DD"
        },
        "PermData":"AwEBUmw=",
        "Qos":{
          "Rate":"JitConflated",
          "Timeliness":"Realtime"
        },
        "SeqNumber":9406,
        "State":{
          "Data":"Ok",
          "Stream":"Open",
          "Text":"*All is well"
        },
        "Type":"Refresh"
      }
    ]

    You can find view Python example in market_price_batch_view.py shipped with WebSocket API Sample Applications

Answers