Monitor the Stock Price"
Line 30: | Line 30: | ||
===Stock Composer=== | ===Stock Composer=== | ||
− | This is the controller that handle the onCellChange event. The key method is the onCellChange$stocck() event listener. Whenever | + | This is the controller that handle the onCellChange event. The key method is the onCellChange$stocck() event listener. Whenever an onCellChange event is triggered, this method will be called and pass through with a CellEvent event. The event listener then compare if the cell changed is in the price column range and check if the price achieve buy or sell price setting by end user. |
<source lang="java" high="17"> | <source lang="java" high="17"> | ||
package demo.stock; | package demo.stock; |
Revision as of 08:41, 21 November 2010
Here is a Stock Price monitoring system that uses the ZK Spreadsheet's onCellChange event and data push mechanism.
Purpose
Automatically place buy or sell command whenever the price of a selected stock reach some preset point.
Template Excel File with Proper Name Expressions
Here is an Excel template file with monitorSheet and dataSheet. monitorSheet shows the selected stocks that refer to the dataSheet with formulas. dataSheet is a sheet that list all available stocks.
How ZK Spreadsheet Do the Job
Assume a stock price service will keep on pumping in updated stock price into the dataSheet on a separate thread. Whenever a new price is updated into dataSheet, ZK Spreadsheet will trigger the cell change event on monitorSheet that refer to the dataSheet. The onCellChange event listener registered on the ZK Spreadsheet will be called and check the prices . It compairs new price with preset selling price and buying price then notify buying or selling via another Web service.
ZUML Example
<spreadsheet apply="demo.stock.StockComposer"
src="/stock.xls"
maxrows="200"
maxcolumns="40"
vflex="1"
width="100%">
</spreadsheet>
Stock Composer
This is the controller that handle the onCellChange event. The key method is the onCellChange$stocck() event listener. Whenever an onCellChange event is triggered, this method will be called and pass through with a CellEvent event. The event listener then compare if the cell changed is in the price column range and check if the price achieve buy or sell price setting by end user.
package demo.stock;
public class StockComposer extends GenericForwardComposer {
}
Result
Version History
Version | Date | Content |
---|---|---|
All source code listed in this book is at Github.