Introduction
Yahoo! Finance offers 15 minutes delayed Stock quotes packed in a neat .csv format. Using this service for my own on the Desktop PC for quite a while, I now decided to write a Pocket PC version. Using the classes of the System.NET
namespace this proved to be a quite a simple task.
The Yahoo Finance Service
The URL we need to retrieve the requested data from the Yahoo Finance service consists of a valid ticker symbol (e.g. Microsoft Germany: MSF.DE) and some query parameters:
- Basic URL: "http://quote.yahoo.com/d/quotes.csv"
- "?s=MSF.de": the symbol used for the query
- "f=sl1d1t1c1ohgvj1pp2owern&e": parameters for the requested information.
A great listing of all parameters for the Yahoo Finance service can be found here.
Using the code
The project consists of a main form and four classes:
cDetectInternet
: Only checks for a valid internet connection by trying to reach yahoo.de.
cDownloadYahooData
: This class actually does the downloading of the Yahoo stock data and the graphic stuff.
cSettings
: Writes and reads the Yahoo URL, ticker symbol and graph URL to and from a simple text file.
cGradientListview
: Creates this cool PPC 2003 style for the listview in the main form.
Problems encountered during development
I started testing the code on a PPC 2003 emulator where it din't run. Reading the data with a BinaryReader
object always threw the error "Invalid chunk size". Searching all over the internet I couldn't find a solution. Amazingly the code proved to work without problems with the PPC 2003 SE emulator and a live PPC 2003 device.
Connecting your PPC Emulator to the Internet
You probably want to test the code with your PPC emulator. To do so you need a working internet connection. I've added some information on how to achieve this task with my download (ConnectPPC.txt).