portfolioplus / pysymbolscanner

Stock symbol scanner for pytickersymbols repo
MIT License
7 stars 2 forks source link

Knowing at which exchange(s) a stock is listed might be interesting #4

Open mdxs opened 3 years ago

mdxs commented 3 years ago

The https://en.wikipedia.org/wiki/List_of_stock_exchanges might provide a starting point to obtain the core data of the major stock exchanges. It appears that the MIC (= market identifier code) is some kind of standard, like XAMS for Amsterdam (as part of Euronext).

And a possible source of the current MICs might be https://www.iso20022.org/market-identifier-codes

Where an Operating MIC (like XAMS) could actually have some sub-MICs for specific markets.

Now, it may not be interesting to utilize all that information; and it may not change too often for Stock Exchanges; it does seem like a good source of the "official" data on them.

Whether it is straightforward to know which Stock Exchange a specific stock is listed at... and in fact stocks can be listed at more than one stock exchange; that I don't know. My assumption is that if the AEX is an index of XAMS, then all stocks that are in the composition of the AEX are also to be listed at the XAMS. That assumption may help to get started; that is: if it is of interest.

SlashGordon commented 3 years ago

Currently, the exchange information is located in the symbol list of each company.

Let us take a look at Linde PLC:

- id: 21
  name: Linde PLC
  symbol: LIN
  country: United Kingdom
  indices:
  - DAX
  - S&P 500
  industries:
  - Commodity Chemicals
  - Basic Materials
  - Chemicals
  symbols:
  - yahoo: LIN.F
    google: FRA:LIN
  - yahoo: LIN
    google: NYSE:LIN
  metadata:
    founded: 1879
    employees: 59715

According to the symbols we see that the stock is listed at Börse Frankfurt and NYSE. The main challenge is to find the specific company symbol for each exchange.

The only source I know is the yahoo finance search API:

https://query1.finance.yahoo.com/v1/finance/search?q=microsof&lang=en-US&region=US&quotesCount=15&enableFuzzyQuery=false&quotesQueryId=tss_match_phrase_query&multiQuoteQueryId=multi_quote_single_token_query&newsQueryId=news_cie_vespa&enableCb=true&enableNavLinks=true&enableEnhancedTrivialQuery=true

To see if I have understood you correctly you want to have the following structure:

- id: 21
  name: Linde PLC
  symbol: LIN
  country: United Kingdom
  exchanges:
  - XNYS
  - XFRA
  indices:
  - DAX
  - S&P 500
  industries:
  - Commodity Chemicals
  - Basic Materials
  - Chemicals
  symbols:
  - yahoo: LIN.F
    google: FRA:LIN
  - yahoo: LIN
    google: NYSE:LIN
  metadata:
    founded: 1879
    employees: 59715

Right or Wrong?

mdxs commented 3 years ago

Right