Python Forum
How can automatize ticker selection to find the trading data of all the tickers
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can automatize ticker selection to find the trading data of all the tickers
#1
Dear Members,
I am trying to download data in Table 1 from https://www.secform4.com/insider-trading

I need to put Company Ticker to get information about the specific company. Say, I want data about Apple Inc. (Ticker=AAPL). I get the following page: https://www.secform4.com/insider-trading/320193.htm. My objective here is to extract table 1 data from all the years for all the stocks including AAPL. Is there any way I can command python to find Company Ticker from a particular file saved on my PC?

import scrapy


class InsiderSpider(scrapy.Spider):
    name = 'insider'
    allowed_domains = ['www.secform4.com']
    start_urls = ['https://www.secform4.com/insider-trading/320193.htm']

    def parse(self, response):
        insiders = response.xpath("(//table[@class='sort-table'])[1]/tbody/tr")
        for insider in insiders:
            transaction_date = insider.xpath(".//td[@class='S']/text()[position()=1]").get()
            buy_sale = insider.xpath(".//td[@class='S']/text()[position()=2]").get()
        
            yield{
                'transaction_date': transaction_date,
                'buy_sale': buy_sale
            }

        next_page = response.xpath("(//div/font/a[11]/@href)[1]").get()
        
        if next_page:
            yield scrapy.Request(url=next_page, callback=self.parse)
Reply
#2
There are different locations for each market where you can download a complete days trading, for example for nasdaq there's https://www.nasdaqtrader.com/Trader.aspx...arketFiles, NYSE: https://www.nyse.com/data/transactions-s...ta-library (archives). And for each country there are links. Google is your friend here.
Reply
#3
Thank you Larz60+ for your response. I wanted to know whether there is any way I can command python to find Company Ticker from a particular file (it could be Jason file or CSV file) saved on my PC?

As you can see, I writing code for each company link. There are more than 5000 Company Tickers. Therefore, It would be convenient to automatize the process.
Reply
#4
That you can download here: https://www.tradinggraphs.com/2012/05/06...nyse-amex/
then just access in python as you would any other file.
Reply
#5
Thank you Larz60+
Reply
#6
I added a class to github that will fetch symbol from company name, of company name from symbol
this can be viewed and/or downloaded here: https://github.com/Larz60p/PySymbol
or cloned with: git clone https://github.com/Larz60p/PySymbol
usage:
>>> import PySymbol
>>> sym = PySymbol.PySymbol()
>>> lookup = sym.Lookup
>>> lookup('NYSE', company_name='Raytheon Company')
'RTN'
>>> lookup('NYSE', ticker='RTN')
'Raytheon Company'
>>>
Example from application see: https://github.com/Larz60p/PySymbol/blob...olFetch.py
Reply
#7
Thank you Larz60+. I will come up with a more specific question about the issue in the next couple of days. Then It would be more convenient for you to understand. I highly appreciate your help.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020