11
$\begingroup$

There are plenty of sources which provide the historical stock data but they only provide the OHLC fields along with volume and adjusted close. Also a couple of sources I found provide market cap data sets but they're restricted to US stocks. Yahoo Finance provides this data online but there's no option to download it ( or none I am aware of ).

  • Where can I download this data for stocks belonging to various top stock exchanges across countries by using their ticker name ?
  • Is there some way to download it via Yahoo Finance or Google Finance ?

I need data for the last decade or so and hence need some script or API which would do this.

$\endgroup$
6
$\begingroup$

Quant SE is better place for questions related to getting financial data:

| improve this answer | |
$\endgroup$
3
$\begingroup$

As far as gathering data goes, you can check out Quandl (there's a tutorial on using it with R on DataCamp if you're interested).

In addition, Aswath Damodaran's site contains a lot of helpful datasets. Though they aren't updated that frequently, they may still be useful, especially as a benchmark for comparing your own output (from the scripts you will inevitably need to write to calculate the necessary metrics).

And, again, Quant SE is probably a better place to be looking...

| improve this answer | |
$\endgroup$
1
$\begingroup$

This site lists historical market capitalizations and enterprise values for S&P 100 and NASDAQ-100 companies for the past 10 years. You can export the data sets to Excel.

http://marketcapitalizations.com/historical-data/historical-data-categories/valuations/

You can also try to contact them for data for a longer period of time.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Are you affiliated with this site BTW? $\endgroup$ – Sean Owen Oct 18 '15 at 16:34
1
$\begingroup$

I would do it this way.

import requests
from bs4 import BeautifulSoup

base_url = 'https://finviz.com/screener.ashx?v=152&s=ta_topgainers&o=price&c=1,2,6,7,25,65,67'
html = requests.get(base_url)
soup = BeautifulSoup(html.content, "html.parser")
main_div = soup.find('div', attrs = {'id':'screener-content'})

light_rows = main_div.find_all('tr', class_="table-light-row-cp")
dark_rows = main_div.find_all('tr', class_="table-dark-row-cp")

data = []
for rows_set in (light_rows, dark_rows):
    for row in rows_set:
        row_data = []
        for cell in row.find_all('td'):
            val = cell.a.get_text()
            row_data.append(val)
        data.append(row_data)

#   sort rows to maintain original order
data.sort(key=lambda x: int(x[0]))

import pandas
pandas.DataFrame(data).to_csv("AAA.csv", header=False)
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.