The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
August 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

How to do stock charting ?

Posted by Salil V Gangal on September 01, 2000 at 8:31 AM

Friends,

I'll like to write an applet and/or a servlet and/or combination for charting the stock(s). For those of you who are not aware of how the stock chart looks/works, please click here to see an example of a stock chart.

To start, let me explain the basics of charting. The stock chart normally consists of two sub-graphs. The first subgraph shows the Price (on Y-Axis) over Time (on X-Axis). The second subgraph shows the Volume (on Y-Axis)over Time (on X-Axis). The chart that's shown in the link above is for Microsoft, which is showing the daily movement of the share price of Microsoft. On every day there is a small vertical line drawn to indicate the Open-High-Low-Close for the share price. Now that may seem a little complicated, so for the time being let's say that we need to plot only one number every day on the first subgraph. Notice the X-Axis and Y-Axis which are showing the Time (Months) and Price. Coming to the second subgraph ... it is showing the Volume (volume means the number of shares traded every day) over Time. Again notice the X-Axis and Y-Axis which are showing the Time (Months) and Volume in millions of shares traded.

Finally, I'll give information about the setup I have. I have a table in relational-database which has the data in the following format ===>


+--------+------------+----------+----------+----------+----------+-------------+
| ticker | quote_date | open | high | low | close | volume |
+--------+------------+----------+----------+----------+----------+-------------+
| QQQ | 2000-08-24 | 97.4375 | 98.6875 | 96.0625 | 98.5625 | 13567700.00 |
| QQQ | 2000-08-25 | 98.4844 | 99.9531 | 97.0000 | 98.0312 | 11764700.00 |
| QQQ | 2000-08-28 | 98.2500 | 99.8438 | 97.9375 | 98.5000 | 12314200.00 |
| QQQ | 2000-08-29 | 98.6250 | 99.1719 | 97.8594 | 99.0000 | 11162800.00 |
| QQQ | 2000-08-30 | 98.3125 | 99.5000 | 97.7656 | 98.8750 | 10545300.00 |
| QQQ | 2000-08-31 | 99.6250 | 102.0000 | 99.5625 | 101.6250 | 15588700.00 |
| SPY | 2000-08-24 | 151.1562 | 151.5000 | 150.5000 | 151.3125 | 4529000.00 |
| SPY | 2000-08-25 | 151.1562 | 151.6250 | 150.9375 | 151.2500 | 2822200.00 |
| SPY | 2000-08-28 | 151.2500 | 152.9062 | 151.2500 | 151.7656 | 5518700.00 |
| SPY | 2000-08-29 | 151.4375 | 151.8750 | 150.9062 | 151.7969 | 3561900.00 |
| SPY | 2000-08-30 | 151.3125 | 151.5000 | 150.3438 | 150.3438 | 3964800.00 |
| SPY | 2000-08-31 | 151.0625 | 153.0938 | 150.9062 | 152.3438 | 4863100.00 |
+--------+------------+----------+----------+----------+----------+-------------+

As you can see the first column has the ticker (that's the symbol used to identify a share for quoting purpose on exchanges) And the remaining columns are self-explanatory.

I have JDBC to access this data. So suppose if want to chart QQQ, then I can get the necessary X-Axis information i.e. 'quote_date' and the Y-Axis information say just the closing price 'close' for the first subgraph and similarly the X-Axis and Y-Axis information for the second subgraph in my Java program. So next step is how do I do this stick charting using an applet and/or a servlet and/or combination ? Any inputs ?

Regards,
Salil V Gangal



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us