I have seen example of filtering the EntityClass. For example, to get the companies with the largest p/e ratios:

EntityClass["Financial", "PriceEarningsRatio" -> TakeLargest[10]] // EntityList

But now I wish to match a field exactly, rather than taking those with the largest elements. How can I get all companies that match the exchange field exactly? I tried this:

(* Find all Financial Entities with "XTKS" (Tokyo Stock Exchange) as its
   "Exchange" value. *)
EntityClass["Financial", "Exchange" -> SameQ["XTKS"]] // EntityList

But I get:

Missing[QueryValueIncompatibleWithProperty, {Financial, Exchange, True}]

I suspect that it's something to do with the use of SameQ.

How do I filter by stock exchange when using a financial EntityClass?

(Note: I know there are other ways of obtaining the list of companies listed on an exchange, but I just want to know how to filter by exact string in a financial EntityClass)

  • 1
    $\begingroup$ In version 12 you can try FilteredEntityClass. I tried this but it is taking a long time to download all the entities. FilteredEntityClass["Financial", EntityFunction[e, e["Exchange"] == "XTKS"]] // EntityList $\endgroup$ – Rohit Namjoshi Aug 25 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.