Benny- / Yahoo-ticker-symbol-downloader

A web scraper for ticker symbols from yahoo finance
https://pypi.python.org/pypi/Yahoo-ticker-downloader/
Other
247 stars 87 forks source link

How to download a list of tickers of an exchange? #20

Closed kopeboy closed 7 years ago

kopeboy commented 7 years ago

Could you please provide an example on how I should write the name of the index? Is it possible to download a list of all the tickers filtered by index right?

YahooTickerDownloader.py index='BIT' would work?

(I am not sure where to find the code of the index used by Yahoo)

Thanks

Benny- commented 7 years ago

YahooTickerDownloader.py {desired ticker type} -E {exchange name}

Some examples: YahooTickerDownloader.py stocks -E NMS YahooTickerDownloader.py stocks -E NYQ YahooTickerDownloader.py stocks -E FRA

I got these by going to https://de.finance.yahoo.com/lookup/S?s=a&b=0&m=ALL&t=S&bypass=true

Benny- commented 7 years ago

Does this answers your question?

kopeboy commented 7 years ago

Yes, thanks!

(Trying with another query I found that Italy exchange code is 'MIL' )

kopeboy commented 7 years ago

Actually it didn't work as expected.

I run YahooTickerDownloader.py stocks -E MIL but it didn't filter on the exchange as you can see here:

req https://de.finance.yahoo.com/lookup/S?bypass=true&s=a&b=120&m=ALL&t=S
Retry attempt: 1. Sleep period: 5 seconds.
req https://de.finance.yahoo.com/lookup/S?bypass=true&s=a&b=120&m=ALL&t=S
Got 20 downloaded Stock symbols:
 Stock NNS.DE GER Nanostart AG
 Stock NGLB.DE GER Anglo American PLC
  ect...
Progress: Query 0/26. Items handled in current query: 140/Unknown. Total collected unique Stock entries: 140

req https://de.finance.yahoo.com/lookup/S?bypass=true&s=a&b=140&m=ALL&t=S
Got 20 downloaded Stock symbols:
 Stock AFRB.L LSE AFI Development PLC
 Stock ADSK NMS Autodesk, Inc.
  ect...
Progress: Query 0/26. Items handled in current query: 160/Unknown. Total collected unique Stock entries: 160

req https://de.finance.yahoo.com/lookup/S?bypass=true&s=a&b=160&m=ALL&t=S
Retry attempt: 1. Sleep period: 5 seconds.
req https://de.finance.yahoo.com/lookup/S?bypass=true&s=a&b=160&m=ALL&t=S
Retry attempt: 2. Sleep period: 25 seconds.
req https://de.finance.yahoo.com/lookup/S?bypass=true&s=a&b=160&m=ALL&t=S
Got 20 downloaded Stock symbols:
 Stock UHRN.SW EBS The Swatch Group AG
 Stock UHAL NMS AMERCO
  ect...
Progress: Query 0/26. Items handled in current query: 180/Unknown. Total collected unique Stock entries: 180

req https://de.finance.yahoo.com/lookup/S?bypass=true&s=a&b=200&m=ALL&t=S
Got 20 downloaded Stock symbols:
 Stock AVL.TO TOR Avalon Advanced Materials Inc.
 Stock ATM.NZ NZE The a2 Milk Company Limited
  ect...
Progress: Query 0/26. Items handled in current query: 220/Unknown. Total collected unique Stock entries: 220

^CSuspending downloader to disk

I tried with LSE as well (London Stock Exchange) without success.

Benny- commented 7 years ago

The filtering is done after all the symbols have been downloaded.

I will consider this a enhancement to alter the description to make this behavior clear.

abhandari73 commented 7 years ago

I tried the following but get a blank csv and excel file

python3 YahooTickerDownloader.py stocks -E FRA -e

how do I export the ticker list

Thanks

Benny- commented 7 years ago

@abhandari73 The -e switch will immediately export the current .pickle file without downloading. I just tested it and it worked as expected. Run without the -e switch first to gather the symbols from Yahoo.

Benny- commented 7 years ago

The changes for making the help text more descriptive are applied just now in e6e2c6311c641aebd870c929ec440c408c429207

abhandari73 commented 7 years ago

Thank you Benny.

Since it is downloading symbols for all exchanges and then applying the filter.

I guess then it is better to download the symbols and then sort it in excel and get the relevant symbols?

Kind Regards, Arjun Bhandari +97150 780 5672

On Feb 4, 2017, at 10:02 PM, Benny Jacobs notifications@github.com wrote:

Closed #20 https://github.com/Benny-/Yahoo-ticker-symbol-downloader/issues/20.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Benny-/Yahoo-ticker-symbol-downloader/issues/20#event-949186440, or mute the thread https://github.com/notifications/unsubscribe-auth/AOkgEBfVyeO9cHquXp5ey2kMcGCmybp0ks5rZL0jgaJpZM4L1K4e.

Benny- commented 7 years ago

I don't know if it is "better" but it should give the same result in the end.