instruction
stringlengths 5
72
| input
stringclasses 1
value | output
stringlengths 22
8.46k
|
---|---|---|
Adding a Custom Account Tab to Account Window | 7.6.12Adding a Custom Account Tab to Account Window
Create a class named apps.refdata.CustomTabAccountPanel that implements
com.calypso.apps.refdata.CustomTabAccount.
CustomTabAccountPanel is invoked from com.calypso.apps.refdata.AccountFrame.
|
|
Applying Custom Validation to Account Attributes | 7.6.13Applying Custom Validation to Account Attributes
Create a class named apps.refdata.CustomAccountAttributeValidator that implements
com.calypso.apps.refdata.AccountAttributeValidator.
CustomAccountAttributeValidator is invoked from com.calypso.apps.refdata.AccountFrame prior to
saving an account.
|
|
Applying Custom Validation to an Account | 7.6.14Applying Custom Validation to an Account
Create a class named apps.refdata.CustomAccountValidator that implements
com.calypso.apps.refdata.AccountValidator.
CustomAccountValidator is invoked from com.calypso.apps.refdata.AccountFrame.
|
|
Creating a Custom Closing Account Name | 7.6.15Creating a Custom Closing Account Name
Create a class named tk.bo.accounting.CustomClosingAccountName that implements the interface
com.calypso.tk.bo.accounting.ClosingAccountName.
CustomClosingAccountName is invoked from com.calypso.tk.bo.BalanceUtil when assigning a
closing account.
|
|
Creating a Custom External Name for Automatic Accounts | 7.6.16Creating a Custom External Name for Automatic Accounts
Create a class named tk.bo.accounting.keyword.CustomAccountExternalName that implements
com.calypso.tk.bo.accounting.keyword.AccountExternalName.
CustomAccountExternalName is invoked from
com.calypso.tk.bo.accounting.keyword.KeywordUtil.
|
|
Adding Custom Attributes to BOPosting | 7.6.17Adding Custom Attributes to BOPosting
Custom attributes are saved when the postings are created so that they are part of the matching.
To generate the attributes, create a class named tk.bo.accounting.CustomFillPostingAttribute
that implements com.calypso.tk.bo.accounting.FillPostingAttribute.
The attributes are saved in the posting_attribute table.
You can customize the save operation by creating a class named
tk.bo.sql.CustomPostingAttributeSQL that implements
com.calypso.tk.bo.sql.PostingAttributeSQL.
|
|
How to Customize the Posting Sender Engine | 7.7 How to Customize the Posting Sender Engine
The Posting Sender engine sends the postings generated by the Accounting engine. During the send,
the status of a posting is updated (to SENT, RE_SENT or DELETED), and the PostingSenderFormater
API is called to produce the output of a posting. You must implement PostingSenderFormater.
Note that the scheduled task POSTING_SENDER also calls PostingSenderFormater for formatting
postings.
Creating a Custom Posting Formatter
Create a class named engine.accounting.PostingSenderFormaterImpl that implements
com.calypso.engine.accounting.PostingSenderFormater.
PostingSenderFormaterImpl is invoked from com.calypso.tk.bo.sql.BOPostingSQL when saving
postings.
|
|
How to Customize the Position Engine | 7.8 How to Customize the Position Engine
|
|
Creating a Custom Liquidation Method | 7.8.1 Creating a Custom Liquidation Method
Create a class named engine.position.Liquidation<liquidation_method> that extends the class
com.calypso.engine.position.Liquidation. Liquidation methods are stored in the
“liquidationMethod” domain.
Liquidation<liquidation_method> is invoked from com.calypso.engine.position.LiquidationUtil.
|
|
Creating a Custom Sort Method | 7.8.2 Creating a Custom Sort Method
Create a class named tk.mo.Comparator<sort_method> that implements java.util.Comparator. Sort
methods are stored in the “sortMethod” domain.
Comparator<sort_method> is invoked from com.calypso.engine.position.LiquidationUtil for
sorting open positions.
|
|
Creating a Custom Routine for Computing the Liquidation Date | 7.8.3 Creating a Custom Routine for Computing the Liquidation Date
Create a class named tk.mo.LiquidationDateCalculator that implements the
com.calypso.tk.mo.LiquidationInfoCalculator interface.
LiquidationDateCalculator is invoked from com.calypso.tk.mo.LiquidationInfo.
Sample Code in calypsox/tk/mo/
LiquidationDateCalculator.java
|
|
Creating a Custom Logic to Load Trade Open Quantities | 7.8.4 Creating a Custom Logic to Load Trade Open Quantities
Create a class named tk.mo.sql.CustomOpenQuantityLoader that implements
com.calypso.tk.mo.sql.OpenQuantityLoader to load trade open quantities using a custom logic.
|
|
How to Customize the Inventory Engine | 7.9 How to Customize the Inventory Engine
Creating a Custom Inventory Position Selector
For example, you want to customize the list of Positions classes handled by the Inventory Engine:
INTERNAL, CLIENT, EXTERNAL.
Create a class named engine.inventory.InventoryPositionSelector that implements the
com.calypso.engine.inventory.PositionSelector interface.
InventoryPositionSelector is invoked from com.calypso.engine.inventory.InventoryEngine.
|
|
How to Customize the CRE Engine | 7.10 How to Customize the CRE Engine
The CRE engine generates CREs (accounting events). The CRE engine calls a generic CreHandler to
specify how to generate a CRE. CreHandler can call a specific CreHandler for a given product type, or
a specific CreEventHandler for a given accounting event. CreHandler also allows adding custom
attributes to the generated CREs.
|
|
Creating a Custom CRE Handler | 7.10.1Creating a Custom CRE Handler
Create a class named tk.bo.accounting.<product_type>CreHandler or
tk.bo.accounting.<product_family>CreHandler that extends
com.calypso.tk.bo.accounting.CreHandler.
Implement a get<accounting event type>() method for each accounting event. For example, getCOT()
for the COT accounting event.
The Product CreHandler is invoked from com.calypso.tk.bo.accounting.CreHandler to generate a
CRE for a given product type of family type.
|
|
Creating a Custom Event CRE Handler | 7.10.2Creating a Custom Event CRE Handler
Create a class named tk.bo.accounting.<accouting_event_type>CreHandler that implements the
com.calypso.tk.bo.accounting.EventCreHandler interface.
The Event CreHandler is invoked from com.calypso.tk.bo.accounting.CreHandler to generate a
CRE for a given type of accounting event.
|
|
Creating a Custom CRE Description | 7.10.3Creating a Custom CRE Description
Create a class named com.calypso.tk.bo.accounting.CustomFillCreDescription that implements
com.calypso.tk.bo.accounting.FillCreDescription.
CustomFillCreDescription is invoked from com.calypso.tk.bo.accounting.CreHandler to add
custom attributes to the generated CREs.
|
|
Creating a Custom Persistence Routine for CRE Attributes | 7.10.4Creating a Custom Persistence Routine for CRE Attributes
Create a class named tk.bo.sql.CustomCreAttributeSQL that implements
tk.bo.sql.CreAttributeSQL.
CreAttributeSQL includes methods for archiving custom attributes that must be implemented. To fully
support archiving and restoring of custom attributes, you must define new history tables for any
custom attribute tables you have added to the database.
CustomCreAttributeSQL is invoked from com.calypso.tk.bo.sql.BOCreSQL when saving CREs.
|
|
How to Customize the CRE Sender Engine | 7.11 How to Customize the CRE Sender Engine
The CRE Sender engine sends the CREs generated by the CRE engine. During the send, the status of a
CRE is updated (to SENT, RE_SENT or DELETED), and the CreSenderFormater API is called to produce
the output of a CRE. You must implement CreSenderFormater.
Note that the scheduled task CRE_SENDER also calls CreSenderFormater for formatting CREs.
Creating a Custom CRE Formatter
Create a class named engine.accounting.CreSenderFormaterImpl that implements
com.calypso.engine.accounting.CreSenderFormater.
CreSenderFormaterImpl is invoked from com.calypso.tk.bo.sql.BOCreSQL when saving CREs.
If you are using multi-threading when running the CRE_SENDER the scheduled task, you need to
make sure that CreSenderFormaterImpl is thread safe.
|
|
How to Customize the Hedge Relationship Engine | 7.12 How to Customize the Hedge Relationship Engine
The Hedge Relationship engine uses the following process to automatically generate Hedge
Relationships using a saved Hedge Relationship Configuration as a template and for events (Trade,
etc.) as applicable:
• The Hedge Relationship engine selects the hedge relationship configuration to apply using a
mapping mechanism between the events it subscribes to and the hedge relationship
configuration configured in the system. It builds a list of new hedge relationships based on the
selected configuration and on existing relationships also. The mapping mechanism can be
customized.
• For each hedge relationship configuration, the Hedge Relationship engine calls a generic
HedgeRelationshipConfigHandler to specify how to generate the corresponding hedge
relationships. The HedgeRelationshipConfigHandler can call a specific
HedgeRelationshipConfigHandler for a given Trade and a specific HedgeRelationshipConfig.
The Hedge Relationship engine also allows adding custom attributes to generate the Hedge
Relationships.
• Once all the new relationships have been built, a matching process occurs to compare a set of
criteria (ratio, start date, end date, etc.) on the new hedge relationships and the old
relationships. The matching mechanism cannot be customized.
Creating a Custom Hedge Relationship Config Handler
Create a class named tk.bo.HedgeRelationshipConfigHandler. The
HedgeRelationshipConfigHandler should have a buildHedgingTradeRelationships() method to build
hedge relationships for a hedging trade based on the configuration set up and a
buildHedgedTradeRelationships() method to build hedge relationships for a hedged trade based on
the configuration setup.
|
|
How to Customize the Diary Engine | 7.13 How to Customize the Diary Engine
The Diary Engine listens for trade creation and modification, and generates trade diary objects which
stand for all the events related to the trade and to its lifecycle.
The Diary Engine calls a generic trade diary handler to specify how to generate the list of diary objects,
but it can call a specific handler for a given product. This handler implements the interface
com.calypso.tk.product.TradeDiaryHandler.
Creating a Custom Trade Diary Handler
Create a class named tk.product.product_typeTradeDiaryHandler that implements the interface
com.calypso.tk.product.TradeDiaryHandler and create a getDiary() method exposed by the
interface.
If you wish to add a diary object to the generic list, your
tk.product.product_typeTradeDiaryHandler custom class must extend the
com.calypso.tk.product.DefaultTradeDiaryHandler generic class and override the getDiary()
method.
|
|
How to Customize the Billing Engine | 7.14 How to Customize the Billing Engine
The purpose of the Billing engine is to generate Billing Fees that must be charged to or delivered to a
CounterParty, an Agent, or any Legal Entity involved in a Trade. These Fees are aggregated in a Billing
Trade with this Legal Entity as a Counterparty.
The Billing engine is able to react on PSEVentTrade(s), PSEventTransfer(s), PSEventMessage(s),
PSEventAccountBilling(s), PSEventTask(s) and PSEventMaintenanceTrade(s).
When processing an incoming event, the Billing engine first creates, and then processes a BillingEvent.
The Billing engine is also able to translate any PSEvent, including Custom events, into a Custom Billing
Event.
Defining a Custom Billing Event
A Billing Event is a Java Class that must implement a Java Interface called BillingEvent. The
BillingEvent Interface is defined as follows:
public interface BillingEvent extends Externalizable {
static final long serialVersionUID = -2533362755239752335L;
public void init(int accountId,
int tradeId,
int tradeVersion,
int transferId,
int transferVersion,
int messageId,
int messageVersion,
int poId,
int bookId,
int leId,
String leRole,
JDate valueDate);
public int getBookId();
public Book getBook() throws Exception; public int getProcessingOrgId();
public LegalEntity getProcessingOrg() throws Exception; public int getLegalEntityId();
public LegalEntity getLegalEntity() throws Exception;
public String getLegalEntityRole(); public int getAccountId();
public List<Integer> getAccountIds();
public Account getAccount() throws Exception; public int getTradeId();
public Trade getTrade() throws Exception;
public int getTradeVersion(); public int getTransferId();
public BOTransfer getTransfer() throws Exception;
public int getTransferVersion(); public int getMessageId();
public BOMessage getMessage() throws Exception;
public int getMessageVersion(); public long getTaskId();
public Task getTask() throws Exception;
public int getTaskVersion();
public boolean matches(BillingEvent event); public String getObjectType();
public int getObjectId();
public Object getObject() throws Exception; public int getObjectVersion();
public JDate getDefaultValueDate();
public JDate getValueDate(String dateType) throws Exception; public boolean
getUnderlyingObjectAmendedB();
public boolean getCancelB();
public void setPricingEnv(PricingEnv pricingEnv); public PricingEnv getPricingEnv();
public BillingEvent cloneEvent();
public Map<String, String> getTradeAttributes(); public long getOccurrenceTime();
}
This CustomBillingEvent is created by a Custom BillingHandler.
Defining a Custom BillingHandler
The custom code placed in buildCustomEvent() must create an instance of a Custom implementation
of the BillingEvent Interface.
calypsox.engine.billing.BillingHandler extends
com.calypso.engine.billing.BiilingHandle {
public BillingEvent buildCustomEvent(PSEvent event) {
// Custom code creating the BillingEvent BillingEvent billingEvent = .....
return billingEvent;
}
}
|
|
How to Customize the Balance Engine | 7.15 How to Customize the Balance Engine
While the Balance Engine itself cannot be customized, two items are available for customization:
• Finding the closing account: Create a class named
tk.bo.accounting.CustomClosingAccountName that implements
tk.bo.accounting.ClosingAccountName.
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.
You can customize the behavior by creating a class named
tk.bo.CustomBalanceHistoryHandler that implements BalanceHistoryHandler. If such a class
exists, it will be called and may update archived balance positions. If that handler returns true,
no error is logged.
|
|
How to Customize the Analysis Server | 7.16 How to Customize the Analysis Server
You can create a custom event filter named tk.event.AnalysisServerPostTradeEventFilter to filter
out trade events. It is invoked from com.calypso.tk.service.PortfolioManager.
|
|
Message Documents | Section 8. Message Documents
Messages in Calypso are converted into documents prior to being physically 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.
|
|
How to Create an HTML Template | 8.1 How to Create an HTML Template
Templates are supported for the HTML format. Calypso provides a standard set of document
templates. You may wish to modify them or to create your own. Templates are associated with
messages using Configuration > Messages & Matching > Message Set-up Configuration from the
Calypso Navigator.
HTML templates contain the text and the format of message documents such as confirmations,
payment, or receipt advices or any other message document generated, based upon the Message
Setup (refer to the Calypso Messages User Guide for details). Any information that is required from the
trade, the message, or the transfer is marked as a keyword in the template. The MessageFormatter
extracts the information from the trade and populates the template keywords. Conditional processing
is also supported to allow for more flexibility in structuring templates. For example, common header
and footer information may be kept in their own files and included in other templates. Sub-documents
may also be included based upon conditions.
Calypso templates are located under <calypso home>/client/resources/com/calypso/templates.
Custom templates should be copied to <calypso home>/tools/calypso-
templates/resources/com/calypso/templates.
You will then need to deploy the files to your applications servers.
Please refer to the Calypso Installation Guide for details.
A list of the keywords available for building your own message templates can be seen in Help >
Message Template Keywords from the Calypso Navigator. Keywords have the format |keyword
name|.
|
|
Creating Custom Functions | 8.1.1 Creating Custom Functions
Although Conditions can retrieve properties for the most commonly used objects (Product, Trade,
Transfer, etc.), it is sometimes necessary to use a custom function derive the value.
Custom classes can be called directly from the FormatterParser if they are placed in the custom
extensions and implementing the FormatterFunction interface. This interface defines one method:
public Object call(DSConnection dsCon, BOMessage message,
BOTransfer transfer,
Trade trade,
LEContact sender,
LEContact receiver,
Vector args);
For example, a custom class named MyFunction is placed in the tk.bo.formatter, and this new class
implements FormatterFunction.
The following code is inserted in the template file:
<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 evaluation results. Using the NOT operator (!) can result in incorrect
branching if an error is encountered during the comparison]
|
|
Creating a Custom Display in Document Manager | 8.1.2 Creating a Custom Display in Document Manager
To provide Document Security, a Document must setup regions. If a document declares no regions,
then it defaults to read-only, meaning that it cannot be modified. Regions are defined using the
following tags in the HTML template:
<!--region:NAME--> ... <!--/region-->
This would define a region named NAME.
Once regions are defined, permissions can be set on the documents based on the region, using
Configuration > Messages & Matching > Document Manager from the Calypso Navigator. Refer to
the Calypso Messages User Guide for details.
Calypso provides an API to customize HTML document display in the Document Manager.
Create a class named tk.bo.document.CustomDocumentFilter that implements
com.calypso.tk.bo.document.DocumentFilter.
|
|
How to Create SWIFT Messages | 8.2 How to Create SWIFT Messages
A standard set of SWIFT messages are provided by the Calypso system. SWIFT messages can be
generated by product type and message type, and are selected using template names, or can be
generated from XML templates.
|
|
How to use the Generic XML Formatter | 8.3 How to use the Generic XML Formatter
To use the generic XML message formatter, you must first define your message setup with the
message type of your choice and use the message format, XML. Second, create a custom formatter
named <Message Type>XMLFormatter (for example CONFIRMXMLFormatter for the message type
CONFIRM) that extends AbstractXMLFormatter. Then add the desired keyword parse methods.
|
|
How to Create Custom Import of Message Documents | 8.4 How to Create Custom Import of Message Documents
Create a class named tk.bo.document.CustomDocumentImporter that implements
com.calypso.tk.bo.document.DocumentImporter.
CustomDocumentImporter is invoked from com.calypso.apps.reporting.MessageDocumentWindow.
The default implementation is in com.calypso.tk.bo.document.DefaultDocumentImporter.
|
|
MX Messages (BO Messaging Module) | Section 9. MX Messages (BO Messaging Module)
The BO Messaging module allows generating MX messages.
It uses a Formatter class to generate the AdviceDocument but the formatters provided by this module
do not use the standard formatter pattern with the parse<KEYWORD> method. They use ReportStyles
instead.
|
|
Objects Involved | 9.1 Objects Involved
When the message type is a MX Message, the MXFormatter is used. This formatter is provided by the
bo-messaging module. To generate an advice document, the MXFormatter uses a MessageContext
and a MessageGenerator.
The MXFormatter does the following:
@Override
public AdviceDocument generate(PricingEnv env, BOMessage message,
boolean newDocument, DSConnection dsCon)
throws MessageGenerationException {
MessageContext context = buildContext(env, message, dsCon);
MessageGenerator generator = getMessageGenerator(context);
if (generator == null) {
Log.error(this, "Could not find generator for message " + message);
return null;
} else {
return generator.generate(context);
}
}
You can customize the AdviceDocument generation by using your own context or generator.
The purpose of the context is to hold necessary data to generate the AdviceDocument, while the
MessageGenerator is supposed to create the AdviceDocument.
To instantiate the MessageGenerator, the following algorithm is used:
tk.bo.document.generator.<product type>MXMessageGenerator
tk.bo.document.generator.<product family>MXMessageGenerator
tk.bo.document.generator.MXMessageGenerator
tk.bo.document.generator.<product type><format type>MessageGenerator
tk.bo.document.generator.<product family><format type>MessageGenerator
tk.bo.document.generator.<format type>MessageGenerator
tk.bo.document.generator.<product type><format family>MessageGenerator
tk.bo.document.generator.<product family><format family>MessageGenerator
tk.bo.document.generator.<format family>MessageGenerator
The class name is built in 3 steps:
1. context.getProductType(),context.getProductFamily(), EMPTY_STRING
2. context.getMessageFamily(), context.getFormatType(),
context.getFormatFamily()
3. “MessageGenerator”
The following classes are provided out-of-the-box: MXMessageGenerator, SPBMessageGenerator,
XMLMessageGenerator, JSONMessageGenerator, CVSMessageGenerator,
XHMTLMessageGenerator.
You can also build your own MessageContext using the same algorithm with the following input:
package: tk.bo.document.context
The class name is built in 3 steps:
1. message.getProductType(), message.getProductFamily(), EMPTY_STRING
2. message.getFormatType(), EMPTY_STRING
3. “MessageContext”
The following classes are provided out-of-the-box: MXMessageContext and MessageContext.
Usually, to generate an MX Message you do not need to define your own MessageGenerator nor any
MessageContext. In this documentation we will assume that MXMessageGenerator and
MXMessageContext are used.
|
|
MXMessageGenerator | 9.2 MXMessageGenerator
This MessageGenerator is based on templating definition. As MXMessageGenerator extends
XMLMessageGenerator, it aims to generate an XML file.
The XML to generate is based on templating (message template). This template must follow a specific
xsd (see template.xsd for a detailed definition). Basically the template contains a list of Element that
contains Content. A Content can be an Element, a Report, a Text or an Include.
An Include is a link to another template file that needs to be located in the classpath. It is useful if you
want to include the exact same piece of XML in different places.
A Text is a hardcoded value
A Report is a call to a ReportStyle (throuh the method getColumnValue). There will be more details
below.
An Element is another Element useful to created nested XML element.
The rest of this document will provide more details through example.
Template example:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<template>
<contents>
<element name="MrgnCallReqId">
<contents>
<text>
<value>NONREF</value>
</text>
</contents>
</element>
<element name="MrgnCallReqValue">
<contents>
<report>
<column>AColumnName</column>
</report>
</contents>
</element>
<element>
<contents>
<include>
<path>SecurityCollateral.xml</path>
</include>
</contents>
</element>
</contents>
</template>
This template will generate the following XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MrgnCallReqId>NONREF</MrgnCallReqId>
<MrgnCallReqValue>foo</MrgnCallReqValue>
<.... all content coming from template SecurityCollateral.xml ...>
where foo is the result of ReportStyle.getColumnValue(“AColumnName”).
|
|
Conditional Element | 9.2.1 Conditional Element
It is possible to define an element that will be displayed only if some conditions are met. A condition is
defining an expression that will be analyzed and executed by the framework. The expression must
return a boolean value. If true the element is kept otherwise this element will not be printed.
Example:
<element name="CodCliNatu">
<condition>
<expression>!isEmpty(getReportValue("AColumnName"))</expression>
</condition>
<contents>
<report>
<column>Cntp_Attr.CodCliNatu</column>
</report>
</contents>
</element>
In this example, it will display the result of getColumnValue(“Cntp_Attr.CodCliNatu”) if
ReportStyle.getColumnValue(“AColumnName”) is not empty. If it is, then whatever the value of
getColumnValue(“Cntp_Attr.CodCliNatu”) is, the value of the element will be empty.
You can add multiple condition as the <condition> element can contain a sequence of <expression>.
In this case, this will be considered as AND condition. If you want to write OR condition it has to be in
the same expression.
Example:
<element name="CodCliNatu">
<condition>
<expression>!isEmpty(getReportValue("AColumnName")) ||
getReportValue("AColumnName") == "MySpecificValue" </expression>
</condition>
<contents>
<report>
<column>Cntp_Attr.CodCliNatu</column>
</report>
</contents>
</element>
Note that even if we test equality on Strings, we use the sign “==”
|
|
if then else simulation | 9.2.2 if then else simulation
It is possible to simulate if < > then <…> else behavior in a template. To do so you can obviously use
the condition we just described above. There is another possibility that necessitate less writing. To do
so we will introduce the usage of the max attribute that can be added to an element.
Let’s imagine you want to display a value from a report style if it exists otherwise you want to add the
text UNKNOWN. You can do it that way:
<element name="OrgId">
<contents max="1">
<element name="AnyBIC">
<contents>
<report>
<column>PO_BENEFICIARY_BIC_CODE</column>
</report>
</contents>
</element>
<element name="Othr">
<contents>
<text>
<value>UNKNOWN</value>
</text>
</contents>
</element>
</contents>
</element>
As you can see, the first element contains a content with attribute max=”1”. That means that it could
contains only one nested element. As soon as an element is non null the parser will stop evaluating the
other elements. Here if ReportStyle.getColumnValue(“PO_BENEFICIARY_BIC_CODE”) returns a
non empty String, the resulting XML is:
<OrgId>
<AnyBIC>MyBICCode</AnyBIC>
</OrgId>
otherwise it is:
<OrgId>
<Othr>UNKNOWN</Othr>
</OrgId>
In such situation we did not have to use any conditions which simplifies the way to write a template.
|
|
Attributes Element | 9.2.3 Attributes Element
It is possible to add attributes in an element as for example the case of an Amount / Currency
Example:
<element name="Amt">
<attributes>
<attribute name="Ccy">
<value>
<report>
<column>SettleCurrency</column>
</report>
</value>
</attribute>
</attributes>
<contents>
<report>
<column>Settle Amount</column>
</report>
</contents>
</element>
the resulting XML is:
<Amt Ccy="USD">1000000</Amt>
|
|
Modifying the output | 9.2.4 Modifying the output
It is possible to use some built-in function that permits to modify the output before printing it.
format attribute
The report element supports an attribute named format. This attribute permit to format the result of a
report. We can use it to format Date or Number.
To format a Date, the SimpleDateFormat class is used and so format take a String that is manageable
by SimpleDateFormat.
Example:
<element name="anElement">
<contents>
<report format="EEE, d MMM yyyy HH:mm:ss Z">
<column>Entered Date</column>
</report>
</contents>
</element>
Of course in such situation, the ReportStyle.getColumnValue must return Date, JDate or JDatetime
object.
See https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html for more examples
on the supported format.
To format a number, NumberFormat from java is used.
Example:
<element name="Amount">
<contents>
<report format="######.######">
<column>Settle Amount</column>
</report>
</contents>
</element>
See https://docs.oracle.com/javase/8/docs/api/java/text/NumberFormat.html for more information on
the supported format.
transformation element
It is also possible to use the element transformation in order to manipulate the result given by the
report.
Out of the box, few transformations are provided. You can add multiple transformation to same result.
Provided transformations are:
• regexp
• substring
• function
When function is select, then you can use the function. You can write your own functions or use one of
the provided ones.
Provided functions are:
• lower
• capital
• words
• upper
• trim
• swiftISOCode
• deaccent
If you want to add your own function you will need to a new method in your formatter and you will
have to annotate this method by the Function annotation.
Some examples:
<element name="Pmt">
<contents>
<report>
<column>Delivery Type</column>
<transformations>
<transformation>
<from>DAP</from>
<to>APMT</to>
</transformation>
<transformation>
<from>DFP</from>
<to>FREE</to>
</transformation>
</transformations>
</report>
</contents>
</element>
Note that transformations are used in the order they are written. When multiple transformations are used, the
output of one transformation is the input of the next one.
In the example above, we simply change the string in the <from> tag by the one in the <to> tag. If the from is
not found nothing happens.
<element name="atag">
<content>
<report>
<column>Payer.Agent.Identifier</column>
<transformations>
<transformation type="regexp">
<from>^.*/</from>
<to></to>
</transformation>
</transformations>
</report>
</content>
</element>
In this case, the element that matches the regular expression will be replace by the content of the <to>
tag, here nothing.
<element name="Status">
<contents>
<report>
<column>TradeStatus</column>
<transformations>
<transformation type="function">
<to>words</to>
</transformation>
<transformation type="function">
<to>lower</to>
</transformation>
<transformation type="function">
<to>capital</to>
</transformation>
</transformations>
</report>
</contents>
</element>
<element>
<contents>
<report>
<column>Swift</column>
<transformations>
<transformation type="substring">
<to>8</to>
</transformation>
<transformation type="function">
<to>lower</to>
</transformation>
</transformations>
</report>
</contents>
</element>
|
|
ReportStyle | 9.3 ReportStyle
The Formatter uses report style to get the different values.
The formatter uses a MessageContextReportHandler. This class is looked up using the concatenation
of these 3 strings:
1. context.getProductType(), context.getProductFamily(),EMPTY_STRING
2. context.getMessageFamily(), context.getFormatType(),
context.getFormatFamily(), EMPTY_STRING
3. MessageContextReportHandler
This lookup is done in package tk.report.
The MessageContextReportHandler is responsible of managing the retrieval of the data. It is also
responsible of the function definition for feature you want to use in the condition tag. These functions
need to be defined using the @Function annotation.
It is recommended to always inherit from the class
com.calypso.tk.report.MessageContextReportHandler.
This class already provides the following functions that can be used (please note that the first argument
of the function always needs to be MessageContext). This list is not exhaustive:
• getReportType return the report type base on the object we are working on (ie Subject, this
will be described later)
• checkStaticDataFilter take as argument the name of a SDFilter and check it against the
Trade, the BOTransfer and the BOMessage using the accept method
• getTimeZone return the timezone store in the context
• getCharacterEncoding returns the Charset stored in the context
• getLocale returns the Locale stored in the context
• currentJDatetime returns the current JDatetime
• currentJDate returns the current JDate
• isEmpty exists with 2 types of arguments, a String or an Object. Returns whether the String is
null or empty or if the Object is null or if Object.toString is null or empty
• length returns the length of the String passed as argument
• isTrue returns Boolean.TRUE if the given String represent a value that is true
• isFalse returns the opposite of isTrue
• equalsIgnoreCase tests 2 String ignoring the case
• contains checks whether the first String contains the second one
• startsWith checks if the first String starts with the second one
• endsWith checks if the first String ends with the second one
• toString return a string value for any objects of type JDatetime, JDate, Date, Boolean,
Integer, Long, Float, Double, Character, String
MessageContextReportHandler is responsible of calling the report style. To select which report style
needs to be called, for following algorithm to build the report style is used:
1. context.getProductType(),context.getProductFamily(), EMPTY_STRING
2. context.getMessageFamily(), context.getFormatType(),
context.getFormatFamily(), EMPTY_STRING
3. Message (if the context subject is a BOMessage), Transfer (if the context subject is a
BOTransfer), Fee (if the context subject is Fee), CashFlow (if the context subject is a CashFlow
and not a Fee) or the context subject object class name.
4. ReportStyle
If a value is found, it is returned, otherwise a check is done on the parent context handler.
If you want to write your own ReportStyle, it is highly suggested that you extend the class
com.calypso.tk.report.AbstractDelegatingReportStyle.
When doing so you can implement the method public Object getColumnValue(ReportRow
row, String columnName, Vector errors)
In this method you can look for any column name and return a value if you want. If you do not manage
the columnName in your method, it is recommended to call at the end of the method getColumnValue
the method public Object callAfterColumnValue(ReportRow row, String columnName,
Vector<String> errors).
You can set the underlying report style of your own custom style by calling
setUnderlyingReportStyle. This permits to have a hierarchy of report style.
|
|
context tag | 9.4 context tag
It is possible to switch the object you are working on by default when writing an element tag. To do
so, you need to use the context tag. The object you are working on is defined by the method public
List<Object> getReportObjects(MessageContext context, String
relatedObjectType) from class MessageContextReportHandler. When you add the context
tag to an element tag, then this method will be called, and based on the name of the context you are
providing, the subject of the context can change.
|
|
Basic usage | 9.4.1 Basic usage
For example:
<element name="TradgSdId">
<context>
<to>ProcessingOrgContact</to>
</context>
<contents>
<element name="SubmitgPty">
<contents>
<element name="AnyBIC">
<contents>
<element name="AnyBIC">
<contents>
<report>
<column>Swift</column>
</report>
</contents>
</element>
</contents>
</element>
</contents>
</element>
</contents>
</element>
As soon as we parse the element TradgSdId, we switch context. The method getReportObjects is
called from the current MessageContextReportHandler and it returns a list of objects based on the
value ProcessingOrgContact. Here it will return a LEContact object which is the sender contact.
That means that until we get out of parsing TradegSdId and its inner element, the object we are
working on is no more the BOMessage but the LEContact.
So when the report column value is called on “Swift” column, as the object is a LEContact, the report
style which is created is a LEContactReportStyle and its getColumnValue is called. This can
simplify a lot the way to write template by making sure which object we are working on.
|
|
Iterator Usage | 9.4.2 Iterator Usage
As when you switch context you can return a new list of objects, it can be easily used to create iterators.
If you have a trade keyword which is a String that represents a comma separated list of values that you
want to display as:
<keywords>
<tradeKeyword>value1</tradeKeyword>
<tradeKeyword>value2</tradeKeyword>
<tradeKeyword>value3</tradeKeyword>
</keywords>
Then you need to create a template that looks like:
<element name="keywords">
<context>
<to>SplitKeywords</to>
</context>
<contents>
<element name="tradeKeyword">
<contents>
<report>
<column>TRADE_KEYWORD.keywordsplitted</column>
</report>
</contents>
</element>
</contents>
</element>
you then need to provide your own MessageContextReportHandler by creating for instance a class
named
<ProductType><MessageFamily>MessageContextReportHandler
This class has to extend MessageContextReportHandler and its method getObjects has to look like:
@Override
public List<Object> getReportObjects(MessageContext context,
String relatedObjectType) throws
MessageGenerationException {
List<Object> newSubjects = new ArrayList<Object>();
if ("SplitKeywords".equals(relatedObjectType)) {
if (context.getTrade() != null &&
!Util.isEmpty(context.getTrade().getKeywordValue(COD_CLAUS_ESPFCO_IF_ATTRIBUTE))) {
String keyword =
context.getTrade().getKeywordValue(COD_CLAUS_ESPFCO_IF_ATTRIBUTE);
List<String> keywords = Util.stringToList(keyword);
for (String k : keywords) {
Trade t = context.getTrade().clone();
t.addKeyword("keywordsplitted",k);
newSubjects.add(t);
}
}
} else {
newSubjects = super.getReportObjects(context, relatedObjectType);
}
return newSubjects;
}
As you can see, when the context is SplitKeywords a call to getReportObjects is done and the trade is
retrieved from the context, a specific keyword is retrieved, and its value is split. Then Trades (cloned)
are added as subjects with a new trade keyword for each of them. The part of the template will be
called for each subject:
<element name="tradeKeyword">
<contents>
<report>
<column>TRADE_KEYWORD.keywordsplitted</column>
</report>
</contents>
</element>
|
|
MXMessageValidator | 9.5 MXMessageValidator
The XML document generated by MXMessageGenerator can be validated against an XML Schema
Definition (XSD).
The MXMessageValidator checks if all the properties defined in the XSD are respected.
For instance: in the below XSD the Element BICFI is a type of “BICFIDec2014Identifier”
<xs:element maxOccurs="1" minOccurs="0" name="BICFI" type="BICFIDec2014Identifier">
<xs:annotation>
<xs:documentation source="Name" xml:lang="EN">BICFI</xs:documentation>
<xs:documentation source="Definition" xml:lang="EN">Code allocated to a
financial institution by the ISO 9362 Registration Authority as described in ISO 9362
"Banking - Banking telecommunication messages - Business identifier code
(BIC)".</xs:documentation>
</xs:annotation>
</xs:element>
And the definition of type “BICFIDec2014Identifier” is :
<xs:simpleType name="BICFIDec2014Identifier">
<xs:annotation>
<xs:documentation source="Name"
xml:lang="EN">BICFIDec2014Identifier</xs:documentation>
<xs:documentation source="Definition" xml:lang="EN">Code allocated to a
financial institution by the ISO 9362 Registration Authority as described in ISO 9362:
2014 - "Banking - Banking telecommunication messages - Business identifier code
(BIC)".</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:pattern value="[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-
9]{3,3}){0,1}"/>
</xs:restriction>
</xs:simpleType>
Then if the MXMessageGenerator return a value of BICFI = BICINTRXXXXDDDDD, the
MXMessageValidator will generate a warning message because it doesn’t respect the described rules.
You should then face an error like this one:
cvc-pattern-valid: Value 'BICINTRXXXXDDDDD' is not facet-valid with respect to pattern
'[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}' for type
'BICFIDec2014Identifier'.
|
|
Specifying the Template to be used for a Custom Gateway | 9.6 Specifying the Template to be used for a Custom Gateway
To specify the template to be used for a custom gateway, you can create a class named
bomsg.<gateway>GatewayResolver that implements the interface
com.calypso.bomsg.GatewayResolver. The method getGatewayTemplateName() should return the
template to be used:
• SAA includes the DataPDU header
• MX does not include the DataPDU header
|
|
Market Data | Section 10. Market Data
Market Data
10.1 Quotes
Quotes and How they are used in Calypso
10.1.1How 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 illustrates 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
10.1.2How to Subscribe to Real-time Quotes
The following example illustrates how to subscribe to real-time quotes. The sample program
regenerates a given zero curve every few seconds using the latest real-time quotes.
Create a class that implements the com.calypso.tk.marketdata.FeedListener interface. The key
method is the newQuote() method which is invoked whenever a real-time quote is available.
Tip
Before running the program, ensure that you have the proper real-time feed configuration in the
system. Refer to Calypso Market Data Server documentation for information on setting up a real-time
feed.
10.1.3How to Connect to a Custom Feed Source
Calypso provides an API to extend the system to support any real-time feed source. The following
example demonstrates how to connect to a real-time feed source.
Overview of Steps
• Step 1 — Create a FeedHandler
• Step 2 — Register the new FeedHandler
Step 1 — Creating a FeedHandler.
Create a class named tk.marketdata.<feed_name>FeedHandler that extends
com.calypso.tk.marketdata.FeedHandler.
The FeedHandler is responsible for creating a physical connection to the real-time feed and providing
a mapping between Calypso quote names and feed quote names based on the Feed Address Config.
<feed_name>FeedHandler is invoked from com.calypso.tk.marketdata.FeedHandler.
Step 2 — Registering the new FeedHandler.
The feed must first be registered with the system before it can be used. To do so, add the feed name
to the “feedType” domain.
Then, you must configure the feed:
» Specify connection parameters using Configuration > Market Data > Feed Configuration from
the Calypso Navigator as shown in the example below. Check Is Default if you wish to use this
feed as the default feed.
» Map Calypso quote names to the feed’s quote names using Configuration > Market Data >
Feed Address Mapping from the Calypso Navigator as shown in the example below.
Refer to the Calypso Market Data Server documentation for information on setting up a real-time feed.
|
|
How to Use Quotes | 10.1.1How 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 illustrates 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
|
|
How to Subscribe to Real-time Quotes | 10.1.2How to Subscribe to Real-time Quotes
The following example illustrates how to subscribe to real-time quotes. The sample program
regenerates a given zero curve every few seconds using the latest real-time quotes.
Create a class that implements the com.calypso.tk.marketdata.FeedListener interface. The key
method is the newQuote() method which is invoked whenever a real-time quote is available.
Tip
Before running the program, ensure that you have the proper real-time feed configuration in the
system. Refer to Calypso Market Data Server documentation for information on setting up a real-time
feed.
|
|
How to Connect to a Custom Feed Source | 10.1.3How to Connect to a Custom Feed Source
Calypso provides an API to extend the system to support any real-time feed source. The following
example demonstrates how to connect to a real-time feed source.
Overview of Steps
• Step 1 — Create a FeedHandler
• Step 2 — Register the new FeedHandler
Step 1 — Creating a FeedHandler.
Create a class named tk.marketdata.<feed_name>FeedHandler that extends
com.calypso.tk.marketdata.FeedHandler.
The FeedHandler is responsible for creating a physical connection to the real-time feed and providing
a mapping between Calypso quote names and feed quote names based on the Feed Address Config.
<feed_name>FeedHandler is invoked from com.calypso.tk.marketdata.FeedHandler.
Step 2 — Registering the new FeedHandler.
The feed must first be registered with the system before it can be used. To do so, add the feed name
to the “feedType” domain.
Then, you must configure the feed:
» Specify connection parameters using Configuration > Market Data > Feed Configuration from
the Calypso Navigator as shown in the example below. Check Is Default if you wish to use this
feed as the default feed.
» Map Calypso quote names to the feed’s quote names using Configuration > Market Data >
Feed Address Mapping from the Calypso Navigator as shown in the example below.
Refer to the Calypso Market Data Server documentation for information on setting up a real-time feed.
|
|
How to Customize Quotes from a Live Feed | 10.1.4How to Customize Quotes from a Live Feed
Calypso provides an API that allows clients to customize quotes sourced from a live feed, such as
Reuters or Bloomberg. The API allows customization of quotes, for example, in cases where quotes are
needed from a market in a different region of the world that hasn’t opened, for illiquid quotes (e.g.,
only Bid and no Ask instance is available), or quotes that are for one reason or another erroneous.
Normally, the Market Data Server looks for a hard coded RTFeedImpl implementation of RTFeed. The
environment property RT_FEED_IMPL allows for customization. Follow the steps below.
Step 1 – Create a custom class name that extends RTFeedImpl. (e.g., "tk.risk.service.TESTRTFeedImpl")
Step 2 – Regiser the class in the environment property RT_FEED_IMPL. (e.g., RT_FEED_IMPL =
"tk.risk.service.TESTRTFeedImpl")
The following example code sets the Bid and Ask quotes to the Last instance if null.
public class TESTRTFeedImpl extends RTFeedImpl {
@Override
public void newQuote(FeedHandler handler, QuoteValue qv) {
if (QuoteValue.isNull(qv.getBid()) && !QuoteValue.isNull(qv.getLast())){
qv.setBid(qv.getLast());
}
if (QuoteValue.isNull(qv.getAsk()) && !QuoteValue.isNull(qv.getLast())){
qv.setAsk(qv.getLast());
}
super.newQuote(handler, qv);
}
}
|
|
Market Data Items | 10.2 Market Data Items
|
|
How to Create a Custom Curve | 10.2.1How to Create a Custom Curve
Do the following to create a custom curve:
1. Create a class named tk.marketdata.<curve_type> that extends the abstract base class
com.calypso.tk.marketdata.Curve.
The <curve_type> class is invoked from com.calypso.tk.marketdata.Curve.
2. To make the curve persistent, create a class named tk.marketdata.sql.<curve_type>SQL
that extends the abstract base class com.calypso.tk.marketdata.sql.MarketDataItemSQL.
<curve_type>SQL is invoked from com.calypso.tk.marketdata.sql.MarketDataItemSQL.
3. If the curve is persistent, create a database table and a corresponding stored procedure for
storing the curve’s instances.
4. Register the curve in the “marketDataType” domain.
|
|
How to Populate a Curve with Quotes | 10.2.2How to Populate a Curve with Quotes
A sample program shows how to populate a curve with quotes:
samples/ImportCurveProbability.java.
|
|
How to Create a Custom Volatility Surface | 10.2.3How to Create a Custom Volatility Surface
Do the following to create a custom volatility surface:
1. Create a class named tk.marketdata.<vol_surface_type> that extends the class,
com.calypso.tk.marketdata.VolatilitySurface3D.
The <vol_surface_type> class is invoked from
com.calypso.tk.marketdata.VolatilitySurface3D.
2. To make the volatility surface persistent, create a class named
tk.marketdata.sql.<vol_surface_type>SQL that extends the abstract base class
com.calypso.tk.marketdata.sql.MarketDataItemSQL.
<vol_surface_type>SQL is invoked from
com.calypso.tk.marketdata.sql.MarketDataItemSQL.
3. If the volatility surface is persistent, create a database table and a corresponding stored
procedure for storing the volatility surface’s instances.
4. Register the volatility surface into the “marketDataType” domain.
|
|
How to make a Custom Market Data Item Available for Selection | 10.2.4How to make a Custom Market Data Item Available for Selection
You can make your market data item available in the market data selector for loading, saving and
deleting.
Create a class named apps.marketdata.<market_data_type>Selector that implements the
com.calypso.apps.marketdata.MarketDataItemSelector interface.
<market_data_type>Selector is invoked by com.calypso.apps.marketdata.MarketDataUtil.
|
|
How to Display a Custom Market Data Item | 10.2.5How to Display a Custom Market Data Item
Create a class named apps.marketdata.<market_data_type>Window that implements the interface
com.calypso.apps.marketdata.MarketDataItemViewer.
<market_data_type>Window is invoked from com.calypso.apps.marketdata.MarketDataUtil.
|
|
How to add a Custom Menu Item to a Curve Window | 10.2.6How to add a Custom Menu Item to a Curve Window
Create a class named apps.marketdata.CustomCurveMenu<name> that implements the interface
com.calypso.apps.marketdata.CustomCurveMenu.
CustomCurveMenu<name> is invoked from the Curve windows.
|
|
How to add a Custom Menu Item to the VolatilitySurface3D Window | 10.2.7How to add a Custom Menu Item to the VolatilitySurface3D Window
Create a class named apps.marketdata.CustomVolSurfaceMenu<generator_name> that implements
the interface com.calypso.apps.marketdata.CustomVolSurfaceMenu.
CustomVolSurfaceMenu<generator_name> is invoked from
com.calypso.apps.marketdata.VolatilitySurface3DWindow.
|
|
How to Create a Custom Volatility Surface Selector | 10.2.8How to Create a Custom Volatility Surface Selector
Create a class named apps.marketdata.VolatilitySurface3DSelector that implements
com.calypso.apps.marketdata.VolatilitySurface3DSelector.
It is invoked from com.calypso.apps.marketdata.VolatilitySurface3DWindow.
10.3 Curve Generation
How Curves are used in Calypso
10.3.1How to Create a Custom Curve Interpolator
Create a class named tk.core.<name> that extends the abstract base class
com.calypso.tk.core.Interpolator.
The <name> class is invoked from com.calypso.tk.marketdata.Curve.
|
|
How to Create a Custom Curve Interpolator | 10.3.1How to Create a Custom Curve Interpolator
Create a class named tk.core.<name> that extends the abstract base class
com.calypso.tk.core.Interpolator.
The <name> class is invoked from com.calypso.tk.marketdata.Curve.
|
|
How to Create a Custom Curve Generation Algorithm | 10.3.2How to Create a Custom Curve Generation Algorithm
The Calypso framework allows users to add new curve generation algorithms to the system. To allow
for maximum flexibility, the framework allows additional input and output values to be added to the
curve for curve generation. The system has built-in capabilities to save, retrieve, and display any new
input and output value required. Specifically, the system can accommodate the following extensions
for input and output values:
• Input parameters
• Adjustments to quote values
• Adjustments to curve points
There are various ways in which adjustments to curve points can be used. For example, a pricer can
use the adjustment values in pricing or a new curve point interpolator can use the adjustment values
when interpolating curve points.
In this example we will create a generation algorithm for a zero curve which will make use of the
input/output extensions. The curve generation algorithm will require alpha and beta for input
parameters, correlation for quote value adjustment, and coefficient for curve point 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 instrument by the correlation value for
the quote.
Overview of Steps
• Step 1 — Create a CurveGenerator
• Step 2 — Register the new CurveGenerator
• Step 3 – Create a CurveGeneratorGuiUtil to display the custom curve parameters if any
Step 1 — Creating a CurveGenerator.
Create a class named tk.marketdata.CurveGenerator<name> which extends the abstract base class
com.calypso.tk.marketdata.CurveGenerator.
[NOTE: For zero curves, the CurveGenerator class should extend
com.calypso.tk.marketdata.CurveGeneratorZero]
The usesQuoteAdjustment() method allows a curve generator to specify whether or not to display
adjustment columns. The curve window does not display adjustment columns if the method returns
false. The method returns true by default.
The notifyChange() method will regenerate the curve if the underlying has changed.
CurveGenerator<name> is invoked from com.calypso.tk.marketdata.Curve.
Step 2 — Registering the new CurveGenerator.
To register the new CurveGenerator, click the button next to the Generation Alg field in the Curve
window where you want this CurveGenerator, then add the CurveGenerator in the Add Domain
window, as shown below.
The new CurveGenerator will be available for selection.
When the curve is generated, the output contains the point adjustment coefficient under the Points
panel of the Curve Window as applicable.
Step 3 – Create a CurveGeneratorGuiUtil.
Create a class named apps.marketdata.CurveGenerator<name>GUIUtil that implements
com.calypso.apps.marketdata.CurveGeneratorGuiUtil.
The input parameters will appear under the Quotes panel of the Curve Window as applicable.
|
|
How to Make Generator Parameters Persistent | 10.3.3How to Make Generator Parameters Persistent
Create a class named tk.marketdata.sql.CurveGenerator<name>SQL that implements
com.calypso.tk.marketdata.sql.CurveGeneratorSQL.
CurveGenerator<name>SQL is invoked from com.calypso.tk.marketdata.sql.CurveSQL.
|
|
How to Display Generator Parameters in a Popup Window | 10.3.4How to Display Generator Parameters in a Popup Window
[NOTE: This also applies to generator parameters for volatility surface]
The user can launch a GeneratorParameter window by double-clicking in the Parameters table of the
Curve window or Volatility Surface window under the Quotes panel.
Create a class named apps.marketdata.GeneratorParameter<parameter_name> that implements the
interface com.calypso.apps.marketdata.GeneratorParameter.
GeneratorParameter<parameter_name> is invoked from
com.calypso.apps.marketdata.GeneratorParameterUtil.
|
|
How to Create a Custom Curve Underlying Instrument | 10.3.5How to Create a Custom Curve Underlying Instrument
Do the following to create a custom curve underlying instrument:
1. Create a class named tk.marketdata.CurveUnderlying<instrument_type> that extends
the abstract base class com.calypso.tk.marketdata.CurveUnderlying.
CurveUnderlying<instrument_type> is invoked from
com.calypso.tk.marketdata.CurveUnderlying.
2. To make the curve underlying instrument persistent, create a class named
tk.marketdata.sql.CurveUnderlying<instrument_type>SQL that extends the class
com.calypso.tk.marketdata.CUSQL.
CurveUnderlying<instrument_type>SQL will be invoked from
com.calypso.tk.marketdata.sql.CurveUnderlyingSQL.
3. Register the new curve underlying instrument in the “CustomCurveUnderlying” domain.
|
|
How to Display a Custom Curve Underlying Instrument | 10.3.6How to Display a Custom Curve Underlying Instrument
Create a class named apps.marketdata.CU<instrument_type>Panel which implements the interface
com.calypso.apps.marketdata.CUPanel.
CU<instrument_type>Panel is invoked from com.calypso.apps.marketdata.CUWindow, which displays
a panel for the new curve underlying instrument.
|
|
How to use a Custom Curve Underlying Instrument | 10.3.7How to use a Custom Curve Underlying Instrument
Contact Help Desk for an example of using a custom curve underlying instrument for curve generation.
10.4 Volatility Surface Generation
How Volatility Surfaces are used
10.4.1How to Create a Custom Volatility Surface Interpolator
Create a class named tk.core.<interpolator_name> which extends the abstract base class
com.calypso.tk.core.Interpolator3D.
The <interpolator_name> class is invoked from com.calypso.tk.marketdata.MarketDataSurface
and com.calypso.tk.marketdata.VolatilitySurface3D.
|
|
How to Create a Custom Volatility Surface Interpolator | 10.4.1How to Create a Custom Volatility Surface Interpolator
Create a class named tk.core.<interpolator_name> which extends the abstract base class
com.calypso.tk.core.Interpolator3D.
The <interpolator_name> class is invoked from com.calypso.tk.marketdata.MarketDataSurface
and com.calypso.tk.marketdata.VolatilitySurface3D.
|
|
How to Create a Custom Volatility Surface Generation Algorithm | 10.4.2How to Create a Custom Volatility Surface Generation Algorithm
Overview of Steps
• Step 1 — Create a VolSurfaceGenerator
• Step 2 — Register the new VolSurfaceGenerator
Step 1 — Creating a VolSurfaceGenerator.
Create a class named tk.marketdata.VolSurfaceGen<name> that extends the abstract base class
com.calypso.tk.marketdata.VolSurfaceGenerator.
VolSurfaceGen<name> is invoked from com.calypso.tk.marketdata.MarketDataSurface and
com.calypso.tk.marketdata.VolatilitySurface3D.
Step 2 — Registering the New VolSurfaceGenerator.
To register the new VolSurfaceGenerator, click the ... button next to the Generation field in the
Volatility Surface window where you want this VolSurfaceGenerator, and add the VolSurfaceGenerator
in the Add Domain window as shown below.
The new VolSurfaceGenerator will be available for selection.
Note that for FX volatility surface generators, derived generators are registered in the domain
“FXVolSurfaceGenerator,” and simple generators are registered in the domain
“FXVolSurface.gensimple.”
|
|
How to Make Generator Parameters Persistent | 10.4.3How to Make Generator Parameters Persistent
Create a class named tk.marketdata.sql.VolSurfaceGenerator<name>SQL that implements
com.calypso.tk.marketdata.sql.VolSurfaceGeneratorSQL.
VolSurfaceGenerator<name>SQL is invoked from
com.calypso.tk.marketdata.sql.VolatilitySurface3DSQL.
Sample Code in calypsox/tk/marketdata/
VSGenCapCurveData.java
|
|
How to Display Generator Parameters in a Popup Window | 10.4.4How to Display Generator Parameters in a Popup Window
See “How to Display Generator Parameters in a Popup Window."
|
|
How to Create a Custom Volatility Surface Underlying Instrument | 10.4.5How to Create a Custom Volatility Surface Underlying Instrument
Do the following for creating a custom volatility surface underlying instrument:
1. Create a class named tk.marketdata.VolSurfaceUnderlying<instrument_type> that
extends the abstract base class com.calypso.tk.marketdata.VolSurfaceUnderlying.
VolSurfaceUnderlying<instrument_type> is invoked from
com.calypso.tk.marketdata.VolSurfaceUnderlying.
2. To make the volatility surface underlying instrument persistent, create a class named
tk.marketdata.sql.VolSurfaceUnderlying<instrument_type>SQL that extends the class
com.calypso.tk.marketdata.sql.VolUSQL.
VolSurfaceUnderlying<instrument_type>SQL is invoked from
com.calypso.tk.marketdata.sql.VolSurfaceUnderlyingSQL.
3. Register the new volatility surface underlying instrument in the
“CustomVolSurfaceUnderlying” domain.
Sample Code in calypsox/tk/marketdata/
VolSurfaceUnderlying sample:
VolSurfaceUnderlyingDEMO_P2.java
|
|
How to Display a Custom Volatility Surface Underlying Instrument | 10.4.6How to Display a Custom Volatility Surface Underlying Instrument
Create a class named apps.marketdata.VolUnderlying<instrument_type>Panel that implements
the interface com.calypso.apps.marketdata.VolUnderlyingPanel.
VolUnderlying<instrument_type>Panel is invoked from
com.calypso.apps.marketdata.VolUnderlyingWindow, which displays a panel for the new volatility
surface underlying instrument.
Sample Code in calypsox/apps/marketdata/
VolUnderlyingDEMO_P2Panel.java
|
|
How to Create a Custom Volatility Type | 10.4.7How to Create a Custom Volatility Type
Create a class named tk.marketdata.VolatilityType<name> that implements
com.calypso.tk.marketdata.VolatilityType.
VolatilityType<name> is invoked from com.calypso.tk.marketdata.VolatilityType.
|
|
How to Create a Custom Correlation Type | 10.4.8How to Create a Custom Correlation Type
Create a class named tk.marketdata.CorrelationType<name> that extends the abstract base class
com.calypso.tk.marketdata.CorrelationType.
CorrelationType<name> is invoked from com.calypso.tk.marketdata.CorrelationType.
|
|
How to Create Custom Selection Criteria for Filter Sets | 10.4.9How to Create Custom Selection Criteria for Filter Sets
Create a class named tk.marketdata.CustomFilter that implements the interface
com.calypso.tk.marketdata.CustomFilterInterface.
This class will be invoked from com.calypso.tk.marketdata.FilterElement.
|
|
How to Store Underlying Market Data with a Volatility Surface | 10.4.10 How to Store Underlying Market Data with a Volatility Surface
Write a custom generator which implements the methods getMDIParameterNames and
getMDIParameterType(String s).
Restart the Calypso Navigator and, in the Volatility Surface window, register the custom generator by
clicking the ... button next to the Generation field in the Volatility Surface window where you want this
generator, and add MDI in the Add Domain window:
|
|
Pricer Configuration | 10.5 Pricer Configuration
How to Extend the Pricer Config Custom Panel
Create a class named tk.product.<product_type>MDataSelector that implements the interface
com.calypso.tk.product.ProductMDataSelector.
<product_type>MDataSelector is invoked from
com.calypso.apps.marketdata.PCProductSpecificMDPanel2.
|
|
Trade Object | 11.1 Trade Object
The trade object references five other objects: the trading book, the bundle the trade belongs to (if
any), the counterparty to the trade, the exchange the product is traded on (if any), and the product
being traded. There are some aspects to every trade and are common across all products, these
details are left on the trade object itself.
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.
These common trade details make up the common components of a trade screen shared across
products. The example below is of a CDS Index trade screen:
|
|
Product Object | 11.2 Product Object
A financial product is any instrument that can be traded. This includes contracts that are traded
multiple times, such as bonds, futures contracts, 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 subclass of the Product class must
override its abstract methods.
|
|
Abstract Methods | 11.2.1Abstract Methods
The product object has four abstract methods to be overwritten: getPrincipal(), getProductClass(),
getProductFamily(), and hasSecondaryMarket(). The first method returns the principal or notional of
the product being traded. The second two methods getProductClass() and getProductFamily() simply
return Strings of the type of product and product family this product belongs to. The last method
returns a Boolean indicating whether or not this product is multiply traded or not. A return value of
false would indicate that this instrument is a one-off deal like an interest rate swap or cap.
|
|
Public Methods | 11.2.2Public Methods
There are several methods already available to any product extending the Product class. Some should
be overridden if such a method makes sense for your product and a few methods shouldn’t be
overridden as it may interfere with the functionality of the system. In addition to these methods, there
are several interfaces which when implemented will add functionality to certain categories of products.
These interfaces are covered in the next section.
The methods that shouldn’t be overridden in the Product class are the getName() and getType()
methods. These methods are used internally for referring to this object. The getName() method will
call the getDescription() method (which should be overridden) and the getType() returns the class
name.
The other methods in the Product class should be overridden only if it makes sense for your particular
product. One method that should always be overridden is the getDescription() method. This returns a
String that describes the product being traded along with its relevant details. A good description
would contain the more salient details of the product.
More methods that might make sense to override for a given product are: getCurrency(), getPutCall(),
getStrike(), getMaturityDate(), getRateIndex(), getSubType(), and the cash flow generation methods
generateFlows(), and calculate().
|
|
Cashflows | 11.2.3Cashflows
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 created all known data such as saved quotes will be
filled in by the calculate(CashFlowSet, PricingEnv, JDate) method on the product.
|
|
Product Interfaces | 11.3 Product Interfaces
There are many public interfaces in the package com.calypso.tk.product available for use in the
product objects. Each interface models a specific characteristic in a financial derivative. A sample of
available interfaces is listed below.
Product Interface Description
CallablePuttable All products having optionality should implement this interface.
CashFlowGenerationBased All products that require cash flow generation must implement
this interface. This interface is used by the CashFlowGenerator for
cash flow generation.
CollateralBased All products that have collaterals must implement this interface.
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 interface.
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.
Product Interface Description
RateResetBased All products that must handle special actions during a change in
the rate reset must implement this interface.
SpecificResetBased To handle specific resets, a product implements the
SpecificResetBased interface. This interface requires the
implementation of the method getSpecificResets(), which returns
a vector of ProductReset.
The pricers use the vector of ProductReset to calculate cashflows
known interest amounts.
|
|
Writing a New Product | 11.4 Writing a New Product
Writing a new product amounts to extending the Product class, implementing any required interfaces,
and defining any necessary variables specific to the product. Choose which methods to override from
the Product class and create getters and setters for the new variables.
[NOTE: This document only covers the creation of a new Product to allow trade capture.
Please contact Calypso Professional Services for handling cross asset reporting and back
office functions for custom products]
Example: Weather Derivatives
Weather derivatives are financial instruments that can be used by organizations or individuals as part
of a risk management strategy to reduce risk associated with adverse or unexpected weather
conditions. The difference from other derivatives is that the underlying asset (rain/temperature/snow)
has no direct value to price the weather derivative. Farmers can use weather derivatives to hedge
against poor harvests caused by drought or frost; theme parks may want to insure against rainy
weekends during peak summer seasons; and gas and power companies may use heating degree days
(HDD) or cooling degree days (CDD) contracts to smooth earnings.
Heating Degree Days/Cooling Degree Days are one of the most common types of weather derivative.
Typical terms for an HDD contract would be: for the November to March period, for each day where
the temperature falls below 18 degrees Celsius (or 65 degrees Fahrenheit) keep a cumulative count.
Depending upon whether the option is a put option or a call option, pay out a set amount per heating
degree day that the actual count differs from the strike (usually $20 per unit).
As an example, suppose we have purchased a thirty day HDD contract at 65 degrees Fahrenheit.
During those thirty days each day average temperature is 50 degrees Fahrenheit. Then at the end of
the thirty day term we are entitled to a payout of (15 * 30) $20 = $9,000.
There is no Weather Derivative product currently in Calypso, so if we were to make one we would
need the following variables: a Start Date, End Date, the strike Temperature, a toggle whether this
temperature is in Celsius or Fahrenheit, also a toggle to indicate whether or not this is an HDD or CDD
contract, and the location the temperature is to be measured from. In addition we will make the payout
equal to the notional times the number heating or cooling units so we will need a variable for the
notional and the currency of the notional.
The following section contains an outline to create this product in Calypso.
Write a New Product
Create the necessary variables and methods.
Step 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
Step 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.
Step 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.
Step 4 - Override the getDescription() method from the Product class. Create a custom String to return
a descriptive combination of the variables on the product.
Example:
CDD.50 F.San Francisco.12/19/2006-01/08/2007
11.5 Persistence
How persistence is used
11.5.1Extending the Data Model
All products, whether they are multiply-traded or singly-traded, have their own table in the database
with the prefix “product_”.
You must create a new table to store the variables on the new product. Every product table must have
a product_id column that is set to the primary key for this table.
Example: Heating Degree Days/Cooling Degree Days
In the case of our Heating Degree Days/Cooling Degree Days we created create a new product table
and named it product_hdd_cdd. The new table stores the variables we created in our product, along
with the Product ID to identify this product. Those variables are Product ID (always), Start Date, End
Date, Notional, Currency, Temperature, Fahrenheit boolean, HDD boolean, and Location.
These columns should have the appropriate type: int, datetime, double precision, char, bit, etc. and all
should be NOT NULL. The following exercise is an SQL sample of adding this table to a Sybase
database.
Add a Product Table to the Database
Use Execute SQL to Add a Table to Your Database.
Step 1 – Run the Execute SQL 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))
Step 2 – Click Execute.
Step 3 - Verify that the table has been created by executing the following SQL statement:
SELECT * FROM product_hdd_cdd
|
|
Extending the Data Model | 11.5.1Extending the Data Model
All products, whether they are multiply-traded or singly-traded, have their own table in the database
with the prefix “product_”.
You must create a new table to store the variables on the new product. Every product table must have
a product_id column that is set to the primary key for this table.
Example: Heating Degree Days/Cooling Degree Days
In the case of our Heating Degree Days/Cooling Degree Days we created create a new product table
and named it product_hdd_cdd. The new table stores the variables we created in our product, along
with the Product ID to identify this product. Those variables are Product ID (always), Start Date, End
Date, Notional, Currency, Temperature, Fahrenheit boolean, HDD boolean, and Location.
These columns should have the appropriate type: int, datetime, double precision, char, bit, etc. and all
should be NOT NULL. The following exercise is an SQL sample of adding this table to a Sybase
database.
Add a Product Table to the Database
Use Execute SQL to Add a Table to Your Database.
Step 1 – Run the Execute SQL 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))
Step 2 – Click Execute.
Step 3 - Verify that the table has been created by executing the following SQL statement:
SELECT * FROM product_hdd_cdd
|
|
Writing a Persistence Class | 11.5.2Writing a Persistence Class
Each new product needs a matching SQL class to persist it into the database. The SQL class follows the
naming convention of <product_name>SQL and extends the ProductSQL class. Any class that extends
the SQL class must implement the insert(), remove(), save(), and getAll() methods in the ProductSQL
class.
Sample Code
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.
SQL Object Persistor
To safely handle the task of persisting objects in the database, utility methods have been written to
handle these tasks properly. This is achieved by creating a private class within the <product>SQL class
that extends from the SQLObjectPersistor class. There are two methods which perform complementary
functions: one creates a Calypso product from the database and the other sets database parameters
from the Calypso product. The order of these parameters is dictated by a prepared SQL statement
defined as a static String.
Sample Code
The SQLObjectPersistor has its own useful methods for reading, updating, and saving to the database:
listFromDB(), saveTODB(), and updateDB() which all take a connection to the database and an SQL
statement as parameters.
Example: Heating Degree Days/Cooling Degree Days
In the running example of the Heating Degree Days/Cooling Degree Days, we must write SQL
statements to read from and write to the product_hdd_cdd database table. Making use of the
SQLObjectPersistor class, we must complete the prepared statements SELECT, INSERT, UPDATE, and
DELETE. Then, describe how to build the object from a result set or create a result set from the product
object.
Because we must also modify the product_desc table, we use the methods saveDescription() and
updateDescription() of the ProductSQL class. After constructing the appropriate prepared SQL
statement, call either listFromDB(), saveToDB(), or updateDB() methods.
Write a Persistence Class
Step 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
Step 2 – Create the prepared SQL INSERT statement using the exact same order of items as in the
SELECT statement above.
For example:
INSERT INTO product_hdd_cdd (start_date, … etc. …, product_id) VALUES
(?,?,?,?,?,?,?,?,?)
Step 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=?
Step 4 – The buildObjectFromResultSet(JResultSet) method constructs the HDDCDD product from the
result set. The items in the result set will be returned in the exact order of the SELECT statement in Step
1.
The ResultSet has get methods for each Calypso data type to return the necessary data type for the
product.
For example:
int j = 1;
ref.setStartDate(rs.getJDate(j++)); ref.setMaturityDate(rs.getJDate(j++));
ref.setNotional(rs.getDouble(j++));
Step 5 – The setParametersFromObject(Object, PreparedStatement) method sets the parameters for
the prepared statement from the variables of the product object. The setParameter() method is used to
set each parameter one by one. It is overloaded to take multiple Java data types.
For example
int j = 1;
setParameter(st, ref.getStartDate(), j++); setParameter(st, ref.getMaturityDate(),
j++); setParameter(st, ref.getNotional(), j++);
|
|
Trade Window | 11.6 Trade Window
Product Panel
The final step in adding a new product is to create a window to display the data. In the Calypso trade
window, only one panel contains the product details and this component is the only class that must be
written.
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 constructor from its public
constructor.
2. Second, add this class to the Calypso Navigator using Utilities > Main Entry Customizer
and add a menu item for action trading.Trade<product_type>Window to the Trade sub-
menu.
3. Finally, create a class named apps.trading.<product_type>TradeProductPanel that
implements the TradeProductPanel interface.
Public Methods
The main methods in the TradeProductPanel are buildTrade(), newTrade(), setDefaults(), and
showTrade(). These methods are responsible for creating new trade display, setting the default fields,
synchronizing the trade object with what is displayed, and conversely synchronizing the display with a
loaded trade and product object.
The other responsibility of this class is to paint the necessary components displayed to the user.
Example: Heating Degree Days/Cooling Degree Days
In the Trade Window for the Heating Degree Days/Cooling Degree Days, we must write the GUI.
Ensure that all of the variables created on our product can be set and displayed through the GUI.
Once all the necessary components have been created: Buy/Sell, HDD/ CDD, Notional, Start Date, End
Date, Strike, Fahrenheit/Celsius, and Location, the buildTrade() add showTrade() methods can then be
used to synch the display with the product object.
Add a Product Container to the Trade Window
Create the necessary fields
Step 1 - Create a CalypsoComboBox for Buy/Sell, HDD/CDD, temperature degree units, and the
currency selection.
Step 2 - Create a JLabel for the Notional, Start Date, End Date, Strike, and Location.
Step 3 - Create a JTextField for the Notional, Start Date, End Date, Strike, and Location.
Define the Layout
Step 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,
SwingConstants.RIGHT).
Step 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 6 –Add to this product container each of the components defined in the previous steps.
Complete the Constructor and initDomains()
Step 7 – Next, call initDomains() from within the Constructor.
Step 8 – In the initDomains() method: Use the AppUtil to add Choice, Date, and Number listeners. For
the End Date use the method addDateListener(JTextField, JTextField startDate) – This allows such
keyboard shortcuts for the end date as “10d” or “3m” which will compute 10 days or 3 months from the
start date, respectively.
newTrade() and setDefaults()
Step 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.
Step 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 preferred currency, and use AppUtil.showFavoriteCcy() to set the currency choice.
showTrade() and buildTrade()
Step 11 – showTrade(Trade) and buildTrade(Trade) perform opposite actions. The showTrade() method
synchronizes 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.
Step 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().
Step 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.
Add the Trade Window to the Calypso Navigator
Step 1 – Make sure that all the classes HDDCDD.java, HDDCDDSQL.java,
HDDCDDTradeProductPanel.java, TradeHDDCDDWindow.java have all been compiled into the correct
directory and the product table has been added to the database.
Step 2 – From the Calypso Navigator, navigate to Utilities > Main Entry Customizer to bring up the
MainEntry Customizer window. Under the Trade menu, create a new menu “Weather Derivatives”.
Then under the sub-menu “Weather Derivatives”, create a new menu item called HDD / CDD with the
action trading.TradeHDDCDDWindow. This will launch the Heating Degree Days/Cooling Degree Days
screen.
Step 3 – Click Save and restart the Calypso Navigator. Select the new item from the menu and you
should see something similar to the following.
You should see a warning message similar to the one below as the window tries to find a default pricer
for this product named PricerHDDCDD and cannot t find one. This warning will go away once a pricer
is assigned.
|
|
How to Validate Security Codes for Custom Products | 11.7 How to Validate Security Codes for Custom Products
Call Product.checkSecConstraints() on the server side or RemoteProduct.checkSecConstraints() on the
client side, to validate the security codes prior to saving. This will return a vector of error messages if
any.
|
|
How to Customize Structured Products | 11.8 How to Customize Structured Products
|
|
Creating a Custom Structured Product | 11.8.1Creating a Custom Structured Product
Structured Product allows new product types that are composed of individual products to be added to
the system in a timely manner. A Structured Product is treated as a single trade by the system. For
instance, a risk report will show a structured product trade as a single trade and the back office will
produce a single confirmation.
In this sample, we will add a butterfly cap, which is composed of one long cap at strike x, two short
caps at strike y and one long cap at strike z with x < y < z. The notional of all the caps should be of the
same amount. The trade entry validation sample code will check that the notional amount in all the
component caps are equal and will issue a warning if the validation fails. The entry validation is
performed before a structured product trade is saved.
Do the following for creating a custom structured product:
1. Register the new Structured Product type in the “StructuredProduct.subtype” domain.
2. Structure the product using Trade > Structured Product from the Calypso Navigator.
Select ButterflyCap from the Type field. Create a butterfly cap structure by adding two long
caps and two short caps.
|
|
Customizing Validation by Product Subtype | 11.8.2Customizing Validation by Product Subtype
You can customize the structured product validation by product subtype. Create a class named
tk.product.StructuredProduct<product_subtype>Constraint that implements
com.calypso.tk.product.StructuredProductConstraint.
Sample Code in calypsox/tk/product/
StructuredProductCorridorCapConstraint.java
|
|
Adding Custom Exotic Functions to the Formula Editor | 11.9 Adding Custom Exotic Functions to the Formula Editor
To create a custom exotic function for use in the Formula Editor, create a class named
tk.product.eXSP.functionI.XFX<function_name> (where <function_name> is the name of your
choice) that implements com.calypso.tk.product.eXSP.function.ExoticFunction, and extends
com.calypso.tk.product.eXSP.functionI.ExoticFunctionI.
At a minimum, your class should implement the following methods:
performCompute(eXSPComputeEnvironment, Vector, CashFlowPeriod, CashFlowPeriod) and
parse(eXSPComputeEnvironment, String).
The name to be registered in the domain “ExoticFunction” is the name defined for the variable
XFUNC_NAME. In the sample, it is "xtest".
private static String XFUNC_NAME = "xtest";
|
|
Customizing Existing Products | 11.10 Customizing Existing Products
|
|
Creating Custom Attributes | 11.10.1 Creating Custom Attributes
Do the following for creating custom attributes for a product:
1. Create a class named tk.product.<custom_data_class_name> which contains all of your
additional attributes and which implements the interface
com.calypso.tk.core.ProductCustomData.
2. To make the custom attributes persistent, create a class named
tk.product.sql.<custom_data_class_name>SQL which extends the abstract base class
com.calypso.tk.core.sql.ProductCustomDataSQL.
<custom_data_class_name>SQL is invoked from com.calypso.tk.core.sql.ProductSQL.
|
|
Creating a Custom Trade Decomposition Routine | 11.10.2 Creating a Custom Trade Decomposition Routine
For example, you want to decompose a complex trade into more than one basic trade so that risk,
positions, etc. can be computed on the basic trades.
Create a class named tk.mo.<product_type>Explode which implements the interface
com.calypso.tk.mo.TradeExplode.
Implement the explode() method.
<product_type>Explode is invoked from com.calypso.tk.mo.TradeExplode.
|
|
Creating a Custom Retrieval Routine for a Product | 11.10.3 Creating a Custom Retrieval Routine for a Product
For example, you may wish to import a bond from another system when a user enters its CUSIP in a
trade.
Create a class named tk.product.sql.CustomProductFinder which extends
com.calypso.tk.core.sql.ProductFinder.
This class will be invoked from com.calypso.tk.core.sql.ProductSQL when retrieving a product.
|
|
Creating a Custom Product Code Provider | 11.10.4 Creating a Custom Product Code Provider
You can add a Product Code provider for a given product type and product sub-type as needed.
Create a class that implements com.calypso.tk.product.util.SecCodeProviderI and provide an
implementation of setSecCode(Product).
Then register the custom class using SecCodeProviderFactory.registerSecCodeProvider(String
productType, String productSubType, SecCodeProviderI provider).
|
|
Applying Custom Validation to a Product | 11.10.5 Applying Custom Validation to a Product
Create a class using one of the following names,
tk.product.<product_type><product_subtype>ProductValidator,
tk.product.<product_type>ProductValidator, tk.product.<product_family>ProductValidator,
or tk.product.DefaultProductValidator, which extends the class
com.calypso.tk.product.ProductValidator.
The following methods should be implemented:
• isValidInput() — Returns true or false depending upon whether validation succeeds or fails.
• applyDefaults() — Sets default values for the product if not already set, for instance holidays.
Method called before a Trade is saved if validation succeeds.
product*.ProductValidator is invoked from com.calypso.tk.product.ProductValidatorUtil to
validate product information and to apply default values as applicable.
|
|
Creating a Custom Product Description | 11.10.6 Creating a Custom Product Description
Typically used in reports, the task station and blotters for product subtype(s) and quote names.
Create a class named tk.product.<product_type>ProductDescriptionGenerator or
tk.product.<product_family>ProductDescriptionGenerator which implements the interface
com.calypso.tk.core.ProductDescriptionGenerator.
product*ProductDescriptionGenerator is invoked from
com.calypso.tk.core.ProductDescriptionGeneratorUtil.
|
|
Creating a Custom Spot Date Calculation | 11.10.7 Creating a Custom Spot Date Calculation
A custom spot date calculation is called from Trade windows by double-clicking the Settle Date and
from pricers where the computation of a spot date is required.
Create a class named tk.product.<product_type>SpotDateCalculator that extends the class
com.calypso.tk.product.SpotDateCalculator.
<product_type>SpotDateCalculator is invoked from
com.calypso.tk.product.SpotDateCalculatorUtil.
|
|
Creating a Custom Basket Calculation | 11.10.8 Creating a Custom Basket Calculation
Create a class named tk.product.<basket_function_name> that implements the interface
com.calypso.tk.product.BasketFunction.
The <basket_function_name> class is invoked from
com.calypso.tk.product.sql.SecurityBasketSQL.
|
Subsets and Splits