Dev Guide
Dev Guide
Dev Guide
Guide
Document History
Revision date Edition number Comment
29 April 2011 First Edition Rel 12.0
Contents
Document History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Figures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Release 13 — 30 April 2012 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Updated — 07 February 2012. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.1 How to Compile and Execute Samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.1.1 Compiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.1.2 Executing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.1.3 Sample Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.1.4 Classpath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.2 Creating a Custom Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.3 How to Create Custom Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.4 Creating a Client Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.4.1 Connecting to Data Server and Event Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.4.2 Handling a Lost Connection to the Data Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.4.3 Creating Custom Initialization Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.4.4 Customizing the RMI Socket Factory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.4.5 Creating a User Startup Routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3 Data Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.1 Using the Data Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.2 Using a Local Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.3 Using BOCache. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.4 Using a Remote Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.5 Extending the Data Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.5.1 Persistence and Caching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.5.2 Using DSTransactionHandler and DSTransactionInput . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.5.3 Creating a Custom Remote Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.6 Read-Only Data Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4 Event Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.1 Subscribing to and Publishing Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.1.1 Event Types and Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.1.2 Publishing Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.1.3 Subscribing to Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.2 Handling Lost Connections to the Event Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.3 Creating a Custom Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
5 Core . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Tables
Table 10-1: Product Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Table 10-2: Variables and Methods for the Weather Derivative Example . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Table 10-3: Use ExecuteSQL to Add a Table to Your Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Table 10-4: Create the Necessary Prepared Statements in the HDDCDDLoader Class . . . . . . . . . . . . . . . 94
Table 10-5: Complete the Methods in the HDDCDDLoader Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Table 10-6: Task 1: Create the Necessary Combo Boxes, Labels, and Text boxes to Display the Data. . . 96
Table 10-7: Task 2: Define the Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Table 10-8: Task 3: Complete the Constructor and initDomains() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Table 10-9: Task 4: newTrade() and serDefaults(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Table 10-10: Task 5: showTrade() and buildTrade() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Table 10-11: Add the new Trade screen to Main Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Table 14-1: ReportTemplate Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Table 19-1: Parameters for getExtensionPoint. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Figures
Figure 4-1: Registering a New Event Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Figure 6-1: Registering a New Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Figure 6-2: Engine Configuration Window — Sample Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Figure 6-3: Event Config Window after Saving a New Subscription . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Figure 9-1: Domain Values Window — Registering a new FeedHandler . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Figure 9-2: Feed Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Figure 9-3: Feed Address Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Figure 9-4: Add Domain — Registering a New CurveGenerator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Figure 9-5: Domain Values Window — Registering a New Curve Underlying Instrument. . . . . . . . . . . . . . 79
Figure 9-6: Add Domain Window — Registering the VolSurfaceGenerator. . . . . . . . . . . . . . . . . . . . . . . . . 81
Figure 9-7: Domain Values Window — Registering a New Volitilty Surface Underlying . . . . . . . . . . . . . . . 82
Figure 9-8: Add Domain Window — Selecting a Volitility Generation Algorithm . . . . . . . . . . . . . . . . . . . . . 83
Figure 10-1: Tables Referenced by the Trade Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Figure 10-2: Trade Window with CDS Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Figure 10-3: Trade Window Details Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Figure 10-4: Extending ProductSQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Figure 10-5: Trade Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Figure 10-6: Example Product Container GUI Layput Specificiations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Figure 10-7: Domain Values Window — Registering a New Structured Product Type . . . . . . . . . . . . . . . . 101
Figure 11-1: Add Pricer Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Figure 11-2: Pricer Measure Window — Regitering a New Pricer Measure Type . . . . . . . . . . . . . . . . . . . . 118
Figure 14-1: DefaultReportTemplatePanel — (Cashflow Report PE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Figure 15-1: Example of Classes used to Create a Custom Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Figure 15-2: Add Risk Analysis Type Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Figure 15-3: Analysis Viewer Config Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Figure 15-4: Economic PL Column . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Changes
This section notes changes made between releases.
Documentation Changes
This documentation makes use of Change Bars to indicate new or modi-
fied material from one publication to the next. Only the most current
changes are marked. Change bars appear in the left-hand margin as
shown to the left of this paragraph.
1 Introduction
The developer’s guide is intended for developers using the Calypso API to
build custom components, or to customize and extend existing function-
ality. Extension capabilities are described through a comprehensive col-
lection of examples.
Refer to the class library documentation on the support web site (also
referred to as Javadoc) for a comprehensive description of all the classes
and methods mentioned in the examples.
2 Getting Started
2.1 How to Compile and Execute Samples
2.1.1 Compiling
To compile the samples located in the samples package, go to
$CALYPSO_HOME or to the root directory where the Calypso system
resides, and type the following at the command line (this is a one-line
command):
javac -d ./build -classpath "./jars/calypso.jar"
-sourcepath ./src src/samples/<class name>.java
For example:
javac -d ./build -classpath "./jars/calypso.jar"
-sourcepath ./src src/samples/LoadTrade.java
To compile the samples located in the calypsox package, rename the
classes from Sample<ClassName> to <ClassName>. In $CALYPSO_HOME
or in the root directory where the Calypso system resides, type the fol-
lowing at the command line (this is a one-line command):
javac -d ./build -classpath "./jars/calypso.jar"
-sourcepath ./src src/calypsox/<the fully qualified name of the class>.java
2.1.2 Executing
Prior to executing the samples, you must populate the database with
sample data using the database scripts located in
samples/cookbook/sql/cookbook_sybase.sql.
To execute any of the samples, type the following at the command line in
$CALYPSO_HOME/build (this is a one-line command):
javac -d ./build -classpath "./jars/calypso.jar:./jars/calypso-core.jar:
./jars/calypso-logging.jar:
./jars/j2ee/j2ee-1.5.jar:<java_libdir>/tools.jar:
./jars/spring/spring.jar:./jars/jcommon.jar:
./jars/jide/lib/jide-grids.jar"
2.1.4 Classpath
Refer to calypso.bat or calypso.sh in $CALYPSO_HOME/bin/ for the lay-
out and necessary items in the Calypso classpath.
Note: If the custom package directory is not placed under $CALYPSO_HOME, you must mod-
ify your class path to include its location.
Tip Choosing the “Instantiate” logging category allows you to debug class
instantiation.
Sample Code in calypsox/tk/util/
CustomGetPackages.java
In this sample, we created a package called samples.cookbook
package calypsox.tk.util;
import com.calypso.tk.util.GetPackages;
import java.util.*;
import java.lang.String;
/**
* A utility interface to search for the particular package.
* That class will be used to get the Packages in Calypso.
*/
public class CustomGetPackages implements GetPackages {
public Vector getPackages() {
Vector v = new Vector();
v.addElement("samples.cookbook");
return v;
}
}
Sample Code
// create a subscriber
MySubscriber eventListener = new MySubscriber();
/**
* MySubscriber class will be the call back point for
* all incoming events. newEvent will be invoked when
* an event matching the subscription list is recieved.
*/
private static class MySubscriber implements PSSubscriber {
}
}
}
-Xmx512m -XX:MaxPermSize=128m
-Djavax.net.ssl.keyStore=/home/some_user_name/keystore
-Djavax.net.ssl.keyStorePassword=calypso
-Djavax.net.ssl.trustStore=/home/ravi_somepalli/keystore
-Djavax.net.ssl.trustStorePassword=calypso
4. For a client, such as MainEntry, add the VM arguments:
-Xmx384m -XX:MaxPermSize=128m
-Djavax.net.ssl.trustStore=/home/some_user_name/keystore
-Djavax.net.ssl.trustStorePassword=calypso
3 Data Services
3.1 Using the Data Server
The Data Server is a single point of access for all Calypso data. No client
application should ever access the database directly. Once you have a
connection to the Data Server as described in Section 2.4.1, “Connecting
to Data Server and Event Server,” on page 18, the Data Server is
accessed through a set of remote services located under the
com.calypso.tk.service package, each of which is responsible for a
different group of data:
• RemoteMarketData — Handles pricing information (e.g., interest
rate curves).
• RemoteReferenceData — Handles static data (e.g., counterparty defi-
nitions).
• RemoteProduct — Handles financial instrument definitions (e.g.,
futures contracts).
• RemoteTrade — Handles trade information.
• RemoteAccess — Handles access permission and system security
data.
• RemoteAccounting — Handles accounting rules data.
• RemoteBackOffice — Handles back office-specific data.
The Calypso online documentation provides detailed descriptions of the
objects handled by each service under com.calypso.tk.service.
The Data Server in turn accesses the database or the data stored in
cache. Caches maintained by the Data Server are configured and admin-
istrated from the Calypso Administrator window. However, for data that
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 23
Core Calypso Development Guide Developer’s Guide Data Services
Applicable to: 12.0
Warning: When the client application must modify domain values (e.g., for display purposes) you
must clone the data using cloneDomainValues(), and then modify the cloned data.
Never directly modify the returned list directly. Doing so changes the master list
in LocalCache and causes data inconsistency.
See also:
• com.calypso.apps.util.AppUtil class for helpful object loading
methods.
• Refer to com.calypso.tk.service.LocalCache for available meth-
ods and details.
Extending BOCache
If the data you want to access is not handled by BOCache or LocalCache,
and you want to cache that locally, you can extend BOCache by providing
an implementation of CustomClientCache in
tk.bo.CustomClientCacheImpl.
BOCache invokes CustomClientCacheImpl.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 25
Core Calypso Development Guide Developer’s Guide Data Services
Applicable to: 12.0
Tip For objects having a unique ID, the ID is assigned by the Data Server
the first time the object is saved. The save methods in the remote
services for those objects return the assigned ID after a successful
save. It is important to set the object’s ID to the returned ID after a
successful the save. Otherwise, the object retains its initial null ID
and any subsequent saves will result in a new copy of the object being
created.
Sample Code in samples/cookbook/
UseDataServer.java
To output all of the IDs of the trades in a TradeFilter, call
getTrades(TradeFilter, JDatetime) on RemoteTrade to return all the
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 26
Core Calypso Development Guide Developer’s Guide Data Services
Applicable to: 12.0
trades associated with the TradeFilter and whose trade date is before
the JDatetime.
DSConnection ds = null;
try {
ds = ConnectionUtil.connect(args, "UseRemoteBO");
}
catch (ConnectException e) {
Log.error(Log.CALYPSOX, e);
System.out.println("ERROR: Connection to data server failed.");
System.exit(-1);
}
for(int i=0;i<v.size();i++) {
Trade trade = (Trade) v.elementAt(i);
System.out.println("Trade : " + trade.getId());
}
}
catch (Exception exc) {}
DSConnection ds = null;
try {
ds = ConnectionUtil.connect(args, "UseRemoteBO");
}
catch (ConnectException e) {
Log.error(Log.CALYPSOX, e);
System.out.println("ERROR: Connection to data server failed.");
System.exit(-1);
}
try {
product = ds.getRemoteProduct().getProduct(inputProductId);
}
catch (Exception exc) {}
try {
q = ds.getRemoteMarketData().getQuoteValue(q);
}
catch (Exception exc) {}
Note: The extension of the Data Server is only required for custom objects that do not extend
from an existing persistent Calypso object. The system has other mechanisms to sup-
port children of persistent Calypso objects and these dedicated mechanisms should be
used instead. For example adding a new product or market data does not require
extending the Data Server.
The following sections demonstrate how to extend the Data Server using
both methods. In the examples, we will extend the Data Server to handle
the persistency, caching, and event publishing of a custom “equity bas-
ket.”
3.5.1.1 Persistence
Handling persistence for the equity basket class requires you to write an
SQL class and create a database table. These steps are required regard-
less of which extension method is used.
Sample Code in samples/cookbook/
tk/product/EquityBasket.java
EquityBasket sample. The EquityBasket class example is only a
sample, it is not suitable for production.
tk/product/sql/EquityBasketSQL.java
EquityBasketSQL sample.
sql/cookbook_sybase.sql
Database scripts examples.
trade.setId(rs.getInt(j++));
trade.setTradeDate(rs.getJDatetime(j++));
trade.setSettleDate(rs.getJDate(j++));
}
rs.close();
}
catch( Exception e ) { display(e); }
finally {
try {ioSQL.close();}
catch (Exception e) {}
ioSQL.releaseConnection(con); }
return tradeVector;
}
Void save(myObject){
try{
Connection con=ioSQL.newConnection();
save(myObject, con);
commit(con);
Update the Cache or any hash Only after commit
}
catch(PersistenceException e){
rollback(Con);
Log.error(e,e)
}
finally{ releaseConnection(con)}
}
3.5.1.2 Caching
It is logical to cache frequently accessed objects so that the Data Server
need not repeatedly retrieve them from the database. Refer to Section
18, “Cache Framework,” on page 186 for details.
Note: PSEventEquityBasket is a new event type. See Section 4.3, “Creating a Custom
Event,” on page 35 for details on creating new event types.
Tips For the Data Server to properly handle a custom persistent object,
the class must implement the Serializable interface.
When publishing a persistent event inside the Transaction Handler,
the event must be published and saved within the same database
transaction that the persistent object is handled, to ensure
transactional atomicity. This way the event will not be published if
any error is encountered while saving the object and the event.
Sample Code in samples/cookbook/
tk/service/EquityBasketTransactionHandler.java
UseEquityBasket.java
A sample client application that illustrates how to use
DSTransactionInput to access an EquityBasket object from the Data
Server.
Note: Read-only Data Servers do not update the cache. The cache is updated by listening for
events sent by the active Data Server and then reloading the information from the
database as needed. This requires database connectivity for the read-only Data Server.
The call to use events to update the cache for a read-only Data Server
rather than RMI services, is controlled by setUseCacheSubscriber(). If the
DS_READ_ONLY property is true, indicating that the Data Server is run-
ning in read-only mode, then setUseCacheSubscriber() also returns true.
Note that the DS_READ_ONLY property must be set prior to starting the
Data Server.
Refer to the Calypso System Guide for complete information on setting
up the Data Server in read-only mode.
4 Event Services
Calypso leverages a standard JMS bus to propagate events throughout
the platform to listeners. The implementation leverages a single JMS
topic for all business related events. The ESStarter interface is the start-
ing point for all access to the event bus.
Note All events are named PSEvent<event type> and are located under
com.calypso.tk.event.
Note: Its important to note that management of the PSConnection should not be done within
the event handling thread (in the PSSubscriber) and should be delegated to a separate
thread allowing the subscriber to continue its lifecycle to either consume events or com-
plete the tear down of the connection.
Note: Since event objects are serialized for communication, each event class must have its
own unique serialVersionUID, and must be included in the class definition. Obtain the
ID by running %JAVA_HOME%\bin\serialver.exe on Windows platforms or
$JAVA_HOME/bin/serialver on Unix platforms,
5 Core
5.1 Creating a Custom Daycount
Create a class named tk.core.CustomDayCountCalculator which
implements the interface
com.calypso.tk.core.DayCountCalculator.
6 Engines
Engines in Calypso are special type of event listeners. These specialized
listeners manage the guaranteed delivery of persisted events, the event
bus reconnect features as well as allow for multi-threaded processing of
events.
Note: The sample program works Transfer Events. This is in addition to registering the
engine as described below.
b. Select your new engine from Engine Name. Your engine name
must first be entered in engineName (Domain Values Window).
See Step 1 on page 39.
c. Assign an unused ID.
d. Enter a Comment, if desired.
e. Click Save to retain your changes
Note: If your engine ID conflicts with a Calypso engine ID in a subsequent release, you must
ensure that all events for your engine are processed and then change the conflicting
engine ID to the next available engine ID.
Note: All engine startup classes should call the Defaults.setEngine(true) method before
instantiating the Engine class. Failure to do so will result in an exception.
When start() is called on the engine, the engine starts a connection to the
Event Server. The Event Server, based on the event types returned from
the method getPersistentClasses(), sends the application any events that
the persistent engine subscribes to and has missed since the last session.
Upon receiving an event, the engine automatically creates a new thread
and calls the method process(). If the event received is of a type that the
engine subscribes to, the engine notifies the Event Server upon the com-
pletion of event processing by calling RemoteTrade.eventProcessed().
You can also use the sample engine that subscribes to PSEventTransfer
events to process payments. The subscription is established in the data-
base. Refer to the script samples/sql/sampleEngine.sql for an exam-
ple.
6.2.2 BOSimpleRepoHandler
BOSimpleRepoHandler is a custom handler that extends
com.calypso.tk.bo.BOSimpleRepoHandler. It provides, for example,
the possiblity to add an attribute to a Transfer by using the
UpdateTransfer() method.
<product_type>ProductNextEventDate is invoked by
com.calypso.tk.product.ProductNextEventDateUtil, which is
used by BOProductHandler.
Note: For message types without a product type, such as STATEMENT, you can create a class
named tk.bo.BOSTATEMENTMessageHandler. In this case, the product-specific mes-
sage handler is simply skipped and the application uses the more generic message-
type-based handler.
Note: In your parse method, you can check if a custom keyword is being evaluated within an
IF statement using FormatterParser.isConditionalEvaluation(), which will return a
Boolean.
For example, an FX Swap needs two trade confirmations when you verify
the trade; one confirm for the near leg and a second confirm for the far
leg.
Note: When sending Advice Messages, users must strip the message prior to calling the
send() method.
Note: When dealing with an Advice message, you must first call
SwiftMessage.stripExtraInfo(AdviceDocument.getDocument()) to strip the message
prior to calling send().
Generally the send() method initiates the physical production of the doc-
ument via some output mechanism such as a printer or email utility. The
send() method must return a Boolean True if successful, or if not, False.
You must also define the isOnline() method. The Sender engine will
query this isOnline to ensure that the sender gateway system is online.
7 Limits
7.1 Creating Custom Limit Types
Create a class named tk.limit.<LimitType>Limit that extends the
abstract base class com.calypso.tk.limit.BaseLimit.
Register custom limit types in the limitType domain.
8 Message Documents
Messages in Calypso are converted into documents prior to being physi-
cally sent out of the system. These documents may also be edited and
stored in the database prior to being sent. By default, Calypso supports
the following document formats: HTML, text, XML and SWIFT.
Code Delimiters
Any code that is between the tags <!--calypso></calypso--> or
<calypso></calypso> is interpreted. Note that there can be multiple
sets of <calypso> tag pairs within a document.
All text outside these tags is ignored by the document parser and is
treated as regular HTML. All text within these tags, however, must be
syntactically correct and cannot include HTML tags. The text within the
tag pair is parsed for special directives. HTML tags included in the tag
pair will raise exception(s) unless they are included in an inline direc-
tive.
Logical Expressions
The following keywords are available in the language: if, else, include,
set, inline, and iterator. They are described below.
Note that they are case sensitive.
The following syntax is used in this section:
• Whenever you see a definition that uses <word>, it means that the
word expression is defined elsewhere.
• A <statement> can be any of the following: <if statement>, <set
statement>, <include statement>, or <inline statement>. Hereaf-
ter if you see the text <statement>, you can substitute any of these
expressions instead.
• <statements> is a succession of <statement>, typically separated
with a semicolon, very much like in modern programming languages.
<if statement>
if ( <conditions> ) <statement>
— or —
if ( <conditions> ) { <statements> }
The start and end brackets are optional, but they are necessary if you
wish to have multiple statements.
<conditions> enables you to chain various <condition> statements
together using logical operators && (AND), || (OR), and ! (NOT). Hence,
the following would be a valid set of conditions:
<condition> && ( <condition> || <condition> || ! <condition>)
It is also possible to parse a |KEYWORD| inside an “if” statement. For
example, if (|MASTERAG_NAME| == "ISDA" && |MASTERAG_SIGN| !=
"SIGNED"), where |MASTERAG_NAME| and |MASTERAG_SIGN| are defined
as keywords available from MessageFormatter.
Nested “if” statements are supported, and the “else” keyword can be
added to provide a catch-all clause at the end.
<condition>
A Condition checks the value of an object attribute or the result of a
method and compares it against a fixed, literal value. Certain values are
directly returned from predefined objects. For more customized opera-
tions, an interface can be implemented so that a call can be made to a
custom class.
<set statement>
set KEYWORD = "value";
All the values for identifiers used in Set statements can be used as
default values. If a keyword is undefined or its value cannot be extracted
otherwise by MessageFormatter, the ‘default’ value could be retrieved
from the ‘set’ directive.
Take this code snippet for example:
<calypso>
set HELLO=”Bonjour”;
</calypso>
...
<center>|HELLO|</center>
...
In this case, the HTML output for keyword HELLO will default to Bonjour
unless it has been overridden elsewhere. For example, there could be a
parseHELLO() method that does the job. In any event, this provides a
convenient method to set default values for keywords inside the docu-
ment. Note that set statements can also be used in Conditions:
<>
calypso>
if ( Message.language == “English” )
set HELLO=”Hello”;
if ( Message.language == “French” )
set HELLO=”Bonjour”;
</calypso
Also, you can use the set statement to store function results, as shown in
the example below:
<!--calypso>
set TRADE_ID = Trade.getId();
set PRODUCT_TYPE = Trade.getProductType();
set CUSTOM_VALUE = MyCustomFunction("One", "Two", "Three");
</calypso-->
...
We are sending you this |PRODUCT_TYPE| Trade Confirmation for Trade ID |TRADE_ID|. Here is
the custom value: |CUSTOM_VALUE|.
...
<include statement>
An Include statement reads and inserts a text specified in the URL string
into the generated document.
include “<url>";
<url> can be a filename “myfile.html” located in the template directory,
or any valid URL (for example,http://www.mysite.com/myfile.html).
<inline statement>
An Inline statement inserts the text within quotation marks directly into
the generated document.
inline "HTML text";
For example:
if ( Trade.quantity == 0 )
inline "<b>Trade quantity is 0.</b>";
Note: You cannot escape the double quote character ( “ ) in an inline statement. For example,
the following comment causes a parsing error:
Inline “This is a \”String\””;
The inline statement is only intended for several lines of text in any case.
<iterator statement>
You can define Iterators as in the example shown below.
<!--calypso>
iterator ( "CashFlow" )
inline "
<tr>
<td>|CASHFLOW_START_DATE|</td>
<td>|CASHFLOW_END_DATE|</td>
<td>|CASHFLOW_RATE|</td>
</tr>
";
</calypso-->
The following Iterators are already provided:
• BondCashFlow
• BondCallSchedule
• CashFlow
• CompoundPeriod
• Fee
• MessageGroup
• PayFee and ReceiveFee
• PayLegCompoundPeriod and ReceiveLegCompoundPeriod
• PayLegFlow and ReceiveLegFlow
• StructuredProduct
<calypso>
if ( MyFunction(“one”, 2) == true )
include “subdocument”;
</calypso>
FormatterParser will locate the class MyFunction and make a call to its
call method as defined above. The args parameter will be a vector with 2
elements representing the arguments “one” and 2.
In this case, the semantics suggest that the call() method should return a
Boolean object since we’re comparing against a true value. Of course,
there’s no real way to check usage so this cannot be enforced.
Note: In the event of an error when checking a Condition, the returned result is False. For
example, if your condition is performing a Boolean comparison and the returns a
String, the Condition will return a false. Therefore, best practice suggests that you
should only perform branching based on True evaluaton results. Using the NOT opera-
tor (!) can result in incorrect branching if an error is encountered during the compari-
son.
9 Market Data
9.1 Balance Engine
While the Balance Engine itself cannot be customized, two items are
available to customize:
• Finding the closing account: Implement a tk.bo.accounting.Custom-
ClosingAccountName implementing tk.bo.accounting.ClosingAc-
countName.
The default behavior is to use the name of the account being closed,
plus the year.
• The behavior when Balance Positions have been archived.
When balance positions are archived and a posting that falls into the
archived range is detected, the default behavior is to not update the
archived entries. An error will be logged. “Live” position total values
should be correct but will not correspond to the sum of daily changes
from archived positions.
If a tk.bo.CustomBalanceHistoryHandler implementing a
BalanceHistoryHandler is found, it will be called and may update
archived balance positions. If that handler returns true, no error is
logged.
9.2 Quotes
9.2.1 How to use Quotes
QuoteSet is a repository for quote values that are used for pricing and
curve generation. Typically, you would obtain a QuoteSet object from a
given PricingEnv.
The following example illustrates how to use QuoteSet. Specifically, it
shows how to obtain quote values for a given product and for the curve
underlying instruments used by a given curve. Furthermore, it illus-
trates how to manipulate quote values (bumping the quotes by 1bp) and
use the bumped quotes for curve generation.
Note: There are other methods in the QuoteSet class that are not used in the example. For
example, there are methods specifically for getting FX quotes, rate index quotes, etc.
Sample Code
samples/cookbook/UseQuoteSet.java
Tip Before running the program, ensure that you have the proper real-
time feed configuration in the system. Refer to the Calypso Market
Data User Guide for information on setting up a real-time feed.
Sample Code in calypsox/apps/reporting/
FXPositionWindow.java
• Map Calypso quote names to the feed’s quote names using Main
Entry -> Configuration -> Market Data -> Feed Address Mapping as
shown in the example below.
Refer to the Calypso Market Data User Guide for information on setting
up a real-time feed.
You can inspect real-time quotes using Main Entry -> Market Data ->
Market Quotes -> Feed Quotes.
9.3.4 How to make a Custom Market Data Item Available for Selection
You can make your market data item available in the market data selec-
tor for loading, saving and deleting.
Create a class named
apps.marketdata.<market_data_type>Selector that implements
the com.calypso.apps.marketdata.MarketDataItemSelector inter-
face.
<market_data_type>Selector is invoked by
com.calypso.apps.marketdata.MarketDataUtil.
adjustment. The algorithm will create a curve point for each underlying
instrument with value equals (1+alpha) multiplied by (1+beta) multipled
by the quote value of underlying instrument. The coefficient for curve
point is calculated by multiplying the quote value of underlying instru-
ment by the correlation value for the quote.
Overview of Steps
• Step 1 — Create a CurveGenerator
• Step 2 — Register the new CurveGenerator
The new CurveGenerator will be available for selection, and the input
parameters will appear under the Quotes panel of the Curve Window as
applicable.
When the curve is generated, the output contains the point adjustment
coefficient under the Points panel of the Curve Window as applicable.
Figure 9-5: Domain Values Window — Registering a New Curve Underlying Instrument
Figure 9-7: Domain Values Window — Registering a New Volitilty Surface Underlying
Trade
Book Product
Bundle Exchange
Counter
Party
Details common to most trades, and which are also included on the trade
object itself, are: ID, Status, Trade Date, Settle Date, Quantity,
Negotiated Price, Negotiated Price Type, Trade Currency, Settle
Currency, Trader Name, Salesperson Name, Comment,
Keywords, and Fees.
e Negotiated ID
Price Type
Status
Settle Date
Trade Negotiated
Currency Price
Trade Date
Fees
Trader Name
Salesperson
Name
Comment
Keywords
tracts, and stocks, and it also includes one-off deals that are structured
to meet client requirements and traded only once, like an interest rate
swap or cap.
Every product must extend the base abstract Product class and any sub-
class of the Product class must override its abstract methods.
10.2.3 Cashflows
Some products can be realized as a series of cash flows between parties,
such as bond coupon payments or simple interest payments. For those
products that have cash flows, each product is responsible for generating
its own cash flows. This is accomplished through the
generateFlows(JDate) method and once the cash flow dates have been
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 86
Core Calypso Development Guide Developer’s Guide Product and Trade
Applicable to: 12.0
created all known data such as saved quotes will be filled in by the
calculate(CashFlowSet, PricingEnv, JDate) method on the product.
Product Description
CallablePuttable All products having optionality should implement this inter-
face.
CashFlowGenerationBased All products that require cash flow generation must imple-
ment this interface. This interface is used by the
CashFlowGenerator for cash flow generation.
CollateralBased All products that have collaterals must implement this inter-
face. This interface is used by the reports.
CreditEventBased All product classes that can be impacted by credit events,
such as credit default swaps, should implement this inter-
face.
CreditRisky Credit risky products should implement this interface.
EventTypeActionBased Any product that will maintain a schedule of
EventTypeActions should implement this interface. Each
EventTypeAction represents a change to the product’s
parameters that is effective at a given time.
Exercisable All options must implement this interface.
FIRollOver This class defines how a product should implement
RollOver.
ForexRollOver This class defines how an FX product should implement
RollOver.
Option All option products must implement this interface.
RateResetBased All products that must handle special actions during a
change in the rate reset must implement this interface.
Table 10-2: Variables and Methods for the Weather Derivative Example
Step Description
1 Extend the Product Class and create the following variables of the appropriate
types:
• startDate
• maturityDate
• notional
• currency
• temperature
• fahrenheit_b (boolean)
• hdd_b (boolean)
• location
2 Create public getters and setters for all of these variables. If you are using an
IDE such as Eclipse, there are tools to automatically generate these methods.
3 Override the abstract methods from the Product class: getPrincipal(),
getProductClass(), getProductFamily(), and hasSecondaryMarket().
In the getPrincipal() method, return the notional variable.
In the second two methods, return the static string HDDCDD for the product
class and WEATHER_DERIVATIVE for the product family.
Return the boolean false for the last method.
4 Override the getDescription() method from the Product class. Create a cus-
tom String to return that is a descriptive combination of the variables on the
product.
One example:
CDD.50 F.San Francisco.12/19/2006-01/08/2007
10.5 Persistence
10.5.1 Extending the Data Model
All products, whether they are multiply-traded or singly-traded, have
their own table in the database with the prefix “product_.”
Step Description
2 Click on the ExecuteSQL window and paste the following text from the WeatherDer.sql file into the Query
window.
CREATE TABLE product_hdd_cdd
(product_id int NOT NULL,
start_date datetime NOT NULL,
maturity_date datetime NOT NULL,
notional double precision NOT NULL,
currency char(3) NOT NULL,
temperature double precision NOT NULL,
fahrenheit_b bit NOT NULL,
hdd_b bit NOT NULL,
location varchar(32) NOT NULL,
CONSTRAINT ct_primarykey PRIMARY KEY CLUSTERED
(product_id))
3 Click Execute.
4 Verify that the table has been created by executing the following SQL statement:
SELECT * FROM product_hdd_cdd
that extends the SQL class must implement the insert(), remove(), save(),
and getAll() methods in the ProductSQL class.
When saving the product details to the product table you must also save
the product description in the product_desc table. There are methods
built in to the ProductSQL class for performing this operation,
updateDescription() and saveDescription(), but you must call the
appropriate method on an update or insert.
Table 10-4: Create the Necessary Prepared Statements in the HDDCDDLoader Class
Step Description
1 Create the SQL SELECT statement which selects each column in the table but where the product_id is the
last column selected.
For example:
SELECT product_hdd_cdd.start_date, … etc.… , product_hdd_cdd.product_id FROM product_hdd_cdd
2 Create the prepared SQL INSERT statement using the exact same order of items as in the SELECT state-
ment above.
For example:
INSERT INTO product_hdd_cdd (start_date, … etc. …, product_id) VALUES (?,?,?,?,?,?,?,?,?)
3 Create the prepared SQL UPDATE statement using the exact same order of items as in the SELECT
statement above.
For example:
UPDATE product_hdd_cdd SET start_date=?, … etc. … WHERE product_id=?
Product Details
Trade Product Panel, which is is invoked from the Trade Window, is for
displays all the product details in the Trade Window. There are three
steps to adding a new window:
1. First , create a class named
apps.trading.Trade<product_type>Window that extends the
TradeWindowBase class. This new class calls the super-class’s con-
structor from its public constructor.
2. Second, add this class to the MainEntry window: From MainEntry
choose Utilities -> MainEntry Configurator and add the action
trading.Trade<product_type>Window to the Trade sub-menu.
3. Finally, create a class named
apps.trading.<product_type>TradeProductPanel that imple-
ments the TradeProductPanel interface.
Table 10-6: Task 1: Create the Necessary Combo Boxes, Labels, and Text boxes to Display the Data
Step Description
1 Create a CalypsoComboBox for Buy/Sell, HDD/CDD, temperature degree units, and the currency selec-
tion.
2 Create a JLabel for the Notional, Start Date, End Date, Strike, and Location.
3 Create a JTextField for the Notional, Start Date, End Date, Strike, and Location.
Step Description
4 Using the diagram above as a guide, make the components with the appropriate labels and bounds. Note
that all of the JLabels and JTextFields should be right-justified.( JTextField.RIGHT, SwingCon-
stants.RIGHT). Complete the private methods in the sample code to make the components.
5 In the case of the Combo Boxes, one can use the utility methods in AppUtil to set the lists of the Combo
Boxes.
For example:
AppUtil.set(CalypsoComboBox, Vector)
AppUtil.setToDomain(CalypsoComboBox, DomainName)
Step Description
9 The newTrade() method is called when the window is opened for the first time and is used to create
defaults for the screen. Once the defaults have been set we call the buildTrade() method.
10 In the setDefaults() method, set the following defaults for the screen:
Buy/Sell Drop-Down: Buy
Heating/Cooling Days Drop-Down: HDD
Notional Text Box: 20.
Temperature Text Box: 65
Temperature Degree Drop-Down: F
Currency: The user’s preferred currency
Hint for the Currency selection: Obtain the UserDefaults from the Data Server connection, get the pre-
ferred currency, and use AppUtil.showFavoriteCcy() to set the currency choice.
Step Description
11 showTrade(Trade) and buildTrade(Trade) perform opposite actions. The showTrade() method synchro-
nizes the Trade object with what is displayed in the window and the buildTrade() method synchronizes
the display in the trade window with the Trade object.
12 showTrade(trade) method: from the passed trade object we set the necessary components. Using the
variables of the trade and product objects, set all of the combo boxes and text fields in the window.
Hint: Buy/Sell is a trade detail and the rest are product details. Also, you can you the utility methods on the
Util object to convert a Number or Date to a String. For example, Util.numberToString().
13 buildTrade(trade) method: from the selected items in the trade window, set the relevant trade and product
details on the passed trade object.
On the trade object:
• Set the Settlement Date to the Start Date.
• Set the Settlement Currency to the selected currency.
• Set the Trade Currency to the selected currency.
• Set the Quantity to be 1 if this derivative is purchased and -1 if it is sold.
• On the product object (HDDCDD):
• Set all the variables on the HDDCDD object.
Hint: Again, you may make use of utility methods in the Util class to convert Strings to Numbers and
JDates.
Goal — Write the components in the product container GUI of the Trade
Window.
Prerequisite: Completion of the HDDCDDTradeProductPanel code.
Step Description
1 Make sure that all the code HDDCDD.java, HDDCDDSQL.java, HDDCDDTradeProductPanel.java, Trade-
HDDCDDWindow.java have all been compiled into the correct directory and the product table has been
added to the database.
2 From Main Entry, choose Utilities > MainEntry Configurator to bring up the customizer window. Under
the Trade menu create a new menu called Weather Derivatives. Then under the sub-menu Weather
Derivatives create a new item called HDD / CDD with the action trading.TradeHDDCDDWindow. This
will launch the Heating Degree Days/Cooling Degree Days screen.
Step Description
3 Click Save, then re-start MainEntry. Select the new item from the menu and you should see something
similar to the following.
3 You should see a warning message similar to the one below as the window tries to find a default pricer for
this product of named PricerHDDCDD and can’t find one. This warning will go away once a pricer is
assigned.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 100
Core Calypso Development Guide Developer’s Guide Product and Trade
Applicable to: 12.0
Figure 10-7: Domain Values Window — Registering a New Structured Product Type
2. Structure the product using Main Entry -> Trade -> Structured Prod-
uct. Select ButterflyCap from the Type field. Create a butterfly cap
structure by adding two long caps and two short caps.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 101
Core Calypso Development Guide Developer’s Guide Product and Trade
Applicable to: 12.0
SpecificResetBased
To handle specific resets, a product implements the
SpecificResetBased interface. This interface requires the implementa-
tion of the method getSpecificResets(), which returns a vector of
ProductReset.
The pricers use the vector of ProductReset to calculate cashflows known
interest amounts.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 103
Core Calypso Development Guide Developer’s Guide Product and Trade
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 104
Core Calypso Development Guide Developer’s Guide Product and Trade
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 105
Core Calypso Development Guide Developer’s Guide Product and Trade
Applicable to: 12.0
• com.calypso.tk.pricer.PricerReferenceEntity — Pricers
which can calculate pricer measures per reference entities (issuer id
and seniority). Used by credit derivatives reports.
• com.calypso.tk.product.CreditRisky — Any product that may
have credit risk associated with it (such as CreditDefaultSwap,
TotalReturnSwap, AssetSwap, Bond, etc.). Used by credit derivatives
reports.
• com.calypso.tk.product.CreditEventBased — Any product that
can be affected by credit events (such as CreditDefaultSwap). Used
by the credit event application.
Note: The Product Specific panel in the Pricer Config call ProductUtil.getChooser(), so if a
custom ProductChooser class exists, it will be invoked from the Pricer Config.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 107
Core Calypso Development Guide Developer’s Guide Product and Trade
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 108
Core Calypso Development Guide Developer’s Guide Product and Trade
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 109
Core Calypso Development Guide Developer’s Guide Product and Trade
Applicable to: 12.0
cfParser.processCashFlows(flows,
getCouponPaymentAtEndB(),
getPrincipalActualB(),
asOfDate,
this);
long idLock = getCfGenerationLocks();
Vector colLocks = cfParser.ids2VectorNames(idLock);
cfParser.setColumnLocks(colLocks);
generateFlows(paySideB);
CashFlowSet newFlows = getFlows();
cfParser.checkBeforeApplyingLocks(newFlows);
cfParser.applyLockedValuesToCashFlows(newFlows,
getCouponPaymentAtEndB(),
getPrincipalActualB(),
this);
setFlows(newFlows);
return newFlows;
}
On the other hand, if only the cashflow generation is different for a prod-
uct, but not the actual display of the cashflows, it may be better to sub-
class an existing CashFlowGeneratorBase implementation, and override
the flow generation methods.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 110
Core Calypso Development Guide Developer’s Guide Product and Trade
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 111
Core Calypso Development Guide Developer’s Guide Pricing
Applicable to: 12.0
11 Pricing
11.1 Pricing Environment
11.1.1 Using a Pricing Environment
A Pricing Environment tells the system what pricers (pricing models)
and market data (interest rate curves, volatility surfaces, quotes etc.) to
use to value each product. A Pricing Environment contains a
PricerConfig and a QuoteSet object. The PricerConfig specifies what
Pricer to use for a product and which market data items to use with the
Pricer. The QuoteSet is a repository of quote values that are needed for
valuation and market data generation.
Sample Code in samples/
PricingEnvSample.java
Demonstrates how to price a trade given a PricingEnv.
11.2 Pricer
11.2.1 Creating a Custom Pricer
Overview of Steps
• Step 1 — Create a Pricer
• Step 2 — Register the new Pricer
Note: If the custom Pricer uses market data specified in the Product Specific, Custom or
Credit panels of the Pricer Configuration, it must be Lazy Refresh compatible (see
below for details).
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 113
Core Calypso Development Guide Developer’s Guide Pricing
Applicable to: 12.0
if (probCurveId != null) {
itemIds.put(probCurveId,probCurveId);
}
}
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 114
Core Calypso Development Guide Developer’s Guide Pricing
Applicable to: 12.0
Note: In Lazy Refresh mode, getProductSpecificMD() will not return the MarketDataItem,
you must use getProductSpecificMDID() instead, as shown above.
Custom Programs
If you have a custom program that must retrieve market data in Lazy
Refresh mode, you must refresh the pricer configuration to load the Mar-
ketDataItems for the MarketDataItem ids.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 115
Core Calypso Development Guide Developer’s Guide Pricing
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 116
Core Calypso Development Guide Developer’s Guide Pricing
Applicable to: 12.0
Tips Use an id that starts with 1000 or higher to avoid any conflict with
Calypso pricer measure types.
Create a single PricerMeasure class to hold all pricer measure types
that are required by your pricing models in order to centralize the
information.
Sample Code in calypsox/tk/pricer/
PricerMeasureTst.java
PricerMeasureMbs.java
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 117
Core Calypso Development Guide Developer’s Guide Pricing
Applicable to: 12.0
Figure 11-2: Pricer Measure Window — Regitering a New Pricer Measure Type
For each PricerMeasure type, enter the name, its associated id and the
fully qualified class name of the PricerMeasure class.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 118
Core Calypso Development Guide Developer’s Guide Trade
Applicable to: 12.0
12 Trade
12.1 Trade
12.1.1 Creating Custom Trade Attributes
Do the following to create custom Trade attributes:
1. Create a class named tk.core.<custom_data_class_name> that
contains all of your additional attributes and which implements the
interface com.calypso.tk.core.TradeCustomData.
2. To make the custom data persistent, create a class named
tk.core.sql.<custom_data_class_name>SQL which extends the
abstract base class
com.calypso.tk.core.sql.TradeCustomDataSQL.
This class will be invoked from com.calypso.tk.core.sql.TradeSQL.
Sample Code in calypsox/tk/core/
TradeCustomData sample:
RepoTradeExtension.java
TradeCustomDataSQL sample:
sql/RepoTradeExtensionSQL.java
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 119
Core Calypso Development Guide Developer’s Guide Trade
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 120
Core Calypso Development Guide Developer’s Guide Trade
Applicable to: 12.0
package calypsox.apps.trading;
import com.calypso.tk.core.*;
import com.calypso.tk.product.*;
import com.calypso.apps.trading.*;
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 121
Core Calypso Development Guide Developer’s Guide Trade
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 122
Core Calypso Development Guide Developer’s Guide Trade
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 123
Core Calypso Development Guide Developer’s Guide Trade
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 124
Core Calypso Development Guide Developer’s Guide Trade
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 125
Core Calypso Development Guide Developer’s Guide Trade
Applicable to: 12.0
Note: These customizations will also appear in the Netting Manager, Assign, and Split win-
dows of the Task Station.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 126
Core Calypso Development Guide Developer’s Guide Trade Lifecycle
Applicable to: 12.0
calypsox/apps/trading/ThreePartyJPanel.java
calypsox/tk/bo/workflow/rule/ThreePartyTradeRule.java
12.11.2 Configuring
1. Add the rule ThreeParty to the available trade rules using the Work-
flow Config.
2. Add the necessary trade keywords (if some required keywords are not
set, the system will give you an error messages when trying to save
the Three Party trade).
• 3PartyType
• NumTrades
• Book, Book2, Book3 (also Bookn if you intend to use n trades)
• Location, Location2, Location3 (same remark as book)
• Direction, Direction2, Direction3 (same remark as book)
• Cpty, Cpty2, Cpty3 (same remark as book)
• Role, Role2, Role3 (same remark as book)
• SeqNo
13 Trade Lifecycle
13.1 How to Create a Custom Allocation Process
Create a class named tk.product.<product_type>ProductAllocator
which implements the interface
com.calypso.tk.product.ProductAllocator.
This class will be invoked from
com.calypso.tk.product.ProductAllocatorUtil.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 127
Core Calypso Development Guide Developer’s Guide Trade Lifecycle
Applicable to: 12.0
package calypsox.tk.product;
import com.calypso.tk.core.Defaults;
import com.calypso.tk.core.JDate;
import com.calypso.tk.core.JDatetime;
import com.calypso.tk.core.Product;
import com.calypso.tk.product.CAOption;
import com.calypso.tk.product.CAOptionManager;
import com.calypso.tk.product.Warrant;
import com.calypso.tk.service.DSConnection;
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 128
Core Calypso Development Guide Developer’s Guide Trade Lifecycle
Applicable to: 12.0
result.setDeliveryQuote(warrant.getStrike());
}
result.setHandleIssuance(manageIssuance);
}
return result;
}
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 129
Core Calypso Development Guide Developer’s Guide Trade Lifecycle
Applicable to: 12.0
13.6 Termination
13.6.1 Creating a Custom Termination Process
Create a class named tk.product.<product_type>Termination or
tk.product.DefaultTermination which implements the interface
com.calypso.tk.product.Termination.
This class can also be used for transferring trades, provided the following
methods are implemented:
• transferTrade() — Transfers a Trade to a new book or a new counter-
party.
• filterFlows() — Filters flows for a Trade terminated or transferred.
This function is called from the getFlows method attached to the
Product when the flag addTradeFlows is set to true. The purpose of
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 130
Core Calypso Development Guide Developer’s Guide Reporting
Applicable to: 12.0
14 Reporting
14.1 Report Framework Overview
The Calypso Report Framework has been designed to clearly separate
the various elements of a report:
• Report Template — The input parameters for the report.
• Report — The database query to retrieve the data.
• Report Output — Data model of the data retrieved by the report.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 131
Core Calypso Development Guide Developer’s Guide Reporting
Applicable to: 12.0
The setDefaults() method allows setting default query parameters for the
report.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 132
Core Calypso Development Guide Developer’s Guide Reporting
Applicable to: 12.0
Parameter Description
Description A free-form String description of this template
Start Date and Start Date cutoff for the report defined as an absolute date or as a rel-
End Date ative tenor, and End Date cutoff for the report defined as an absolute
date or as a relative tenor.
Start and end dates are used in most reports, so it makes sense to
provide the parameters as defaults in the base ReportTemplate class.
However, it is to the discretion of the Report as to whether these are
used or not. Most of these “input” parameters useful will only be if the
Report class makes use of it; in other words, if it uses these parame-
ter values in generating the query.
Holidays Vector of Holidays to use when calculating dates.
Business Days Boolean flag to differentiate between Business and Calendar Days.
Columns Columns to be displayed in the Report. The Columns parameter
enables you to select which columns to display in the output report.
The selection of columns depend on the report and the selection is
retrieved from the ReportStyle class and for each column that is
defined, the ReportStyle class must code the logic on how that value
is to be extracted from the Report row.
Sort Columns Columns by which the report data should be sorted. The SortColumns
parameter allows you to dictate how the data rows are to be sorted.
The user can specify one or more sorting columns. For example,
some reports must be sorted by Book, then by trade ID, while others
may simply require sorting by date. The set of Sort Columns available
is taken from the set of Columns mentioned above and it is not possi-
ble to sort on a column that is not included in the Columns parameter.
Subheadings Columns to be displayed as “subheadings”. Some reports must show
subheadings. This only applies when sorting is being used and the
columns to be shown as subheadings are chosen from those selected
as sort columns. For example, to sort by Settlement Date, select the
“Settlement Date” column as a subheading, this will result in the value
being shown on its own row, with the rows that match its value being
demarcated underneath.
Subtotals Columns for which subtotals should be displayed. It is possible to tag
columns for which subtotals should be computed. This only applies to
columns that represent numeric values such as amounts. Attempting
to generate a subtotal for a Legal Entity Name, say, will result in a
subtotal of 0.0. Subtotals are shown whenever a break occurs in the
sorting order. If a Transfer report is being sorted by Settlement Date
and subtotaled by Transfer Amount the subtotal for all transfers
matching the specific settlement date will be displayed. Subtotals are
reset to 0 after each break in the sorting order.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 133
Core Calypso Development Guide Developer’s Guide Reporting
Applicable to: 12.0
Parameter Description
Totals Columns for which totals should be displayed. Totals are cumulative
subtotals. The only difference between a Total and a Subtotal is that
the total is not reset at each break in the sorting order but a tally is
kept for each row in the report.
Subtotal Func- Aggregation functions to use in calculating subtotals and totals. For
tions and Total each column defined as a subtotal or total, you can use an aggrega-
Functions tion function to calculate that subtotal. The default function is Sum but
other functions are available out-of-the-box including Maximum, Mini-
mum, and Average.
AggregationFlag There are times when an aggregated view of the report is required
without displaying all row details. If the flag is set to true (default being
false) then only an aggregated view will be displayed in the report.
Only rows with subheadings, subtotals, and totals will be displayed
while the specific row details will be hidden from view. Of course, the
subtotals and totals will include these hidden rows; they simply will not
be visible in the report.
Columns, Sort Columns, Subheadings, Totals, Subtotals, and the
associated Function parameters are used to control what data is dis-
played, how it is sorted, and if and how it is aggregated into groups
(with subheadings and subtotals.) Although how the data is displayed
may differ depending upon the ReportViewer (HTML will look differ-
ent from a GUI table), the actual data should remain the same across
all viewers.
As far as data persistence is concerned, this is managed by the
tk.report.sql.ReportTemplateSQL class and, since it
implements the tk.core.Attributable interface, most of the
attributes are stored in the entity_attributes table.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 134
Core Calypso Development Guide Developer’s Guide Reporting
Applicable to: 12.0
return output;
}
…
public String buildQuery(Hashtable from) {
// go through the CustomObjectReportTemplate and build
// the where query based on the values set.
// Add the associated tables to from Hashtable
…
}
}
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 135
Core Calypso Development Guide Developer’s Guide Reporting
Applicable to: 12.0
The ReportStyle classes provide one core method which provides all of
the functionality for the class, for example:
if (columnId == ID_AVAILABLE_DATE) {
return transfer.getAvailableDate();
}
else if (columnId == ID_DELIVERY_TYPE) {
return transfer.getDeliveryType();
}
…
return super.getColumnValue(row, columnId);
}
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 136
Core Calypso Development Guide Developer’s Guide Reporting
Applicable to: 12.0
• com.calypso.tk.report.PDFReportViewer
• com.calypso.tk.report.CSVReportViewer
• com.calypso.apps.reporting.TableReportViewer
• com.calypso.apps.reporting.TreeTableReportViewer
• com.calypso.apps.reporting.PivotTableReportViewer
The search criteria for the reports are selected at the top in the
ReportTemplatePanel. Some control buttons and additional environment
settings are available at the bottom of the window in the button panel.
There, you can set the Pricing Env, the Valuation Date, and connect to
real-time events. These options are only available when applicable.
Given the argument passed to the Report Window (“Message” for exam-
ple), the following GUI classes will be instantiated and attached to the
Report Window (if and when applicable):
• apps.reporting.MessageReportTemplatePanel
• apps.reporting.MessageReportWindowCustomizer
• apps.reporting.MessageReportRealTimeHandler
The corresponding toolkit classes are also instantiated:
• tk.report.MessageReportTemplate
• tk.report.MessageReport
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 137
Core Calypso Development Guide Developer’s Guide Reporting
Applicable to: 12.0
• tk.report.MessageReportStyle
14.1.7 Import/Export
It is possible to import/export report template parameters from/to XML.
This provides a convenient way to distribute a suite of out-of-the-box
reports to one or more users. The report templates can be stored in a
directory and imported into the system on an as-needed basis.
Because the template parameters are stored as attributes, it should be
unnecessary to modify or extend the import/export functionality. For ref-
erence, the relevant classes can be found in the following package:
com.calypso.bridge.object.reportTemplate.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 139
Core Calypso Development Guide Developer’s Guide Reporting
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 140
Core Calypso Development Guide Developer’s Guide Reporting
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 141
Core Calypso Development Guide Developer’s Guide Reporting
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 142
Core Calypso Development Guide Developer’s Guide Risk Analysis
Applicable to: 12.0
15 Risk Analysis
15.1 Analysis
15.1.1 How to Create a Custom Analysis
To add your own analysis, create a subclass of Analysis, for example
XAnalysis (see illustration below), that implements the run() method,
and creates an AnalysisOutput class, XAnalysisOutput, that will format
the results of your analysis class.
To display your results, Calypso provides a standard viewer, Default-
AnalysisViewer, which can display any report that is a spreadsheet-style
table of values. If you wish to create a different type of display, then you
can create a class that implements the AnalysisViewer interface. What-
ever viewer you choose, you must register it in the Analysis Viewer Con-
fig window
Standard analysis parameters are specified in AnalysisParamStd. You
may must subclass AnalysisParamStd to add custom parameters, and
create a custom parameters viewer that implements
AnalysisParamViewer for editing these parameters.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 143
Core Calypso Development Guide Developer’s Guide Risk Analysis
Applicable to: 12.0
The following class diagram shows you the classes involved in creating a
custom analysis.
implements
AnalysisParameters AnalysisParamViewer
implements
Class hierarchy diagram: Adding your own Analysis. Optional classes are shown in grey.
Overview of Steps
• Step 1 — Create analysis parameters if applicable
• Step 2 — Create an analysis parameters viewer if applicable
• Step 3 — Create an AnalysisOutput
• Step 4 — Create an Analysis
• Step 5 — Register the new Analysis
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 144
Core Calypso Development Guide Developer’s Guide Risk Analysis
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 145
Core Calypso Development Guide Developer’s Guide Risk Analysis
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 146
Core Calypso Development Guide Developer’s Guide Risk Analysis
Applicable to: 12.0
1. Add the analysis name to the riskAnalysis domain using the Add
Risk Analysis Type window as shown below. This window is accessed
from the Risk Analysis window when you click the button next to
the Analysis Type field.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 147
Core Calypso Development Guide Developer’s Guide Risk Analysis
Applicable to: 12.0
Implementation Requirements
AnalysisOutput must implement PresentableAnaysisOutput and
Externalizable. In this case calypsox.tk.risk.XXXCustomAnalysisOut-
put must implement the mentioned methods.
• Implementation of the getRiskPresenterHeader(String user)
method is required — this provides the header information used by
the risk presenter. The method should construct
RiskPresenterHeaderResult with the following collections:
1. All headers — Map of headers that comprises of BASE_CURRENCY
and ELAPSED_TIME.
2. All columns list — All column names. In
XXXCustomAnalysisOutput, it is the all headers string array trans-
formed to a collection as a value tagged to the key “Default.”
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 148
Core Calypso Development Guide Developer’s Guide Risk Analysis
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 149
Core Calypso Development Guide Developer’s Guide Risk Analysis
Applicable to: 12.0
• default_obj_key
• default_obj_settle_date)
• At a minimum, the column default_obj_book_id, which is used
for access permission in presentation server, must be popu-
lated.
Implement a translator for the analysis output. The translator should
extend com.calypso.tk.risk.translator.AbstractTranslator.
The naming convention is (XXXTranslator) where XXX is the analysis
name. The translator should:
• Define an overridable LOG string of “XXXTranslator.”
• Implement the abstract method,
getData(AnalysisOutput, List<String> columnNames) which will:
• Return the collection of rows or items in an analysis output
with each element in the collection being a map that consist of
keys as column names and values
• For each row, create a collection of cell values for each column
as key. This provides an entire 2D data array.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 150
Core Calypso Development Guide Developer’s Guide Risk Analysis
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 151
Core Calypso Development Guide Developer’s Guide Risk Analysis
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 152
Core Calypso Development Guide Developer’s Guide Risk Analysis
Applicable to: 12.0
switch(column.getType()) {
case CALYPSO_COLUMN_ID:{
need to fill the PricerMeasure[] measures
pricer.price(...measures)
}
break;
default:super.process(column,todayTrade,yesterdayTrade,pricer,
measures,
isPositionB);
break;
}
}
Note: Your Column ID must be greater than 100 to avoid conflicts with Calypso IDs.
The new column must be registered in the eco_pl_column domain, and in the Eco-
nomic PL Column window.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 153
Core Calypso Development Guide Developer’s Guide Risk Analysis
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 154
Core Calypso Development Guide Developer’s Guide Risk Analysis
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 156
Core Calypso Development Guide Developer’s Guide Risk Analysis
Applicable to: 12.0
Assessing Completion
Most client applications will use a counter to count results as they
arrive. Once the number of results equals the number of jobs sent, the
client application can exit or proceed to other work.
Handling Errors
The method for handling errors is established in the DispatcherUserLis-
tener interface:
public void onDisconnect();
The onDisconnect() method is called if your connection to the Dispatcher
is dropped. In this method you should implement error reporting,
informing the user that the calculation has failed due to the lost connec-
tion.
Sample Code in calypsox/tk/distproc/
BatchPricing.java
16 Reference Data
16.1 Legal Entities
16.1.1 How to Create Custom Attributes on Legal Entities
You can build a custom input window. Your custom window can contain
the fields you need in order to record the additional attributes. Users can
then launch the window by clicking the custom button in the legal
entity window
Create a class named apps.refdata.LegalEntityCustomInputWindow
which implements the interface
com.calypso.apps.refdata.LegalEntityCustomInput.
You must define the following methods in your LegalEntityCustomInpu-
tWindow class:
• input() — applies the display for your window.
• allowAttributeWindow() — specifies if you still allow Calypso’s Legal
Entity Attribute window to be launched.
This class will be invoked from
com.calypso.apps.refdata.BOLegalEntityWindow.
Sample Code in calypsox/apps/refdata/
SampleLegalEntityCustomInputWindow.java
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 158
Core Calypso Development Guide Developer’s Guide Reference Data
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 159
Core Calypso Development Guide Developer’s Guide Reference Data
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 161
Core Calypso Development Guide Developer’s Guide Reference Data
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 162
Core Calypso Development Guide Developer’s Guide Reference Data
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 163
Core Calypso Development Guide Developer’s Guide Reference Data
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 164
Core Calypso Development Guide Developer’s Guide Reference Data
Applicable to: 12.0
16.8 CFD
16.8.1 How to Apply Custom Validation to a CFDContractDefinition
Create a class named apps.refdata.CustomCFDContractValidator
which implements the interface
com.calypso.apps.refdata.CFDContractValidator.
This class will be invoked from
com.calypso.apps.refdata.CFDContractWindow.
Sample Code in calypsox/apps/refdata/
SampleCustomCFDContractValidator.java
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 165
Core Calypso Development Guide Developer’s Guide Reference Data
Applicable to: 12.0
the interface
com.calypso.apps.refdata.CFDCountryGridValidator.
This class will be invoked from
com.calypso.apps.refdata.CFDCountryGridWindow.
Sample Code in calypsox/apps/refdata/
SampleCustomCFDCountryGridValidator.java
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 166
Core Calypso Development Guide Developer’s Guide Reference Data
Applicable to: 12.0
• String user
Authorization
Implement the following methods on Authorizable:
• getId()
• setId()
• diff()
• apply()
• getAuthName()
The following variable must be defined:
• int id
Sample Code
samples.cookbook.tk.refdata.LegalEntityLimit.java
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 168
Core Calypso Development Guide Developer’s Guide Reference Data
Applicable to: 12.0
16.10.2 Extensions
The AS contains multiple extension points which may be used to connect
Calypso to an external identity management system such as LDAP,
Active Directory, etc. These extension points allow users to login to
Calypso using credentials managed in an external or centralized system.
Calypso does not currently support the additional ability to implement a
single sign on, which implies removing the need for users to login to
Calypso.
The extension points within the AS are defined below:
UserDetailService Extension
The default configured AuthenticationProvider is ACEGI's
DAOAuthenticationProvider type, which gives an extension point for
loading user details based on username.
If the requirement is to load user information from other (i.e., non-
Calypso database) userstores (Stores that contains user information)
such as LDAP or a client’s custom database, then you must replace the
default UserDetailsService with a custom User Details Service and cor-
responding PasswordEncoder.
The PasswordEncoder will compare the incoming (user provided) unen-
crypted password with the encrypted password from the userstore, while
the custom implementation of the User Details Service must return
userdetails of type
com.calypso.infra.authentication.providers.CalypsoUserDetails.
When the user details service is replaced, the PasswordEncoder must
also be replaced because the encrypted password in the custom userstore
is could potentially be encrypted using a different encryption algorithm.
A DAO named UserSQL is available for any implementation of the
UserDetailsService to provide it with access to the Calypso User Reposi-
tory. Scenarios in which user attributes, such as locked state, are not
managed by the external identity store may require the use of the
UserDetailsService. This reference can be passed to the
UserDetailsService using the same pattern as is used by the
CalypsoUserDetails service in the configuration section (outlined below).
AuthenticationProvider
This component is the lowest level responsible for the entire authentica-
tion process. The default implementation of this component is the:
com.calypso.infra.authentication.providers.CalypsoAuthenticationProvider
CalypsoAuthenticationProvider extends the ACEGI’s
DaoAuthenticationProvider. This default implementation leverages the
UserDetailsService and the PasswordEncoder to process the authentica-
tion of the user. In most cases, connectivity to eternal identity systems
only require extension of the UserDetailsService and the
PasswordEncoder.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 169
Core Calypso Development Guide Developer’s Guide Reference Data
Applicable to: 12.0
16.10.3 Configuration
The AS components are defined in the following Spring configuration
file:
$CALYPSO_HOME/resources/appconfig/AuthenticationServer.xml
Implementations for the various components defined above are changed
here.
The Authentication provider is defined in the
<bean id="authenticationManager" /> node. New authentication pro-
viders can be configured to replace the default Calypso Authentication
Provider or can be added to the existing list.
The default Authentication Provider is defined in the
<bean id="defaultAuthenticationProvider"/> node. This node is
where you would change the UserDetailsService and PaswordEncoder
beans to custom implementations.
Changes to AuthenticationService.xml
Replace the beans passwordEncoder and userDetailsService with the
customs versions as shown below.
<bean id="passwordEncoder"
class="com.calypso.authentication.providers.encoding.DummyEncoder" />
<bean id="userDetailsService"
class="com.calypso.authentication.userdetails.DummyUserDetailsService"
init-method="init"/>
PasswordEncoder
This custom implementation does not encode the password data stored
in the userstore nor is it encrypted.
@Override
public String encodePassword(String arg0, Object arg1)
throws DataAccessException {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isPasswordValid(String enc, String plain, Object arg2)
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 170
Core Calypso Development Guide Developer’s Guide Reference Data
Applicable to: 12.0
throws DataAccessException {
return (enc.equals(plain));
}
UserDetailsService
This custom User Details Service holds on the user/data in memory and
the password as an unencrypted Map<user, password> password:
@Override
public UserDetails loadUserByUsername(String username)
throws UsernameNotFoundException, DataAccessException {
CalypsoUserDetails userDetails = new CalypsoUserDetails(username,
users.get(username), true,
true, true, true,
new GrantedAuthority[] {
new GrantedAuthorityImpl("ROLE_ADMIN"),
});
userDetails.setFullName("FullName");
userDetails.setAdmin(true);
return userDetails;
}
}
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 171
Core Calypso Development Guide Developer’s Guide Reference Data
Applicable to: 12.0
Calypso does not use role-based Authorization. The only role that is
allowed in the ROLE_ADMIN is hard coded in the above code.
Details of whether the user is an admin should be fetched from the
calypso DB as this information is not available in the external Creden-
tialsStore.
PasswordEncoder is the implementation of the interface
org.acegisecurity.providers.encoding.PasswordEncoder. Currently,
Calypso only needs the the implemented method:
public boolean isPasswordValid(String encPass, String rawPass, Object salt)
Where encPass is the encrypted password from the CredentialsStore,
rawPass is the user presented password, and salt is the encryption salt.
verifyToken
A call to verify token extends the validity of the AuthenticationToken by
SESSIONTIMEOUT_INMINUTES minutes. Client applications call the
SESSIONTIMEOUT_INMINUTES method
“MIN_TOKEN_VERIFY_ATTEMPTS” times within a
SESSIONTIMEOUT_INMINUTES duration.
e.g. if SESSIONTIMEOUT_INMINUTES=30 and
MIN_TOKEN_VERIFY_ATTEMPTS=4, a verifyToken method call is made
every 7.5 minutes (30/4 = 7.5 minutes).
The Authentication Service stores Tokens in the DB. The tokens are
deleted when they expire or if the client make an explicit logout call.
Applications that are logged in are considered logged in for
SESSIONTIMEOUT_INMINUTES duration, even in the event of a Authen-
tication Service crash.
Applications are typically stopped using the stopAll feature in Admin,
which stop all applications except the Event Server, which functions as a
JMS messaging bus (Calypso ships with activemq components/services).
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 172
Core Calypso Development Guide Developer’s Guide Reference Data
Applicable to: 12.0
In the event of system wide crash, some users may remain logged in for
SESSIONTIMEOUT_INMINUTES minutes, which may prevent certain
engines from starting because only single instance of the engine is per-
mitted in the system.
In the event of a system crash (not an orderly restart) Calypso advises
that user restart the Authentication Service with the -clean argument
to force a clean instance of Authentication Service to launch which will
purge all tokens from the tokenstore table. After a clean start of the
Authentication Service any users who remained logged in must be
restarted as well..
java com.calypso.apps.statup.StartAuthService -user user -password passwd
-env envname -clean
getConnectedClients returns the list of currently logged in clients
based on the session timeout and the clients connection status with the
event server.
The granularity of the SESSIONTIMEOUT_INMINUTES is in minutes,
which is large enough to ignore transient network issues that prevents
the clients from being able to renew the token. The secondary require-
ment is to quickly determine if client is still connected. To obtain feed-
back more rapidly, the connection with the Event Server is used to
provide client connection status.
In effect, getConnectedClient returns the list of currently logged in clients
(tokens are still valid in the DB) that are connected to the Event Server.
Applications that do not need a connection to the Event Server rely on the
granularity of this method based on the SESSIONTIMEOUT_INMINUTES set-
ting.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 173
Core Calypso Development Guide Developer’s Guide Reference Data
Applicable to: 12.0
Note: It is not recommended to audit every data member encapsulated within a custom
ScheduledTask implementation. You should consider the following alternatives:
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 174
Core Calypso Development Guide Developer’s Guide Reference Data
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 175
Core Calypso Development Guide Developer’s Guide Workflow
Applicable to: 12.0
17 Workflow
17.1 Workflow Process
17.1.1 How to Create a Custom Exception Handler
Create a class named
tk.bo.workflow.exhandler.<exception_type>ExceptionHandler
which implements the interface
com.calypso.tk.bo.workflow.ExceptionHandler.
This class will be invoked from
com.calypso.tk.bo.workflow.ExceptionHandlerUtil.
Sample Code in calypsox/tk/bo/workflow/exhandler/
EX_MISSING_SIExceptionHandler.java
Note: For performance reasons, workflow rules are executed within the Data Server. Be very
careful to clone any objects retrieved from the Data Server prior to modifying them.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 176
Core Calypso Development Guide Developer’s Guide Workflow
Applicable to: 12.0
Note: The rule names must be registered with the appropriate workflow rule domains: work-
flowRuleMessage, workflowRuleTrade, and workflowRuleTransfer.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 177
Core Calypso Development Guide Developer’s Guide Workflow
Applicable to: 12.0
This method can be run on both client and data server sides. When
applying a transition for saving/updating objects, the workflow will
run on the server, but if a user wants to simulate a transition, the
workflow runs on the client side.
• When loading static data, you should use BOCache, Local-
Cache, and the remote services when possible. The workflow
will know by itself on which side the code runs. The following
code for example, can be run on both sides.
LegalEntity po = BOCache.getLegalEntity(dsCon, transfer.getProcessingOrg());
When loading active data, you should first check if you run on
the client or server side - to know that you have to test if the
dbCon is null or not.
• If it is not null, you run on the server side and you must use
the SQL class. Otherwise, you must use the remote services.
Note that a DSConnection is never null, even on the server
side. Therefore, the code should be like:
if (dbCon != null) {
trade = TradeSQL.getTrade(id, (Connection)dbCon);
} else {
trade = dsCon.getRemoteTrade().getTrade(id);
}
• getDescription() — This method will be called from the Workflow
Config window to display information about the rule.
• update() — This method will be called by the system when all rules
return true from the check() methods. You can modify object in this
method. Note that this method will always be run on the server side.
Therefore, only the dbCon can be used. For example, you can do:
TaskSQL.save(newTask, (Connection)dbCon);
Moreover, if you want to save and publish new events inside a work-
flow rule, that must be done in the update() method. You must create
the event and add it to the events vector that is one of the arguments
of the method. For example, you can do:
TaskSQL.save(newTask, (Connection)dbCon);
PSEventTask taskEvent = new PSEventTask();
taskEvent.setTask(newTask);
events.addElement(taskEvent);
If you want to create exception tasks, it is recommended to create
BOException objects and add them to the excps vector that is one of
the arguments of the method. For example, you can do:
BOException boExcp = new BOException(tradeId,
this.getClass().getName(),
"Exception Message",
BOException.INFORMATION);
excps.addElement(boExcp);
These classes will be invoked from
com.calypso.tk.bo.workflow.WorkflowRuleUtil.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 178
Core Calypso Development Guide Developer’s Guide Workflow
Applicable to: 12.0
Sample Code
calypsox.tk.bo.workflow.rule.
17.3.1 Entity
The object for which you want to implement a custom workflow must be
identified as an Entity.
Implementing EntityObject
The object for which you want to implement a generic workflow must
implement com.calypso.tk.core.EntityObject.
For example, the following code was added to the class
com.calypso.tk.core.LegalEntity to become an EntityObject.
New imports are needed:
import java.sql.Connection;
import com.calypso.tk.core.sql.LegalEntitySQL;
The following methods provide a simple yet sufficient implementation of
EntityObject interface:
/**
* New class field keeps a reference to EntityState
* @see com.calypso.tk.core.EntityState
*/
protected EntityState _entityState = new EntityState();
/**
* Returns a unique id for this EntityObject. Note that together with
* the value returned by <code>getEntityType()</code>, the ID-type pair
* must uniquely identify this Entity Object in the system.<br>
* It is possible, however, for 2 or more EntityObjects to have the same
* id if they have different Entity Types.
* <p>
*/
public int getEntityId() { return getId(); }
/**
* Returns a type that uniquely identifies this EntityObject "type".
* Typically, the simplest way to implement this method is simply to
* return getClass().toString(). However, this is left as an implementation
* detail to permit more customization control.
*/
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 179
Core Calypso Development Guide Developer’s Guide Workflow
Applicable to: 12.0
/**
* Returns an object that encapsulates the Workflow State for this
* <code>EntityObject</code>.
*
* @return the state associated to this entity object
* @see com.calypso.tk.core.EntityState
*/
public EntityState getEntityState() { return _entityState; }
/**
* Sets the object which encapsulates the Workflow State for this
* <code>EntityObject</code>
*
* @param state the workflow state to associate to this entity object.
* @see com.calypso.tk.core.EntityState
*/
public void setEntityState(EntityState state) { _entityState = state; }
/**
* Returns the Processing Org associated with this entity. Note
* that if not applicable, the method should return "ALL", preferably.
*
*/
public String getProcessingOrg() { return “ALL”; }
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 180
Core Calypso Development Guide Developer’s Guide Workflow
Applicable to: 12.0
Implementing EntityPersistence
When an object goes through the workflow, the actual saving to the data-
base is done via the EntityObject interface. The object goes through the
workflow and, if no error is raised, the object and its state are saved to
persistent data by calling EntityObjectSQL.save(EntityObject, Connec-
tion). To properly persist your object at this point, you must implement
the appropriate persistence class. For example, if you have the following
class calypsox.tk.mypackage.MyObject which implements EntityOb-
ject, then you must create calypsox.tk.mypackage.sql.MyObjectSQL
that implements com.calypso.tk.core.sql.EntityPersistence. In
doing so, you ensure that EntityObjectSQL is able to save, retrieve,
remove your objects properly as the object goes through the workflow.
The changes to EntityObjectSQL are minimal. For this example, the
changes are made to com.calypso.tk.core.sql.LegalEntitySQL.
The idea is for the object’s associated EntityState to be saved/removed/
retrieved as needed. Hence, all those methods which retrieve the Legal-
Entity object from the database make a call as follows:
EntityObjectSQL.setEntityState(legalEntity, con);
Similarly, the following calls are used in the save and remove methods,
respectively:
EntityObjectSQL.saveEntityState(legalEntity, con);
EntityObjectSQL.removeEntityState(legalEntity, con);
We have established an association between the LegalEntity, an entity
object, and its associated EntityState, its state. To ensure data integrity
we must be sure that the memory image for the object matches that in
the database.
Modifying ReferenceDataServerImpl
You must change the API for saving the object.
For this example, we change the save(LegalEntity) method. Currently,
the save operation is invoked as follows:
int lid = LegalEntitySQL.save(legalEntity);
By changing this to the following, everything is handled in the workflow,
including the actual “save” operation:
saveEntityObject(legalEntity);
int lid = legalEntity.getId();
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 181
Core Calypso Development Guide Developer’s Guide Workflow
Applicable to: 12.0
The workflow can have the following status: NONE, PENDING, or VERI-
FIED. The Action NEW creates the transition from NONE to PENDING.
The Action AMEND, with STP flag on, links PENDING to VERIFIED with
a call to this rule. Lastly, there is a link back from VERIFIED to PEND-
ING, also on AMEND, so that any changes to the LegalEntity are vali-
dated back through the rule.
17.3.3 Workflow
Once the domain values have been set, the workflow can be configured
using Main Entry > Configuration > Workflow > Workflow Configura-
tion.
Make sure to add the actions, rules, and status codes as applicable using
the menu items under Domain > Entity. You will be prompted to enter
the entity (LegalEntity in our example).
We provide a sample configuration of the LegalEntity workflow. You
must start with a clean database and apply Demonstration Data in order
to load the sample configuration.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 182
Core Calypso Development Guide Developer’s Guide Workflow
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 183
Core Calypso Development Guide Developer’s Guide Workflow
Applicable to: 12.0
the interface
com.calypso.apps.reporting.ExceptionSummaryPanel.
This class will be invoked from
com.calypso.apps.reporting.TaskStationJFrame.
Sample Code in calypsox/apps/reporting/
SampleCustomExceptionSummaryPanel.java
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 184
Core Calypso Development Guide Developer’s Guide Workflow
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 185
Core Calypso Development Guide Developer’s Guide Cache Framework
Applicable to: 12.0
18 Cache Framework
The Cache Framework allows any cache mechanism to be plugged-in at
the data level. For example, accounts can be cached using the LRU cache
mechanism, while postings can be cached using a custom cache mecha-
nism.
Out-of-the-box, the following cache mechanisms are available:
• The LRU (Least Recently Used) cache — This is a fixed size LRU
cache. The cache has a maximum size specified when it is created.
When an item is added to the cache, if the cache is already at the
maximum size, the least recently used item is deleted, then the new
item is added.
• The LFU (Least Frequently Used) cache — The behavior is identical
to that of HashtableCache until the cache gets full. If and when the
cache gets full, all the items in cache are sorted based on their popu-
larity, and the 10% least popular objects in the cache are removed.
Popularity is defined as the number of requests for that particular
object in cache, so a popular object will be requested more than an
unpopular object.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 186
Core Calypso Development Guide Developer’s Guide Extension Point Factory Framework
Applicable to: 12.0
Where:
Table 19-1: Parameters for getExtensionPoint
Parameter Description
theType The type expected for the extension class.
extensionName The name of the extension point without the package prefix.
defaultExtensionClassname No Backward compatibility:
Set to Null. This forces users to specify the extension point’s classname (either fully quali-
fied or without the package prefix) in a property name having the form:
extensionName_EXTENSION_CLASSNAME
where extensionName is the class name without the package prefix.
On failure, a Null is returned and a RuntimeException is thrown and a log entry is made
(wrong assignable type or extension point not found).
On success, ExtensionPointFactory returns an instance of the extension type associ-
ated with the extensionName.
— Or —
Support Backward Compatibility:
Set to the extension point’s classname (either fully qualified or with the package prefix).
For example, CustomFilter, tk.marketdata.CustomFilter, or client.tk.marketdata.Cus-
tomFilter.
If ExtensionPointFactory does not find an explicitly named in the application’s properties
file, it then attempts to load the classname specified by defaultExtensionClassname.
On failure, a Null is returned and a “failed to load” log entry is made.
On success, ExtensionPointFactory returns an instance of the extension type associ-
ated with the extensionName.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 187
Core Calypso Development Guide Developer’s Guide Administration
Applicable to: 12.0
20 Administration
20.1 How to customize the login dialg.
The following section allows you to add custom panels to the login dialog.
These panels are for display use only, and do not modify the form inputs.
Create a class named tk.util.ClientVersion that implements
com.calypso.tk.util.ClientVersionInterface.
This class will be invoked from
com.calypso.apps.util.CalypsoLoginDialog.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 188
Core Calypso Development Guide Developer’s Guide Developer’s Notes
Applicable to: 12.0
21 Developer’s Notes
21.1 How to Add a Non-transient Attribute to an
Externalizable Class
21.1.1 Release
You are adding the attribute under release.
1. Look at AUDIT_VERSION in
release.src.com.calypso.tk.core.CalypsoVersion. For exam-
ple, it is 90100.
2. In the readExternal() method of the Externalizable class in release,
call CalypsoVersion.checkAuditVersion(__auditVersion, 90100). This
means that this attribute was added in version 90100.
21.1.2 Patch
You are patching the attribute into one code line.
1. Look at AUDIT_VERSION in
patch.com.calypso.tk.core.CalypsoVersion. For example, it is
90200.
2. In the readExternal() method of the Externalizable class in both the
release and the patch, call
CalypsoVersion.checkAuditVersion(__auditVersion, 90100, 90200).
This means that this attribute was added in version 90100 and
patched in 90200.
You are patching the attribute into two code lines.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 189
Core Calypso Development Guide Developer’s Guide Developer’s Notes
Applicable to: 12.0
3. Look at AUDIT_VERSION in
patch.com.calypso.tk.core.CalypsoVersion. For example, it is
90200.
4. In the readExternal() method of the Externalizable class in the
release and in both patches, call
CalypsoVersion.checkAuditVersion(__auditVersion, 80400, 80100,
60024). This means that this attribute was added in version 80400,
and patched in 80100 and 60024.
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 190
Core Calypso Development Guide Developer’s Guide
Applicable to: 12.0
Index
A Comparator 59, 161
AccountExternalName 58 ContractSelectorInterface 124
AccountingHandler 55 CopyTrade 120
AccountingMatching 56 CorporateActionHandler 127
AccountingRuleSelector 55 CorrelationType 82
AccountKeyword 56 CreAttributeSQL 61
AccRuleValidator 57 CreHandler 60
AggregationInterface 147 CreSenderFormater 61
Amortization parameters 111 CUPanel 79
Analysis 143, 146 Curve 74
AnalysisDispatcher 157 CurveGenerator 77
AnalysisHandler 148 CurveGeneratorSQL 78
AnalysisOutput 143, 145 CurveGeneratorZero 77
AnalysisParameters class 146 CurveUnderlying 79
AnalysisParamStd 143, 144 CUSQL 79
AnalysisParamViewer 145 Custom code 18
AnalysisVerifier 148 CustomAttributePanel 163
AnalysisViewer 147 CustomBundleValidator 124
Auditable 166 CustomClientCache 25
Authorizable 166 CustomCriterion 164
AuthViewer 168 CustomCriterionPanelInterface 165
CustomCurveMenu 75
B CustomFillCreDescription 60
BlotterMenu 125 CustomFilterInterface 83
BlotterTradeSelector 124 CustomListener 188
BOMessageHandler 48 CustomManualLiquidationValidator 125
BookValidator 162 CustomPeriodGenerator 109
BOProductHandler 43 CustomPriceFixingHandlerInterface 130
BORepoDispatchInterestHandler 44 CustomPrincipalGenerator 111
BOTradeDisplay 125 CustomProcessTradeMenu 131
BOTransferDateSelector 45 CustomProfileValidator 174
CustomReportFilter 140, 141
C
CustomScenarioMarketDataInterface 154
CacheConnection 24, 25
CustomTabTradeWindow 121
CacheValidator 186
CustomTaskStationColumn 184
CalypsoDateDocument 188
CustomTaskStationMenu 184
CalypsoVersion 189
CustomTradeMenu 122
CashFlowCompound 109
CustomUserSetup 174
CashFlowLayout 110
CustomVolSurfaceMenu 76
CashFlowSimple 109
CashSettleEntryValidator 124 D
CFDContractValidator 165 Database dates 30
CFDCountryGridValidator 165 DayCountCalculator 36
CFDExecutionPortfolio 123 DefaultAnalysisViewer 143, 147
CheckAccess 174 DefaultPLCalculator 152
CheckAuthorization 168 DispatcherJobOutput 155
ClientVersionInterface 188 DocumentFilter 70
ClosingAccountName 58 DocumentSender 53
CommentableObjectSQL 142 DSConnection 19
Commit 30
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 191
Core Calypso Development Guide Developer’s Guide
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 192
Core Calypso Development Guide Developer’s Guide
Applicable to: 12.0
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 193
Calypso Technology Contacting Calypso
Contacting Calypso
Americas
SAN FRANCISCO NEW YORK
FRANKFURT JOHANNESBURG
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 194
Calypso Technology Contacting Calypso
Asia Pacific
TOKYO SINGAPORE
SYDNEY MUMBAI
© Calypso Technology, Inc. All Right Reserved. Confidential Material. Page 195