instruction
stringlengths 5
72
| input
stringclasses 1
value | output
stringlengths 22
8.46k
|
---|---|---|
Creating a Custom ObservedData | 11.10.9 Creating a Custom ObservedData
Do the following for creating a custom ObservedData:
1. Create a class named tk.product.<custom_data_class_name> that implements the
interface com.calypso.tk.product.CustomObservedData.
2. To make the ObservedData persistent, create a class named
tk.product.sql.<custom_data_class_name>SQL that extends
com.calypso.tk.product.sql.CustomObservedDataSQL.
Invoke this class from com.calypso.tk.product.sql.ObservedDataSQL.
|
|
Creating a Custom Payout Formula | 11.10.10 Creating a Custom Payout Formula
Create a class named tk.product.util.PayOutFormula<name> that extends
com.calypso.tk.product.util.PayOutFormula.
This class will be invoked from com.calypso.tk.product.util.PayOutFormula.
|
|
Customizing a Bond | 11.10.11 Customizing a Bond
Creating a Custom Bond
Create a class named tk.product.<bond_type> that extends com.calypso.tk.product.Bond.
Handling Bond Prices
Bond prices are handled in the BondPrice class (in the com.calypso.tk.core package). This class
does for bond prices what the tk.core.Amount class does for currency amounts. That is, it allows the
user to store complete information about the price, including the tick size. Such information could not
be represented in a primitive data type like a double. To support the use of BondPrice, the
tk.core.Util class now has two methods, bondPrice2String() and string2BondPrice(), to convert from
and to a BondPrice object.
When creating a new BondPrice object, you must set its tick size. Use the new method getQuoteBase()
in the Bond class to find out the tick size, and set the BondPrice’s tick size accordingly. The tick size is
the integer denominator in the fractional portion of the bond’s price (for example, 32, 64, or 100).
Creating a Custom Dialog for the Bond Product Window
A Custom Data button is available on the Bond product window. It will invoke a class that implements
CustomDataWindow.
Create a class named apps.product.BondCustomDataWindow that implements
com.calypso.apps.product.CustomDataWindow.
Invoke this class from com.calypso.apps.product.Bond.
|
|
Customizing an ETOContract | 11.10.12 Customizing an ETOContract
Creating a Custom ETOContract
Create a class named tk.product.ETO<ETO_underlying_type> that extends
com.calypso.tk.product.ETO.
|
|
Customizing a FutureContract | 11.10.13 Customizing a FutureContract
Creating a Custom FutureContract
Create a class named tk.product.Future<future_type> that extends
com.calypso.tk.product.Future.
Creating a Custom DateGenerator for a FutureContract
Create a class named tk.product.ContractDateGenerator<custom_name> that implements the
interface com.calypso.tk.product.ContractDateGenerator.
This class will be invoked from com.calypso.tk.product.FutureContract.
|
|
Customizing a FutureOptionContract | 11.10.14 Customizing a FutureOptionContract
Creating a Custom FutureOptionContract
Create a class named tk.product.FutureOption<future_option_type> that extends
com.calypso.tk.product.FutureOption.
Create a Custom DateGenerator for a FutureOptionContract
Create a class named tk.product.OptionContractDateGenerator<custom_name> that implements
the interface com.calypso.tk.product.OptionContractDateGenerator.
This class will be invoked from com.calypso.tk.product.FutureOptionContract.
Sample Code in calypsox/tk/product/
OptionContractDateGeneratorTest.java
|
|
Credit Derivatives | 11.10.15 Credit Derivatives
Some useful interfaces:
• com.calypso.tk.pricer.PricerReferenceEntity — Pricers which can calculate pricer
measures per reference entities (issuer id and seniority). Used by credit derivatives reports.
• com.calypso.tk.product.CreditRisky — Any product that may have credit risk associated
with it (such as CreditDefaultSwap, TotalReturnSwap, AssetSwap, Bond, etc.). Used by credit
derivatives reports.
• com.calypso.tk.product.CreditEventBased — Any product that can be affected by credit
events (such as CreditDefaultSwap). Used by the credit event application.
|
|
ProductChooser Window Customization | 11.11 ProductChooser Window Customization
NOTE – ProductChooser Window customization is not supported for Equity products.
|
|
Creating a Custom Panel in the ProductChooser Window | 11.11.1 Creating a Custom Panel in the ProductChooser Window
Create a class named tk.product.<product_type>ProductChooserHandler which extends
com.calypso.tk.product.ProductChooserHandler.
This class will be invoked from com.calypso.tk.product.ProductChooserHandler.
|
|
Creating a Custom ProductChooser | 11.11.2 Creating a Custom ProductChooser
Create a class named apps.product.<product_family>ProductChooser which implements
com.calypso.apps.product.ProductChooser.
This class will be invoked from com.calypso.apps.product.ProductUtil to load a list of products for
display in the ProductChooser window.
[NOTE: The Product Specific panel in the Pricer Config call ProductUtil.getChooser(), so if a
custom ProductChooser class exists, it will be invoked from the Pricer Config]
|
|
Printing a Product | 11.12 Printing a Product
Create a class named tk.product.<product_type>ProductPrint that implements
tk.product.ProductPrint.
<product_type>ProductPrint is invoked from com.calypso.tk.core.ProductPrintUtil.
|
|
How to Use Cashflows | 11.13 How to Use Cashflows
When using out-of-the-box products, cashflows are automatically generated (provided they implement
the CashFlowGeneratorBased interface).
|
|
Cashflows Generation | 11.13.1 Cashflows Generation
The Calypso system assumes that cashflows and all of their “known” attributes are generated from
contractual data, i.e. Trade and Product classes. In other words, attributes such as flow dates and
known flow amounts (for example a fixed flow, or a floating flow where the reset date is in the past)
should not depend on the pricing algorithm being used. Hence, the cashflows are generated and the
known amounts are calculated by the Product class (generateFlows() and calculate() methods). These
flows are used by the entire Calypso system including back office components, for example to
generate payments – again the assumption here being that the known payments should only depend
on contractual data and not the pricing algorithm being used. If a flow attribute which is assumed to be
part of the contractual data (such as the payment date of a swap flow) must be customized, this again is
done and saved as part of trade/product using the customized checkbox on the cashflow tab.
The Pricer’s responsibility is to calculate the values of the requested pricer measures. It can also project
valuation attributes on the cashflows, such as the projected amount of an unknown flow (for example a
floating flow where the reset date is in the future) or the survival probability used for a credit default
swap flow. In addition to all of the existing attributes on the cashflows which can be set by the pricer
(such as the projected amount, discount factor, etc.), the pricers can also add their own attributes by
implementing the getCashFlowColumnNames() and getCashFlowColumn() methods. All of these
attributes are displayed on the cashflows tab of the trade windows.
In short, the Calypso system separates the cashflow generation into two parts:
• The first part generates and sets the contractually defined attributes of the cashflows, and
• The second part sets the attributes necessary for valuation.
Creating a Custom Cashflow Calculator for a Reference Index
Create a class named tk.product.flow.<currency><index_name>Calculator or
tk.product.flow.<index_name>Calculator which implements the interface
com.calypso.tk.product.flow.IndexCalculator.
Note that <index_name> can be the value of the rate index attribute IndexCalculator.
The <index_name>.Calculator class is invoked from
com.calypso.tk.product.flow.IndexCalculatorUtil.
Creating a Custom Cashflow Generator for a Product
Create a class named tk.product.flow.CashFlow<name> that implements
com.calypso.tk.product.flow.CashFlowSimple.
CashFlow<name> is invoked from com.calypso.tk.product.sql.CashFlowSQL.
Creating a Custom Coupon Period
Create a class named tk.product.util.<product_type>PeriodGenerator,
tk.product.util.<product_family>PeriodGenerator, or
tk.product.util.CustomDefaultPeriodGenerator that implements
com.calypso.tk.product.util.CustomPeriodGenerator.
The *PeriodGenerator class is invoked from com.calypso.tk.product.util.PeriodGenerator to
calculate coupon period dates when generating the cashflows.
Creating a Compound Period
Create a class named tk.product.flow.CashFlowCompound<name> that implements
com.calypso.tk.product.flow.CashFlowCompound.
This class will be invoked from com.calypso.tk.product.sql.CashFlowCompoundSQL.
Customizing the IBOR Fallback Methodology
Create a class named tk.product.flow.CustomFdnIBORFallbackUtil that implements
com.calypso.tk.product.flow.IBORFallbackUtilI. Detailed information is provided in
IBORFallbackUtilI.
This class is not automatically instantiated. You need to provide a CustomDSConnectionInit to initialize
it.
Example:
package calypso.tk.service;
import com.calypso.tk.core.Log;
import com.calypso.tk.service.DSConnection;
import com.calypso.tk.service.DSConnectionInit;
import calypso.tk.product.flow.CustomFdnIBORFallbackUtil;
public class CustomDSConnectionInit implements DSConnectionInit {
public void init(DSConnection ds) {
Log.debug(“calypso”,”Custom DSConnection Init Called…”);
CustomFdnIBORFallbackUtil instance = new CustomFdnIBORFallbackUtil();
}
}
|
|
Cashflows Display | 11.13.2 Cashflows Display
The functionality involving columns (accessible through the GUI) is distinct from the actual generation
of cashflows by products. It is made possible via the CashFlowLayout class or possibly one of its
product-specific subclasses, for example SwapCashFlowLayout. Such a class converts a CashFlowSet
returned by the product’s getFlows() method to a table for GUI display, and allows users to edit
cashflows and lock cashflows to prevent changes.
All flows will initially be generated and calculated independent of the column configuration in
CashFlowLayout or its subclasses. However, if the values in that column have subsequently been
edited and locked, the product should contain a method that uses the appropriate CashFlowLayout
class using the static method CashFlowLayout.createCashFlowLayout(Product) to take into account the
locked flows. For example, see SwapLeg.generateAndKeepLocksFlows(), below.
public CashFlowSet generateAndKeepLocksFlows(boolean paySideB, JDate asOfDate)
throws FlowGenerationException
{
CashFlowSet flows = getFlows(); //just to make sure it is uncompressed
if (flows == null || flows.size() == 0) {
generateFlows(paySideB); return getFlows();
}
CashFlowLayout cfParser = CashFlowLayout.createCashFlowLayout("Swap");
cfParser.processCashFlows(flows,
getCouponPaymentAtEndB(),
getPrincipalActualB(),
asOfDate,
this);
long idLock = getCfGenerationLocks();
Vector colLocks = cfParser.ids2VectorNames(idLock);
cfParser.setColumnLocks(colLocks);
generateFlows(paySideB);
CashFlowSet newFlows = getFlows();
cfParser.checkBeforeApplyingLocks(newFlows);
cfParser.applyLockedValuesToCashFlows(newFlows,
getCouponPaymentAtEndB(),
getPrincipalActualB(),
this);
setFlows(newFlows);
return newFlows;
}
On the other hand, if only the cashflow generation is different for a product, but not the actual display
of the cashflows, it may be better to subclass an existing CashFlowGeneratorBase implementation, and
override the flow generation methods.
Creating a Custom Cashflow Panel
Create a class named tk.product.util.<product_type>CashFlowLayout,
tk.product.util.<product_family>CashFlowLayout, or tk.product.util.CustomCashFlowLayout
which extends the class com.calypso.tk.product.util.CashFlowLayout.
This class will be invoked from com.calypso.tk.product.util.CashFlowLayout.
You can add custom columns to a custom CashFlowLayout in the following manner:
final static public int XYZ = 999; // column id
final static public String S_XYZ = 'xyz'; // column name
For editable columns you can use the following ids: 51, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, and 64.
Editable columns ids are stored with a product to indicate which columns are locked and modified.
Thus, you have the opportunity to edit the values in the columns, provided they are editable. The
custom CashFlowLayout should implement isColumnEditable(String colName) for editable columns.
For non editable columns it is recommended to use ids 500 and above to avoid any conflict with the
base class.
Note that while a subclass and its parent cannot have overlapping column IDs, overlapping ids are
allowed across subclasses.
The parseCustomFlow() method in a custom CashFlowLayout should only parse those custom flow
fields that are not known by standard cashflow types, since the parseFlow() method in CashFlowLayout
handles parsing of the standard cashflow types.
|
|
Principal Schedule | 11.13.3 Principal Schedule
Creating a Custom Principal Schedule Generator
This could be used in conjunction with ProductCustomData to store the attributes for the generator.
Create a class named tk.product.util.PrincipalGenerator<structure_name> which implements
the interface com.calypso.tk.product.util.CustomPrincipalGenerator.
This class will be invoked from com.calypso.tk.product.util.PrincipalScheduleGenerator.
Creating a Custom Principal Schedule Window
Currently available in the swap, cap/floor, swaption and cash trade windows.
Create a class named apps.product.<structure_name>PrincipalStructureDialog which
implements the interface com.calypso.apps.product.PrincipalStructureDialog.
Creating Set and Get Amortization Parameters
To set and get amortization parameters, the following must be done.
1. Get the parameters Hashtable from the underlying product (we currently support SwapLeg
and CapFloor): cast the product appropriately and call getParams().
The returned Hashtable will be used to store and retrieve the amortization parameters.
2. To set the Start Date for example, do the following:
PrincipalScheduleGenerator.setStartDate(params, date);
where params is the previously retrieved Hashtable, and date is a JDate object representing
the start date to be stored.
3. To get the Start Date for example, do the following:
JDate date = PrincipalScheduleGenerator.getStartDate(params);
where params is the previously retrieved Hashtable.
The amortization schedule, amount, rate, frequency and daycount can be obtained from the
SwapLeg or CapFloor directly by calling get and set methods like
getAmortAmount()/setAmortAmount(amount).
|
|
How to Use Trade Keywords | 11.14 How to Use Trade Keywords
|
|
Trade Keyword Configuration | 11.14.1 Trade Keyword Configuration
The class TradeKeywordConfig allows adding a type and a searchable flag on the keywords.
In order to handle legacy keywords (encoded in DomainValues thanks to the name of the keyword or
the comment of the domain), use the BOCache API:
static public <T> TradeKeywordConfig<T> getTradeKeywordConfig(DSConnection ds, String
keywordName);
This API automatically creates a TradeKeywordConfig from the domainValue or legacy keywords and
relies on the real definition of a TradeKeywordConfig.
The Trade API allows setting a keyword using the type of the Config:
public <T> String addKeywordFromType(String keywordName, T value);
public final <T> T getKeywordAsType(Class<T> expextedType, String keywordName);
|
|
Using Trade Keywords | 11.14.2 Using Trade Keywords
The class tk.core.keyword.sql.TradeKeywordWhereClauseBuilder handles the existence of a
TradeKeywordConfig or not, and hence creates the query against the legacy trade_keyword table or
the new trade_keyword_accel table.
This class provides the following methods:
• static public String isSet(String columnName, String keywordName, Option
options);
• static public String isNotSet(String columnName, String keywordName, Option
options);
• static public String eq(String columnName, String keywordName, String
keywordValue, Option options)
• static public String ne(String columnName, String keywordName, String
keywordValue, Option options)
• static public String in(String columnName, String keywordName, List<String>
keywordValues, Option options)
• static public String notIn(String columnName, String keywordName, List<String>
keywordValues, Option options)
• static public String like(String columnName, String keywordName, String
keywordValue, Option options)
• static public String notLike(String columnName, String keywordName, String
keywordValue, Option options)
The Option is meant to select which table will be used for the query, the archive table or the live table.
TradeKeywordWhereClauseBuilder.Option.FromArchive should be used when running against the
archive table.
For Searchable TradeKeywordConfig, the query will look like:
isSet: columnName IN (SELECT trade_id from trade_keyword_accel WHERE db_column_name is
not null)
in: columnName IN (SELECT trade_id from trade_keyword_accel WHERE db_column_name in
(persistentVal1, ..., persistentValx))
For the other keywords (without a config or a non searchable keyword) the query will be like
columnName IN (SELECT trade_id from trade_keyword where keyword_name = 'keywordName')
columnName IN (SELECT trade_id from trade_keyword where keyword_name = 'keywordName'
and keyword_value in ('keywordValue1', ...., 'keywordValuen'))
|
|
How to Add Custom Attribute Types | 11.15 How to Add Custom Attribute Types
The trade keyword enrichment has introduced the possibility to create different AttributeType (like
AccountAttributeType, LegalEntityAttributeType, AMStrategyAttributeType, JDatetimeAttributeType,
…).
The different components are now managed by Spring annotations on some classes implementing
specific interfaces (AttributeType, AttributeTypeConverter, etc.).
The build of the Spring Bean managing all these compoenents is done automatically by the class
AttributeConfigManager scanning some specific packages and sub-packages (".tk.core.attribute"
and ".tk.core.keyword") with custom prefixes.
The list of custom packages to check for AttributeConfigManager can be set in the environment
property ATTRIBUTE_CONFIG_MANAGER_PACKAGES.
If not set, the system uses InstantiateUtil.getPackages to check for custom packages.
If set, the system looks in the specified packages only.
Example: ATTRIBUTE_CONFIG_MANAGER_PACKAGES = com.mybank.calypsox,com.calypso
(Make sure that you add com.calypso at the end).
If you don’t have any custom attribute types, set ATTRIBUTE_CONFIG_MANAGER_PACKAGES =
NONE.
|
|
Pricing | Section 12. Pricing
12.1 Pricing Environment
|
|
Using a Pricing Environment | 12.1.1Using a Pricing Environment
A Pricing Environment tells the system what pricers (pricing models) and market data (interest rate
curves, volatility surfaces, quotes etc.) to use to value each product. A Pricing Environment contains a
PricerConfig and a QuoteSet object. The PricerConfig specifies what Pricer to use for a product and
which market data items to use with the Pricer. The QuoteSet is a repository of quote values that are
needed for valuation and market data generation.
Sample Code in samples/
PricingEnvSample.java
Demonstrates how to price a trade given a PricingEnv.
|
|
Creating a Custom Panel for the PricerConfig Window | 12.1.2Creating a Custom Panel for the PricerConfig Window
Create a class named apps.marketdata.PCProductSpecificMDPanel that implements the interface
com.calypso.apps.marketdata.PCProductSpecificMDPanel.
This class will be invoked from com.calypso.apps.marketdata.PricerConfigWindow.
12.2 Pricer
How pricers are used
12.2.1Creating a Custom Pricer
Overview of Steps
• Step 1 — Create a Pricer
• Step 2 — Register the new Pricer
Step 1 — Create a Pricer.
Create a class named tk.pricer.Pricer<pricer_name> which extends the abstract base class
com.calypso.tk.core.Pricer.
The Pricer calculates a number of pricer measures: NPV, DELTA, etc. Note that the Calypso framework
does not limit the type or number of pricer measures that a pricing model can support.
[NOTE: If the custom Pricer uses market data specified in the Product Specific, Custom or
Credit panels of the Pricer Configuration, it must be Lazy Refresh compatible (see below for
details)]
This class will be invoked from com.calypso.tk.core.Pricer.
Sample Code in samples/cookbook/tk/pricer
PricerCapFlrDEMO.java
PricerCapFlrDEMO is a pricing model for Cap/Floor. The pricing model supports the
calculation of the following pricer measures:
− NPV returns (zero rate * volatility) at the maturity date of the cap.
− DELTA, GAMMA, THETA, VEGA, and CASH return 1, 2, 3, 4, and, 0 respectively.
Step 2 — Register the new Pricer.
Register the new pricer using Configuration > System > Add Pricer from the Calypso Navigator.
12.2.2Creating a Custom Pricer for Structured Products
In order to show proper Reset Risk report product details, you can create a custom pricer that extends
PricerStructuredProduct and implements ResetRiskItemProviderI and ResetRiskItemExplodedProviderI.
Implement public ResetRiskAnalysisDetailsI generateResetRiskDetails() and public Map<Trade,
ResetRiskData> explodeRiskDataForSubProducts() to map underlying product data to risk data.
|
|
Creating a Custom Pricer | 12.2.1Creating a Custom Pricer
Overview of Steps
• Step 1 — Create a Pricer
• Step 2 — Register the new Pricer
Step 1 — Create a Pricer.
Create a class named tk.pricer.Pricer<pricer_name> which extends the abstract base class
com.calypso.tk.core.Pricer.
The Pricer calculates a number of pricer measures: NPV, DELTA, etc. Note that the Calypso framework
does not limit the type or number of pricer measures that a pricing model can support.
[NOTE: If the custom Pricer uses market data specified in the Product Specific, Custom or
Credit panels of the Pricer Configuration, it must be Lazy Refresh compatible (see below for
details)]
This class will be invoked from com.calypso.tk.core.Pricer.
Sample Code in samples/cookbook/tk/pricer
PricerCapFlrDEMO.java
PricerCapFlrDEMO is a pricing model for Cap/Floor. The pricing model supports the
calculation of the following pricer measures:
− NPV returns (zero rate * volatility) at the maturity date of the cap.
− DELTA, GAMMA, THETA, VEGA, and CASH return 1, 2, 3, 4, and, 0 respectively.
Step 2 — Register the new Pricer.
Register the new pricer using Configuration > System > Add Pricer from the Calypso Navigator.
|
|
Creating a Custom Pricer for Structured Products | 12.2.2Creating a Custom Pricer for Structured Products
In order to show proper Reset Risk report product details, you can create a custom pricer that extends
PricerStructuredProduct and implements ResetRiskItemProviderI and ResetRiskItemExplodedProviderI.
Implement public ResetRiskAnalysisDetailsI generateResetRiskDetails() and public Map<Trade,
ResetRiskData> explodeRiskDataForSubProducts() to map underlying product data to risk data.
|
|
Making a Pricer Lazy Refresh Compatible | 12.2.3Making a Pricer Lazy Refresh Compatible
Lazy Refresh is a mode on the Pricer Configuration which improves the system performance by not
loading the market data items, only their ids. The actual market data items are loaded when requested
by an application, such as a Pricer. This is achieved by giving the list of MarketDataItem ids which are
not yet loaded to the Pricer Configuration, and refreshing the Pricer Configuration.
The Lazy Refresh mode only applies to market data specified in the Product Specific, Custom and
Credit panels of the Pricer Configuration. If a custom Pricer uses market data from these panels it
MUST be made Lazy Refresh compatible, otherwise the market data will not be loaded in Lazy Refresh
mode.
To make a Pricer compatible with the Lazy Refresh mode, you must override the following methods:
• getMarketDataItemIds(Trade trade, PricingEnv env, JDate valDate, Hashtable itemIds)
In the itemIds Hashtable provide the list of lazy refresh enabled MarketDataItem IDs required
by the Pricer that are not yet loaded as: Key=Integer (MarketDataItem id), Value=Integer
(MarketDataItem id).
• getMarketDataItemsWithoutRefresh(Trade trade, PricingEnv env, JDate valDate, Hashtable
items)
In the items Hashtable provide the list of MarketDataItems that are already loaded from the
Pricer Configuration and can be used without refreshing the Pricer Configuration as:
Key=MarketDataItem, Value=MarketDataItem.
Sample Code for Retrieving a Probability Curve
Probability curves are defined in the Credit panel of the Pricer Configuration.
public void getMarketDataItemIds(Trade trade,
PricingEnv env,
JDate valDate,
Hashtable itemIds) {
CreditDefaultSwap cds = (CreditDefaultSwap)trade.getProduct();
ReferenceEntitySingle refEntity = (ReferenceEntitySingle)cds.getReferenceEntity();
if (refEntity == null) return;
PricerConfig config = env.getPricerConfig();
Integer probCurveId = getCreditMarketDataItemId(config,
cds,
refEntity,
PricerConfig.PROBABILITY);
if (probCurveId != null) { itemIds.put(probCurveId,probCurveId);
}
}
private Integer getCreditMarketDataItemId(PricerConfig config,
CreditDefaultSwap cds,
ReferenceEntitySingle refEntity,
String usage) {
Integer itemId = null;
int tickerId = refEntity.getTickerId();
if (tickerId > 0) {
itemId = config.getCreditMarketDataItemId(usage, tickerId);
}
if (itemId != null) return itemId;
int issuerId = refEntity.getLegalEntityId();
String seniority = refEntity.getSeniority();
itemId = config.getCreditMarketDataItemId(usage, cds.getCurrency(),
issuerId,
seniority,
cds.getRestructuringType());
return itemId;
}
Sample Code for Retrieving a Dividend Curve
Dividend curves are defined in the Product Specific panel of the Pricer Configuration.
public void getMarketDataItemIds(Trade trade,
PricingEnv env,
JDate valDate,
Hashtable itemIds) {
Product equityOption = trade.getProduct();
Product underlying = getOptionUnderlying(equityOption);
PricerConfig config = env.getPricerConfig();
Integer divId =getDividendCurveId(equityOption, underlying, config);
if (divId != null) { itemIds.put(divId,divId);
}
}
protected Integer getDividendCurveId(Product option,
Product underlying,
PricerConfig config) {
if (underlying == null) return null;
return (Integer) config.getProductSpecificMDId(PricerConfig.DIVIDEND, underlying);
}
[NOTE: In Lazy Refresh mode, getProductSpecificMD() will not return the MarketDataItem,
you must use getProductSpecificMDID() instead, as shown above]
Custom Programs
If you have a custom program that must retrieve market data in Lazy Refresh mode, you must refresh
the pricer configuration to load the MarketDataItems for the MarketDataItem ids.
mdataItem = config.getProductSpecificMD(usage, pe);
if (mdataItem == null) {
Integer mdataItemId = config.getProductSpecificMDID(usage, pe);
if (mdataItemId == null) {
// the market data is really not there
// throw an exception that market data is missing
}
else {
Vector ids = new Vector(); ids.addElement(mdataItemId);
// refresh the pricer configuration config.refresh(ids, env);
mdataItem = config.getMarketDataItem(mdataItemId);
}
}
If you want to load the full pricing environment, use PricerConfig.getAllMarketDataItems(). It will load
all MarketDataItems, including market data specified in the Product Specific, Custom and Credit
panels of the Pricer Configuration.
|
|
Creating a Custom Pricing Parameter Entry Panel | 12.2.4Creating a Custom Pricing Parameter Entry Panel
Create a class which implements the interface com.calypso.apps.trading.PricerInputViewer. The
name of the class should be returned by your pricer’s getInputViewerClassName() method. By default
apps.trading.PricingJPanel will be used.
This class will be invoked from com.calypso.apps.trading.TradeViewerJFrame.
|
|
Performing a Custom Action after Pricing | 12.2.5Performing a Custom Action after Pricing
For example, you want to change the color or font of your pricing results after pricing.
Create a class named apps.trading.PricerOutputViewer<pricer_name> which implements the
interface com.calypso.apps.trading.PricerOutputViewer.
This class will be invoked from com.calypso.apps.trading.TradeWindow.
|
|
Creating a Custom Solver | 12.2.6Creating a Custom Solver
Create a class named tk.pricer.<product_family>SolveFor or
tk.pricer.<product_type>SolveFor that implements com.calypso.tk.pricer.SolveFor.
This class will be invoked from com.calypso.tk.pricer.SolveForUtil.
|
|
Creating a Custom Inflation Forecasting Method | 12.2.7Creating a Custom Inflation Forecasting Method
Create a class named tk.pricer.<currency><index_name>InflationCalculator or
tk.pricer.<index_name>InflationCalculator that implements
com.calypso.tk.pricer.InflationCalculator.
It will be invoked from com.calypso.tk.pricer.InflationUtil.
12.3 Pricer Measure
How Pricer Measures are used
12.3.1Creating a Custom Pricer Measure
A new pricer can calculate pricer measures that are not supported by the PricerMeasure class. In this
case you must create a new PricerMeasure class.
Overview of Steps
• Step 1 — Create a PricerMeasure
• Step 2 — Register the new PricerMeasure types
Step 1 — Create a Pricer Measure.
Create a class named <pricer_measure_class_name> which extends the class
com.calypso.tk.core.PricerMeasure. It is recommended to place the PricerMeasure class in the
tk.pricer package but it is not mandatory.
Overwrite the following methods:
• getName()
• toString()
• toInt()
• getDisplayClass()
• isAdditive()
− calculate() — This method should be implemented if a given pricer measure type is applicable
for all pricers across all product types. All existing pricers will invoke this method when a new
pricer measure type is encountered.
− isImplementedByPricer()
public boolean isImplementedByPricer(Pricer pricer) { return true; }
This class will be invoked from com.calypso.tk.util.PricerMeasureUtility.
Specify a name and an id for each PricerMeasure type as shown below.
final static public int ZV_SPREAD=138; final static public int ZV_YIELD=139;
final static public String S_ZV_SPREAD="ZV_SPREAD";
final static public String S_ZV_YIELD="ZV_YIELD";
Tips
• Use an id that is greater than 1000 and less than 10,000 to avoid any conflict with Calypso
pricer measure types. You also need to check that the id isn’t already in use as there can be
some legacy pricer measures with ids greater than 1000.
• Create a single PricerMeasure class to hold all pricer measure types that are required by your
pricing models in order to centralize the information.
Step 2 — Register New Pricer Measures.
Register the PricerMeasures using Configuration > System > Add Pricer Measure from the Calypso
Navigator.
For each PricerMeasure, enter the name, its associated id and the fully qualified name of the
PricerMeasure class.
12.3.2Creating Client Data for a Pricer Measure
Create a class that implements the interface com.calypso.tk.core.PricerMeasureClientData to
specify a custom viewer for example. Your pricer creates an object of this type, and attaches it to the
PricerMeasure by calling PricerMeasure.setClientData().
|
|
Creating a Custom Pricer Measure | 12.3.1Creating a Custom Pricer Measure
A new pricer can calculate pricer measures that are not supported by the PricerMeasure class. In this
case you must create a new PricerMeasure class.
Overview of Steps
• Step 1 — Create a PricerMeasure
• Step 2 — Register the new PricerMeasure types
Step 1 — Create a Pricer Measure.
Create a class named <pricer_measure_class_name> which extends the class
com.calypso.tk.core.PricerMeasure. It is recommended to place the PricerMeasure class in the
tk.pricer package but it is not mandatory.
Overwrite the following methods:
• getName()
• toString()
• toInt()
• getDisplayClass()
• isAdditive()
− calculate() — This method should be implemented if a given pricer measure type is applicable
for all pricers across all product types. All existing pricers will invoke this method when a new
pricer measure type is encountered.
− isImplementedByPricer()
public boolean isImplementedByPricer(Pricer pricer) { return true; }
This class will be invoked from com.calypso.tk.util.PricerMeasureUtility.
Specify a name and an id for each PricerMeasure type as shown below.
final static public int ZV_SPREAD=138; final static public int ZV_YIELD=139;
final static public String S_ZV_SPREAD="ZV_SPREAD";
final static public String S_ZV_YIELD="ZV_YIELD";
Tips
• Use an id that is greater than 1000 and less than 10,000 to avoid any conflict with Calypso
pricer measure types. You also need to check that the id isn’t already in use as there can be
some legacy pricer measures with ids greater than 1000.
• Create a single PricerMeasure class to hold all pricer measure types that are required by your
pricing models in order to centralize the information.
Step 2 — Register New Pricer Measures.
Register the PricerMeasures using Configuration > System > Add Pricer Measure from the Calypso
Navigator.
For each PricerMeasure, enter the name, its associated id and the fully qualified name of the
PricerMeasure class.
|
|
Creating Client Data for a Pricer Measure | 12.3.2Creating Client Data for a Pricer Measure
Create a class that implements the interface com.calypso.tk.core.PricerMeasureClientData to
specify a custom viewer for example. Your pricer creates an object of this type, and attaches it to the
PricerMeasure by calling PricerMeasure.setClientData().
|
|
Creating a Custom Display for a Pricer Measure | 12.3.3Creating a Custom Display for a Pricer Measure
Create a class named apps.trading.PricerMeasure<viewer_name>Viewer or
apps.trading.PricerMeasure<pricer_measure_name>Viewer that extends Jdialog and implements
com.calypso.apps.trading.PricerMeasureViewer. The viewer name can be set through client data.
This class will be invoked from com.calypso.apps.trading.PricerMeasureUtil and will display a
popup window when you double-click on the PricerMeasure results. If client data has been set on this
pricer measure, it will retrieve the viewer name from the client data, otherwise, it will invoke
PricerMeasure<pricer_measure_name>Viewer.
|
|
Creating a Custom Margin Calculator | 12.3.4Creating a Custom Margin Calculator
Step 1 — Create a Margin Calculator.
Create a class named MarginCalculator<margin type name> which implements the interface
MarginCalculator.
Step 2 — Use the Margin Calculator.
Margin calculations are run using the “HistSimMargin” analysis. The parameters for a run of this
analysis include a reference to the Margin Calculator name.
In the configuration of the HistSimMargin parameter, set the parameter “Methdology” to be <margin
type name>. For example, if a calculator is named “MarginCalculatorNewMarginA”, then the
configuration will be Methdology = NewMarginA.
12.4 Pricing Sheet
How Pricing Sheets are used
12.4.1Pricing Sheet Custom Trade and Pricing Validation.
Clients may configure the Pricing Sheet to validate the list of trades being priced or saved with custom,
client provided validation methods by implementing the apps.trading.TradeListValidator
interface in one or more Java classes. These classes must be registered under a designated Domain
value in order to make them visible to the Pricing Sheet. Classes registered under the
“SaveTradeListValidator” domain will be called during the save trade operation (when the Save key is
pressed). Classes registered under the “PriceTradeListValidator” domain will be called before the
pricer is invoked (when the Price key is pressed). Multiple classes may be registered and each class will
be invoked during the appropriate operation. If one or more validators return FALSE, the invoking
operation will cease without saving any trade or invoking any pricer. The client class should provide an
error message String describing the validation failure to be displayed to the user.
public boolean isValidInput(List tradeList,
List transientMarketDataList,
PricingEnv env,
JDatetime valDatetime,
List errorMessageList);
PARAMETER TYPE DESCRIPTION
tradeList java.util.List A list of tk.core.Trade objects to be validated.
These objects are clones of each pricing sheet
leg not marked “Ignore”. As they are clones,
client code shall not modify them.
transientMarketDataList java.util.List A list of java.util.Map<String, Object> objects,
associated with their respective trades in
tradeList. The contents of each Map consist of
the transient market data items which may
have been manually entered by the Pricing
Sheet user.
env tk.marketdata.PricingEnv A clone of the PricingEnv in use by the current
Pricing Sheet. As this is a clone, client code
shall not modify the PricingEnv.
valDateTime tk.core.JDateTime The current valuation date and time in use by
the current Pricing Sheet.
errorMessageList java.util.List A list of String error messages describing any
validation failure to be displayed to the user.
12.4.2Pricing Sheet Custom Menus
Clients may extend the Pricing Sheet by writing custom functions that may be invoked through the
Pricing Sheet’s menu extensions. Two separate menu extensions are provided.
Pricing Sheet Menu
Clients may extend the Pricing Sheet’s main menu bar by writing a class which implements the
apps.pricingSheet.CustomPricingSheetMenu interface. These classes must be registered under the
“CustomPricingSheetMenu” Domain in order to make them visible to the Pricing Sheet. Two methods
must be implemented by the client class.
public String getName();
This method returns the String value that names the menu item. This will be the string shown to the
Pricing Sheet user under the “Custom” main menu bar item; therefore the name should be unique and
meaningful to the user.
public void processMenu(List tradeList,
List transientMarketDataList,
PricingEnv env,
JDatetime valDatetime);
This is the method called by the Pricing Sheet when the user selects the menu item. Clients may
implement whatever functionality they choose within this method.
PARAMETER TYPE DESCRIPTION
tradeList java.util.List A list of tk.core.Trade objects to be processed
by the client function. These objects are the
trades represented by each pricing sheet leg
not marked ‘Ignore’.
transientMarketDataList java.util.List A list of java.util.Map<String, Object> objects,
associated with their respective trades in
tradeList. The contents of each Map consist of
the transient market data items which may
have been manually entered by the Pricing
Sheet user.
env tk.marketdata.PricingEnv A clone of the PricingEnv in use by the current
Pricing Sheet. As this is a clone, client code
shall not modify the PricingEnv.
valDateTime tk.core.JDateTime The current valuation date and time in use by
the current Pricing Sheet.
Pricing Sheet Context Menu
Clients may extend the Pricing Sheet’s right-click context menu by writing a class which implements
the apps.pricingSheet.CustomPricingSheetContextMenu interface. These classes must be registered
under the “CustomPricingSheetContextMenu” Domain in order to make them visible to the Pricing
Sheet. Two methods must be implemented by the client class.
public String getName();
This method returns the String value which names the menu item. This will be the string shown to the
Pricing Sheet user in the context menu; therefore the name should be unique and meaningful to the
user.
public void processMenu(Trade trade,
Map transientMarketDataMap,
PricingEnv env,
JDatetime valDatetime);
This is the method called by the Pricing Sheet when the user selects the context menu item, Clients may
implement whatever functionality they choose within this method.
PARAMETER TYPE DESCRIPTION
Trade tk.core.Trade A Trade object to be processed by the client
function. This object is the trade represented
by the pricing sheet leg currently in context.
transientMarketDataMap java.util.Map A java.util.Map<String, Object> object
associated with the trade in context. The
contents of the Map consist of the transient
market data items which may have been
manually entered by the Pricing Sheet user.
env tk.marketdata.PricingEnv A clone of the PricingEnv in use by the
current Pricing Sheet. As this is a clone, client
code shall not modify the PricingEnv.
valDateTime tk.core.JDateTime The current valuation date and time in use by
the current Pricing Sheet.
|
|
Pricing Sheet Custom Trade and Pricing Validation | 12.4.1Pricing Sheet Custom Trade and Pricing Validation.
Clients may configure the Pricing Sheet to validate the list of trades being priced or saved with custom,
client provided validation methods by implementing the apps.trading.TradeListValidator
interface in one or more Java classes. These classes must be registered under a designated Domain
value in order to make them visible to the Pricing Sheet. Classes registered under the
“SaveTradeListValidator” domain will be called during the save trade operation (when the Save key is
pressed). Classes registered under the “PriceTradeListValidator” domain will be called before the
pricer is invoked (when the Price key is pressed). Multiple classes may be registered and each class will
be invoked during the appropriate operation. If one or more validators return FALSE, the invoking
operation will cease without saving any trade or invoking any pricer. The client class should provide an
error message String describing the validation failure to be displayed to the user.
public boolean isValidInput(List tradeList,
List transientMarketDataList,
PricingEnv env,
JDatetime valDatetime,
List errorMessageList);
PARAMETER TYPE DESCRIPTION
tradeList java.util.List A list of tk.core.Trade objects to be validated.
These objects are clones of each pricing sheet
leg not marked “Ignore”. As they are clones,
client code shall not modify them.
transientMarketDataList java.util.List A list of java.util.Map<String, Object> objects,
associated with their respective trades in
tradeList. The contents of each Map consist of
the transient market data items which may
have been manually entered by the Pricing
Sheet user.
env tk.marketdata.PricingEnv A clone of the PricingEnv in use by the current
Pricing Sheet. As this is a clone, client code
shall not modify the PricingEnv.
valDateTime tk.core.JDateTime The current valuation date and time in use by
the current Pricing Sheet.
errorMessageList java.util.List A list of String error messages describing any
validation failure to be displayed to the user.
|
|
Pricing Sheet Custom Menus | 12.4.2Pricing Sheet Custom Menus
Clients may extend the Pricing Sheet by writing custom functions that may be invoked through the
Pricing Sheet’s menu extensions. Two separate menu extensions are provided.
Pricing Sheet Menu
Clients may extend the Pricing Sheet’s main menu bar by writing a class which implements the
apps.pricingSheet.CustomPricingSheetMenu interface. These classes must be registered under the
“CustomPricingSheetMenu” Domain in order to make them visible to the Pricing Sheet. Two methods
must be implemented by the client class.
public String getName();
This method returns the String value that names the menu item. This will be the string shown to the
Pricing Sheet user under the “Custom” main menu bar item; therefore the name should be unique and
meaningful to the user.
public void processMenu(List tradeList,
List transientMarketDataList,
PricingEnv env,
JDatetime valDatetime);
This is the method called by the Pricing Sheet when the user selects the menu item. Clients may
implement whatever functionality they choose within this method.
PARAMETER TYPE DESCRIPTION
tradeList java.util.List A list of tk.core.Trade objects to be processed
by the client function. These objects are the
trades represented by each pricing sheet leg
not marked ‘Ignore’.
transientMarketDataList java.util.List A list of java.util.Map<String, Object> objects,
associated with their respective trades in
tradeList. The contents of each Map consist of
the transient market data items which may
have been manually entered by the Pricing
Sheet user.
env tk.marketdata.PricingEnv A clone of the PricingEnv in use by the current
Pricing Sheet. As this is a clone, client code
shall not modify the PricingEnv.
valDateTime tk.core.JDateTime The current valuation date and time in use by
the current Pricing Sheet.
Pricing Sheet Context Menu
Clients may extend the Pricing Sheet’s right-click context menu by writing a class which implements
the apps.pricingSheet.CustomPricingSheetContextMenu interface. These classes must be registered
under the “CustomPricingSheetContextMenu” Domain in order to make them visible to the Pricing
Sheet. Two methods must be implemented by the client class.
public String getName();
This method returns the String value which names the menu item. This will be the string shown to the
Pricing Sheet user in the context menu; therefore the name should be unique and meaningful to the
user.
public void processMenu(Trade trade,
Map transientMarketDataMap,
PricingEnv env,
JDatetime valDatetime);
This is the method called by the Pricing Sheet when the user selects the context menu item, Clients may
implement whatever functionality they choose within this method.
PARAMETER TYPE DESCRIPTION
Trade tk.core.Trade A Trade object to be processed by the client
function. This object is the trade represented
by the pricing sheet leg currently in context.
transientMarketDataMap java.util.Map A java.util.Map<String, Object> object
associated with the trade in context. The
contents of the Map consist of the transient
market data items which may have been
manually entered by the Pricing Sheet user.
env tk.marketdata.PricingEnv A clone of the PricingEnv in use by the
current Pricing Sheet. As this is a clone, client
code shall not modify the PricingEnv.
valDateTime tk.core.JDateTime The current valuation date and time in use by
the current Pricing Sheet.
|
|
Saving Bundle Attributes in Pricing Sheet Save panel | 12.4.3Saving Bundle Attributes in Pricing Sheet Save panel
Clients may have a requirement to attach contextual information to the trade bundle which can be
created by the pricing sheet. By configuring the names of bundle attributes in the domain
“TradeBundleAttributes”, the pricing sheet will give the user an opportunity to enter text into these
bundle attributes in the Save panel. A list of valid values may also be configured in the domain
“TradeBundleAttributes.attributeName”. These values will be presented for selection as a dropdown
list in the Save panel.
|
|
Trade | Section 13. Trade
13.1 Trade
Trades and their properties
13.1.1Creating Custom Trade Attributes
Do the following to create custom Trade attributes:
1. Create a class named tk.core.<custom_data_class_name> that contains all of your
additional attributes and which implements the interface
com.calypso.tk.core.TradeCustomData.
2. To make the custom data persistent, create a class named
tk.core.sql.<custom_data_class_name>SQL which extends the abstract base class
com.calypso.tk.core.sql.TradeCustomDataSQL.
This class will be invoked from com.calypso.tk.core.sql.TradeSQL.
13.1.2Creating a Custom Trade Attribute Provider
You can add a Trade Attribute provider for a given product type and product subtype as needed.
Create a class that implements com.calypso.apps.trading.TradeAttributeProviderI and provide
an implementation of setTradeAttribute(Trade trade).
Then register the custom class using
TradeAttributeProviderFactory.registerTradeAttributeProvider(String productType,
String productSubType, TradeAttributeProviderI provider).
13.1.3Applying Custom Validation to a Trade
Create a class named apps.trading.<ProductTypeCode>TradeValidator or
apps.trading.CustomTradeValidator which implements the interface
com.calypso.apps.trading.TradeValidator and extends Frame or javax.swing.Jframe.
The custom TradeValidator will apply to all product types for which a product-specific TradeValidator
is not found. Define the following methods in your TradeValidator:
• inputInfo() — Displays a Dialog that lets the user input extra data.
• isValidInput() — Checks a trade to make sure it is ready to be saved. This class will be invoked
from com.calypso.apps.trading.TradeViewerJFrame to create a popup window for users to
input extra data as applicable, and to validate the trade prior to saving.
Sample Code in calypsox/apps/trading/
StructuredProductButterflyCapTradeValidator.java
13.1.4Creating a Custom Copy and Paste Function
You can create copy and paste functions between two trades. Create a class
apps.trading.CopyTrade<from_product_type>2<to_product_type> which implements the interface
com.calypso.apps.trading.CopyTrade.
This class will be invoked from com.calypso.apps.trading.TransferableTrade.
13.1.5Creating a Custom Save As New Function
Create a class named apps.trading.CustomSaveAsNewTrade which implements the interface
com.calypso.apps.trading.SaveAsNewTrade.
This class will be invoked from com.calypso.apps.trading.TradeUtil.
13.1.6Creating a Custom Keyword Validator
Create a class named apps.trading.CustomKeywordValidator which implements the interface
com.calypso.apps.trading.KeywordValidator.
This class will be invoked from com.calypso.apps.trading.TradeViewerJFrame.
|
|
Creating Custom Trade Attributes | 13.1.1Creating Custom Trade Attributes
Do the following to create custom Trade attributes:
1. Create a class named tk.core.<custom_data_class_name> that contains all of your
additional attributes and which implements the interface
com.calypso.tk.core.TradeCustomData.
2. To make the custom data persistent, create a class named
tk.core.sql.<custom_data_class_name>SQL which extends the abstract base class
com.calypso.tk.core.sql.TradeCustomDataSQL.
This class will be invoked from com.calypso.tk.core.sql.TradeSQL.
|
|
Creating a Custom Trade Attribute Provider | 13.1.2Creating a Custom Trade Attribute Provider
You can add a Trade Attribute provider for a given product type and product subtype as needed.
Create a class that implements com.calypso.apps.trading.TradeAttributeProviderI and provide
an implementation of setTradeAttribute(Trade trade).
Then register the custom class using
TradeAttributeProviderFactory.registerTradeAttributeProvider(String productType,
String productSubType, TradeAttributeProviderI provider).
|
|
Applying Custom Validation to a Trade | 13.1.3Applying Custom Validation to a Trade
Create a class named apps.trading.<ProductTypeCode>TradeValidator or
apps.trading.CustomTradeValidator which implements the interface
com.calypso.apps.trading.TradeValidator and extends Frame or javax.swing.Jframe.
The custom TradeValidator will apply to all product types for which a product-specific TradeValidator
is not found. Define the following methods in your TradeValidator:
• inputInfo() — Displays a Dialog that lets the user input extra data.
• isValidInput() — Checks a trade to make sure it is ready to be saved. This class will be invoked
from com.calypso.apps.trading.TradeViewerJFrame to create a popup window for users to
input extra data as applicable, and to validate the trade prior to saving.
Sample Code in calypsox/apps/trading/
StructuredProductButterflyCapTradeValidator.java
|
|
Creating a Custom Copy and Paste Function | 13.1.4Creating a Custom Copy and Paste Function
You can create copy and paste functions between two trades. Create a class
apps.trading.CopyTrade<from_product_type>2<to_product_type> which implements the interface
com.calypso.apps.trading.CopyTrade.
This class will be invoked from com.calypso.apps.trading.TransferableTrade.
|
|
Creating a Custom Save As New Function | 13.1.5Creating a Custom Save As New Function
Create a class named apps.trading.CustomSaveAsNewTrade which implements the interface
com.calypso.apps.trading.SaveAsNewTrade.
This class will be invoked from com.calypso.apps.trading.TradeUtil.
|
|
Creating a Custom Keyword Validator | 13.1.6Creating a Custom Keyword Validator
Create a class named apps.trading.CustomKeywordValidator which implements the interface
com.calypso.apps.trading.KeywordValidator.
This class will be invoked from com.calypso.apps.trading.TradeViewerJFrame.
|
|
Creating a Custom Mirror Trade | 13.1.7Creating a Custom Mirror Trade
Create a class named tk.product.<product_type>MirrorHandler or
tk.product.DefaultMirrorHandler, which implements the interface
com.calypso.tk.product.MirrorHandler.
This class will be invoked from com.calypso.tk.product.MirrorHandlerUtil.
13.2 Trade Window
How the Trade Window is used
13.2.1Creating a Custom Trade Window Title
Create a class named apps.trading.<product_type>TradeWindowTitleGenerator that implements
com.calypso.apps.trading.TradeWindowTitleGenerator.
This class will be invoked from com.calypso.apps.trading.TradeWindowTitleGeneratorUtil.
13.2.2Creating Custom Default Values
Create a class named apps.trading.Trade<product_type>DefaultValues that implements
com.calypso.apps.trading.TradeDefaultValues.
This class is invoked from com.calypso.apps.trading.TradeWindowBase, and will override existing
product default values with custom values. TradeDefaultValues is not available to trade windows based
on TradeWindow.
Sample Code
package calypsox.apps.trading;
import com.calypso.tk.core.*;
import com.calypso.tk.product.*;
import com.calypso.apps.trading.*;
public class TradeCommoditySwapDefaultValues implements TradeDefaultValues {
public void setDefaultValues(Trade trade,ShowTrade w){
CommoditySwap swap = (CommoditySwap)trade.getProduct();
swap.setStartDate(JDate.getNow().addTenor(new Tenor("1Y")));
}
}
13.2.3Adding a Custom Panel to a Trade Window
Create a class named apps.trading.CustomTabTrade<product_type>Window that implements
apps.trading.CustomTabTradeWindow.
Note that _tradeDetailsPanel will call the methods buildTrade(), newTrade(), and showTrade() of the
CustomTabTradeWindow instance.
This class will be invoked from com.calypso.apps.trading.TradeWindow.
13.2.4Creating a Custom Trade Dialog
A custom trade dialog can be implemented to enter additional details for a trade. Those details can be
saved as trade keywords, therefore simplifying the trade customization.
This custom trade dialog can currently only be implemented for the Bond Front trade window and
Repo Front trade window. An Info button will appear in the Trade panel that will invoke the custom
dialog.
Create a class name apps.trading.<product_type>TradeCustomDetailsDialog or
apps.trading.TradeCustomDetailsDialog that implements
com.calypso.apps.trading.CustomDetailsDialog.
13.2.5Creating a Custom Trade Display
Only those trade windows that inherit from the TradeWindowBase class can use the
CustomViewTrade.
Create a class named apps.trading.CustomViewTrade which implements the interface
com.calypso.apps.trading.ViewTrade. The CustomViewTrade show() method is called from the
customView() method of the TradeWindow class. The customView() method is only called from the
showTrade() method of the TradeWindowBase class.
This class is invoked only by the showTrade() method of the TradeWindowBase class.
13.2.6Adding a Custom Menu Item to a Trade Window
For a specific pricer or a specific product.
Create a class named apps.trading.CustomTradeMenu<pricer_name> or
apps.trading.CustomTradeMenuProduct<product_type> which implements the interface
com.calypso.apps.trading.CustomTradeMenu.
This class will be invoked from com.calypso.apps.trading.TradeWindow.
|
|
Creating a Custom Trade Window Title | 13.2.1Creating a Custom Trade Window Title
Create a class named apps.trading.<product_type>TradeWindowTitleGenerator that implements
com.calypso.apps.trading.TradeWindowTitleGenerator.
This class will be invoked from com.calypso.apps.trading.TradeWindowTitleGeneratorUtil.
|
|
Creating Custom Default Values | 13.2.2Creating Custom Default Values
Create a class named apps.trading.Trade<product_type>DefaultValues that implements
com.calypso.apps.trading.TradeDefaultValues.
This class is invoked from com.calypso.apps.trading.TradeWindowBase, and will override existing
product default values with custom values. TradeDefaultValues is not available to trade windows based
on TradeWindow.
Sample Code
package calypsox.apps.trading;
import com.calypso.tk.core.*;
import com.calypso.tk.product.*;
import com.calypso.apps.trading.*;
public class TradeCommoditySwapDefaultValues implements TradeDefaultValues {
public void setDefaultValues(Trade trade,ShowTrade w){
CommoditySwap swap = (CommoditySwap)trade.getProduct();
swap.setStartDate(JDate.getNow().addTenor(new Tenor("1Y")));
}
}
|
|
Adding a Custom Panel to a Trade Window | 13.2.3Adding a Custom Panel to a Trade Window
Create a class named apps.trading.CustomTabTrade<product_type>Window that implements
apps.trading.CustomTabTradeWindow.
Note that _tradeDetailsPanel will call the methods buildTrade(), newTrade(), and showTrade() of the
CustomTabTradeWindow instance.
This class will be invoked from com.calypso.apps.trading.TradeWindow.
|
|
Creating a Custom Trade Dialog | 13.2.4Creating a Custom Trade Dialog
A custom trade dialog can be implemented to enter additional details for a trade. Those details can be
saved as trade keywords, therefore simplifying the trade customization.
This custom trade dialog can currently only be implemented for the Bond Front trade window and
Repo Front trade window. An Info button will appear in the Trade panel that will invoke the custom
dialog.
Create a class name apps.trading.<product_type>TradeCustomDetailsDialog or
apps.trading.TradeCustomDetailsDialog that implements
com.calypso.apps.trading.CustomDetailsDialog.
|
|
Creating a Custom Trade Display | 13.2.5Creating a Custom Trade Display
Only those trade windows that inherit from the TradeWindowBase class can use the
CustomViewTrade.
Create a class named apps.trading.CustomViewTrade which implements the interface
com.calypso.apps.trading.ViewTrade. The CustomViewTrade show() method is called from the
customView() method of the TradeWindow class. The customView() method is only called from the
showTrade() method of the TradeWindowBase class.
This class is invoked only by the showTrade() method of the TradeWindowBase class.
|
|
Adding a Custom Menu Item to a Trade Window | 13.2.6Adding a Custom Menu Item to a Trade Window
For a specific pricer or a specific product.
Create a class named apps.trading.CustomTradeMenu<pricer_name> or
apps.trading.CustomTradeMenuProduct<product_type> which implements the interface
com.calypso.apps.trading.CustomTradeMenu.
This class will be invoked from com.calypso.apps.trading.TradeWindow.
|
|
Adding Custom Callbacks to a Trade Window | 13.2.7Adding Custom Callbacks to a Trade Window
You can add callbacks before and/or after a trade is saved, removed, created, or priced, and before
the trade window is closed.
Create a class named apps.trading.CustomTradeWindowListener which implements the interface
com.calypso.apps.trading.TradeWindowListener.
This class will be invoked from com.calypso.apps.trading.TradeWindow.
|
|
Creating a Custom Warning Window | 13.2.8Creating a Custom Warning Window
Create a class named apps.trading.CustomTradeUpdate that implements the interface
com.calypso.apps.trading.TradeUpdate.
This class will be invoked from com.calypso.apps.trading.TradeWindow when a trade is modified.
|
|
Applying Custom Validation to a Trade Template | 13.2.9Applying Custom Validation to a Trade Template
Create a class named apps.trading.CustomTradeTemplateChecker that implements the interface
com.calypso.apps.trading.TradeTemplateChecker.
This class will be invoked from com.calypso.apps.trading.TradeWindow.
|
|
Creating a Custom FundingTradeHandler for AssetSwap | 13.2.10 Creating a Custom FundingTradeHandler for AssetSwap
Create a class named apps.util.CustomFundingTradeHandler which implements the interface
com.calypso.apps.util.FundingTradeHandler.
This class will be invoked from com.calypso.apps.trading.AssetSwapTradeProductPanel.
|
|
Creating a Custom CFD Execution Portfolio | 13.2.11 Creating a Custom CFD Execution Portfolio
Create a class named apps.trading.CustomCFDExecutionPortfolio that implements
com.calypso.apps.trading.CFDExecutionPortfolio.
This class will be invoked from com.calypso.apps.trading.CFDTerminationWindow.
|
|
Creating a Custom ETO Contract Selector Window | 13.2.12 Creating a Custom ETO Contract Selector Window
Create a class named apps.trading.CustomContractSelector that implements
com.calypso.apps.trading.ContractSelectorInterface.
This class will be invoked from com.calypso.apps.trading.ContractSelectorWindow.
|
|
Applying Custom Validation to CashSettleEntryWindow | 13.3 Applying Custom Validation to CashSettleEntryWindow
Create a class named apps.trading.CustomCashSettleEntryValidator that implements the
interface com.calypso.apps.trading.CashSettleEntryValidator.
This class will be invoked from com.calypso.apps.trading.CashSettleEntryWindow.
|
|
Applying Custom Validation to a Bundle | 13.4 Applying Custom Validation to a Bundle
Create a class named apps.trading.CustomBundleValidator which implements the interface
com.calypso.apps.trading.CustomBundleValidator.
This class will be invoked from com.calypso.apps.trading.TradeBundleWindow.
|
|
Creating a Custom Blotter Trade Selector | 13.5 Creating a Custom Blotter Trade Selector
Create a class named apps.trading.CustomBlotterTradeSelector which implements the interface
com.calypso.apps.trading.BlotterTradeSelector.
This class will be invoked from com.calypso.apps.trading.TradeBlotterPanel to extend the list of
tags available in the blotter under the “Add Trades” button for loading a single trade. Currently, it
contains Trade Id, Internal Ref, External Ref.
|
|
Adding Custom Menu Items to the Trade Blotter | 13.6 Adding Custom Menu Items to the Trade Blotter
You can customize the popup menu that appears when you right-click a trade.
Create a class named apps.trading.<custom window> that implements
com.calypso.apps.trading.blotter.CustomTradeBlotterMenu.
This class will be invoked from com.calypso.apps.trading.blotter.TradeBlotterTabView.
You need to register the custom class in the domain “CustomTradeBlotterMenu”.
If you register the class as <class name>$<key>, the <key> can be used as a shortcut. For example,
registering app.trading.CustomBlotterWindow$ctrlL allows to use Ctrl+L as a shortcut key to invoke
the custom window.
The interface CustomTradeBlotterMenuWithUI (which extends CustomTradeBlotterMenu) can be
implemented to display a UI in the "southern" half of the Trade Blotte. The protocol is to return a
JPanel.
Example: Panel that displays all the id's of the selected trades in random colors.
package com.calypso.apps.trading.blotter;
import java.awt.Color;
import java.util.List;
import java.util.Random;
import javax.swing.JLabel;
import javax.swing.JPanel;
import com.calypso.infra.util.Util;
import com.calypso.tk.core.JDatetime;
import com.calypso.tk.core.Trade;
public class TestMenu implements CustomTradeBlotterMenuWithUI {
@Override
public String getName() {
return "TEST_MENU";
}
@Override
public void processMenu(List<Trade> trades, String pricingEnvName, JDatetime
valDatetime) {
if (!Util.isEmpty(trades)) {
//do something if required
}
}
@Override
public JPanel getUI(List<Trade> trades, String pricingEnvName, JDatetime
valDatetime) {
JPanel panel = new JPanel();
panel.setBackground(java.awt.Color.white);
for (Trade trade : trades) {
JLabel lbl=new JLabel(Long.toString(trade.getLongId()));
lbl.setOpaque(true);
Random random = new Random();
final float hue = random.nextFloat();
final float sat = (random.nextInt(2000) + 1000) / 10000f;
final float lum = 0.8f;
final Color color = Color.getHSBColor(hue, sat, lum);
lbl.setBackground(color);
panel.add(lbl);
}
return panel;
}
}
|
|
Applying Custom Validation to a ManualLiquidation | 13.7 Applying Custom Validation to a ManualLiquidation
Create a class named apps.trading.CustomManualLiquidationValidator that implements the
interface com.calypso.apps.trading.CustomManualLiquidationValidator.
This class will be invoked from com.calypso.apps.trading.ManualLiquidationJDialog.
|
|
Creating a Custom Reference Entity Selection Window | 13.8 Creating a Custom Reference Entity Selection Window
Calypso’s selection dialog lets users specify reference entities based on existing issuers in the system,
for credit derivatives.
Create a class named apps.trading.CustomRefEntityChooser which extends the class
com.calypso.apps.trading.RefEntityChooserInterface.
|
|
Creating a Custom BO Trade Display | 13.9 Creating a Custom BO Trade Display
Create a class named apps.trading.CustomBOTradeDisplay which implements the interface
com.calypso.apps.trading.BOTradeDisplay.
This class will be invoked from com.calypso.apps.trading.BOTradeFrame.
Tips
• To override the PO SDI selection whenever the counterparty SDI is manually selected,
implement the methods getReceiverSDISelection() and getPayerSDISelection().
• You can also use the BOTradeDisplay interface to override the assignment of netting methods
for standards SDIs as well as manual SDIs by implementing the getNettingType() method.
[NOTE: These customizations will also appear in the Netting Manager, Assign, and Split
windows of the Task Station]
• The method modifyTransferRule() allows modifying the behavior of a transfer rule when it is
manually modified.
|
|
Creating a Custom Fee Calculator | 13.10 Creating a Custom Fee Calculator
Do the following to create a custom fee calculator:
1. Create a class named tk.bo.<fee_method>FeeCalculator which implements the interface
com.calypso.tk.bo.FeeCalculator. Implement the following methods:
− calculate() — Calculates the fee amount.
− calculateInverse() — Reverts the amount computed and stored on the Fee. For example, if
you have a Fee Amount of 1,000 expressed as a percentage of the notional, its purpose is
to display the initial percentage amount, 2%.
− getDescription() – Returns a fee description.
This class will be invoked from com.calypso.tk.bo.FeeDefinition.
2. Register the new fee calculator in the “feeCalculator” domain.
|
|
How to Create a Custom Allocation Process | 14.1 How to Create a Custom Allocation Process
Create a class named tk.product.<product_type>ProductAllocator which implements the interface
com.calypso.tk.product.ProductAllocator.
This class will be invoked from com.calypso.tk.product.ProductAllocatorUtil.
|
|
Creating a Custom Corporate Actions Handler | 14.2 Creating a Custom Corporate Actions Handler
Create a class named tk.product.<product_type>CorporateActionHandler,
tk.product.<product_family>CorporateActionHandler or
tk.product.DefaultCorporateActionHandler that implements
com.calypso.tk.product.CorporateActionHandler.
This class will be invoked from com.calypso.tk.product.CorporateActionHandlerUtil.
|
|
Customizing Actions for Corporate Action | 14.2.1Customizing Actions for Corporate Action
Create a class named tk.product.CustomCATradeActionLookup that implements
com.calypso.tk.product.CATradeActionLookup.
The method getTradeAction() can change the action to be selected when a corporate action is applied
or amended. The input parameters are the original action, the trade, and the CorporateAction.
It will be invoked from com.calypso.tk.product.CorporateActionHandlerUtil. It applies to both the
manual Corporate Action process, and the CORPORATE_ACTION scheduled task.
|
|
Custom Application of Corporate Actions | 14.2.2Custom Application of Corporate Actions
Create a class named tk.product.<product_type>CAOptionManager that implements
com.calypso.tk.product.CAOptionManager.
Sample Code
package calypsox.tk.product;
import com.calypso.tk.core.Defaults;
import com.calypso.tk.core.JDate;
import com.calypso.tk.core.JDatetime;
import com.calypso.tk.core.Product;
import com.calypso.tk.product.CAOption;
import com.calypso.tk.product.CAOptionManager;
import com.calypso.tk.product.Warrant;
import com.calypso.tk.service.DSConnection;
public class WarrantCAOptionManager implements CAOptionManager {
public CAOption instanciateCAOption(Product product,
JDate applicationDate,
JDatetime processDateTime,
boolean manageIssuance){
CAOption result = null;
if (product instanceof Warrant) {
Warrant warrant = (Warrant) product;
result = new CAOption();
result.setUnderlying(warrant);
result.setDeliveryType(warrant.getDeliveryType());
result.setParityDenominator(warrant.getParityDenominator());
result.setParityNumerator(warrant.getParityNumerator());
result.setExDate(applicationDate);
result.setNotificationDate(applicationDate);
result.setRecordDate(applicationDate);
result.setValueDate(warrant.getDeliveryDate(applicationDate));
result.setEnteredDatetime(processDateTime);
result.setCurrency(warrant.getCurrency());
result.setComment("CA Generated by CAOptionEntryManager");
result.setEnteredUser(DSConnection.getDefault().getUser());
if (Defaults.isAutoFeedDeliveryQuote()) {
result.setDeliveryQuote(warrant.getStrike());
}
result.setHandleIssuance(manageIssuance);
}
return result;
}
}
|
|
Exercise and Expiration | 14.3 Exercise and Expiration
|
|
Creating a Custom Exercise Process | 14.3.1Creating a Custom Exercise Process
Create a class named tk.product.<product_type>Exercisable which implements the interface
com.calypso.tk.product.Exercisable.
This class will be invoked from com.calypso.tk.product.OptionExerciseUtil.
|
|
Applying Custom Validation to the Exercise Process | 14.3.2Applying Custom Validation to the Exercise Process
Create a class named tk.product.<product_type>ExerciseValidator,
tk.product.<product_family>ExerciseValidator, or tk.product.DefaultExerciseValidator that
implements com.calypso.tk.product.ExerciseValidator.
This class is invoked from com.calypso.tk.product.OptionExerciseUtil.
|
|
Applying Custom Validation to the ETOExcerciseWindow | 14.3.3Applying Custom Validation to the ETOExcerciseWindow
Create a class named apps.reporting.CustomFutureOptionExerciseExpiryValidator that
implements the interface com.calypso.apps.reporting.FutureOptionExerciseExpiryValidator.
This class will be invoked from com.calypso.apps.reporting.ETOExerciseWindow.
|
|
Applying Custom Validation to the FutureExpiryWindow | 14.3.4Applying Custom Validation to the FutureExpiryWindow
Create a class named apps.reporting.CustomFutureExpiryValidator that implements the interface
com.calypso.apps.reporting.FutureExpiryValidator.
This class will be invoked from com.calypso.apps.reporting.FutureExpiryWindow.
|
|
Creating a Custom Price Fixing Handler | 14.4 Creating a Custom Price Fixing Handler
To perform any additional processing during price fixing — invoked from the Price Fixing window when
the user publishes the price fixings.
Create a class named apps.reporting.CustomPriceFixingHandler which implements the interface
com.calypso.apps.reporting.CustomPriceFixingHandlerInterface.
This class will be invoked from the com.calypso.apps.reporting.PriceFixingFrame to perform any
additional processing during price fixing.
|
|
Creating a Custom Rollover Process | 14.5 Creating a Custom Rollover Process
Currently, Calypso implements rollover for treasury products such as Loans and Deposits, Repos, and
FX products. The rollover process for Calypso Fixed Income products implements FIRollOver, and for
Calypso FX products ForexRollOver.
Create a class named tk.product.<product_type>RollOver which implements the interface
com.calypso.tk.product.FIRollOver or com.calypso.tk.product.ForexRollOver.
This class will be invoked from com.calypso.tk.product.RollOverUtil.
|
|
TermFrame Termination Window | 14.6 TermFrame Termination Window
The default Termination window is TermFrame. It is displayed by default for all the product types that
use the default Termination window.
For all the product types that were using an extension of TerminationWindow, they can also use
TermFrame, provided they now use the <product type>TermPanel API, and they are added to the
domain “ProductUseTermFrame”.
Out-of-the-box, the following product types use the <product type>TermPanel API: CDSIndex, Cash,
CreditDefaultSwap, CreditDefaultSwap Loan, EquityLinkedSwap, Repo, SecLending.
|
|
Architecture | 14.6.1Architecture
TermFrame is the default Termination Window. It can contain a panel for specific inputs by defining
com.calypso.apps.product.termination.<ProductType>TermPanel. The interaction between
TermFrame and <ProductType>TermPanel is assured by the TermFrameCallBack and
ProductTermPanel interfaces.
The two following sections provide usage examples:
SWAP Product Use TermFrame — No Product-Specific Panel
CreditDefaultSwap — Using TermFrame a Product-Specific Panel
|
|
Setting and Getting information from a ProductType TermPanel | 14.6.2Setting and Getting information from a ProductType TermPanel
To set input values, use <ProductType>TermPanel.show(TerminationInfo).
To retrieve input values, use <ProductType>TermPanel.build(TerminationInfo).
If you have a JIDE properties pane, the Listener is <ProductType>TermPanel.propertyChange().
Please refer to TermFrame, CreditDefaultSwapTermPanel, and EquityLinkedSwapTermPanel as
examples.
|
|
Default TermFrame Properties | 14.6.3Default TermFrame Properties
The default values for properties held in the Termination window are in TermFrame.initProperties().
Create a TerminationInfo that contains the default information, and then call the method
show(TerminationInfo termInfo) to set the property values.
Private void initProperties(){
TerminationInfo termInfo = TerminationUtil.createTerminationInfo(_trade, _env);
show(termInfo);
}
By default, Calypso saves the last User choices for the following properties as Calypso User Properties:
• Pricer Measure
• Termination Reason
• Include Fee
• Pay Inter Flows
• FFCP Option
|
|
Sales Margin, Principal Exchange, and Interest Effective Date Properties | 14.6.4Sales Margin, Principal Exchange, and Interest Effective Date Properties
The mehtods to display the Sales Margin, Principal Exchange, and Interest Effective Date Properties
are explained below:
• Sales Margin: The display of the Sales Margin property is managed dynamically. No action is
required from developers to show/hide it. The logic is implemented in
TermFrame.hasSalesMarginProperty().
• Interest Effective Date: This property is hidden by default. To show it, you must override
createTerminationInfo(Trade trade, PricingEnv env) in <ProductType>Termination and then
add termInfo.setUseInterestEffectiveDate(true).
• Principal Exchange: This property is hidden by default. To show it, you must override
createTerminationInfo(Trade trade, PricingEnv env) in <ProductType>Termination and then
add termInfo.setPrincipalExchange(true) (or false).
|
|
Adding a Product-Specific Termination Panel | 14.6.5Adding a Product-Specific Termination Panel
To add a product specific panel to the Termination window, create a class named
com.calypso.apps.product.termination.<ProductType>TermPanel. This class must implement the
ProductTermPanel interface and extend JPanel. For example:
The product-specific panel can contain Swing components, as well as, JIDE components. JIDE
properties are preferred for defining inputs.
The initialization must take place in the constructor <ProductType>TermPanel().
|
|
Specifying a Requirement for an FX Rate or Fixing | 14.6.6Specifying a Requirement for an FX Rate or Fixing
<ProductType>TermPanel implements ProductTermPanel, which contains two methods to achieve this
goal.
Overriding either of the follwoing methods returns the desired values. For example:
@Override
public boolean isFXRateRequired() { return true;
}
@Override
public boolean isFixingRequired() { return true;
}
|
|
Working with TermFrame Attributes From a <ProductType>TermPanel | 14.6.7Working with TermFrame Attributes From a <ProductType>TermPanel
Retrieve TermFrame attributes from the <ProductType>TermPanel:
private TermFrameCallBack _termFrameCallBack;
@Override
public void init(TermFrameCallBack termFrameCallBack){
_termFrameCallBack = TermFrameCallBack;
}
The interface TermFrameCallBack information from TermFrame:. For example:
• _termFrameCallBack.getTrade()
• _termFrameCallBack.getPricingEnv()
|
|
Modify or Rename a TermFrame Property | 14.6.8Modify or Rename a TermFrame Property
1. Use the TermFrameCallBack method, getProperty(String propertyName). Properties names
are public static in TermFrameCallBack.
2. Rename the desired property directly using the renameProperty(String propertyName)
method of TermFrameCallBack. For example:
DateProperty termDateProperty = (DateProperty)_termFrameCallBack.
getProperty(TermFrameCallBack.PROPERTY_TRADE_DATE);
_termFrameCallBack.renameProperty(TermFrameCallBack.
PROPERTY_PRIMARY_PARTIAL_TERMINATED_AMOUNT, "Primary Quantity");
|
|
Adding Custom Flow Filtering in the Termination Process | 14.6.9Adding Custom Flow Filtering in the Termination Process
You can add custom flow filtering in the Termination process by creating a class named
tk.product.termination.<domain value>FilterFlows that implements
com.calypso.tk.product.termination.FilterFlows, where <domain value> must be added to the
domain “TerminationAdditionalFiltersFlows”.
It is invoked from com.calypso.tk.product.termination.DefaultTermination through
com.calypso.tk.product.termination.FilterFlowsUtil.
|
|
Adding Custom Menu Items to the Process Trade Window | 14.7 Adding Custom Menu Items to the Process Trade Window
Create a class named apps.util.CustomProcessTradeMenu which implements the interface
com.calypso.apps.util.CustomProcessTradeMenu.
This class will be invoked from com.calypso.apps.util.ProcessTradeUtil.
|
|
Creating a Custom Attribute Matching Mechanism | 14.8 Creating a Custom Attribute Matching Mechanism
Create a class named tk.bo.matching.<matching name>MatchingAttributes that implements
com.calypso.bo.matching.MatchingAttributes.
This class will be invoked from com.calypso.tk.bo.matching.DefaultMatchingUtil when
performing attributes matching in the Financial Matching Window.
|
|
Creating a Custom Reconvention Panel | 14.9 Creating a Custom Reconvention Panel
You can implement a class named apps.product.reconvention.ReconventionPanel that extends
com.calypso.apps.product.reconvention.ReconventionPanel.
It is invoked from com.calypso.apps.product.reconvention.ReconventionDialog.
|
|
Structured Flows - Customizing how Reconventions are Processed | 14.10 Structured Flows - Customizing how Reconventions are Processed
You can create a class named tk.product.reconvention.impl.<reconvention
type>ReconventionHookHandler or
tk.product.reconvention.impl.DefaultReconventionHookHandler (for all reconvention types) that
implements com.calypso.tk.product.reconvention.impl.ReconventionHookHandler.
ReconventionHookHandler has 3 methods:
• isSingleton - Returns boolean to denote whether the instance can be cached at calypso layer
• preProcess - Hook to preprocess reconvention, passes all args supplied to apply method
• postprocess - Hook to preprocess reconvention, passes all args supplied to apply method
This class will be invoked from
com.calypso.tk.product.reconvention.impl.DefaultReconventionHandler.
|
|
Report Framework Overview | 15.1 Report Framework Overview
The Calypso Report Framework has been designed to clearly separate the various elements of a
report:
• Report Template — The input parameters for the report.
• Report — The database query to retrieve the data.
• Report Output — Data model of the data retrieved by the report.
• Report Style — Utility to extract atomic values (columns) from the Report Output.
• Report Viewer — An interface to “render” or display the report output to the end-user.
• Report Window — A single GUI window drives all the reports. In so doing, a new report can
easily be implemented and plugged into the system, immediately inheriting of all the services
available in the report framework: Export to Excel, HTML, PDF, Aggregation functions, sorting,
etc.
|
|
Defining Report Templates | 15.1.1Defining Report Templates
The ReportTemplate and its subclasses provide the means to define search query parameters and
what data the report should contain. It allows this information to be stored in the database for use in
Report windows and/or in running Report Scheduled Tasks.
For example, a user wants to create a custom report with the following parameters:
• Currency
• Min and Max Amount
• Display Derivatives
• Start Date and End Date
The class would be named tk.report.<CustomObject>ReportTemplate and should extend
ReportTemplate. It will look similar to:
public class CustomObjectReportTemplate extends ReportTemplate {
public static final String CURRENCY="Currency";
public static final String MIN_AMOUNT=”MinAmount”;
public static final String MAX_AMOUNT=”MaxAmount”;
public static final String DERIVATIVES_FLAG=”DerivativesFlag”;
public void setDefaults() {
Hashtable contents = getContents();
contents.put(DERIVATIVES_FLAG, new Boolean(false));
}
}
The setDefaults() method allows setting default query parameters for the report.
The base class “ReportTemplate” handles the following parameters:
Parameters Description
Description A free-form String description of this template
Parameters Description
Start Date and End Start Date cutoff for the report defined as an absolute date or as a relative tenor,
Date and End Date cutoff for the report defined as an absolute date or as a relative
tenor.
Start and end dates are used in most reports, so it makes sense to provide the
parameters as defaults in the base ReportTemplate class. However, it is to the
discretion of the Report as to whether these are used or not. Most of these
“input” parameters useful will only be if the Report class makes use of it; in other
words, if it uses these parameter values in generating the query.
Holidays Vector of Holidays to use when calculating dates.
Business Days Boolean flag to differentiate between Business and Calendar Days.
Columns Columns to be displayed in the Report. The Columns parameter enables you to
select which columns to display in the output report. The selection of columns
depend on the report and the selection is retrieved from the ReportStyle class
and for each column that is defined, the ReportStyle class must code the logic
on how that value is to be extracted from the Report row.
Sort Columns Columns by which the report data should be sorted. The SortColumns
parameter allows you to dictate how the data rows are to be sorted. The user
can specify one or more sorting columns. For example, some reports must be
sorted by Book, then by trade ID, while others may simply require sorting by
date. The set of Sort Columns available is taken from the set of Columns
mentioned above and it is not possible to sort on a column that is not included
in the Columns parameter.
Subheadings Columns to be displayed as “subheadings”. Some reports must show
subheadings. This only applies when sorting is being used and the columns to
be shown as subheadings are chosen from those selected as sort columns. For
example, to sort by Settlement Date, select the “Settlement Date” column as a
subheading, this will result in the value being shown on its own row, with the
rows that match its value being demarcated underneath.
Subtotals Columns for which subtotals should be displayed. It is possible to tag columns
for which subtotals should be computed. This only applies to columns that
represent numeric values such as amounts. Attempting to generate a subtotal
for a Legal Entity Name, say, will result in a subtotal of 0.0. Subtotals are shown
whenever a break occurs in the sorting order. If a Transfer report is being sorted
by Settlement Date and subtotaled by Transfer Amount the subtotal for all
transfers matching the specific settlement date will be displayed. Subtotals are
reset to 0 after each break in the sorting order.
Parameters Description
Totals Columns for which totals should be displayed. Totals are cumulative subtotals.
The only difference between a Total and a Subtotal is that the total is not reset at
each break in the sorting order but a tally is kept for each row in the report.
Subtotal Aggregation functions to use in calculating subtotals and totals. For each
Functions and column defined as a subtotal or total, you can use an aggregation function to
Total Functions calculate that subtotal. The default function is Sum but other functions are
available out-of-the-box including Maximum, Minimum, and Average.
AggregationFlag There are times when an aggregated view of the report is required without
displaying all row details. If the flag is set to true (default being false) then only
an aggregated view will be displayed in the report. Only rows with subheadings,
subtotals, and totals will be displayed while the specific row details will be
hidden from view. Of course, the subtotals and totals will include these hidden
rows; they simply will not be visible in the report.
Columns, Sort Columns, Subheadings, Totals, Subtotals, and the associated
Function parameters are used to control what data is displayed, how it is sorted,
and if and how it is aggregated into groups (with subheadings and subtotals.)
Although how the data is displayed may differ depending upon the
ReportViewer (HTML will look different from a GUI table), the actual data should
remain the same across all viewers.
As far as data persistence is concerned, this is managed by the
tk.report.sql.ReportTemplateSQL class and, since it implements the
tk.core.Attributable interface, most of the attributes are stored in the
entity_attributes table.
|
|
Defining Reports | 15.1.2Defining Reports
The Report class is where a query is built based on the input parameters in the ReportTemplate. The
query is built; a call is made to the Calypso Data server (via the remote API) and the returned data is a
ReportOutput with a set of ReportRows. A ReportRow identifies the objects retrieved from the system
on a per-row basis.
The reason for having the ReportRow objects (as opposed to simply passing the objects Vector itself) is
because there are times when one must associate several different objects to one row. For example, a
Message Report will sometimes have a Message, a Transfer, and a trade all attached to the same
ReportRow.
Continuing with the earlier example, <CustomObject>Report would be as follows:
class CustomOjectReport extends Report {
public ReportOutput load() {
initDates();
DefaultReportOutput output = new DefaultReportOutput(this);
Hashtable from = new Hashtable ();
String where = buildQuery(from);
Vector objects = null;
try {
...
RemoteCustom rc = ds.getRemoteCustom();
objects = rc.getObjects(where, from);
...
}
catch (Exception e) { … }
ReportRow[] rows = new ReportRow[objects.size()];
for (int i=0; i < rows.length; i++) {
rows[i] = new ReportRow(objects.get(i));
}
output.setRows(rows);
return output;
}
...
public String buildQuery(Hashtable from) {
// go through the CustomObjectReportTemplate and build
// the where query based on the values set.
// Add the associated tables to from Hashtable
...
}
}
|
|
Defining Report Outputs | 15.1.3Defining Report Outputs
The core class that “handles” the report output is com.calypso.tk.report.DefaultReportOutput. Its
purpose is not to render or display the data. This task is left to the report viewers. Its purpose is to
arrange the report data which was set by the report with the setRows() method in a way compatible
with the parameters given in the ReportTemplate (Columns, SortColumns, Subtotals, etc.)
Hence, the DefaultReportOutput class will sort the rows based on the SortColumns. It will parse
through each row and calculate the subtotals and totals, and pass that information along to the
ReportViewer.
|
|
Defining Report Styles | 15.1.4Defining Report Styles
ReportStyle is a helper class that provides the functionality to extract column values from ReportRow
objects. A ReportRow encapsulates one or more Calypso objects. It is necessary to extract a column
value from the object because the column might be a direct mapping to an object field value (e.g., the
TRADE_ID column maps to Trade.getId() method). Other column values might be computed and/or
generated when queried.
ReportStyle is extensible. For example, TradeReportStyle extends ReportStyle.
The behavior to extract column values for a custom column can be done by inheriting or extending
from a superclass. Java reflection of the superclass in ReportStyle makes available in the GUI, all of the
public static fields defined for the class, as columns that can be configured or used.
When extending an existing calypso ReportStyle class, it is important to use the following naming
convention to ensure that all columns are available in the GUI:
com.calypso Class Name Custom Class Name Extended Class
Name
AccountReportStyle AccountExtensionColumnsReportStyle ReportStyle
com.calypso Class Name Custom Class Name Extended Class
Name
BOPositionReportStyle BOPositionExtensionColumnsReportStyle ReportStyle
LegalEntityReportStyle LegalEntityExtensionColumnsReportStyle ReportStyle
MessageReportStyle MessageExtensionColumnsReportStyle ReportStyle
ProductReportStyle ProductExtensionColumnsReportStyle ReportStyle
SwapReportStyle SwapExtensionColumnsReportStyle ReportStyle
TradeReportStyle TradeExtensionColumnsReportStyle ReportStyle
TransferReportStyle TransferExtensionColumnsReportStyle ReportStyle
TradeTransferRules TradeTransferRulesExtensionColumnsReportStyle ReportStyle
ReportStyle
Note the use of ExtensionColumns in the custom class name.
The ReportStyle class provides the following methods:
// All String constats (public static final) are considered a columnId
static final public String SOME_COLUMN = "Some Column";
protected Object getColumnValue (ReportRow row, int columnId, Vector errors) {
...
// Based on columnId, extract column value (columned) from the ReportRow.
// If there is no match, you can delegate the class to have it extract the
// value.
return super.getColumnValue(row, columnId, errors);
}
// When extending a column, you must extend ColumnMetaData and getColumnValue
public ColumnMetaData getColumnMetaData(String columnId) {
// Return the appropriate metadata for columnId
ColumnMetaData metadata = new ColumnMetaData();
metadata.setAdditive(false);
metadata.setCharacterLimit(512);
metadata.setColumnClass(String.class);
metadata.setDimension(true);
metadata.setDistinct(true);
metadata.setEditable(false);
metadata.setName(columnId);
metadata.setNumeric(false);
return metadata;
}
// The following is a more specific example of the TransferReportStyle and
// provides a short excerpt of how it is implemented:
protected Object getColumnValue (ReportRow, row, int columnId, Vector errors) {
BOTransfer transfer = (BOTransfer)row.getProperty(ReportRow.TRANSFER);
if (ID_AVAILABLE_DATE.equals(columnId)) {
return transfer.getAvailableDate();
}
else if (ID_DELIVERY_TYPE.equals(columnId)) {
return transfer.getDeliveryType();
}
...
return super.getColumnValue(row, columnId, errors);
}
[NOTE: When writing a custom ReportStyle, you must extend ReportStyle, and you must
override getColumnMetaData and getColumnValue]
Example of ReportStyle Extension
public class ProductExtensionColumnsReportStyle extends ReportStyle {
static final public String EXTENSION_COLUMN1 = "EXTENSION - Column 1";
static final public String EXTENSION_COLUMN2 = "EXTENSION - Column 2";
public Object getColumnValue(ReportRow row, String columnId, Vector errors)
throws InvalidParameterException {
if (row == null) {
return null;
}
if (EXTENSION_COLUMN1.equals(columnId)) {
return "EXTENSION - value 1";
}
if (EXTENSION_COLUMN2.equals(columnId)) {
return "EXTENSION - value 2";
}
// Override these columns
Trade trade = (Trade) row.getProperty(ReportRow.TRADE);
if (trade != null) {
if (ProductReportStyle.MATURITY_DATE.equals(columnId)) {
if (trade.getKeywordValue("CustomMaturityDate") != null) {
return trade.getKeywordAsJDate("CustomMaturityDate");
}
}
}
return null;
}
public ColumnMetaData getColumnMetaData(String columnId) {
// columnId is either EXTENSION_COLUMN1 or EXTENSION_COLUMN2,
// metadata for MATURITY_DATE is handled by ProductReportStyle
ColumnMetaData metadata = new ColumnMetaData();
metadata.setAdditive(false);
metadata.setCharacterLimit(512);
metadata.setColumnClass(String.class);
metadata.setDimension(true);
metadata.setDistinct(true);
metadata.setEditable(false);
metadata.setName(columnId);
metadata.setNumeric(false);
return metadata;
}
}
An additional note is required regarding TradeReportStyle. To place Product-specific columns in their
own style classes and permit clients to extend the framework easily, TradeReportStyle proceeds to
search for matching column name(s) if it does not find it in its own set of columns. First, it will iterate
over product interfaces since these report styles span multiple Products. All product interfaces are
defined in the “productInterface” domain and the following Report Styles are packaged with Calypso:
OptionReportStyle, CashSettledReportStyle, among others. If the column is not located in any of the
available interface report styles, then TradeReportStyle attempts to spawn a product specific
ReportStyle based on the product type (i.e., SwapReportStyle, BondReportStyle, etc.)
If Legal Entity and Book attribute values are not populated in the CWS pricing analysis, you need to
add the following:
@Override public boolean containsPricingEnvDependentColumns(ReportTemplate
template) {
return true;
}
@Override public String[] getPossibleColumnNames() {
return columns;
}
|
|
Defining Trade Report Styles with Additional Data | 15.1.5Defining Trade Report Styles with Additional Data
The TradeReportStyle described above allows adding trade data only. You can also add data from
other bjects using the following mechanism.
TradeReportStyle extensions are configurable using the domain name "ExtensionTradeReportStyle".
Each value in this domain will instantiate a class named <value>ReportStyle and a class named
TradeExtension<value>Report.
If found, the extension report is then loaded using DefaultReportOutput Report.load(new Vector<>()).
This report needs to populate the following properties:
• TradeExtension<value>
• TRADE_EXTENSION.LOADED_TRADE_ID
Example:
If you add TestCustomTradeOtherData to the domain “ExtensionTradeReportStyle” , you need to
create the following classes: TestCustomTradeOtherDataReportStyle that extends ReportStyle and
TradeExtensionTestCustomTradeOtherDataReport that extends Report.
TestCustomTradeOtherDataReportStyle
package calypsox.tk.report;
import java.security.InvalidParameterException;
import java.util.List;
import java.util.Vector;
import com.calypso.tk.report.ReportRow;
import com.calypso.tk.report.ReportStyle;
/**
* Class used in TestTradeReportExtension
*/
public class TestCustomTradeOtherDataReportStyle extends ReportStyle {
private static final String TRADE_EXTENSION_DATA =
"TradeExtensionTestCustomTradeOtherData";
private static final long serialVersionUID = -1010269453040033505L;
static final public String NAME = "CustomTradeData.CustomColumn";
@Override
public Object getColumnValue(ReportRow row, String columnName, Vector errors)
throws InvalidParameterException {
List<String> property = row.getProperty(TRADE_EXTENSION_DATA);
return property.get(0);
}
}
TradeExtensionTestCustomTradeOtherDataReport
package calypsox.tk.report;
import java.util.Arrays;
import java.util.Collection;
import java.util.Vector;
import org.apache.commons.lang.ArrayUtils;
import org.springframework.util.Assert;
import com.calypso.tk.report.DefaultReportOutput;
import com.calypso.tk.report.Report;
import com.calypso.tk.report.ReportOutput;
import com.calypso.tk.report.ReportRow;
import com.google.common.collect.Lists;
/**
* Class used in TestTradeReportExtension
*/
public class TradeExtensionTestCustomTradeOtherDataReport extends Report {
public static final String CUSTOM_DATA_FOR_TRADE = "Custom Trade Data for Trade ";
private static final String TRADE_EXTENSION_DATA =
"TradeExtensionTestCustomTradeOtherData";
private static final String TRADE_EXTENSION_PREFIX = "TRADE_EXTENSION.";
private static final String TRADES = TRADE_EXTENSION_PREFIX + "LOADED_TRADES";
private static final String TRADE_IDS = TRADE_EXTENSION_PREFIX +
"LOADED_TRADE_IDS";
private static final String TRADE_ID = TRADE_EXTENSION_PREFIX + "LOADED_TRADE_ID";
private static final String IM_PORTFOLIO_NAME = "IM_PORTFOLIO_NAME";
@Override
public <T extends ReportOutput> T load(Vector errorMsgs) {
Collection<Long> tradeIds = getTradeIds();
Collection<ReportRow> rows = Lists.newArrayList();
for (Long tradeId : tradeIds) {
ReportRow row = new ReportRow(CUSTOM_DATA_FOR_TRADE + tradeId,
TRADE_EXTENSION_DATA);
row.setProperty(TRADE_ID, tradeId);
rows.add(row);
}
DefaultReportOutput output = new DefaultReportOutput(this);
output.setRows(rows.toArray(new ReportRow[0]));
return (T) output;
}
private Collection<Long> getTradeIds() {
Object object = _reportTemplate.get(TRADE_IDS);
Assert.notNull(object, String.format("TradeExtensionReport - expected criteria
%s to be defined on the template", TRADES));
Assert.isTrue(long[].class.isAssignableFrom(object.getClass()),
String.format("TradeExtensionReport - expected criteria %s to be a
TradeArray", TRADES));
return Arrays.asList(ArrayUtils.toObject(long[].class.cast(object)));
}
}
|
|
Defining Report Viewers | 15.1.6Defining Report Viewers
The Report Viewer renders the report output. Calypso currently provides the following report viewers:
CSV, HTML, Excel, PDF, and GUI tables. ReportWindow provides the ability to view any report
implemented using the framework. A customer need not worry about implementing a GUI for a report,
the report is immediately available via a GUI interface.
A report viewer implements the com.calypso.tk.report.ReportViewer interface.
Out-of-the-box, Calypso provides the following report viewers:
• com.calypso.tk.report.CSVReportViewer
• com.calypso.tk.report.HTMLReportViewer
• com.calypso.tk.report.XLSReportViewer
• com.calypso.tk.report.PDFReportViewer
• com.calypso.apps.reporting.TableReportViewer
• com.calypso.apps.reporting.TreeTableReportViewer
• com.calypso.apps.reporting.PivotTableReportViewer
To create a custom Excel/ExcelX report output for a report in table mode, you can create a class
named calypsox.apps.util.CustomTableModelFormatExcel / ExcelX that extends
com.calypso.apps.util.TableModelFormaExcel / ExcelX to export data to Excel / ExcelX files.
It is invoked from com.calypso.apps.reporting.ReportPanel.
To create a custom HTML report output for a report in table mode, you can create a class named
calypsox.apps.util.CustomTableModelFormatHTML that extends
com.calypso.apps.util.TableModelFormatHTML to export data to HTML files.
It is invoked from com.calypso.apps.reporting.ReportPanel and from tables (Ctrl + H and Ctrl + Z
in a table).
To create a custom CSV report output for a report in table mode, you can create a class named
apps.util.CustomTableModelFormatCSV that extends
com.calypso.apps.util.TableModelFormatCSV to export data to CSV files.
It is invoked from com.calypso.apps.reporting.ReportPanel and from tables (Ctrl + H and Ctrl + Z
in a table).
Sample Code
package calypsox.apps.util;
import com.calypso.apps.util.TableModelFormatCSV;
import com.calypso.apps.util.TableModelUtil;
import com.calypso.tk.core.Log;
public class CustomTableModelFormatCSV extends TableModelFormatCSV {
@Override
public String format(TableModelUtil tableModel) {
Log.system(CustomTableModelFormatCSV.class.getSimpleName(),
"Formatting CSV document ...");
return super.format(tableModel);
}
}
|
|
Report Window | 15.1.7Report Window
All reports that are built on top of the Reporting Framework share the same default GUI code. At its
simplest level, a report can be added to any GUI window by adding a new ReportPanel to an existing
GUI window:
// Insert a Message Report Panel
JPanel messagePanel = new ReportPanel(“Message”);
Of course, this only provides the ability to embed a Report in an existing window and does not provide
a way to set search criteria (ReportTemplate) on this report. This must be done programmatically
elsewhere in the code.
For most reports, it will often be more practical to use ReportWindow:
// Create a new Message Report Window and make it visible JFrame frame = new
ReportWindow(“Message”); Frame.setVisible(true);
All reports embedded in the ReportWindow have a similar look and feel.
Search Criteria (ReportTemplatePanel)
Report Filter Report Viewer (ReportPanel)
(BookHierarchy)
Additional Parameters (Buttons, PricingEnv, etc.)
The search criteria for the reports are selected at the top in the ReportTemplatePanel. Some control
buttons and additional environment settings are available at the bottom of the window in the button
panel. There, you can set the Pricing Env, the Valuation Date, and connect to real-time events. These
options are only available when applicable.
Given the argument passed to the Report Window (“Message” for example), the following GUI classes
will be instantiated and attached to the Report Window (if and when applicable):
• apps.reporting.MessageReportTemplatePanel
• apps.reporting.MessageReportWindowCustomizer
• apps.reporting.MessageReportRealTimeHandler
The corresponding toolkit classes are also instantiated:
• tk.report.MessageReportTemplate
• tk.report.MessageReport
• tk.report.MessageReportStyle
|
|
Import/Export | 15.1.8Import/Export
It is possible to import/export report template parameters from/to XML. This provides a convenient
way to distribute a suite of out-of-the-box reports to one or more users. The report templates can be
stored in a directory and imported into the system on an as-needed basis.
Because the template parameters are stored as attributes, it should be unnecessary to modify or
extend the import/export functionality. For reference, the relevant classes can be found in the
following package: com.calypso.bridge.object.reportTemplate.
|
|
How to Add a New Report | 15.2 How to Add a New Report
In order to add a new report, create a new ReportTemplate (which may or may not extend an existing
one), a new Report, and a new ReportStyle, and place them in the tk.report package. For example, in
order to create a CustomObject report three classes would be created:
− tk.report.CustomObjectReportTemplate
− tk.report.sql.CustomObjectReportTemplateSQL
− tk.report.CustomObjectReport
− tk.report.CustomObjectReportStyle
Add the domain value (“CustomObject” in this example) to the “REPORT.Types” domain, and add a
menu item for the report using Utilities > Main Entry Customizer from the Calypso Navigator as
follows:
• Name — Custom Object Report
• Action — reporting.ReportWindow$CustomObject
After restarting the Calypso Navigator, it will be possible to access the new report from the
Reports menu, and to input the appropriate parameters, load/ save templates and, run the
report.
|
|
How to Create a Report Template Panel | 15.2.1How to Create a Report Template Panel
However, in order to be generic, the GUI to manipulate the ReportTemplate is not intuitive. It lists most
of the parameters in tabular format and does not perform any type-checking (Some minor type-
checking is done, whenever possible, by parsing the parameter names). This is certainly not failsafe,
however. This limitation is due to the need to keep ReportTemplate backward compatible. Since the
template is stored in the database as a Hashtable object, it is very difficult upgrade.
However, there is a way to customize how the user will interact with your template. All that is needed is
to create a class named apps.reporting.CustomObjectReportTemplatePanel which extends
com.calypso.apps.reporting.ReportTemplatePanel. This abstract class extends JPanel and
provides two methods to set and get the ReportTemplate in order to determine how the report
template should be displayed on the GUI:
• setTemplate()
• getTemplate()
This panel, once compiled, will automatically be loaded and inserted at the top of the ReportWindow.
The following ReportTemplatePanels are provided by Calypso and are used in the respective report
windows. By launching these various reports, you can see the customized template GUI:
• AuditReportTemplatePanel
• DailyBlotterReportTemplatePanel
• FailsReportTemplatePanel
• FeeReportTemplatePanel
• SettlementReportTemplatePanel
In the case of a simple, straightforward report template, the implementation of this class is not
required; rather the DefaultReportTemplatePanel is used and will display the report parameters in
tabular format, as shown below. DefaultReportTemplatePanel — (Cashflow Report PE):
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.