For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
5 2 4 8

Request same field with different parameters in data_grid

If I do a request like the following:

ek.get_data('BHP.AX', ['TR.TradePriceClose', ('TR.TradePriceClose', {'Curn': 'USD'})])

The second TradePriceClose field (in USD) doesn't come through as an additional column as expected whereas this works fine in say excel, or through the COM apis (Dex2).

Instead what appears to be happenning is it is collapsing the data by bare field name (not including parameters) causing it to get folded together with the first field as a single column in the response, leaving only one instance of TradePriceClose in the returned json headers. Using either by itself works fine. Is there some way of modifying the request in data_grid to avoid this (eg passing some different parameters)?

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythonapi
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

It seems to work if I add a .value suffix to both fields, and put the USD one first, otherwise I get two identical columns. Can't quite figure make sense of this one.

1 Answer

Upvotes
Accepted
38.1k 71 35 53

I got the same result as yours.

The following is the Request and Response after using the above code.

Request

{
  "Entity": {
    "W": {
      "fields": [
        {
          "name": "TR.TradePriceClose"
        },
        {
          "parameters": {
            "Curn": "USD"
          },
          "name": "TR.TradePriceClose"
        }
      ],
      "instruments": [
        "BHP.AX"
      ]
    },
    "E": "DataGrid"
  }
}

Response

{
    "columnHeadersCount": 1,
    "data": [
        [
            "BHP.AX",
            23.8
        ],
        [
            "BHP.AX",
            23.8
        ]
    ],
    "headerOrientation": "horizontal",
    "headers": [
        [
            {
                "displayName": "Instrument"
            },
            {
                "displayName": "Trade Price Close",
                "field": "TR.TRADEPRICECLOSE"
            }
        ]
    ],
    "rowHeadersCount": 1,
    "totalColumnsCount": 2,
    "totalRowsCount": 3
}

However, if I use your workaround, I can get the correct data.

Request

{
  "Entity": {
    "W": {
      "fields": [
        {
          "name": "TR.TradePriceClose.value",
          "parameters": {
            "Curn": "USD"
          }
        },
        {
          "name": "TR.TradePriceClose.value"
        }
      ],
      "instruments": [
        "BHP.AX"
      ]
    },
    "E": "DataGrid"
  }
}

Response

{
  "columnHeadersCount": 1,
  "data": [
    [
      "BHP.AX",
      17.933300179333,
      23.8
    ]
  ],
  "headerOrientation": "horizontal",
  "headers": [
    [
      {
        "displayName": "Instrument"
      },
      {
        "displayName": "Trade Price Close",
        "field": "TR.TRADEPRICECLOSE(Curn=USD).value"
      },
      {
        "displayName": "Trade Price Close",
        "field": "TR.TRADEPRICECLOSE.value"
      }
    ]
  ],
  "rowHeadersCount": 1,
  "totalColumnsCount": 3,
  "totalRowsCount": 2
}

This could be the problem in Data Grid. I will contact Data Grid team to verify the issue.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Thanks for taking a look. Note that it is also reproducible in excel, ie this formula doesn't work correctly unless you flip the order:

=TR("BHP.AX","TR.TradePriceClose;TR.TradePriceClose(Curn=USD)","CH=Fd",B2)

So this has the potential to trip up many more people than just those using DataGrid via the scripting API or JET. Another thing to note is that it works fine with TR.PriceClose, so it is something peculiar to these items (which I believe get pulled from a different source than data cloud?).

Click below to post an Idea Post Idea