Welcome to the Stock Demo Explanation
The applets on the
Financial PortFolio Page
get their stock data by connecting to a URL specified in their
applet parameters.
The information that applets read from this URL must be sent in a specific
data format
in order for them to understand it and plot daily highs, lows, and histories.
The standalone version of this demo uses a URL that points to a static
file containing a snapshot of stock transaction information for some
specific historical date. The
data format
of this static file is the same
as the format of the data that the applets would receive from a live
stock server if one existed on the Web. The difference is that the
static file will reach an EOF (End of File), whereas a live feed would
never end, staying open indefinitely.
The live version of this demo connects to an HTTP server with a script
that queries a live (or 15 minute delayed) stock quote feed and sends
information back to the applet in the stock
data format. It
leaves the connection open so that more quote information can
be sent back as time progresses and new quotes become known.
These applets were originally written to demonstrate how Java
applets can be used to customize the presentation of information for a
a web site. The applets are used internally behind the Sun firewall
with an HTTP server that generates live data. Since we do not have
permission to publish this live data outside our firewall, we have
made the applets capable of reading that same information from static
files on our external Web server so that you can see what they look
like.
The applets are not meant to be commercial quality as you see them
here and Sun has no desire to make a product out of this demo
itself. If a financial institution wishes to provide live data for
these applets, the institution may use these applets as a starting
point for such a service, provided that is made available free of
charge.
The applets are compiled from 5 different source files:
The standalone version of the applets you see here rely on 5 different
data files for their information:
- The StockTicker snapshot data.
- The SUNW history data for the quote chart.
- The Netscape history data for the quote chart.
- The Neato history data for the quote chart.
- The closed caption file.
The entire demo is available in
compressed tar format (120K)
for easy downloading.
The applet tags for the various applets on the
Financial PortFolio Page
contain information on where to find a stock information data feed.
The specific parameters are different for the different types of applet
(StockTicker,
QuoteChart,
ClosedCaption):
- Stock Ticker applet parameters
- Example:
<applet codebase=classes code=StockTicker.class width=500 height=20>
<param name=stocks value="SUNW|HWP|SGI|MSFT|INTC|IBM|DEC|CY|ADBE|AAPL|SPX|ZRA|NSCP|NEATO">
<param name=staticdata value=tickerdata>
<param name=fudge value=true>
</applet>
This applet can use any of the following 11 parameters:
- stocks
- The list of stock symbols to display quotes for. Each symbol is
separated from the next by a vertical bar or pipe character, '|'.
- scrollt
- The time in seconds the applet should take to scroll one entire
set of quotes through the ticker display.
- deltat
- The time in milliseconds to wait between scroll updates. This
parameter controls how smooth or "jumpy" the scrolling is.
- freshfg
- The color to use to display fresh quotes representing new information
not previously displayed.
- stalefg
- The color to use to display old quotes that have been scrolled across
the display at least once previously.
- errorfg
- The color to use to display quotes which the server has been unable
to fetch or verify for more than 15 minutes.
- bgcolor
- The background color of the scrolling ticker.
- livedata
- The URL to use to fetch data from a live source.
- staticdata
- The URL to use to fetch data from a static file.
- fudge
- A boolean controlling whether or not the server should fudge new
quotes if it is unable to read real quotes from the stock feed (used
to show dynamic data in demo situations - deprecated).
- delay
- The time in seconds between generating fake quotes when fudge mode
is activated.
- Quote History Chart applet parameters
- Example:
<applet codebase=classes code=QuoteChart.class width=190 height=100>
<param name=staticdata value=chartdata%>
<param name=stock value=NSCP>
<param name=label value=Netscape>
<param name=history value="8h">
<param name=fudge value=true>
</applet>
This applet can use any of the following 14 parameters:
- stock
- The stock symbol to display history information for.
- history
- How much historical data to display in the graph window,
with units (d - days, h - hours, m - minutes, s - seconds).
- label
- The text to use to label the graph instead of the (often cryptic)
stock symbol.
- graphborder
- The size in pixels of the border around the graph.
- graphbg
- The color of the background of the graph.
- graphfg
- The color of the lines used to graph the quote data.
- quotefg
- The color to display the current quote at the top of the graph in.
- zerofg
- The color for the baseline of the graph (for stocks, the closing
quote from the previous day is the baseline, not 0).
- tickfg
- The color to draw the horizontal tick marks which divide up the
graph to provide a sense of scale.
- legendfg
- The color to draw the numbers representing the values that would be
plotted at the very top and bottom of the chart.
- errorfg
- The color to display the current quote at the top of the graph if
the stock server is having trouble retrieving a stock quote.
- livedata
- The URL to use to fetch data from a live source.
- staticdata
- The URL to use to fetch data from a static file.
- fudge
- A boolean controlling whether or not the server should fudge new
quotes if it is unable to read real quotes from the stock feed (used
to show dynamic data in demo situations - deprecated).
- Closed Caption applet parameters
- Example:
<applet codebase=classes code=ClosedCaption.class width=320 height=112>
<param name=lines value=8>
<param name=channel value=KPIX>
<param name=data value="static:captiondata">
</applet>
- data
- The URL to fetch the closed caption text from. The data is simply
read as lines of ascii text. The URL can point at a static file of
ascii text, or it could point to an HTTP script which continuously
monitored the closed captioning channel of a live broadcast and
downloaded the resulting text over the connection, leaving it open
until the applet closes the connection.
- channel
- The call letters of the station to be monitored.
- lines
- The number of lines of caption text to be displayed and buffered.
The formats for the data streams for the various applets on the
Financial PortFolio Page
contain information on where to find a stock information data feed.
The specific formats are different for the different types of applet
(StockTicker,
QuoteChart,
ClosedCaption):
- Stock Ticker and Quote History Chart applet data format
- Example (for SUNW):
@SUNW 0 99.75
^SUNW 100
_SUNW 93.125
<SUNW 93.25
#SUNW
SUNW 99.75
The lines above are all of the same format. Each line consists of 3 or
4 items:
- '@'{stock symbol} {timestamp} {floating point quote}
- The '@' character indicates a historical quote. If the timestamp is
0 or less, then it is the number of seconds prior to the current time when
the quote was valid. This relative format lets a static file contain
information which always appears "new", even though it is a snapshot of
past data. Live quote servers should always use absolute positive timestamps
representing the number of seconds since 00:00:00 GMT on January 1, 1970.
- '^'{stock symbol} {floating point quote}
- The '^' character indicates a localized "high" quote, or the highest
value the stock was traded at in the past day of trading.
- '_'{stock symbol} {floating point quote}
- The '_' character indicates a localized "low" quote, or the lowest
value the stock was traded at in the past day of trading.
- '<'{stock symbol} {floating point quote}
- The '<' character indicates the previous trading day's closing
price for this stock.
- '#'{stock symbol}
- The '#' character indicates that quotes for the stock are temporarily
or permanently unavailable due to technical difficulties with the stock
data feed.
- {stock symbol} {floating point quote}
- If none of the above prefix characters appears as the first character
of the line, then the line is the latest stock price available to the
stock feed server.
- Closed Caption applet data format
- The Closed Caption applet reads a simple ascii file. The file
can either be a static file or it could be a dynamic file generated
by a server reading live closed caption text from a television
broadcast and sending the information down through some sort of
network connection to the applet.
Questions?
If you need help modifying these applets to work with an existing stock
service, the best resources would be the
comp.lang.java
newsgroup or the
java-interest
mailing list.
This document maintained by
Jim Graham
(Flar@bendenweyr.Eng.Sun.COM)