Apama Capital Markets Foundation Documentation : Capital Markets Foundation : Analytics : Creating and configuring a currency converter : Creating a currency calculation extension
Creating a currency calculation extension
A currency converter uses a currency calculation extension to obtain the latest values for normalizing to a base currency. An extension connects to a datasource to get its price data. The CMF provides two sample currency calculation extensions in the samples\Currency Converter Sample\eventdefinitions directory of your CMF installation directory:
*BBAMidPriceExtension connects to a Best Bid Ask datasource to obtain values.
*DepthPriceExtension connects to a Depth Market Data datasource to obtain values.
The CMF does not supply any supported extensions. It is expected that you will modify one of the provided extensions or create your own new extension. To create an extension, call the create() action on a com.apama.ccyconverter.CalculationExtensionFactory object. This action takes no parameters and returns a default implementation of a CalculationExtension object. Override the CalculationExtension actions as needed to define your custom extension.
To use the extension, specify it when you create a currency converter. See Creating a currency converter.
The currency converter supplies the extension with the symbols for which the currency converter needs data from the extension. The extension connects to a datasource and subscribes to receive data for the specified symbols. The extension obtains the latest values at time intervals specified by the setting of the currency converter's CONFIG_UPDATE_TIMEOUT parameter.
To obtain data from the calculation extension, a currency converter calls the following CalculationExtension actions. See the ApamaDoc for details.
Action
Description
getSchema()
During startup, the currency converter calls this action to obtain the sequence of field names that the currency converter needs to store in its cache. These are the values that the currency converter uses to normalize all symbols to a base currency. The default is that this action returns a sequence that contains the single entry "VALUE". If the extension is to supply more than one value then you must override this action to return all required field names. Also, you must call the currency converter setCustomValue() action for each additional value you need from the extension. See Getting values from the currency converter.
onRegistered()
When startup is complete the currency converter calls this action, which provides the calculation extension with the currency converter interface that the extension uses to provide values.
refresh()
The currency converter calls this action each time it wants the latest values from the calculation extension. The setting of the currency converter's CONFIG_UPDATE_TIMEOUT configuration parameter determines how often the currency converter calls this action. The default is 0.5, which means that the extension provides the latest data every half second. This happens automatically and the currency converter does not need to explicitly invoke the refresh() action. If the setting of the currency converter's CONFIG_UPDATE_TIMEOUT parameter is 0.0 then refresh() is not automatically called and the extension is expected to provide values when it can, either constantly or on its own timer.
addSymbol()
The currency converter calls this action after startup for all possible combinations of symbols that the currency converter has been configured to supply values for. It is not expected that the extension can provide values for all configured symbols but it is expected to do its best. For example, if the currency converter has been configured to supply a value to convert from GBP to EUR, addSymbol() will be called for both "GBP/EUR" and "EUR/GBP", but the extension might only be able to supply values for "GBP/EUR". The addSymbol() action can also be called any time the parameters for the currency converter have been updated and a new symbol is required.
removeSymbol()
The currency converter calls this action after startup if it no longer needs data for a particular symbol.
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback