如何从雅虎财经获取完整的股票代码列表? [英] How to get a complete list of ticker symbols from Yahoo Finance?

查看:78
本文介绍了如何从雅虎财经获取完整的股票代码列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无休止地在谷歌上搜索了一种方法,可以通过 http 获得所有雅虎股票代码的完整列表(并且每天更新)://finance.yahoo.com

I've googled endlessly for a method of getting a complete (and daily updated) list of all Yahoo ticker symbols available through http://finance.yahoo.com

雅虎拥有全球许多交易所的股票、期货等信息,我想要一份包含所有可用股票代码的综合列表.我试过 YQL,但它们有where symbol = (or in)"子句限制,所以我不能从符号中选择 *.

Yahoo has information for stocks, futures etc for a lot of exchanges worldwide, and I'd like a combined list of all the ticker symbols available through them. I've tried YQL but they have a "where symbol = (or in)" clause restriction so I cannot select * from symbols.

所以基本上,一次获取单个或多个代码的详细信息很容易,但我似乎无法找到如何获取所有可用代码的列表.

So basically, getting detailed information for a single symbol or several symbols at one time is easy but I just can't seem to find out how to get a list of all available tickers.

有人可以帮忙吗?

推荐答案

http://code.google.com/p/yahoo-finance-managed/ 这会让你到达那里.不幸的是,没有直接下载股票代码列表的方法,但以下内容通过按字母顺序排列的组进行迭代来创建列表:

There is a nice C# wrapper for the Yahoo.Finance API at http://code.google.com/p/yahoo-finance-managed/ that will get you there. Unfortunately there is no direct way to download the ticker list but the following creates the list by iterating through the alphabetical groups:

        AlphabeticIDIndexDownload dl1 = new AlphabeticIDIndexDownload();
        dl1.Settings.TopIndex = null;
        Response<AlphabeticIDIndexResult> resp1 = dl1.Download();

        writeStream.WriteLine("Id|Isin|Name|Exchange|Type|Industry");

        foreach (var alphabeticalIndex in resp1.Result.Items)
        {
            AlphabeticalTopIndex topIndex = (AlphabeticalTopIndex) alphabeticalIndex;
            dl1.Settings.TopIndex = topIndex;
            Response<AlphabeticIDIndexResult> resp2 = dl1.Download();

            foreach (var index in resp2.Result.Items)
            {
                IDSearchDownload dl2 = new IDSearchDownload();
                Response<IDSearchResult> resp3 = dl2.Download(index);


                int i = 0;
                foreach (var item in resp3.Result.Items)
                {
                    writeStream.WriteLine(item.ID + "|" + item.ISIN + "|" + item.Name + "|" + item.Exchange + "|" + item.Type + "|" + item.Industry);
                }

            }
        }

它在大约 4 分钟内给了我大约 75,000 种证券的清单.

It gave me a list of about 75,000 securities in about 4 mins.

这篇关于如何从雅虎财经获取完整的股票代码列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆