Home | Assignments | Journal | Progress | Proposal | Techlab

Iteration IV

18 November 2002

Plan

Using PHP, the basics of which I learned during Quarter I, I plan to retrieve data from Yahoo! Finance pertaining to the major American indices (Dow Jones Industrial, NASDAQ Composite, and Standard & Poor's 500). These data will include the current level of the index (in points) and its change from the start of the current session (both in points and in percent) relative to the closing level from the previous session. Upon completion of this iteration, the current homepage, index.html, will be replaced by index.php in order to display my results in the form of a table. This iteration will serve as a prelude for future work in collecting the various technical data of user-selected quotes in the American markets. Additionally, some form of the code produced in this iteration will be incorporated into the user interface as a method of giving users a glance at the market's status during their use of the interface.

Design

This iteration primarily will involve two PHP pages: one for displaying the results, and another containing the function used to obtain those results. The display page, index.php, will contain that included in the current HTML page, open and close the aforementioned table, show the listings to which the data obtained correspond, and call the retrieving function in fn.php. In turn, fn.php will open Yahoo! Finance to a page containing information about the index passed from index.php. (Yahoo! Finance designates the major American indices shown above as ^DJI, ^IXIC, and ^GSPC, respectively; the character preceding the letters indicates that the specified quote is an index, not a listing.) Then, the retrieving function will search for designated strings in a specified number of characters in the source code of the resulting page, using the function preg_match. These strings for which the function will search will correspond to the formatting used to show the data that I intend to display. Finally, using echo statements, the data will be displayed in the table created in index.php. At this point, index.php will revert to regular HTML code to include other information included on index.html.

Code

As mentioned above, coding will occur in HTML and PHP on two pages designated as PHP files. Due to the ability to display results using these languages, the code will include such characteristics. Therefore, the code's effectiveness in accomplishing the plan stated above will be validated by the output that it produces. A model for the code was found at PHPBuilder.com, which includes a discussion of erroneous code in addition to functional code. This code will be modified and expanded to match the objectives of the plan. Also, I will comment my code as per the requirements of Quarter II.

The result of the code is index.php. The following link provides the code, as a text file, for fn.php.

Testing

This iteration was generally successful because all goals set in the plan were achieved in the manner described above. All links to "Home" in this site now lead to index.php to reflect the results of this iteration and the goal of displaying results. One significant problem with the code in its current status is the unusually long amount of time taken in loading the page. Anticipating the future user's desire for timely delivered information, index.php refreshes itself every two minutes. However, the time taken to perform this operation is unsatisfactory. I will endeavor to alter the code to reduce loading time. One strong idea to this end is sending the indices as a list so that Yahoo! Finance is not "opened" and "closed" three times.

Notes

I originally intended to perform this iteration using both PHP and MySQL, as per the approach of Gregory Polins, who worked in a similar area last year. His technique calls for establishing a proxy connection through a MySQL account. On 07 November 2002, I created the groundwork for this method in the table Access. However, on 11 November 2002, when searching for the tools necessary to complete this combined approach, I found that only PHP was required. This new model, found at PHPBuilder.com, showed the use of the function preg_match to identify and display desired strings. As discussed in the preceding sections, I adapted this method to meet the expectations of Iteration IV.

Progress

Home