alvarobartt / investpy

Financial Data Extraction from Investing.com with Python
https://investpy.readthedocs.io/
MIT License
1.63k stars 377 forks source link

OTC data missing #270

Closed budik601 closed 3 years ago

budik601 commented 3 years ago

Hello, I would like to get list of all tickers, but when I use "investpy.get_stocks(country=None)", there are no OTC tickers. Is there a way how to get OTC tickers? (e.g. tickers MPNGF,CHLKF,SFTBF,DCMYY,NTTYY, ...)

Thank you Jan

alvarobartt commented 3 years ago

Hi @budik601!

Could you please share with me an Investing.com URL which contains the data you are looking for so that I can evaluate if it's worth integrating a new feature for that or not? Thanks a lot! 🤗

In the mean time, please check the function investpy.search_quotes() which uses Investing.com's search engine and will let you retrieve the data from the OTC tickets you are looking for. For more information please read: https://github.com/alvarobartt/investpy/wiki/investpy.search_quotes()

budik601 commented 3 years ago

Hi @alvarobartt . I need to download only list of all OTC tickers, but I solved it. Here is solution with selenium and chromedriver:

`from selenium import webdriver from selenium.webdriver.common.keys import Keys import pandas as pd from bs4 import BeautifulSoup import lxml import time from tqdm import tqdm

driver = webdriver.Chrome('/home/jan/Notebooks/chromedriver') nyse = 'https://www.investing.com/stock-screener/?sp=country::5|sector::a|industry::a|equityType::a|exchange::1%3Ename_trans;' nasdaq = 'https://www.investing.com/stock-screener/?sp=country::5|sector::a|industry::a|equityType::a|exchange::2%3Ename_trans;' otc = 'https://www.investing.com/stock-screener/?sp=country::5|sector::a|industry::a|equityType::a|exchange::95%3Ename_trans;' urls = [nyse, nasdaq, otc] name = ['nyse','nasdaq','otc'] driver.get('https://www.investing.com/stock-screener/?sp=country::5|sector::a|industry::a|equityType::a|exchange::a%3Ename_trans;1')

for url, exchange in zip(urls, name): tickers = pd.DataFrame(columns = ['ticker', 'company']) for i in tqdm(range(1,100)): driver.get(str(url)+str(i)) time.sleep(4) soup = BeautifulSoup(driver.page_source, 'lxml') table = soup.find('table', id="resultsTable") rows = table.findAll('tr')[1:] for row in rows: company = row.findAll('td')[1].text ticker = row.findAll('td')[2].text tickers = tickers.append({'company': company, 'ticker': ticker}, ignore_index = True) tickers.tocsv('tickers'+str(exchange)+'.csv') `

alvarobartt commented 3 years ago

Ok sorry for not being able to help you sooner! 😩 But it's cool that you managed to find a solution for this issue you had!

If you don't need anything else, please close this issue 👍🏻