Message Boards Message Boards

0
|
5433 Views
|
9 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Confusion about suitable Entity types for certain functions

Posted 2 years ago
POSTED BY: Raymond Low
9 Replies
Posted 2 years ago

Again Thanks Rohit -- I am two thirds of the way there, for some reason EntityClass would not take nine of the company names provided by FinancialData, By chance is there another way???

d = FinancialData["^DJI", "Members"] 

dd = FinancialData[#, "Name"] & /@ d

In[99]:= ddd = 
 EntityValue[EntityList[EntityClass["Company", {"Name" -> #}]], 
    "CanonicalName"] & /@ dd

Out[99]= {{"3MCompany::k67x2"}, {"AmericanExpressCompany::9d6vt"}, \
{"Amgen::6yq5w"}, {"Apple::5zkjq"}, {"Boeing::374s8"}, \
{"Caterpillar::48f69"}, {"ChevronCorporation::tj685"}, {}, \
{"CocaCola::78tc4"}, {}, {"DowHoldings::7wkrd"}, {}, \
{"HomeDepot::cb9gp"}, {}, \
{"InternationalBusinessMachinesCorporation::vq88c"}, \
{"IntelCorporation::vj6f2"}, {"Johnson&Johnson::7z9hd"}, \
{"JPMorganChase&Company::258fx"}, {"McDonaldsCorporation::92mv4"}, \
{}, {"MicrosoftCorporation::j3gxm"}, {"Nike::4b7r6"}, \
{"Procter&GambleCompany::sy7qs"}, {"SalesforceDotCom::zbp4j"}, {}, \
{}, {"VerizonCommunications::g84hj"}, {"Visa::r2fcs"}, {}, {}}
POSTED BY: Raymond Low
Posted 2 years ago

Hi Rohit,
Thanks so much for your help, I tried again with better success, but it is real madness trying to guess what name Mathematica wants for their name. I had to go to StockCharts to get various names and even then had to play around with the names to see what worked. Dow Holding did not work, but Dow did, Verizon did not work, but Verizon Communications did. I never figured out what name they wanted for 3M Company -- tried several variations but never found the secret.

In[89]:= EntityValue[
 EntityList[
  EntityClass["Company", {"Name" -> "Apple"}]], "CanonicalName"]
EntityValue[
 EntityList[
  EntityClass["Company", {"Name" -> "IBM"}]], "CanonicalName"]
EntityValue[
 EntityList[
  EntityClass[
   "Company", {"Name" -> "Eastman Kodak"}]], "CanonicalName"]
EntityValue[
 EntityList[
  EntityClass["Company", {"Name" -> "3M Co"}]], "CanonicalName"]
EntityValue[
 EntityList[
  EntityClass[
   "Company", {"Name" -> "Verizon Communications"}]], "CanonicalName"]
EntityValue[
 EntityList[
  EntityClass["Company", {"Name" -> "Microsoft"}]], "CanonicalName"]
EntityValue[
 EntityList[
  EntityClass["Company", {"Name" -> "Dow"}]], "CanonicalName"]
EntityValue[
 EntityList[
  EntityClass["Company", {"Name" -> "Facebook"}]], "CanonicalName"]

Out[89]= {"Apple::5zkjq"}

Out[90]= {"InternationalBusinessMachinesCorporation::vq88c"}

Out[91]= {"EastmanKodakCompany::g2j5c"}

Out[92]= {}

Out[93]= {"VerizonCommunications::g84hj"}

Out[94]= {"MicrosoftCorporation::j3gxm"}

Out[95]= {"DowHoldings::7wkrd"}

Out[96]= {"Facebook::79qbc"} 

I would like to work with the companies in the DJIA and got the symbols from FinanceData, but that will not work in CompanyData

dd = FinancialData["^DJI", "Members"]

{"NYSE:MMM", "NYSE:AXP", "NASDAQ:AMGN", "NASDAQ:AAPL", "NYSE:BA", \
"NYSE:CAT", "NYSE:CVX", "NASDAQ:CSCO", "NYSE:KO", "NYSE:DIS", \
"NYSE:DOW", "NYSE:GS", "NYSE:HD", "NASDAQ:HON", "NYSE:IBM", \
"NASDAQ:INTC", "NYSE:JNJ", "NYSE:JPM", "NYSE:MCD", "NYSE:MRK", \
"NASDAQ:MSFT", "NYSE:NKE", "NYSE:PG", "NYSE:CRM", "NYSE:TRV", \
"NYSE:UNH", "NYSE:VZ", "NYSE:V", "NASDAQ:WBA", "NYSE:WMT"}

any suggestions in how to download the names for these 30 stocks that is compatible with CompanyData????

POSTED BY: Raymond Low
Posted 2 years ago
POSTED BY: Rohit Namjoshi
Posted 2 years ago
POSTED BY: Raymond Low
Posted 2 years ago

Hi Raymond,

In an earlier response, I said "WL is case sensitive, facebook is not the same as Facebook. Try that e.g.

EntityValue[
 EntityList[EntityClass["Company", {"Name" -> "Microsoft"}]], "CanonicalName"]
(* {"MicrosoftCorporation::j3gxm"} *)
POSTED BY: Rohit Namjoshi
Posted 2 years ago

One more thing: looks like you are using a companies stock symbol for its name. That will not work, FinancialData takes symbol name.

EntityValue[
 EntityList[EntityClass["Company", {"Name" -> "Apple"}]], "CanonicalName"]
(* {"Apple::5zkjq"} *)

symbols = EntityValue[EntityList[EntityClass["Company", {"Name" -> "Apple"}]], 
  "CommonShares"] // CanonicalName // First
(* {"NASDAQ:AAPL", "DE:APC", "F:APC"} *)

FinancialData[#, "OHLCV"] & /@ symbols

FinancialData[#, "Exchange"] & /@ symbols
POSTED BY: Rohit Namjoshi
Posted 2 years ago
POSTED BY: Updating Name
Posted 2 years ago
POSTED BY: Rohit Namjoshi

These are related entities, but they aren't exactly interchangeable. A company can have multiple associated Financial entities. So for FinancialData, you will want to give it Financial entities. For CompanyData, you want to give it a Company entity.

It's best to just try following the documentation examples, which should largely work as they're written without adjustment.

https://reference.wolfram.com/language/ref/CompanyData.html https://reference.wolfram.com/language/ref/FinancialData.html

You also noted this isn't working:

Interpreter["Company"]["FB"]

It is probably no longer considered unambiguous enough. Less ambiguous input like "Facebook" should work.

In your other example... "Company" isn't a property. So this doesn't work:

EntityValue[Interpreter["Company"]["FaceBook"], "Company"]

You're effectively asking for a Company entity that corresponds to "FaceBook" and then asking that Company entity be turned into a Company entity... which you don't need to do. It's already a company entity. You can give a Company Entity directly to CompanyData:

CompanyData[Interpreter["Company"]["FaceBook"], "Dataset"]
POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract