Using [NSString stringWithFormat:] to change the AAPL to the stock ticker you want to use. The retrieved data is in CSV format so you will need to parse that to get the individual values you require. This can be done in this simple case using [NSString componentsSeparatedByString: @","] to retieve an array which you can parse using two loops.
For a full code example of this, check out the AAPLot sample application in the Core Plot framework. It downloads stock data and plots it with open-high-low-close information, as well as trading volume.
The Quandl Stock API is free and let's you retrieve Yahoo or Google finance data. In addition to CSV, it provides the data in some more modern formats like JSON and XML. Here's how to retrieve for CSV:
发布评论
评论(5)
使用
NSURLRequest
对象检索以下地址的数据:http://download.finance.yahoo.com/d/quotes.csv?s=AAPL&f=sl1d1t1c1ohgv&e=.csv
使用
[NSString stringWithFormat:]
将 AAPL 更改为您要使用的股票代码。检索到的数据采用 CSV 格式,因此您需要对其进行解析以获取所需的各个值。在这个简单的情况下,可以使用[NSString ComponentsSeparatedByString: @","]
来检索一个可以使用两个循环解析的数组来完成此操作。Use an
NSURLRequest
object to retrieve the data at this address:http://download.finance.yahoo.com/d/quotes.csv?s=AAPL&f=sl1d1t1c1ohgv&e=.csv
Using
[NSString stringWithFormat:]
to change the AAPL to the stock ticker you want to use. The retrieved data is in CSV format so you will need to parse that to get the individual values you require. This can be done in this simple case using[NSString componentsSeparatedByString: @","]
to retieve an array which you can parse using two loops.我知道的最简单的代码片段如下:
它检索 BP 在伦敦的股价并将其打印到控制台。
The simplest code snippet for this I know is along the lines of:
It retrieves BP's share price in London and prints it to the console.
有关完整的代码示例,请查看 Core Plot 框架中的 AAPLot 示例应用程序。它下载股票数据并用开盘价、最高价、最低价、收盘价信息以及交易量绘制图表。
For a full code example of this, check out the AAPLot sample application in the Core Plot framework. It downloads stock data and plots it with open-high-low-close information, as well as trading volume.
您可能可以从雅虎开发者网络的财务部分获得很多答案。
You could probably get a lot of your answers from the Yahoo Developer Network, in the Finance section.
Quandl Stock API 是免费的,可让您检索 Yahoo 或 Google 财务数据。除了 CSV 之外,它还提供一些更现代的格式(例如 JSON 和 XML)的数据。以下是检索 CSV 的方法:
这是以 JSON 格式检索的小改动:
不需要 API 密钥,但获取 API 密钥是免费的,并且允许您每小时最多进行 5000 次调用。
另一个很大的优点是,可以使用相同的 API 来检索有关公司的基本数据。
The Quandl Stock API is free and let's you retrieve Yahoo or Google finance data. In addition to CSV, it provides the data in some more modern formats like JSON and XML. Here's how to retrieve for CSV:
Here's the small change to retrieve in JSON format:
No API key is needed, but getting an API key is free and allows you to make up to 5000 calls per hour.
Another big plus is that the same API can be used to retrieve fundamental data about companies.