Stockwatcher Agent

Stockwatcher agent is an agent-version of the stockwatcher application which allows users to select a set of stock quotes and check current price, trade volume, today high and low. Particularly, the agent embeds a rule-based inference engine such that it executes clips-like rules. For example, a user can write a notification rule which sends E-mail when stock values become higher or lower than a threshold.

If you're interested only in how to run this stockwatcher agent, click here.


Main contribution of the stockwatcher agent is the agent configuration by rules, which in turn are interpreted by inference engine. Since rules can be written in a number of ways, the configurability of the agent is unlimited.

The stockwatcher agent is a multi-plane agent, having three planes: Update plane, GUI, Inference. You can check the blueprint.

Update plane

It is responsible for requesting HTML pages containing stock information, parsing them, and retrieving the required information.

GUI plane

It provides a Graphical User Interface.

Inference plane

It has a state associated with a inference strategy, which reads in the rules provided by users, collects facts concerning stock values, and excutes the rules on the facts to trigger actions such as E-mail notification.

The following is a simple rule. It checks wether the dow industrial average index, given as $INDU, goes higher than 12000 points. If it does, send a notification E-mail titled, "Dow Exploding" to user@cs.purdue.edu.

(defrule email
   (quoteobj (quoteName "$INDU") (currentPrice ?c))
   (test (> ?c 12000))
   (not (sentmail "user@cs.purdue.edu"))
=>
   (assert (sentmail "user@cs.purdue.edu"))
   (call (fetch Model) set "MailServer" "ector.cs.purdue.edu")
   (call (fetch Model) set "Sender" "stockwatcher")
   (call (fetch Model) set "Receiver" "user@cs.purdue.edu")
   (call (fetch Model) set "Subject" "DOW EXPLODING!!")
   (call (fetch Model) set "Message" (str-cat "Current Dow is " ?c))
   (call (fetch Model) set "NextState" "email"))

How to run the stockwatcher agent

  1. Start resident, then you will see this GUI
  2. java Resident
    
  3. Select "Start Agent" and press "Start"
  4. Blueprint selection window opens. Select the blueprint of the stockwatcher agent, stockwatcheragent.bpt
  5. The GUI of the stockwatcher agent is easy to understand. To terminate the agent, press "Stop" button at the bottom.