CAPDM Tutorial Applets

Porfolio Management: Risk

Functionality:

This applet allows you to assess Risk.

Remote Control using JavaScript

Information about the applet can be shown. See the 'Runtime Applet API Calls' section below for details.

Examples

Set RoRA to 25

Set Standard Deviation for B to 12

Set Correlation to 0.6

Set Investment in A to 55%

Reset Applet

Show 'About' dialog

Show applet status

How to Invoke the Applet

The applet can be invoked by embedding an APPLET tag into your HTML document (if you look at the source of this document you will see a working example you can copy). The table below details the basic parameters used and additional startup parameters that are specific to this applet.

<APPLET 
  CODEBASE="../../../../classes"
  ALT="Porfolio Management - Correlation"
  CODE="applet.capdm.finance.riskandcorrelation.RiskAndCorrelationApp" 
  NAME="RiskAndCorrelation"
  WIDTH="425"
  HEIGHT="500">
  <param name="show" value="risk">
<param name="rora" value="20">
<param name="rorb" value="35">
<param name="sda" value="15.0">
<param name="sdb" value="20.0">
<param name="correlation" value="0.0">
<param name="investmenta" value="50"> </APPLET>
Basic Parameters Use
CODEBASE="../../../../classes" The CODEBASE of the applet must point at the top-level classes directory in order for the applet to be found.
CODE="applet.capdm.finance.
riskandcorrelation.RiskAndCorrelationApp"
This required attribute gives the name of the file that contains the applet's compiled Applet subclass. This file is relative to the base URI of the applet.
ALT="Porfolio Management - Risk" This optional attribute specifies any text that should be displayed if the browser understands the APPLET tag but can't run Java applets.
NAME="PortfolioManagement" This optional attribute specifies a name for the applet instance, which makes it possible for applets on the same page to find (and communicate with) each other. If you intend to use JavaScript/Applet scripting then the applet must be named a shown.
WIDTH="360" HEIGHT="400" These required attributes give the initial width and height (in pixels) of the applet display area, not counting any windows or dialogs that the applet brings up.
Applet Startup Parameters Use
<param name="show" value="correlation">
Tells the Applet to show the Risk or Correlation version of the applet
<param name="rora" value="20">
starting value of rora
<param name="rorb" value="35"> starting value of rorb

<param name="sda" value="15.0">
starting value of sda
<param name="sdb" value="20.0">
starting value of sdb
<param name="correlation" value="0.0">
Starting Correlation - must be between -1 and 1
<param name="investmenta" value="50"> starting investment a value. Must be between 0 and 100. Note that investment percentage for b is calculated at 100 minus investmenta.

For more information on the use of the APPLET tag and other attributes you can use but which are not listed above, visit the W3.org specification page at: APPLET tag in HTML 4.

Runtime Applet API Calls

This applet can be called into using Javascript 1.1 while running. Although JavaScript can call the Applet directly, some convenient JavaScript functions have been created which deal with the details of the communication. The following table lists the call Names which can be made, and gives examples of their use and results.

API Call Name Parameters Use and Result
setValue(name,value) 'name' can be one of "RoRA", "RoRB", "SDA", "SDB", "Correlation", "InvestmentA" or "InvestmentB"
'value' is its new value

eg. javascript:document.CallEquivalentPortfolio.setValue('RoRA','25');

Used to set the value of an independent variable in the applet

getValue() none javascript:document.CallEquivalentPortfolio.getValue(); Gets the status of the applet
getValue(name) 'name' can be one of "RoRA", "RoRB", "SDA", "SDB", "Correlation", "InvestmentA" or "InvestmentB"

eg. javascript:document.CallEquivalentPortfolio.getValue('RoRA');

Returns the current value of the variable from the applet.

getValue(name,dp) 'name' can be one of "RoRA", "RoRB", "SDA", "SDB", "Correlation", "InvestmentA" or "InvestmentB"
'dp' is the number of decimal places of accuracy required
javascript:document.CallEquivalentPortfolio.getValue("Correlation",2); Gets the current value of the variable as a string to the number of decimal places specified
showAbout() none javascript:showAbout(); Shows the version dialog box of this applet.
reset() none javascript:reset(); resets the applet to initial starting position