investpy icon indicating copy to clipboard operation
investpy copied to clipboard

Stock name not found

Open Towasi opened this issue 3 years ago • 2 comments

I am trying to download the detail of the S&P500 index (the historical price of each of the current stocks in the index).

I notice that to download the historical prices of the index we must use:

db = investpy.get_index_historical_data (index = "S&P 500", country = 'United States', from_date = "01/01/2021", to_date = "10/14/2021", as_json = True, order = 'ascending', interval = 'Daily')

and for the stocks:

db = investpy.get_stock_historical_data (stock = "MMM", country = 'United States', from_date = "01/01/2021", to_date = "10/14/2021", as_json = True, order = 'ascending', interval = 'Daily')

The problem I have is that there are some stocks in the S&P500 index that are impossible to download with these methods.

This is the list of stocks: ['BBWI', 'CARR', 'CDAY', 'CTRA', 'HWM', 'J', 'LUMN', 'MRNA', 'OGN', 'OTIS' , 'PAYC', 'RTX', 'TT', 'TFC', 'VIAC', 'VTRS']

The error I get is this:

in get_stock_historical_data raise RuntimeError ("ERR # 0018: stock" + stock + "not found, check if correct"). RuntimeError: ERR # 0018: bbwi stock not found, check if it is correct.

PS: I have already checked the ticker symbol for the stocks on the list, and at least for NYSE and Investing.com they are correct.

Thanks in advance

Towasi avatar Oct 17 '21 10:10 Towasi

This Error occurs because the mentioned stocks are not available in resources/stock.csv. You can add the missing code to get this working. Please take a backup of this file before any modification to be on safer side. For example let us take CDAY Before adding to stocks.csv import investpy as inv rslt=inv.get_stock_information('CDAY','united states') RuntimeError: ERR#0018: stock cday not found, check if it is correct.

Get the required information by executing the below function

search_result = inv.search_quotes(text='CDAY', products=['stocks'], countries=['united states'], n_results=1) print(search_result ) {"id_": 1073206, "name": "Ceridian HCM Holding Inc", "symbol": "CDAY", "country": "united states", "tag": "/equities/ceridian-hcm-holding-inc", "pair_type": "stocks", "exchange": "NYSE"}

However ISIN is missing from above which can be look up at https://stockmarketmba.com/symbollookup.php

After updating the stocks.csv, rslt=inv.get_stock_information('CDAY','united states') print(rslt) Stock Symbol Prev. Close Todays Range Revenue Open 52 wk Range EPS
0 CDAY 125.25 124.51-127.08 912.1M 125.05 78.2-130.35 -0.42

  Volume    Market Cap Dividend (Yield)  Average Vol. (3m) P/E Ratio  \

0 1005971.0 1.904000e+10 N/A(N/A) 1340641.0 -

Beta 1-Year Change Shares Outstanding Next Earnings Date
0 1.36 47.32% 149861732.0 03/11/2021

Hope this helps.

rvenkkat70 avatar Nov 02 '21 11:11 rvenkkat70

Just in case you're doing this again, I created a script here to extract and format a complete row entry in stocks.csv based on the url on investing.com

aphi avatar Feb 19 '22 17:02 aphi